jq(document).ready(function() {
	//切换出发地城市
	/*jq("#choosecity").click(function(){
		jq(".city").show(); 
	}).mouseout(function(){		
		jq(".city").hide(); 
	});
	jq(".city").mouseover(function(){
		jq(".city").show(); 
	}).mouseout(function(){
		jq(".city").hide();
	});
	jq(".city ul li a").click(function(){
		var id = this.id;
		var area = jq("#"+this.id).html();
		jq.ajax({
			type: "POST",
			url: siteUrl + "/jq.ajax.php",
			data:"citychoose="+area+"&cityid="+id+"&type=citych",
			success: function(data){
				window.location = window.location.href;
			}
		});
	});*/
	//////end///////
	//切换出发地城市
	jq(".citymenu a").click(function(){
		var id = this.id;
		var area = jq("#"+this.id).html();
		
		jq.ajax({
			type: "POST",
			url: siteUrl + "/jq.ajax.php",
			data:"citychoose="+area+"&cityid="+id+"&type=citych",
			success: function(data){
				var str = window.location.href ;
				var url = str.split("#");
				window.location = url[0];
			}
		});
	});
	//跟多
	jq(".changeall a").click(function(){
		
		var id = this.id;
		var area = jq("#"+this.id).html();
		jq.ajax({
			type: "POST",
			url: siteUrl + "/jq.ajax.php",
			data:"citychoose="+area+"&cityid="+id+"&type=citych",
			success: function(data){
				window.location = siteUrl;
			}
		});
	});
	//////end///////
	
	
	
	
//	jq("#skey").val(1);
//	
//	jq(".selectare .menu li").click(function(){
//		var clthis = this;
//		
//		jq(".selectare .menu li").each(function(index,domEle){
//			
//			if(jq(this).is(".last")) return false;
//			jq(this).removeClass();			
//			if(jq(clthis).text() == jq(this).text()){
//				jq(clthis).addClass("clickcss");
//				jq("#skey").val(index + 1);
//				jq(".last span").text("更多");
//				jq(".selectare .menu li").removeClass("morecss");
//			}
//		});
//
//	});
//	
//	jq(".menu-hd").mouseover(function(){		
//		jq("#select_main").show(); 
//	});
//	jq("#select_main").mouseover(function(){		
//		jq("#select_main").show(); 
//	});
//	jq(".menu-hd").mouseout(function(){		
//		jq("#select_main").hide(); 
//	});
//	jq("#select_main").mouseout(function(){		
//		jq("#select_main").hide(); 
//	});
//	
//	jq(".last").mouseover(function(){		
//		jq("#moresl").show(); 
//		jq(".last b").hide();
//	});	
//	jq("#moresl").mouseover(function(){		
//		jq("#moresl").show(); 
//		jq(".last b").hide();
//	});	
//	jq(".last").mouseout(function(){		
//		jq("#moresl").hide(); 
//		jq(".last b").show();
//	});	
//	jq("#moresl").mouseout(function(){		
//		jq("#moresl").hide(); 
//		jq(".last b").show();
//	});
//	
//	jq(".more-sel li").click(function(){
//		jq(".last span").text(jq(this).text());
//		jq(".last").addClass("morecss");
//		jq(".last b").addClass("bcss");
//		var slthis = this;
//		jq(".selectare .menu .last .more-sel li").each(function(index,domEle){
//			if(jq(slthis).text() == jq(this).text()){
//				jq("#skey").val(index + 10);
//			}
//		});
//		
//	});
//	
//	
	jq("#raidersdh a").click(function(){
		
		jq(".tourstrategy .content").each(function(i){
			jq("#raiders-"+(i+1)).hide();			
		});

		jq("#raiders-"+this.rel).show();	
		
	});
	
	//
	jq("ul.menumv li.next").click(function(){
		var numli ;
		jq("ul.menumv li").each(function(i){
			if(jq(this).attr("class") == 'on'){
				numli = i; 
			}
		});
		
		if(numli <= 2){
			jq("ul.menumv li:eq("+numli+")").removeClass();
			jq("ul.menumv li:eq("+(numli+1)+")").addClass('on');

		}else if(numli > 2 && numli < 12){
			jq("ul.menumv li:eq("+numli+")").removeClass();
			jq("ul.menumv li:eq("+(numli+1)+")").addClass('on');
			if(numli == 11){
				jq("ul.menumv li:eq("+(numli-3)+")").hide();
			}else{
				jq("ul.menumv li:eq("+(numli-2)+")").hide();
			}
			
			jq("ul.menumv li:eq("+(numli+2)+")").show();
		}
		if((numli) == 12){
			jq(".goodcot .cot ul.content").hide();
			jq(".goodcot .cot ul.hot_"+(numli)).show();
		}else{
			jq(".goodcot .cot ul.content").hide();
			jq(".goodcot .cot ul.hot_"+(numli+1)).show();
		}
	});
	//
	jq("ul.menumv li.pro").click(function(){
		var numli ;
		jq("ul.menumv li").each(function(i){
			if(jq(this).attr("class") == 'on'){
				numli = i; 
			}
		});
		
		if(numli <= 2){
			jq("ul.menumv li:eq("+numli+")").removeClass();
			jq("ul.menumv li:eq(1)").addClass('on');
			jq("ul.menumv li:eq(1)").show();
		}else if(numli > 2 && numli <= 12){
			jq("ul.menumv li:eq("+numli+")").removeClass();
			
			if(numli == 11){
				jq("ul.menumv li:eq("+(numli)+")").hide();
				jq("ul.menumv li:eq("+(numli-4)+")").show();
				jq("ul.menumv li:eq("+(numli-1)+")").addClass('on');
			}else if(numli == 12){
				jq("ul.menumv li:eq("+(numli)+")").hide();
				jq("ul.menumv li:eq("+(numli-4)+")").show();
				jq("ul.menumv li:eq("+(numli-1)+")").addClass('on');
			}else{
				jq("ul.menumv li:eq("+(numli+2)+")").hide();
				jq("ul.menumv li:eq("+(numli-2)+")").show();
				jq("ul.menumv li:eq("+(numli-1)+")").addClass('on');
			}
			
			//alert(numli)
		}
		if((numli-1) == 0){
			jq(".goodcot .cot ul.content").hide();
			jq(".goodcot .cot ul.hot_"+(numli)).show();
		}else{
			jq(".goodcot .cot ul.content").hide();
			jq(".goodcot .cot ul.hot_"+(numli-1)).show();
		}
		
		
		//alert(numli);
	});
	
});

function zdc_favorite(obj1,obj2,obj3,obj4,obj5){
var x = new Ajax('HTML', '');
x.post(siteUrl+'/zdc_attr_ajax.php', 'class=favorite&type='+obj1+'&title='+obj2+'&bloguid='+obj3+'&blogid='+obj4+'&uid='+obj5,function(s){alert(s)});
}

function showmap(num,ztype){
	jq(".leftall").hide();
	jq("#map span").removeClass();
	jq(".left"+num).show();
	jq("#con"+num+" span").addClass("on");
	
	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"country="+num+"&type="+ztype,
		success: function(data){ jq( ".top20 .topul").html(''); jq( ".top20 .topul").html(data);} 
	}); 
}

function onlocation(obj){	
	window.location = jq("#urljswin").val() + jq("#"+obj).val();
}

//加入对比
function addcont(id,name,price,fix){
	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"itemid="+id+"&name="+name+"&price="+price+"&fix="+fix+"&action=add&type=cont&sub=false",
		success: function(data){
			if(data){
				jq("#contid li").each(function(i){
					if(i>6){
						jq("#contid li:first").remove();
					}
				});
				jq("#contid").html(jq("#contid").html() + data);
			}else{
				alert("此项已经添加对比箱！");
			}
		}
	});
}
//对比箱删除
function delx(id,fix){
	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"itemid="+id+"&action=del&type=cont&fix="+fix,
		success: function(data){
			jq("#"+id).remove();
		}
	});

}
//列表页面选择跳转
function winlocaurl(obj){
	window.location=obj;
}


//对比页面加入对比
function addconts(obj1,obj2){
	jq("#"+obj1).fadeOut("slow",function(){ jq("#"+obj2).fadeIn("slow"); }); 	
}
//对比页面删除  目的地
function delcont(id){
	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"itemid="+id+"&action=del&type=cont2",
		success: function(data){
			if(data == 1){
				window.location = '?action-channel-name-cont';
			}else{
				alert("删除失败");
			}
		}
	});
}
//对比页面删除  线路
function dellinecont(id){
	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"itemid="+id+"&action=del&type=linecont",
		success: function(data){
			if(data == 1){
				window.location = '?action-channel-name-linecont';
			}else{
				alert("删除失败");
			}
		}
	});
}
//对比页面添加
function selectcont(obj,cat,cls){

	jq.ajax({
		type: "POST",
		url: siteUrl + "/jq.ajax.php",
		data:"id="+obj+"&flag="+cat+"&action=add&type=sel",
		success: function(data){
			jq("."+cls).html(jq("."+cls).html() + data);
		}
	});
}
//对比页面选择
function vail(){
	var area = jq("#areaid").val();
	var spot = jq("#spotid").val();

	if(area==0){
		alert("请选择景区或者景点!");
		return false;
	}

	jq("#spotidhid").val(spot);
	jq("#areaidhid").val(area);
	
	return true;
}
//景区内页评论星星
function starclick(num,id){
	if(id==0){
		var star1 = parseInt(jq("#starid1").val());
		var star2 = parseInt(jq("#starid2").val());
		var star3 = parseInt(jq("#starid3").val());
		var star4 = parseInt(jq("#starid4").val());
		var star5 = parseInt(jq("#starid5").val());
		var star6 = parseInt(jq("#starid6").val());
		var area = jq("#areaid").val();
		var itemid = jq("#itemid").val();
		if(!star1) {alert("请为风景评分！"); return false;}
		if(!star2) {alert("请为住宿评分！"); return false;}
		if(!star3) {alert("请为美食评分！"); return false;}
		if(!star4) {alert("请为娱乐评分！"); return false;}
		if(!star5) {alert("请为购物评分！"); return false;}
		if(!star6) {alert("请为交通评分！"); return false;}
		if(!area) {alert("您还没有添加评论！"); return false;}

		jq.ajax({
			type: "POST",
			url: siteUrl + "/jq.ajax.php",
			data:"star1="+star1+"&star2="+star2+"&star3="+star3+"&star4="+star4+"&star5="+star5+"&star6="+star6+"&itemid="+itemid+"&content="+area+"&action=add&type=destpcom",
			success: function(data){
				if(data == 0){
					alert("请不要频繁提交!");
				}else if(data == 1){
					alert("已提交，等待审核中!");
				}else if(data == 2){
					alert("评论添加失败!");
				}else{
					alert("非法提交");
				}
			}
		});

	}else{
		
		jq("#star"+num+" img").each(function(i){
			if(id<=i){
				jq(this).attr("src",siteUrl + "/templates/zdc/simages/comment_gray.gif");
			}else{
				jq(this).attr("src",siteUrl + "/templates/zdc/simages/comment_huang.gif");
			}
		});
		jq("#starid"+num).val(id);
		
		
		//算分
		var star1 = parseInt(jq("#starid1").val());
		var star2 = parseInt(jq("#starid2").val());
		var star3 = parseInt(jq("#starid3").val());
		var star4 = parseInt(jq("#starid4").val());
		var star5 = parseInt(jq("#starid5").val());
		var star6 = parseInt(jq("#starid6").val());
		jq("#showfen"+num).html(id+"星");
		var sum = (star1+star2+star3+star4+star5+star6)/6*2;
		jq(".jutipingfen h3").html(sum.toFixed(1));
		
	}
	
}

//加入收藏
function AddFavorite(sURL, sTitle) {   
    try {   
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {   
        try {   
            window.sidebar.addPanel(sTitle, sURL, "");   
        } catch (e) {   
            alert("加入收藏失败，请使用Ctrl+D进行添加");   
        }   
    }   
}   

//资讯内页提交评论
function subpcom(obj){
	if (obj=="我也来说几句!"){ alert("请填写内容！");return false;}
	var itemidpcom = jq("#itemidpcom").val();
	var typepcom = jq("#typepcom").val();
	var uid = jq("#uid").val();
	var surl = jq("#surl").val();

	jq.ajax({
		type: "POST",
		url: siteUrl+"/jq.ajax.php",
		data:"content="+obj+"&uid="+uid+"&idpcom="+itemidpcom+"&tpcom="+typepcom+"&action=add&type=infopcom",
		success: function(data){
			if(data == 0){
				alert("请不要频繁提交!");
			}else if(data == -1){
				alert("非法提交");
			}else{
				alert("已提交，等待审核中!");
			}
		}
	});
}

//线路内页评论
function linepoll(id){
	var id = parseInt(id);
	if(id == 0){
		var star = jq("#linestarid").val();
		var obj = jq("#linetext").val();
		var itemid = jq("#lineitemid").val();
		if(!star) {alert("请为该线路评分！"); return false;}
		if(!obj) {alert("请添加您的评论！"); return false;}
		
		jq.ajax({
			type: "POST",
			url: siteUrl+"/jq.ajax.php",
			data:"content="+obj+"&star="+star+"&itemid="+itemid+"&action=add&type=linepoll",
			success: function(data){
				if(data == 0){
					alert("请不要频繁提交!");
				}else if(data == -1){
					alert("非法提交");
				}else{
					alert("已提交，等待审核中!");
				}
			}
		});
		
	}else{
		jq("#linestarspan img").each(function(i){
			if(id<=i){
				jq(this).attr("src",siteUrl + "/templates/zdc/simages/comment_gray.gif");
			}else{
				jq(this).attr("src",siteUrl + "/templates/zdc/simages/comment_huang.gif");
				jq(".starspan").html((i+1)+"星");
			}
		});
		
		jq("#linestarid").val(id);
	}
}

//线路内页展示
function linemodule(obj){
	if(jq("#module"+obj).attr("class") == 'theday'){
		jq("#module"+obj).removeClass().addClass("module");
	}else{
		//jq("#module"+obj).toggleClass("theday");
		jq("#module"+obj).removeClass().addClass("theday");
	}
	
	jq(".con"+obj).toggle();
	if(jq("#module"+obj+" span.l a.gray").html() == '点击隐藏'){
		jq("#module"+obj+" span.l a.gray").html("点击查看");
	}else{
		jq("#module"+obj+" span.l a.gray").html("点击隐藏");
	}
}

//删除浏览记录
function delsession(obj){
	jq.ajax({
		type: "POST",
		url: siteUrl+"/jq.ajax.php",
		data:"fix="+obj+"&action=del&type=sessionp",
		success: function(data){
			if (data == 1){
				var str = window.location.href ;
				var url = str.split("#");
				window.location = url[0];
			}else{
				alert("删除失败，请稍后在试!");
			}
		}
	});
}

//黄页内容页联系人滚动
function yellowcontact(obj,sum){
	var num = parseInt(jq("#contacthid").val());
	if(obj == 'next' && sum > 1){
		jq(".contact_"+num).animate({left: -50, opacity: 'hide' },'slow',function(){
			if((num+1)<sum){
				jq(".contact_"+(num+1)).animate({left: 50, opacity: 'show' },'slow',function(){
					jq("#contacthid").val(num+1);
				});
			}else{
				jq(".contact_0").animate({left: 50, opacity: 'show' },'slow',function(){
					jq("#contacthid").val(0);
				});
			}
		});
	}else if(obj == 'pre' && sum > 1){
		jq(".contact_"+num).animate({left: -50, opacity: 'hide' },'slow',function(){
			if(num>0){
				jq(".contact_"+(num-1)).animate({left: 50, opacity: 'show' },'slow',function(){
					jq("#contacthid").val(num-1);
				});
			}else{
				jq(".contact_"+(num+1)).animate({left: 50, opacity: 'show' },'slow',function(){
					jq("#contacthid").val(num+1);
				});
			}
		});
	}
}

//黄页搜索ajax select列表
function yellowcity(obj){
	var obj = parseInt(obj);
	if(obj != -1){
		jq.ajax({
			type: "POST",
			url: siteUrl+"/jq.ajax.php",
			data:"citypid="+obj+"&action=ysel",
			success: function(data){
				jq("#areasel").html(data);
			}
		});
	}
	
}

//景区首页  本季旅游推荐
function divul(obj){
	var obj = parseInt(obj);
	if(obj == 1){
		jq("#ulli2").removeClass();
		jq("#ulli"+obj).addClass("on");
		jq("#featureul_"+obj).show();
		jq("#featureul_2").hide();		
	}else{
		jq("#ulli1").removeClass();
		jq("#ulli"+obj).addClass("on");
		jq("#featureul_"+obj).show();
		jq("#featureul_1").hide();
	}

}

//目的地列表提交对比
function subform(){
	var j=0;
	jq(":checkbox").each(function(i){
		if(parseInt(jq("input:eq("+i+"):checked").val())){
			j++;
		}
	});
	if(j<=0){alert("您还没有勾选！"); return false;}
	if(j>4){alert("最多能对比4个产品！"); return false;}
	return true;
}

//按出发日期查看
function showdateprice(){
	jq("#trone td").toggle();
	jq("#trtwo td").toggle();
	if(jq('#tday').html()=='十天后'){
		jq('#tday').html("十天前");
	}else{
		jq('#tday').html("十天后");
	}
}

//栏位切换
function showlinearea(obj,num){
	jq("ul#gul"+obj+" li").each(function(i){
		jq(this).removeClass();
	});
	jq("ul#gul"+obj+" li:nth-child("+num+")").addClass("on");
	jq("."+obj).hide();
	jq("#"+obj+num).show();
}

//目的地内页 本月热卖
function showlinedest(num){
	jq(".taball table").hide();
	jq("#tab"+num).show();
	jq(".showline a").removeClass();
	jq("#atab"+num).addClass("on");
}