var doc = document.all;

function v() {
	return;
}

function errorImg(aImg,cSrc){
	//alert("文件显示出错，将被替换成logo.gif");
	aImg.src=cSrc;
}

function funShowGetpass(){
	var url = "/membersys/findpwd/iMain.vm";
	freezeBG("getPass",590,420);
	//$("#getPass").show();
	$("#getPass").load(url);
}

/*四舍五入
	v - 待处理值；	e - 保留小数多少位？
*/
function round(v,e){ 
	var t=1; 
	for(;e>0;t*=10,e--); 
	for(;e<0;t/=10,e++); 
	return Math.round(v*t)/t; 
} 

/**login & reg fun for jQuery - Start**/
function ajaxOpenRegPage(){
	document.getElementById("login").style.display = "none";
	document.getElementById("regUser").style.display = "block";
}
function ajaxLogin(methodName){
	var url = "/j_security_check.aifei";
	$.ajax({
	  url: url,
      data: $('#loginForm').serialize(),
      type: 'GET',
	  success: function(html){
	    if(html.Trim()=="1"){eval(methodName);}
	    else{alert("登陆不成功!\n\n请检查您是否正确输入用户名和密码,注意大小写喔!");}
	  }
	});
}
function ajaxReg(methodName){
	if(!ajaxCheckRegValid()){return false;}
	var url = "/userFrontScript.do?method=registerMember&f=ajax";
	$.ajax({
	  url: url,
      data: $('#RegisterForm').serialize(),
      type: 'GET',
	  success: function(html){
	    if(html.Trim()=="1"){
	    	$("#j_username").val($("#loginName").val());$("#j_password").val($("#pwd").val());
	    	ajaxLogin(methodName);
	    }else{alert("注册失败!\n\n请检查您输入的注册资料是否正确!");}
	  }
	});
}
	/*reg valid*/
	function ajaxCheckRegValid(){
		if($("#tel").val().Trim()==""){
			$("#reg_tel_msg").show();
			$("#tel").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
			$("#reg_tel_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>请填写手机号</font>");
			return false;
		}else if($("#tel").val().match(/^[0-9]+$/)==null){return false;}
		if($("#loginName").val().Trim()==""){
			$("#reg_loginName_msg").show();
			$("#loginName").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
			$("#reg_loginName_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>请填写用户名</font>");
			return false;
		}if($("#pwd").val()!=$("#pwdConfirm").val() || $("#pwd").val().Trim()==""){
			$("#reg_pwdConfirm_msg").show();
			$("#pwdConfirm").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
			$("#reg_pwdConfirm_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>两次密码不相同</font>");
			$("pwdConfirm").select();
			return false;
		}if($("#IDCard").val().Trim()==""){
			$("#reg_IDCard_msg").show();
			$("#IDCard").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
			$("#reg_IDCard_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>请填写身份证号</font>");
			return false;
		}else{
			var cs = checkIdcard($("#IDCard").val());
			$("#reg_IDCard_msg").show();
			if(cs!="验证通过!"){
				$("#IDCard").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
				$("#reg_IDCard_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>"+cs+"</font>");
				return false;
			}else{
				$("#IDCard").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
				$("#reg_IDCard_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />&nbsp;<font color=green>"+cs+"</font>");
			}
		}
		$("#valid").val(1);return true;
	}
		function ajaxCheckLoginName(cValue){
			$("#reg_loginName_msg").show();
			if(cValue.Trim()!=""){
				var url = '/userFrontScript.do?method=hasSameUser&loginName='+cValue;
				$.ajax({
				  url: url,
				  success: function(html){
				    checkLoginNameed(html);
				  }
				});
			}else{
				$("#loginName").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
				$("#reg_loginName_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>请填写用户名</font>");
				$("#valid").val(0);
			}			
		}
			function checkLoginNameed(cValue){
				if(cValue.Trim()=="true"){
					//把域边框或底色换成绿色表示通过验证
					$("#loginName").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
					$("#reg_loginName_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />&nbsp;<font color=green>可用</font>");
					return true;
				}else{
					$("#loginName").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' });
					$("#reg_loginName_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>该用户名已被注册</font>");
					$("#valid").val(0);return false;
				}
			}
		function ajaxCheckPWD(cValue){
			if(cValue.length>5){
				$("#pwd").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
				$("#reg_pwd_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />");
				$("#pwdConfirm").attr("readonly",false);
			}else{
				$("#pwd").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' });
				$("#reg_pwd_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />&nbsp;<font color=red>必须多于6个字符</font>");
				$("#valid").val(0);$("#reg_pwd_msg").show();$("#pwdConfirm").attr("readonly",true);
			}
		}
			function ajaxCheckPWDC(cValue){
				if(cValue.Trim()!="" && cValue==$("#pwd").val()){
					$("#pwd").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
					$("#reg_pwd_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />");
					$("#pwdConfirm").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
					$("#reg_pwdConfirm_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />");
				}else{
					$("#pwdConfirm").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' });
					$("#reg_pwdConfirm_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />&nbsp;<font color=red>密码不一致</font>");
					$("#valid").val(0);$("#reg_pwdConfirm_msg").show();
				}
			}
		function ajaxCheckTel(cValue){
			$("#reg_tel_msg").show();
			if(cValue.Trim()!=""){
				if(cValue.match(/^[0-9]+$/)==null){
					$("#tel").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
					$("#reg_tel_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>手机号必须是数字</font>");
				}else{
					if(cValue.length>=11 && cValue.length<20){
						var url = '/userFrontScript.do?method=hasSameTel&tel='+cValue;
						$.ajax({
						  url: url,
						  success: function(html){
						    ajaxCheckTeled(html);
						  }
						});
					}else{
						$("#tel").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
						$("#reg_tel_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>手机号不正确</font>");
					}
				}
			}else{
				$("#tel").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
				$("#reg_tel_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>请填写联系电话</font>");
				$("#valid").val(0);
			}
		}
			function ajaxCheckTeled(cValue){
				if(cValue.Trim()=="true"){
					//把域边框或底色换成绿色表示通过验证
					$("#tel").css({   backgroundColor: '#C4FFC4',  border:'1px solid #0f0' });
					$("#reg_tel_msg").html("<img src='/style/img/checkr.gif' align='absmiddle' />");
					return true;
				}else{
					$("#tel").css({   backgroundColor: '#ffd7d7',  border:'1px solid #f00' }); 
					$("#reg_tel_msg").html("<img src='/style/img/checke.gif' align='absmiddle' />&nbsp;<font color=red>该号码已被注册</font>");$("#reg_tel_msg").show();
					$("#valid").val(0);return false;
				}
			}
/**login & reg fun - End**/

function keyUp(e) {
 　 	var currKey=0,e=e||event;
	currKey=e.keyCode||e.which||e.charCode;
　　 var keyName = String.fromCharCode(currKey);
　　 //alert("按键码: " + currKey + " 字符: " + keyName);
	if(currKey==9){document.getElementById("j_username").focus();}
}

function freezeBG(winID,winW,winH){
	//document.onkeyup = keyUp;
//	$(window).bind("keydown",function(event){if(event.keyCode==9){event.preventDefault();}});	//can use ff ; can't use ie
	//document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	var w = document.body.clientWidth*1;var h = document.documentElement.clientHeight*1+document.documentElement.scrollTop*2+100;
	var winL = (w-winW)/2;var winT = (h-winH)/2;
  	var win=document.createElement("div");
	var p = document.getElementsByTagName('body')[0];
	if(document.getElementById("freezeDiv")==null){
	  	var div=document.createElement("div");
	  	div.name="freezeDiv";div.id="freezeDiv";
	  	div.className="opacityBg";
	  	div.style.display = "block";
	  	div.style.top = (document.documentElement.scrollTop-100)+"px";
	  	div.style.width=w+"px";div.style.height=h+"px";
		if(document.getElementById(winID)==null){
		  	win.name=winID;win.id=winID;
		  	win.className="freezePopWin";
		  	win.style.width=winW+"px";win.style.height=winH+"px";
		  	win.style.left=winL+"px";win.style.top=winT+"px";
		  	win.style.display = "block";
		  	p.appendChild(win);
		}
	  	p.appendChild(div);
  	}else{
		document.getElementById("freezeDiv").style.display='block';
	  	document.getElementById("freezeDiv").style.top = document.documentElement.scrollTop+"px";
		if(document.getElementById(winID)==null){
		  	win.name=winID;win.id=winID;
		  	win.className="freezePopWin";
		  	win.style.width=winW+"px";win.style.height=winH+"px";
		  	win.style.left=winL+"px";win.style.top=winT+"px";
		  	win.style.display = "block";
		  	p.appendChild(win);
		}else{document.getElementById(winID).style.display='block';}
  	}
	if(document.getElementById(winID)!=null){
		var win = document.getElementById(winID);
	  	win.style.width=winW+"px";win.style.height=winH+"px";
	  	win.style.left=winL+"px";win.style.top=winT+"px";
		win.style.display='block';win.style.visibility='visible';
	}
  	hiddenElementByType(0);
  	
	$(window).scroll( function() {fol(winID,winW,winH);} );
	$(window).resize( function() {fol(winID,winW,winH);} );
}
	function fol(winID,winW,winH){
		if(winID==0)return;
		var win = document.getElementById(winID);
		var w = document.body.clientWidth*1;var h = document.documentElement.clientHeight*1+document.documentElement.scrollTop*2+100;
		var winL = (w-winW)/2;var winT = (h-winH)/2;
		var div = document.getElementById("freezeDiv");
		div.style.top = (document.documentElement.scrollTop-100)+"px";
	  	div.style.width=w+"px";div.style.height=h+"px";
		win.style.left=winL+"px";win.style.top=winT+"px";
	}
function disfreezeBG(winID){
	if(document.getElementById("freezeDiv")!=null){
		document.getElementById("freezeDiv").style.display='none';
		document.getElementById(winID).style.display='none';
  	}
	//document.getElementsByTagName('html')[0].style.overflow = 'auto';		//lock or unlock scroll bar
  	hiddenElementByType(1);
}
	var _fBackCallForLogin_OK="";	//回调方法
	/**
	pop login box
		boxid - window's id
		fbc   - backCall's function name, sample: "abc()";
	**/
	function popLoginBox(boxid,fbc){
		_fBackCallForLogin_OK = fbc;
		//alert("popLoginBox:"+_fBackCallForLogin_OK);
		var url = "/module/login_and_reg.vm";
		$.ajax({
		  url: url,
		  cache: false,
		  success: function(html){
		    $("#"+boxid).html(html);
		    document.getElementById("login").style.display="block";
		  }
		});
	}
function hiddenElementByType(s){
	try{
		for (var i=0;i<document.all.tags("select").length; i++ ){
			if(s==0){document.all.tags("select")[i].style.visibility='hidden';}
			else{document.all.tags("select")[i].style.visibility='visible';}
		}
	}catch(e){}
}

function searchRecord(){
	var placeToS = document.getElementById("placeToS").value;
	if(placeToS.Trim()==""){alert("您未选择目的地城市!");return false;}
	var placeTo = document.getElementById("placeTo").value;
	var contentType = document.getElementById("contentType").value;
	setCookie("placeToS",placeToS,365);
	//alert(placeToS+"\n\nx:"+getCookie("placeToS"));
	setCookie("placeTo",placeTo,365);
	setCookie("contentType",contentType,365);
}
function searchHotelRecord(){
		var flag=[];
/*		alert("checkInDate:"+$('#checkInDate').val()+"\n\n"+$('#checkOutDate').val());
		if($('#checkInDate').val().indexOf("-")==-1 && $('#checkInDate').val().length==8){
			var cid = $('#checkInDate').val();				//20091112
			var ccid = cid.substring(0,4)+"-";
			ccid = ccid + cid.substring(4,6)+"-";
			ccid = ccid + cid.substring(6);
			$('#checkInDate').val(ccid);
		}else{
			var cid = $('#checkInDate').val();
			if(cid.length<10){
				var vc = cid.split("-");
				if(vc[0].length<4) cid="20"+vc[0];
				else cid=vc[0];
				if(vc[1].length<2) cid=cid+"0"+vc[1];
				else cid=cid+vc[1];
				if(vc[2].length<2) cid=cid+"0"+vc[2];
				else cid=cid+vc[2];
			}
			$('#checkInDate').val(cid);
		}
		if( $('#checkOutDate').val().indexOf("-")==-1  && $('#checkOutDate').val().length==8){
			var cid = $('#checkOutDate').val();				//20091112
			var ccid = cid.substring(0,4)+"-";
			ccid = ccid + cid.substring(4,6)+"-";
			ccid = ccid + cid.substring(6);
			$('#checkOutDate').val(ccid);
		}else{
			var cid = $('#checkOutDate').val();
			if(cid.length<10){
				var vc = cid.split("-");
				if(vc[0].length<4) cid="20"+vc[0];
				else cid=vc[0];
				if(vc[1].length<2) cid=cid+"0"+vc[1];
				else cid=cid+vc[1];
				if(vc[2].length<2) cid=cid+"0"+vc[2];
				else cid=cid+vc[2];
			}
			$('#checkOutDate').val(cid);
		}*/
		//return false;
		flag[0]=$('#checkInDate').val().isDateTime();
		if (!flag[0]){
			alert("入住时间不符合格式规范或无效的日期");
			return false;
		}
		flag[1]=$('#checkOutDate').val().isDateTime();
		if (!flag[1]){
			alert("离店时间不符合格式规范或无效的日期");
			return false;
		}
		if (flag[1]<=flag[0]){
			alert("离店时间不能早于或等于入住时间,"+$('#checkInDate').val());
			return false;
		}
		if (flag[1]-flag[0]>2419200000){
			alert("入住时间段不能超过28天");
			return false;
		}
		if($("#city").val()==""){
			alert("请您选择入住城市!");return false;
		}
		if($("#city").val()=="null"){
			alert("抱歉,所选城市目前无酒店资料!");return false;
		}
/* 	try{
		var s = replaceAll($('#checkInDate').val(),"-","");
	 	var e = replaceAll($('#checkOutDate').val(),"-","");
 		$('#checkInDate').val(s);
 		$('#checkOutDate').val(e);
 	}catch(e){
		var s = replaceAll($j('#checkInDate').val(),"-","");
	 	var e = replaceAll($j('#checkOutDate').val(),"-","");
 		$j('#checkInDate').val(s);
 		$j('#checkOutDate').val(e); 		
 	}
 	*/ 
	var cityTo = document.getElementById("city").value;
	var rankCode = document.getElementById("rankCode").value;
	var priceS = document.getElementById("priceS").value;
	var priceE = document.getElementById("priceE").value;
	setCookie("hotelCityTo",cityTo,365);
	setCookie("hotelRankCode",rankCode,365);
	setCookie("hotelPriceS",priceS,365);
	setCookie("hotelPriceE",priceE,365);
	return true;
	//alert(cityTo+"\n\nx:"+getCookie("hotelCityTo"));
}


/*
	@function - 	把阿拉伯数字转换成中文
	@param  Num -	传入需要转换的数字
	@return
*/
function Arabia_to_Chinese(Num){
	var i;
	Num = Num+"";
	for(i=Num.length-1;i>0;i--){
		Num = Num.replace(",","");	//替换tomoney()中的",”
		Num = Num.replace(" ","");	//替换tomoney()中的空格
	}
	Num = Num.replace("￥","");		//替换掉可能出现的￥字符
	if(isNaN(Num)) { //验证输入的字符是否为数字
		alert("请检查小写金额是否正确");
		return;
	}
	//---字符处理完毕，开始转换，转换采用前后两部分分别转换---//
	part = String(Num).split(".");
	newchar = ""; 
	//小数点前进行转化
	for(i=part[0].length-1;i>=0;i--){
		if(part[0].length > 10){ alert("位数过大，无法计算");return "";}	//若数量超过拾亿单位，提示
		tmpnewchar = ""
		perchar = part[0].charAt(i);
		switch(perchar){
			case "0": tmpnewchar="零" + tmpnewchar ;break;
	    		case "1": tmpnewchar="壹" + tmpnewchar ;break;
	    		case "2": tmpnewchar="贰" + tmpnewchar ;break;
		    	case "3": tmpnewchar="叁" + tmpnewchar ;break;
		    	case "4": tmpnewchar="肆" + tmpnewchar ;break;
		    	case "5": tmpnewchar="伍" + tmpnewchar ;break;
		    	case "6": tmpnewchar="陆" + tmpnewchar ;break;
		    	case "7": tmpnewchar="柒" + tmpnewchar ;break;
		    	case "8": tmpnewchar="捌" + tmpnewchar ;break;
		    	case "9": tmpnewchar="玖" + tmpnewchar ;break;
		}
		switch(part[0].length-i-1){
	    		case 0: tmpnewchar = tmpnewchar +"元" ;break;
	    		case 1: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
	    		case 2: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
	    		case 3: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
	    		case 4: tmpnewchar= tmpnewchar +"万" ;break;
	    		case 5: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
	    		case 6: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
	    		case 7: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
	    		case 8: tmpnewchar= tmpnewchar +"亿" ;break;
	    		case 9: tmpnewchar= tmpnewchar +"拾" ;break;
		}
		newchar = tmpnewchar + newchar;
	}
	//小数点之后进行转化
	if(Num.indexOf(".")!=-1){
		if(part[1].length > 2) {
			alert("小数点之后只能保留两位,系统将自动截段");
			part[1] = part[1].substr(0,2)
		}
		for(var i=0;i<part[1].length;i++){
	    		tmpnewchar = ""
	    		perchar = part[1].charAt(i)
	    		switch(perchar){
		    		case "0": tmpnewchar="零" + tmpnewchar ;break;
			    	case "1": tmpnewchar="壹" + tmpnewchar ;break;
			    	case "2": tmpnewchar="贰" + tmpnewchar ;break;
			    	case "3": tmpnewchar="叁" + tmpnewchar ;break;
			    	case "4": tmpnewchar="肆" + tmpnewchar ;break;
			    	case "5": tmpnewchar="伍" + tmpnewchar ;break;
			    	case "6": tmpnewchar="陆" + tmpnewchar ;break;
			    	case "7": tmpnewchar="柒" + tmpnewchar ;break;
			    	case "8": tmpnewchar="捌" + tmpnewchar ;break;
			    	case "9": tmpnewchar="玖" + tmpnewchar ;break;
	    		}
	    		if(i==0)tmpnewchar =tmpnewchar + "角";
	    		if(i==1)tmpnewchar = tmpnewchar + "分";
	    		newchar = newchar + tmpnewchar;
	   	}
	}
   	//替换所有无用汉字
   	while(newchar.search("零零") != -1)
		newchar = newchar.replace("零零", "零");
   	newchar = newchar.replace("零亿", "亿");
   	newchar = newchar.replace("亿万", "亿");
   	newchar = newchar.replace("零万", "万");
   	newchar = newchar.replace("零元", "元");
   	newchar = newchar.replace("零角", "");
   	newchar = newchar.replace("零分", "");
	if (newchar.charAt(newchar.length-1) == "元" || newchar.charAt(newchar.length-1) == "角")
		newchar = newchar+"整"
   	return newchar;
}

// 显示字数
function showStrLen(ele,strLimit,showLenDiv) {
	render(ele,strLimit);
	$(showLenDiv).innerHTML = "字数:" + ele.innerHTML.length;
}
/**
* 截取字符
*/
function render(ele,size) {
	if(!checkLength(ele.value,size)) {
		ele.value = ele.value.substr(0,size);
	}
}	
//-----打开前置的模式窗口[0]
//可用参数：urls，styles_t-top位置，styles_l--left位置，styles_w--窗口的宽，styles_h--窗口的高
function openbox_arrf(urls,styles_t,styles_l,styles_w,styles_h,strStyle,cT){
  var PrintStyle = "scroll:"+strStyle;
  var dialogArgs = new Array(); //定义参数 
  var result = new Array(); //定义参数   
  dialogArgs=cT; //参数赋值 
  styles = PrintStyle+";help:off;unadorned:no;center:yes;status:no;resizable:no;dialogTop:"+styles_t+";dialogLeft:"+styles_l+";dialogWidth:"+styles_w+"px;dialogHeight:"+styles_h+"px";
  result = showModalDialog(urls,dialogArgs,styles);
  try{return result;}
  catch(e){return 1}
}
//-----打开不前置的模式窗口
//可用参数：urls，styles_t-top位置，styles_l--left位置，styles_w--窗口的宽，styles_h--窗口的高
var result = "";
function openbox_m(urls,styles_t,styles_l,styles_w,styles_h,strStyle,cT){
  var PrintStyle = "scroll:"+strStyle;
  var dialogArgs = new Array(); //定义参数 
  var result = new Array(); //定义参数   
  dialogArgs=cT; //参数赋值 
  styles = PrintStyle+";center:yes;status:no;resizable:no;dialogTop:"+styles_t+";dialogLeft:"+styles_l+";dialogWidth:"+styles_w+"px;dialogHeight:"+styles_h+"px";
  result = showModelessDialog(urls,dialogArgs,styles)
  try{return result;}
  catch(e){return 1}
}

function getDateCC(dd,dadd){
	var a = new Date(dd)
	a = a.valueOf()
	a = a - dadd * 24 * 60 * 60 * 1000
	a = new Date(a)
	return (a.getFullYear() + "-" + (a.getMonth() + 1) + "-" + a.getDate())
}
function getDateCCC(dd,dadd){
	var a = new Date(dd);
	a = a.valueOf();
	a = a - dadd * 24 * 60 * 60 * 1000;
	a = new Date(a);
	var m = (a.getMonth() + 1);if(m<10)m="0"+m;
	var d = a.getDate();if(d<10)d="0"+d;
	return (a.getFullYear() + "-" + m + "-" + d);
}

function getDateFromString(strDate) { 
    var arrYmd = strDate.split("-");; 
    var numYear = parseInt(arrYmd[0]); 
    var numMonth = parseInt(arrYmd[1]) - 1; 
    var numDay = parseInt(arrYmd[2]); 
    return new Date(numYear, numMonth, numDay); 
     
}
/**
	maxDate : "2008-1-21"
	minDate : "2008-1-2"
**/
function getDiff(maxDate,minDate){
	var datTo = getDateFromString(maxDate); 
	var datFrom = getDateFromString(minDate); 
	var numDays = (datTo - datFrom)/(1000*60*60*24); 
	return numDays;
}
function recommendedURL(id){
	if(id!=""){
		var myHerf="http://www.aifei.com/userFrontScript.do?method=regMemberPage&binder="+id;
		var title="快来注册购机票换积分！";
		if(window.clipboardData){
			var tempCurLink=title + "\n" + myHerf;
			var ok=window.clipboardData.setData("Text",tempCurLink);
			if(ok) alert("按Ctrl + V ,粘贴发给您的朋友吧 ！");
		}else{alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");}
	}else{
		alert("抱歉，您可能未登陆成功！");
	}
}

//copy url
function CopyURL(){
	var myHerf=top.location.href;
	var title=document.title;
	if(window.clipboardData){
		var tempCurLink=title + "\n" + myHerf;
		var ok=window.clipboardData.setData("Text",tempCurLink);
		if(ok) alert("按Ctrl + V ,粘贴发到你需要的地方吧 ！");
	}else{alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");}
}
function CopyURL(txt){
	var myHerf=top.location.href;
	var title=document.title;
	if(window.clipboardData){
	var tempCurLink=title + "\n" + myHerf;
	var ok=window.clipboardData.setData("Text",tempCurLink);
	if(ok){if(txt!="")alert(txt)};
	}else{alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");}
}
//较验投票表单
function checkPollForm(){
	var obj = document.getElementsByName("optionid");
	var blPoll = false;
	for(var i=0;i<obj.length;i++){if(obj[i].checked){blPoll=true;break}}
	if(blPoll){document.getElementById("btnSubmit").click()}
	else{alert("请您最少选择一项！谢谢");return false;}
}

function checkContentType(cValue){
	if(cValue.Trim()!=""){
		if((/^([a-zA-Z0-9])+$/g.test(cValue))){
			//被检测的内容是字母+数字
			document.getElementById("contentType").value="1";
		}else{
			document.getElementById("contentType").value="0";
		}
	}
}

	function getCookie(NameOfCookie){
		if(document.cookie.length>0){
			var begin = document.cookie.indexOf(NameOfCookie+"=");
			if (begin!=-1){
				begin += NameOfCookie.length+1;
				var end = document.cookie.indexOf(";",begin);
				if (end==-1) end=document.cookie.length;
				return replaceAll(decodeURI(unescape(document.cookie.substring(begin,end)))," ","+");
			}return '';
		}return '';
	}
	function setCookie(NameOfCookie,value,expiredays){
		var ExpireDate = new Date();
		ExpireDate.setTime(ExpireDate.getTime()+(expiredays*24*3600*1000));
		document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays==null)?"":";expires="+ExpireDate.toGMTString()+";path=/");
	}
	function delCookie(NameOfCookie){
		var exp = new Date();
		exp.setTime(exp.getTime()-1);
		if(getCookie(NameOfCookie)!=null){document.cookie = NameOfCookie + "=" + ";expires="+exp.toGMTString();}
	}

function isMobil(s){
	var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;    
	if (!patrn.exec(s)) return false;
	return true   
}

//--强力校验身份证
function checkIdcard(idcard){
  var Errors=new Array("验证通过!","身份证号码位数不对!","身份证号码出生日期超出范围或含有非法字符!","身份证号码校验错误!","身份证地区非法!");
  var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
  var idcard,Y,JYM;
  var S,M;
  var idcard_array = new Array();
  idcard_array = idcard.split("");
  if(area[parseInt(idcard.substr(0,2))]==null) return Errors[4];
  switch(idcard.length){
    case 15:
      if ((parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
        ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
      }
      else{
        ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
      }
      if(ereg.test(idcard))
        return Errors[0];
      else
        return Errors[2];
    break;
  case 18:
    if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
      ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
    }
    else{
    ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
    }
    if(ereg.test(idcard)){
      S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 + parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6 + parseInt(idcard_array[9]) * 3 ;
      Y = S % 11;
      M = "F";
      JYM = "10X98765432";
      M = JYM.substr(Y,1);
      if(M == idcard_array[17])
        return Errors[0];
      else
        return Errors[3];
    }
    else
      return Errors[2];
    break;
  default:
    return Errors[1];
    break;
  }
  return true;
}

function onColor(td){
       td.className="trbgcolor2";
       td.style.color='#0600FF';
}

//打开/关闭tip...
function showTip(div,msg,evnt) {
	var obj = document.getElementById(div);
	var scrollTop;
	var scrollLeft;
	if (window.pageYOffset){scrollTop = window.pageYOffset;} 
	else if(document.documentElement && document.documentElement.scrollTop){scrollTop = document.documentElement.scrollTop; } 
	else if(document.body){scrollTop = document.body.scrollTop; } 
	if(window.pageXOffset){ scrollLeft=window.pageXOffset;} 
	else if(document.documentElement && document.documentElement.scrollLeft){scrollLeft=document.documentElement.scrollLeft;} 
	else if(document.body){scrollLeft=document.body.scrollLeft;}
	var x = evnt.clientX + scrollLeft;	//document.body.scrollLeft;
	var y = evnt.clientY + scrollTop;  //document.body.scrollTop;
//	if(msg!="") 
	obj.innerHTML = msg;
	obj.style.left = x + 10 + "px";
	obj.style.top = y - 52 + "px";
	if(obj.style.display != "block"){obj.style.display = "block";}
}
function closeTip(div){document.getElementById(div).style.display = "none";}

function hasChecked(cbid) {
	var cb = document.all[cbid];
	if(cb) {
		if(cb.length) {
			for(i=0;i<cb.length;i++) {
				if(cb[i].checked) {
					return true;
				}
			}
		} else {
			if(cb.checked) {
				return true;
			}
		}
	}
	return false;
}
/*通用checkbox检查*/

function commonCBCheck(cbid,alertStr,form) {
	if(hasChecked(cbid)) {
		if(confirm("你确定要进行此操作")) {
			form.submit();
			return true;
		}
	} else {
		alert(alertStr);
		return false;
	}
}



/**
*	检测字符长度
*/
function checkLength(str,len) {
	if(str.length>len)
		return false;
	return true;
}

/**
*	显示WIN层
*/
function openWinByID(winID) {
	openWin($(winID));
}
function openWin(win) {
	win.style.display = "block";
}

/**
*	隐藏WIN层
*/
function closeWin(win) {
	//alert(win);
	$(win).style.display = "none";
}


//这是以前的版本
//function closeWinByID(winID) {
//	try{
//		if($(winID)) {
//			$(winID).style.display = "none";
//		}
//	}catch(e){
//		document.getElementById(winID).style.display = "none";
//	}
//}

//这是现在的版本2010-1-4
function closeWinByID(winID) {
	try{
		if(ScriptHelperV2!=null ||ScriptHelperV2!=undefined){
			ScriptHelperV2.closeDivCommon(winID);
		}
		if($(winID)) {
			$(winID).style.display = "none";
		}
		
	}catch(e){
		document.getElementById(winID).style.display = "none";
	}
}

//结束



/**
*	在转跳之前进行检测
*   tips:提示信息,如:你还否要.... 
* 	url:转跳的地址
*/
function redirectURL(tips,url) {
	if(confirm(tips)) {
		self.location.href = url;
		return true;
	}
	return false;
}



/**
 * 处理AJAX返回信息
*/
function dealAjaxReturnInfo(originalRequest) {
	return originalRequest.responseText;
}

//提取菜单项，cMark用于通知后台当前选中的菜单（菜单name和方法名必须相同）
function loadAgentPublicMenu(cMark) {
	new Ajax.Updater('agentPublicMenu', '/menu.do?method=loadAgentPublicMenu&mark='+cMark, {asynchronous:true, evalScripts:true}); 
}

//将悬浮层的位置定位在屏幕中央
function setDivLocation(objdiv,obj){
	Position.clone(obj.id, objdiv.id);
	var top = objdiv.style.top;
	objdiv.style.top = getPositionNum(top) -200 + obj.offsetHeight + 2 + "px";	
	objdiv.style.left = "350px";
}
//将PX值转成数字
function getPositionNum(pos) {
	return pos.replace("px","")*1;
}

    /*
    	显示一个被隐藏的DIV，并在DIV中显示定义好的文字
    	@param color ：标准的HTML颜色代码：red或#FF0000
    	@param divID ：DIV的ID
    	@param txt   ：需要显示的文字
    */
    function showTxtToDiv(color,divID,txt){
    	try{
    		var tag = $(divID)
    		tag.style.display = "block";
    		tag.style.color=color;
    		tag.innerHTML = txt;
    	}catch(e){}
    }
    /*
    	把目标域的值转找成大写
    	@param objF 域对象
    */
    function changeToUC(objF){
    	try{
    		var tag = objF;
    		tag.value = tag.value.toUpperCase();
    	}catch(e){}
    }
/*
	@function - 循环替换字串字符
	@param cSrc - 源字符串
	@param cFind - 需要被替换的字符串
	@param cReplace - 将要被替换成的字符串
	@return - 返回替换成功的字符串
*/
function replaceAll(cSrc,cFind,cReplace){
	try{
		while (cSrc.indexOf(cFind)!=-1){
			cSrc = cSrc.replace(cFind,cReplace);
		}
		return cSrc;
	}catch(e){}
}
	/*
	* 调整字符串，使之在多值中唯一
	* @param srcValue 源字串（被检测的目标字串）
	* @param newItem 监控字串（检测此字串在“源字串”中是否存在，无则添加；有则剔除掉）
	* @param separate 多值分隔符号
	* @Return 返回处理后的字符串
	*/
	function ajustValue(srcValue,newItem,separate){
		var ajustedValue = "";
		try{
			var blExist = false;
			var arrValue = srcValue.split(separate);
			for (var i=0;i<arrValue.length;i++){
				if (arrValue[i].Trim()==newItem){		//-发现新加的item在源值中已经存在，则剔除掉
					arrValue[i] = "";
					blExist = true;
				}
				if (ajustedValue.Trim()=="")
					ajustedValue = arrValue[i].Trim();
				else{
					if (arrValue[i].Trim()!="")
						ajustedValue = ajustedValue + separate + arrValue[i];
				}
			}
			if (!blExist) ajustedValue = ajustedValue + separate + newItem;
		}catch(e){}
		return ajustedValue;
	}
	/*
	* -显示标签选择
	* 标签显示位置（div）必须存在
	*/
	var divTagsID = "";
	var tField = "";		//需要存放值的域名
	var tidField = "";		//需要存放ID的域名
	var blClose = false;	//选择完成后是否要关闭选择区域
	function loadTags(TagsID,targetField) {
		try{
			divTagsID = TagsID;
			tField = targetField;
			blClose = false;
			openWinByID(divTagsID);
			new Ajax.Updater(divTagsID,'/ajaxTagsList.do?method=ajaxTagList', {asynchronous:true, evalScripts:true});
		}catch(e){}
	}
	function selectItem(obj){
		if ($(tField).value.Trim()==""){
			$(tField).value = obj.innerHTML;
			if (tidField!=null && tidField!="") $(tidField).value=obj.id;
		}else{
			$(tField).value = ajustValue($(tField).value,obj.innerHTML,";");
			if (tidField!=null && tidField!="") $(tidField).value=ajustValue($(tidField).value,obj.id,";");
			//$(tField).value = $(tField).value + ";" + obj.innerHTML;
		}
		if (blClose) closeWinByID(divTagsID);
	}
	/*
	* - 选择航空公司
	*/
	function loadAirlines(TagsID,targetField,targetFieldID) {
		try{
			divTagsID = TagsID;
			tField = targetField;
			blClose = true;
			if (targetFieldID!=null && targetFieldID!="") tidField=targetFieldID;
			openWinByID(divTagsID);
			new Ajax.Updater(divTagsID,'/AirlineFrontScript.do?method=ajaxAirlineList', {asynchronous:true, evalScripts:true});
		}catch(e){}
	}	
//-对传入内容进行排版
function formatHTML(content){
		try
		{
			//处理多余符号
			content = content.replace(/(\n|\r|&nbsp;|　|)/ig,"");
			//杀死js
			content = content.replace(/<script.*?>.*?<\/scrip[^>]*>/ig,"");
			//content = content.replace(/<(.*?)[\s]+[^\s]+javascript:[^>^\s]*[\s]+(.*?)>/ig,"<$1 $2>");
			//content = content.replace(/<img([^>]*?)javascript:([^>]*)>/ig,"<img$1$2>");
			//杀死style
			content = content.replace(/<style[^>]*>.*?<\/styl[^>]*>/ig,"");
			//杀死垃圾内容
			content = content.replace(/<img[^>]*?http:\/\/www.pcpop.com\/doc\/Image\/popup.gif[^>]*>/ig,"");
			content = content.replace(/<img[^>]*?http:\/\/www.pcpop.com\/doc\/Image\/0ic.gif[^>]*>/ig,"");
			content = content.replace(/<img[^>]*?http:\/\/www.it.com.cn\/images\/comm\/arrow.gif[^>]*>/ig,"");
			content = content.replace(/<img[^>]*?http:\/\/images.enet.com.cn\/end.gif[^>]*>/ig,"");
			content = content.replace(/\([^\)]*资料[^\)]*文章[^\)]*价格[^\)]*评论[^\)]*\)/ig,"");
			content = content.replace(/\([^\)]*参数[^\)]报价*[^\)]*评论[^\)]*\)/ig,"");
			//清理多余html
			//Tag首
			content = content.replace(/<font[^>]*>/ig,'');
			content = content.replace(/<span[^>]*>/ig,'');
			content = content.replace(/<div([^>]*)>/ig,'<p$1>');
			content = content.replace(/<h1[^>]*>/ig,'');
			content = content.replace(/<h2[^>]*>/ig,'');
			content = content.replace(/<h3[^>]*>/ig,'');
			content = content.replace(/<code[^>]*>/ig,'<br>');
			content = content.replace(/<center([^>]*)>/ig,'<center$1>');
			content = content.replace(/<th[^>]*>/ig,'');
			content = content.replace(/<sohu[^>]*>/ig,'');
			content = content.replace(/<form[^>]*>/ig,'');
			content = content.replace(/<input[^>]*>/ig,'');
			content = content.replace(/<select[^>]*>/ig,'');
			content = content.replace(/<textarea[^>]*>/ig,'');
			content = content.replace(/<iframe[^>]*>/ig,'');
			content = content.replace(/<strong[^>]*>/ig,'<b>');
			content = content.replace(/<b\s[^>]*>/ig,'<b>');
			content = content.replace(/<st[^>]*>/ig,'');
			content = content.replace(/<o:p[^>]*>/ig,'');
			//Tag尾
			content = content.replace(/<\/font>/ig,'');
			content = content.replace(/<\/span>/ig,'');
			content = content.replace(/<\/div>/ig,'</p>');
			content = content.replace(/<\/h1>/ig,'');
			content = content.replace(/<\/h2>/ig,'');
			content = content.replace(/<\/h3>/ig,'');
			content = content.replace(/<\/code>/ig,'<br>');
			content = content.replace(/<\/center>/ig,'</center>');
			content = content.replace(/<\/th>/ig,'');
			content = content.replace(/<\/sohu[^>]*>/ig,'');
			content = content.replace(/<\/form[^>]*>/ig,'');
			content = content.replace(/<\/input[^>]*>/ig,'');
			content = content.replace(/<\/select[^>]*>/ig,'');
			content = content.replace(/<\/textarea[^>]*>/ig,'');
			content = content.replace(/<\/iframe[^>]*>/ig,'');
			content = content.replace(/<\/strong>/ig,'</b>');
			content = content.replace(/<\/st[^>]*>/ig,'');
			content = content.replace(/<\/o:p[^>]*>/ig,'');
			//单tag		
			content = content.replace(/<\?xml[^>]*>/ig,'');
			content = content.replace(/(<br[^>]*>)+/ig,'<br>');
			//清除解释文字
			content = content.replace(/<\!--.*?-->/ig,'');
			
			//处理表格
			//保留表格内容
			content = content.replace(/<(table|tbody|tr|td)[^>]*>/ig,'');
			content = content.replace(/<\/(table|tbody|tr|td)[^>]*>/ig,'');
					
			//去掉链接中的无用参数
			content = content.replace(/<a.*?href="([^"]*)"[^>]*>/ig,'<a href=\"$1\">');
			content = content.replace(/点击放大/ig,'<font color=#ff0000><b>点击放大</b></font>');
			//去掉图片中的无用参数
			content = content.replace(/<img.*?src=([^>]*)[^>]*>/ig,'<img src=$1 border=\"0\">');
			//去掉图片链接和加粗
			content = content.replace(/<a[^>]*>(([^\/]|\/[^a])*?<img([^\/]|\/[^a])*?)<\/a>/ig,'$1');
			content = content.replace(/<b>(([^\/]|\/[^b])*?<img([^\/]|\/[^b])*?)<\/b>/ig,'$1');
			content = content.replace(/(<img[^>]*>)\s*<\/a>/ig,'$1');
			//去多余b
			content = content.replace(/<b><\/b>/ig,'');
			content = content.replace(/<\/b><b>/ig,'');			
			
			//*/
			//*//强制图片居中，并处理小图并列，中间加空格
			content = content.replace(/(<img[^>]*>)/ig ,'<center>$1<\/center>');
			var re=/(<img[^>]*>)<\/center>(<b>|<\/b>|\s)*<center><img/;
			while(re.test(content)){
				content = content.replace(/(<img[^>]*>)<\/center>(<b>|<\/b>|\s)*<center><img/ig,"$1　<img");
			}
			
			//*/
			//格式文本
			content = "MM163brMM" + content;
			//换掉br
			content = content.replace(/<br[^>]*>/ig,'<br>');
			content = content.replace(/<br>(<br>|\s)*/ig,'<p>');
			//处理center和P
			content = content.replace(/<center>(<center>|\s)*/ig,'<center>');
			content = content.replace(/<\/center>(<\/center>|\s)*/ig,'</center>');
			content = content.replace(/<center>\s*<\/center>/ig,'');
			content = content.replace(/<p[^>]*>\s*<\/p>/ig,'');
			content = content.replace(/<center>/ig,'MM163brMM<center>');
			content = content.replace(/<\/center>/ig,'</center>MM163brMM');
			content = content.replace(/<p[^>]*>/ig,'MM163brMM');
			content = content.replace(/<\/p[^>]*>/ig,'');
			//处理段落
			content = content.replace(/MM163brMM(MM163brMM|\s)*/ig,'MM163brMM');
			content = content.replace(/MM163brMM/ig,'</p><p style="text-indent: 2em">');
			content = content.replace(/<p[^>]*>\s*<center>/ig,'<p><center>');//center不用退两格
			//去头加尾
			content = content.replace(/([^>\s]?)\s*<HR color=#ff0123>/ig,'$1</p><HR color=#ff0123>');
			content = content.replace(/<HR color=#ff0123>\s*([^<\s]?)/ig,'<HR color=#ff0123><p>$1');
			content = content.replace(/<p[^>]*>\s*?<\/p>/ig,'');
			content = content.replace("</p>","");
						
			content = replaceAll(content," onload=",'title=');
	
			
		}
		catch(ex){}
		finally{}
		return content;
}
function killA(content){
	try{
		content = content.replace(/<a[^>]*>(.*?)<\/a>/ig, "$1");
	}catch(e){}
	return content;
}
	//->格式化排版（针对编辑器）
	function fastFormat(objName){
		try{
			var cContent = FCKeditorAPI.GetInstance(objName).EditorDocument.body.innerHTML;
			cContent = formatHTML(cContent);
			FCKeditorAPI.GetInstance(objName).EditorDocument.body.innerHTML = cContent;
		}catch(e){}
	}
	//->清除超链（针对编辑器）
	function fastFormatA(objName){
		try{
			var cContent = FCKeditorAPI.GetInstance(objName).EditorDocument.body.innerHTML;
			cContent = killA(cContent);
			FCKeditorAPI.GetInstance(objName).EditorDocument.body.innerHTML = cContent;
		}catch(e){}
	}

	/**
	* - 初始化下拉框，使之默认选中initValue
	* @param obj			//目标select域对象	
	* @param initValue		//需要Select的值
	*/
	function initSelect(obj,initValue){
		try{
			var someNodeList = obj.getElementsByTagName('option');
        	var nodes = $A(someNodeList);
			var nIndex = 1;
			var i = 1;
        	nodes.each(function(node){
                if (node.innerHTML==initValue)
                	nIndex = i;
                i++;
            	});
        	obj.selectedIndex = (nIndex-1);  				
		}catch(e){window.status=e}	
	}

/* 监控按键，按回车执行指定事件（函数）
* @param event	事件，调用时直接传入event即可
* @param func	指定事件（函数）名
*/
function checkEnter(event,func){
	try{
		var NS4 = (document.layers) ? true : false;
	    var code = 0;
	    if (NS4)
	        code = event.which;
	    else
	        code = event.keyCode;
	    if (code==13){
	    	eval(func);
	    }
	}catch(e){}
}
function l(){try{setCookie('loginName',document.getElementById('j_username').value,3);}catch(e){}document.getElementById("loginForm").submit();}
	
/*
	@function - 去两边空格
	@param  - 
	@return 
*/
String.prototype.Trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}    

function isEqual(string1,string2) {
	if(string1.Trim()==string2.Trim()) {
		return true;
	} 
	return false;
}

function loadRecommendAgentWithNoCate(bType) {
	new Ajax.Updater('recommendAgentsWithCate', '/agentFrontScript.do?method=recommendAgentsWithCate&bType='+bType, {method:'post',asynchronous:true, evalScripts:true});
}

//-文件夹效果切换 - Start
	var c_IFRAMEID;
	function setFolderChange(obj,cCurID){
		try{
			for (var i=0;i<vFolder.length;i++){
				var cVF = vFolder[i];
				if (cVF==cCurID){
					//document.getElementById(cVF).className='menubar';
					$("img"+i).src="/style/default/header/img/search_m0"+(i+1)+"b.gif";
					$(vFolder[i]).style.display="block";
				}else{
					try{
						if ($(cVF).style.display!='none'){
							//document.getElementById(cVF).className='menubar1';
							$("img"+i).src="/style/default/header/img/search_m0"+(i+1)+".gif";
							$(vFolder[i]).style.display="none";
						}
					}catch(e){}	//-如果传入参数与定义的数组不一致时跳过
				}
			}
		}catch(e){alert("setFolderChange:"+e)}
	}
	
//-文件夹效果切换 - Start
	/*
		使用说明：
			vFolder - 文件夹内容区域的各个div的ID名称，数组方式传递进来
			cCurID	- 当前要操作的ID（也就是要显示的div的ID名称
			enabledName - 点亮当前操作的样式名
			disabledName - 关闭当前操作的样式名
	*/
	function setFolderChangeCSS(vFolder,cCurID,enabledName,disabledName){
		try{
			for (var i=0;i<vFolder.length;i++){
//				alert("cCurID="+cCurID+"\n\nvFolder["+i+"]="+vFolder[i]+"\n\nvFolder["+i+"].className="+$(vFolder[i]+"T").className);
				var cVF = vFolder[i];
				if (cVF==cCurID){
					//document.getElementById(cVF).className='menubar';					
					$(cVF).className=enabledName;
					//$(cVF).style.display="block";
				}else{
					try{
						if ($(cVF).style.display!='none'){
							//document.getElementById(cVF).className='menubar1';
							$(cVF).className=disabledName;
							//$(cVF).style.display="none";
						}
					}catch(e){}	//-如果传入参数与定义的数组不一致时跳过
				}
			}
		}catch(e){alert("setFolderChangeCSS:"+e)}
	}

	
//提取供应商产品
function loadProductList(cURL){
	var pars = "";
	var url = cURL;
	var myAjax = new Ajax.Request(
		url,{method: 'get', parameters: pars, onComplete: showResponse});
}
function showResponse(originalRequest){
    	cValue = originalRequest.responseText;
    	$("products").innerHTML = cValue;
}

//处理域内容显示效果
function tipsFieldFocus(obj,cValue){
	obj.style.color='#000000';
	obj.style.fontStyle='normal';
	if(obj.value==cValue){
		obj.value='';
	}
}
function tipsFieldBlur(obj,cValue){
	if(obj.value==''){
		obj.style.color='gray';
		obj.style.fontStyle='italic';
		obj.value=cValue;
	}
}

function funSshow(sshow){
	window.open("http://www.aifei.com/PlanTicketFrontScript.do?method=planTicketShowByID&id="+sshow+"&type=show&cReturn=/publish/planTicketShowByTemp1.vm","","");
}

/**
 标签搜索
*/
function searchTag(searchResult,tagName,type) {
	if(searchResult==null || searchResult=="") {

		location.href = 'tagSearch.do?method=search&goto=page&tagName='+ encodeURI(tagName) + '&type=' + type;

	} else {

		new Ajax.Updater(searchResult, 'tagSearch.do?method=search&goto=page&tagName='+encodeURI(tagName) + '&type=' + type, {method:'post',asynchronous:true, evalScripts:true});

	}
}

/**
 供应商登录后在供应商首页显示的供应商辅助面板
*/
function loadAgentInfoPanel() {
	new Ajax.Updater('agentInfoPanel', 'userManage.do?method=agentInfoPanel', {asynchronous:true, evalScripts:true});
}


//后台快捷搜索
function skey(className,value){
	var url = "/admin/"+className+"AdminScript.do?method=searchByKey&key="+$("cate").value+"&keyValue="+encodeURI(value);
	new Ajax.Updater(className.toLowerCase()+"List",url, {asynchronous:true, evalScripts:true});	
}

function adv_load(advDiv,advID) {
	new Ajax.Updater(advDiv, '/adv/' + advID + ".html", {asynchronous:true, evalScripts:true});
}

//////////////////////////////////////////////////////////////////////
//
// Move Div Begin...
//
//////////////////////////////////////////////////////////////////////

var Obj='';
document.onmouseup=MUp;
document.onmousemove=MMove;

function MDown(Object){
Obj=Object.id;
document.all(Obj).setCapture();
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}

function MMove(){
if(Obj!=''){
	document.all(Obj).style.left=event.x-pX;
	document.all(Obj).style.top=event.y-pY;
	}
}

function MUp(){
if(Obj!=''){
	document.all(Obj).releaseCapture();
	Obj='';
	}
}

//////////////////////////////////////////////////////////////////////
//
// Move Div End...
//
//////////////////////////////////////////////////////////////////////


/*
* 判断一个对象是否可见
*/
function isDisplayed(objID) {
	if($(objID).style.display!="none") {
		return true;
	}
}

//初始化航空公司下拉选择框
function loadAirlineSelect(originalRequest){
	new Ajax.Updater("",'/AirlineFrontScript.do?method=ajaxAirlineList', {asynchronous:true, evalScripts:true,onComplete:setAirCompanyChoose});
}
//--更新FlowChooseFun的域值  value1;value2           value1=text|value
function setChoosefunField(vValue){
	try{
		vValue = vValue.split(";");
		var i=0;
		for (i=0;i<vValue.length;i++){
			var vV = vValue[i].split("|");
			if (vV!=null){
//				alert("num="+vV.length+"\n\n-"+vV[0].Trim()+"-\n\n~"+vV[1].Trim().replace("\n","")+"~");
				document.getElementById("airlineSubject").options[i+1]=new Option(vV[0].Trim());
				document.getElementById("airlineSubject").options[i+1].value=vV[1].Trim();
			}
		}
	}catch(e){}
}
//-回调函数
function setAirCompanyChoose(originalRequest){
    var cValue = originalRequest.responseText;
    setChoosefunField(cValue);
}

	//预订表单提交
	function DestineformSubmit(id,source){
		try{
			if(document.getElementById("key01").value==""){alert("请填写您的姓名！");return false};
			if(document.getElementById("key02").value==""){alert("请填写您的去程日期！");return false};
			if(document.getElementById("key03").value==""){alert("请填写您的返程日期！");return false};
			if(document.getElementById("key04").value==""){alert("请填写您的电话！");return false};
			var subject = document.getElementById("key01").value+"先生/小姐需要订票";
//			var body = "航线："+$("key00")+"[br]去程日期："+$F("key02")+"[br]返程日期："+$F("key03")+"[br]电话："+$F("key04")+"[br]电子邮件："+$F("key05")+"[br]地址："+$F("key06")+"[br]留言："+$F("key07")+"[br]机票数量："+$F("key08");
			var body = "机票行程："+document.getElementById("key00").value+"[br]出发日期："+document.getElementById("key02").value+"[br]回程日期："+document.getElementById("key03").value+"[br]乘机人数："+document.getElementById("key08").value+"[br]联系人名："+document.getElementById("key01").value+"[br]联系电话："+document.getElementById("key04").value+"[br]乘客签证："+document.getElementById("key07").value+"[br]电子邮件："+document.getElementById("key05").value+"[br]地址："+document.getElementById("key06").value;
			var alertTxt = replaceAll(body,'[br]','\n');
			var url = "";
			if(id=="" || id==undefined) url=location.href;
			else if(id=="0") url= "无";
			else url = "http://www.aifei.com/PlanTicketFrontScript.do?method=planTicketShowByID~id="+id+"~type=show";
//			else url = "/airticket/"+id+".html";
			//alert("id:"+id+"\n\nurl:"+url);
			body = body + "[br]机票链接："+url;
			if(confirm("您将要预订的机票情况：\n\n"+alertTxt+"\n\n请确认！")){
				sendNoteToAdmin(subject+"("+document.getElementById("key04").value+")C",body,78);
				sendNoteToAdmin(subject+"("+document.getElementById("key04").value+")C",body,236);
				//var op = DestineformSelectOP();
				//sendNoteToAdmin(subject,body,op);
				sendNoteToBargain(subject,body,source);
			}else{return false;}
			//alert($F("key01")+" 先生/小姐，恭喜您！预订成功！\n\n稍后我们将联系您。");
			//location.reload();
			//$("btnReset").click();
		}catch(e){alert("预订失败，麻烦您直接致电我们的操作员(400-700-4066)\n\n"+e.description);return false;}
		return true;
	}
		rnd.today=new Date(); 
    	rnd.seed=rnd.today.getTime(); 
	    function rnd() { 
	　　　　rnd.seed = (rnd.seed*9301+49297) % 233280; 
	　　　　return rnd.seed/(233280.0); 
	    }
	    function rand(number) {return Math.ceil(rnd()*number);}
		function DestineformSelectOP(){
			var number = rand(2); 
			var vv = new Array("78","137","138");
			return vv[number];
		}
		/**异步发送小纸条给指定人员*/
		function sendNoteToBargain(noteTitle,noteBody,source) {
			if(noteTitle == "" || noteBody == "") {
				alert("你未填写标题或内容");
			} else {
				if(checkLength(noteTitle,50) && checkLength(noteBody,1024)) {
					var postData = "noteTitle=" + encodeURI(noteTitle) + "&noteBody=" + encodeURI(noteBody);
			//		var url = "http://lvtou.vicp.net/bargainOutside.do?method=sendOrderToBargain&type=tel&"+postData;
					var url = "/bargainOutside.do?method=sendOrderToBargainBefore&type=tel&"+postData;
					url=url+"&source="+source;
					document.getElementById("actionBargain").src=(url);
		
//					var postData = "noteTitle=" + noteTitle + "&noteBody=" + noteBody ;
//					var url = "http://lvtou.vicp.net/userManage.do?method=sendOrderToBargain&"+postData;
//					var url = "http://lvtou.vicp.net/bargainOutside.do?method=sendOrderToBargain&"+postData;
//					var url = "/bargainOutside.do?method=sendOrderToBargain&"+postData;
//					document.getElementById("actionBargain").src=encodeURI(url);
					try{if(top.document.getElementById('fillSubmitForm')!=null)setTimeout("top.document.getElementById('fillSubmitForm').style.display = 'none'",1500);}catch(e){}
//					new Ajax.Updater('', encodeURI(url), {method:'post',postBody:postData,onComplete:sendNoteToBargained ,asynchronous:true, evalScripts:true}); 
				} else {
					alert("提交内容过多,请缩减字数!");
				}
			}
		}
			function sendNoteToBargained(originalRequest) {
    			var cValue = originalRequest.responseText;
    			cValue = cValue.Trim();
    			var tmp = parent.$("key01").value+" 先生/小姐，";
				alert(tmp+cValue);
				setTimeout("parent.$('fillSubmitForm').style.display = 'none'",1500);
			} 
	

//--->机票搜索
	//检查搜索条件
	function checkRadio(objName){
		try{
			var obj = document.getElementsByName(objName);
			for (var i=0;i<obj.length;i++){
				if (obj[i].checked){
					getCate(i);
				}
			}		
		}catch(e){window.status=e}	
	}
	//定制搜索条件相关类别，发送请求给goSearch()
	function getCate(num){
		try{
			switch (num){
				case 0 :
					document.getElementById("category").value="";
					try{document.getElementById("rtdiv").style.display='block'}catch(e){}
					break;
				case 1 :
					document.getElementById("category").value="DC";
					try{document.getElementById("rtdiv").style.display='none'}catch(e){}
					break;
				case 2 :
					document.getElementById("category").value="SF";
					try{document.getElementById("rtdiv").style.display='block'}catch(e){}
					break;
				default:
			}	
		}catch(e){window.status=e}	
	}
	
	function showDetail(c,id,mode){
		var url = "/airticket/"+c+"-"+id+".html";
		if(mode=="blank"){window.open(url,"","");}
		else if(mode=="self"){self.location=(url);}
	}
	
//document.write("<script type='text/javascript' src='/script/reg_login.js'></script>");

	//Favorite item
	function getFavoriteIt(obj,type){
		this.obj=obj;
		this.type=type;
		var url="/FavoriteFront.do?method=isLogin&key="+Math.random()*1000;
//		new Ajax.Request(url,{method:'get',asynchronous:true,onSuccess:checkresponse});
		$.ajax({
		   type: "get",
		   url: url,
		   success: function(cValue){
			 	getFavoriteIted(cValue)
		   }
		});
	}
	function storeFavoriteIt(uid,obj,type){
		var url="/FavoriteFront.do?method=storeTicket&userID="+uid+"&ticket="+obj+"&type="+type+"&key="+Math.random()*1000;
		try{new Ajax.Request(url, {method:'get',asynchronous:true,onSuccess:favresponse});}
		catch(e){
			$.ajax({
			   type: "get",
			   url: url,
			   success: function(cValue){
				 	alert(cValue)
			   }
			});
		}
	}
