$(document).ready(function() {
	//alert($(".xlfenlei li").size()%2);
	for (i=0;i<$(".xlfenlei li").size();i++){
		if (i%2==1){
			$(".xlfenlei li").eq(i).css("background-color","#f4fafa");
		}
	}
	$(".ss").click(function(){
		document.soso_form.submit();
	});
	var reg=/^([1-9]\d*)$/;
	$(".gr_tab input").change(function(){		
		if(!reg.test($(this).val())){
			alert("数量只允许正整数");
			$(this).val("1");
			return false;			
		}
		var zj = 0;
		var ss = $(this).val()*$(this).parent().parent().find(".danjia").text();
		$(this).parent().parent().find(".jiage").text(ss);
		for (i=0;i<$(".jiage").size();i++ ){
			zj+=$(".jiage").eq(i).text()*1;
		}
		$(".zongjia1").text(zj);
		$(".zong_prices").text(zj);
	});
	$(".sub").click(function(){
		document.zhaohui_form.submit();
	});
	$("#checkboxs").click(function(){
		if($(this).attr("checked")==true){
			$(".zc_ul2").show();
		}else{
			$(".zc_ul2").hide();
		}
	});
	$(".dsxq").hover(function(){
		$(".mst_1_2").show();
	},function(){
		$(".mst_1_2").hide();
		}
	);
	$(".zhuc_3").click(function(){
		document.zhuc_form.submit();
	});
	$(".opimg1").click(function(){
		document.fx_form.submit();
	});
	$(".opimg2").click(function(){
		document.fx_form.reset();
	});
	$(".quanxuan").click(function(){
		if($(this).attr("checked")==true){
			$(".fx_tab").find("input").attr("checked", true); 
		}else{
			$(".fx_tab").find("input").attr("checked", false); 
		}
	});
	$(".xgpsword").click(function(){
		document.xgpssword_form.submit();
	});
	for (i=1;i<$(".fx_tab tr").size();i++){
		if (i%2==0){
			$(".fx_tab tr").eq(i).css("background-color","#f0f0f0");
		}
	}
	$(".yqimg1").click(function(){
		document.yq_form.submit();
	});
	$(".yqimg2").click(function(){
		document.yq_form.reset();
	});
	for (i=0;i<$(".qjlist1").size();i++){
		if (i%2==1){
			$(".qjlist1").eq(i).css("background-color","#f0f0f0");
		}
	}
	$(".soimg").click(function(){
		document.soso1_form.submit();
	});
	$(".ix_r2_1 li").hover(function(){
		for (i=0;i<$(".ix_r2_1 li").size();i++){
			if($(this).text() == $(".ix_r2_1 li").eq(i).text()){
				$(".ix_r2_1 li").eq(i).addClass('ix_bg1')
				$(".ix_r2_2").eq(i).show();
			}else{
				$(".ix_r2_1 li").eq(i).removeClass('ix_bg1')
				$(".ix_r2_2").eq(i).hide();
			}
		}
	});
	$(".tplh_2 img").hover(function(){
		//alert($(this).parent().attr("href"));
		$(".tplh_1 img").attr("src",$(this).attr("src"));
		$(".tplh_1 a").attr($(this).parent().attr("href"))
	});
	$(".tplh_1 a").attr("href",$(".tplh_2 a").eq(0).attr("href"));
	$(".tplh_1 img").attr("src",$(".tplh_2 img").eq(0).attr("src"));
	$(".tplh_2 img").hover(function(){
		$(".tplh_1 img").attr("src",$(this).attr("src"));
		$(".tplh_1 a").attr("href",$(this).parent().attr("href"));
	});
	$(".fb_i3ll_1 a").click(function(){
		var x = $(".tjxc").size()+1;
		$(".fb_i3ll").append("<div class='tjxc'> <ul> <li> <span class='fb_s2'>第"+x+"天行程</span> </li><li> 住宿介绍：<input name='zhus[]' type='text' value='' /> </li> <li>游览景区：<input name='jingqu[]' type='text' value='' /> </li> <li>交通方式： <select name='jiaotong[]'> <option value='飞机'>飞机</option><option value='火车'>火车</option> <option value='汽车'>汽车</option></select> </li> <li> 饮食包含： <input name='yongc["+(x-1)+"][]' type='checkbox' value='早' />&nbsp;早&nbsp; <input name='yongc["+(x-1)+"][]' type='checkbox' value='中' />&nbsp;中&nbsp; <input name='yongc["+(x-1)+"][]' type='checkbox' value='晚'/>&nbsp;晚&nbsp; </li> <li> 活动安排：<br /> <textarea name='ap_text[]'></textarea> </li> <li> 备注<br /> <textarea name='bz_text[]'></textarea><br /> </li> <li><a href='###' onclick='del(this)'>删除当天行程</a></li> </ul> </div>");
	});
	$(".shide").click(function(){
		$(".tdxl").toggle();
	})
	var zongjia = $(".tshus").text()*1*$(".jshu").val()*1*$(".danjia").text();//预订房间总价格
	$(".st1_s1").text(zongjia);
	$(".st1_s4").text($(".jshu").val());
	$("#zj_s").val(zongjia);
	$(".jshu").change(function(){		
		if(!reg.test($(this).val())){
			alert("数量只允许正整数");
			$(this).val("1");			
			$(".st1_s1").text($(".danjia").text());
			return false;
		}
		var zjia = $(".tshus").text()*1*$(this).val()*1*$(".danjia").text();
		$(".st1_s1").text(zjia);
		$(".st1_s4").text($(this).val());
		$("#zj_s").val(zjia);
	});
	$(".ann").hover(function(){
		$(this).width(102);
		$(this).height(32);
	},function(){
		$(this).width(104);
		$(this).height(34);
	});
	$(".delsub").click(function(){
		document.del_form.submit();
	});
	$(".delres").click(function(){
		$("#tanc").hide();
	});
});

function alertWin(title, w, h, ref,act){
    var titleheight = "22px"; // 提示窗口标题高度 
    var bordercolor = "#8fc704"; // 提示窗口的边框颜色 
    var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
    var titlebgcolor = "#8fc704"; // 提示窗口的标题背景色
    var bgcolor = "#FFFFFF"; // 提示内容的背景色
    
    var iWidth = document.documentElement.clientWidth; 
    var iHeight = document.documentElement.clientHeight; 
    var bgObj = document.createElement("div"); 
	var kheiget = document.body.offsetHeight;//网页可见区域的高
		per =document.getElementById("disb");
    

	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
    document.body.appendChild(bgObj); 
    
    var msgObj=document.createElement("div");
	if (window.navigator.userAgent.indexOf("MSIE")>=1){
		msgObj.style.cssText = "position:absolute;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;top:"+(kheiget-h)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	}
	if (window.navigator.userAgent.indexOf("Firefox")>=1){
		msgObj.style.cssText = "position:fixed;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	}

   // msgObj.style.cssText = "position:fixed;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
    document.body.appendChild(msgObj);
    
    var table = document.createElement("table");
    msgObj.appendChild(table);
    table.style.cssText = "margin:0px;border:0px;padding:0px;";
    table.cellSpacing = 0;
    var tr = table.insertRow(-1);
    var titleBar = tr.insertCell(-1);
    titleBar.style.cssText = "width:92%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
    titleBar.style.paddingLeft = "10px";
    titleBar.innerHTML = title;
    var moveX = 0;
    var moveY = 0;
    var moveTop = 0;
    var moveLeft = 0;
    var moveable = false;
    var docMouseMoveEvent = document.onmousemove;
    var docMouseUpEvent = document.onmouseup;
    titleBar.onmousedown = function() {
    var evt = getEvent();
    moveable = true; 
    moveX = evt.clientX;
    moveY = evt.clientY;
    moveTop = parseInt(msgObj.style.top);
    moveLeft = parseInt(msgObj.style.left);
    
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
					if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
					}
			}
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
    }
    
    var closeBtn = tr.insertCell(-1);
    closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
    closeBtn.innerHTML = "<span id='span00' style='font-size:15pt; color:"+titlecolor+";'>×</span>";
    $("#span00").click(function(){//关闭窗口
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj);
    });
    var msgBox = table.insertRow(-1).insertCell(-1);
    msgBox.style.cssText = "font:10pt '宋体';";
    msgBox.colSpan = 2;
	if(act == "cate"){
		 msgBox.innerHTML = "<div class='liuyan'><form name='ly_form' action=''><ul><li>口味：<input name='kw' value='1' type='radio' checked  />&nbsp;1&nbsp;<input name='kw' value='2' type='radio' />&nbsp;2&nbsp;<input name='kw' value='3' type='radio' />&nbsp;3&nbsp;<input name='kw' value='4' type='radio' />&nbsp;4&nbsp;<input name='kw' value='5' type='radio' />&nbsp;5&nbsp;</li><li>环境：<input name='hj' value='1' type='radio' checked  />&nbsp;1&nbsp;<input name='hj' value='2' type='radio' />&nbsp;2&nbsp;<input name='hj' value='3' type='radio' />&nbsp;3&nbsp;<input name='hj' value='4' type='radio' />&nbsp;4&nbsp;<input name='hj' value='5' type='radio' />&nbsp;5&nbsp;</li><li>人均消费:<input type='text' name='rjxf' class='rjxf'>元</li><li>点评内容：</li><li><textarea name='nr'></textarea></li><li><img onclick='ly_img11()' src='var/template/images/third_6_Buy_ticket_29.gif' alt='' />&nbsp;&nbsp;<img onclick='ly_img22()' src='var/template/images/third_6_Myhome_mail1_05.gif' alt='' /></li></ul></form></div>";
	}
	if(act == "tese"){
		msgBox.innerHTML = "<div class='liuyan'><form name='ly_form' action=''><ul><li>推荐：<input name='kw' value='1' type='radio' checked  />&nbsp;1&nbsp;<input name='kw' value='2' type='radio' />&nbsp;2&nbsp;<input name='kw' value='3' type='radio' />&nbsp;3&nbsp;<input name='kw' value='4' type='radio' />&nbsp;4&nbsp;<input name='kw' value='5' type='radio' />&nbsp;5&nbsp;</li><li>特色：<input name='hj' value='1' type='radio' checked  />&nbsp;1&nbsp;<input name='hj' value='2' type='radio' />&nbsp;2&nbsp;<input name='hj' value='3' type='radio' />&nbsp;3&nbsp;<input name='hj' value='4' type='radio' />&nbsp;4&nbsp;<input name='hj' value='5' type='radio' />&nbsp;5&nbsp;</li><li>点评内容：</li><li><textarea name='nr'></textarea></li><li><img onclick='ly_img12()' src='var/template/images/third_6_Buy_ticket_29.gif' alt='' />&nbsp;&nbsp;<img onclick='ly_img22()' src='var/template/images/third_6_Myhome_mail1_05.gif' alt='' /></li></ul></form></div>";
	}
     // 获得事件Event对象，用于兼容IE和FireFox
	function getEvent() {
			 return window.event || arguments.callee.caller.arguments[0];
	}
}
function ly_img11(){
	$.ajax({
		url:"/ajax/pinglun_cate.php",
		type:"POST",
		data:"kw="+$('.liuyan li input:checked').eq(0).val()+"&hj="+$('.liuyan li input:checked').eq(1).val()+"&content="+$('.liuyan li textarea').val()+"&aid="+$('#archivesid').val()+"&price="+$('.rjxf').val(),
		success:function(subm){
			if (subm=='succ'){
				$(".ms_text").prepend("<div class='ms_pl'><div class='mspl_1'><img src='"+$('#photopic').val()+"' alt='' /></div><div class='mspl_2'><div class='mspl_2_1'><ul><li class='pl_usname'>"+$('.usnames').text()+"</li><li>口味："+$('.liuyan li input:checked').eq(0).val()+"</li><li>卫生："+$('.liuyan li input:checked').eq(1).val()+"</li><li>人均消费："+$('.rjxf').val()+"元</li></ul></div><div class='mspl_2_2'>"+$('.liuyan li textarea').val()+"</div></div></div>");
				$("#span00").click();
			} else {alert(subm)}
		},
		error:function(){
			alert("Error！");
		}
	});

	//document.ly_form.submit();
}

function ly_img12(){
	$.ajax({
		url:"/ajax/pinglun_tese.php",
		type:"POST",
		data:"kw="+$('.liuyan li input:checked').eq(0).val()+"&hj="+$('.liuyan li input:checked').eq(1).val()+"&content="+$('.liuyan li textarea').val()+"&aid="+$('#archivesid').val(),
		success:function(subm){
			if (subm=='succ'){
				$(".ms_text").prepend("<div class='ms_pl'><div class='mspl_1'><img src='"+$('#photopic').val()+"' alt='' /></div><div class='mspl_2'><div class='mspl_2_1'><ul><li class='pl_usname'>"+$('.usnames').text()+"</li><li>口味："+$('.liuyan li input:checked').eq(0).val()+"</li><li>卫生："+$('.liuyan li input:checked').eq(1).val()+"</li></ul></div><div class='mspl_2_2'>"+$('.liuyan li textarea').val()+"</div></div></div>");
				$("#span00").click();
			} else {alert(subm)}
		},
		error:function(){
			alert("Error！");
		}
	});

	//document.ly_form.submit();
}

function ly_img22(){
	document.ly_form.reset();
}

function alertWin1(title, w, h, ref){

    var titleheight = "22px"; // 提示窗口标题高度 
    var bordercolor = "#8fc704"; // 提示窗口的边框颜色 
    var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
    var titlebgcolor = "#8fc704"; // 提示窗口的标题背景色
    var bgcolor = "#FFFFFF"; // 提示内容的背景色
    
    var iWidth = document.documentElement.clientWidth; 
    var iHeight = document.documentElement.clientHeight; 
    var bgObj = document.createElement("div"); 
	var kheiget = document.body.offsetHeight;//网页可见区域的高
		per =document.getElementById("disb");
    

	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
    document.body.appendChild(bgObj); 
    
    var msgObj=document.createElement("div");
	if (window.navigator.userAgent.indexOf("MSIE")>=1){
		msgObj.style.cssText = "position:absolute;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;top:"+(kheiget-h)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	}
	if (window.navigator.userAgent.indexOf("Firefox")>=1){
		msgObj.style.cssText = "position:fixed;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	}

   // msgObj.style.cssText = "position:fixed;font:11px '宋体';bottom:100px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
    document.body.appendChild(msgObj);
    
    var table = document.createElement("table");
    msgObj.appendChild(table);
    table.style.cssText = "margin:0px;border:0px;padding:0px;";
    table.cellSpacing = 0;
    var tr = table.insertRow(-1);
    var titleBar = tr.insertCell(-1);
    titleBar.style.cssText = "width:92%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
    titleBar.style.paddingLeft = "10px";
    titleBar.innerHTML = title;
    var moveX = 0;
    var moveY = 0;
    var moveTop = 0;
    var moveLeft = 0;
    var moveable = false;
    var docMouseMoveEvent = document.onmousemove;
    var docMouseUpEvent = document.onmouseup;
    titleBar.onmousedown = function() {
    var evt = getEvent();
    moveable = true; 
    moveX = evt.clientX;
    moveY = evt.clientY;
    moveTop = parseInt(msgObj.style.top);
    moveLeft = parseInt(msgObj.style.left);
    
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
					if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
					}
			}
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
    }
    
    var closeBtn = tr.insertCell(-1);
    closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
    closeBtn.innerHTML = "<span id='span00' style='font-size:15pt; color:"+titlecolor+";'>×</span>";
    $("#span00").click(function(){//关闭窗口
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj);
    });
    var msgBox = table.insertRow(-1).insertCell(-1);
    msgBox.style.cssText = "font:10pt '宋体';";
    msgBox.colSpan = 2;
    msgBox.innerHTML = "<div class='liuyan'><form name='ly_form' action=''><ul><li>好评度：<input name='tuijian' value='1' type='radio' checked  />&nbsp;1&nbsp;<input name='tuijian' value='2' type='radio' />&nbsp;2&nbsp;<input name='tuijian' value='3' type='radio' />&nbsp;3&nbsp;<input name='tuijian' value='4' type='radio' />&nbsp;4&nbsp;<input name='tuijian' value='5' type='radio' />&nbsp;5&nbsp;</li><li>点评内容：</li><li><textarea name='nr'></textarea></li><li><input type='hidden' name='userid' value='{user.id}' id='userid'/></li><li><img onclick='ly_img1()' src='/var/template/images/third_6_Buy_ticket_29.gif' alt='' />&nbsp;&nbsp;<img onclick='ly_img2()' src='/var/template/images/third_6_Myhome_mail1_05.gif' alt='' /></li></ul></form></div>";

     // 获得事件Event对象，用于兼容IE和FireFox
	function getEvent() {
			 return window.event || arguments.callee.caller.arguments[0];
	}
}
function ly_img1(){
	$.ajax({
		url:"/ajax/pinglun.php",
		type:"POST",
		data:"tuijian="+$('.liuyan li input:checked').eq(0).val()+"&content="+$('.liuyan li textarea').val()+"&aid="+$('#archivesid').val(),
		success:function(subm){
			if (subm=='succ'){
				$(".ms_text").prepend("<div class='ms_pl'><div class='mspl_1'><img src='"+$('#photopic').val()+"' alt='' /></div><div class='mspl_2'><div class='mspl_2_1'><ul><li class='pl_usname'>"+$('.usnames').text()+"</li><li>推荐度："+$('.liuyan li input:checked').eq(0).val()+"</li></ul></div><div class='mspl_2_2'>"+$('.liuyan li textarea').val()+"</div></div></div>");
				$("#span00").click();
			} else {alert(subm)}
		},
		error:function(){
			alert("Error！");
		}
	});
	//document.ly_form.submit();
}
function ly_img2(){
	document.ly_form.reset();
}
function panduan(act){
	$.ajax({
		url:"/ajax/panduan.php",
		type:"POST",
		data:"aid="+$('#archivesid').val(),
		success:function(subm){
			if (subm=='succ'){
				if(act == "0"){
					alertWin1($('.ms_name').text(),400,315,this);
				}
				if(act == "1"){
					alertWin($('.ms_name').text(),400,315,this,'cate');
				}
				if(act == "2"){
					alertWin($('.ms_name').text(),400,315,this,'tese');
				}
			} else {alert(subm)}
		},
		error:function(){
			alert("Error！");
		}
	});
}
function queren1(){
	document.form_queren.submit();
}
function del(x,y){	
	if(confirm("您确定要删除吗?")){
		window.location.href='del.php?id='+y;
    }
}

function admin_del(id){
	var iWidth = document.documentElement.clientWidth; 
	var kheiget = document.body.offsetHeight;//网页可见区域的高
	var iHeight = document.documentElement.clientHeight; 
	//(iWidth-w)/2
	var w = $("#tanc").width();
	var h = $("#tanc").height();
	var Twidth = (iWidth-w)/2;
	var Theight = (iHeight-h)/2;
	$("#tanc").css({left:Twidth+'px',top:Theight+'px'});
	$("#tanc").show();
	$("#aid").val(id);
}
