﻿function OpenUrl(Url,Width,Height,scrollbars){
 window.open(""+Url,"","Width="+Width+",Height="+Height+",top=100,left=100,status=no,scrollbars="+scrollbars)
}
function GP(n){
 var dight = n/10;
 var l = dight.toString().length - (dight.toString().indexOf('.') + 1);
 for(var i=l;i>=0;i--)
	dight = new Number(dight.toFixed(i));
 return dight*10; 
} 
function showTable(sel){
 var val ,cur;
 var r_one = document.getElementById('r_one');
	var r_two = document.getElementById('r_two');
	if(r_one.checked){
		val = 0;
		cur = 0;
	}
	if(r_two.checked){
		val = 1;
		cur = 1;
	}
 if(val == 0){
	document.getElementById("BackDate").style.display = "none";
	document.getElementById("sMultiCity").style.display = "none";
	document.getElementById("eMultiCity").style.display = "none";
	document.getElementById("MultiDate").style.display = "none";
	searchInit();
	}
 else if(val == 1){
	document.getElementById("BackDate").style.display = "block";
	document.getElementById("sMultiCity").style.display = "none";
	document.getElementById("eMultiCity").style.display = "none";
	document.getElementById("MultiDate").style.display = "none";
	searchInit();
	}
 else{
	document.getElementById("BackDate").style.display = "none";
	document.getElementById("sMultiCity").style.display = "none";
	document.getElementById("eMultiCity").style.display = "none";
	document.getElementById("MultiDate").style.display = "none";
	searchInit();
	}
 form1.Istrue.value = val;
}
function CheckDate(s){
 var Today = new Date();
 var y,m,d,t;
 y = Today.getFullYear();
 m = Today.getMonth() + 1;
 if(m<10) m = "0"+m;
 d = Today.getDate();
 if(d<10) d = "0"+d;
 t = y + "-" + m + "-" + d;
 return (t>s);
}
function Check(){
with(form1){
 var sel = Istrue.value;
 if(sel == 3){}
 else{
	if(EndCity.value == StartCity.value){
		alert("出发城市与到达城市不能相同！");
		EndCity.focus();
		return false;}
	if(CheckDate(StartDate.value)){
		alert("出发日期不能小于当前日期！");
		StartDate.focus();
		return false;}
	if(sel == 1){
		if(CheckDate(BackDate.value)){
			alert("回程日期不能小于当前日期！");
			BackDate.focus();
			return false;}
		if(BackDate.value < StartDate.value){
			alert("回程日期不能小于出发日期！");
			BackDate.focus();
			return false;}}
//	if(sel == 2){
//		if(EndCity2.value == StartCity2.value){
//			alert("出发城市与到达城市不能相同！");
//			EndCity2.focus();
//			return false;}
//		if(CheckDate(StartDate2.value)){
//			alert("第二出发日期不能小于当前日期！");
//			StartDate2.focus();
//			return false;}
//		if(StartDate2.value < StartDate.value){
//			alert("第二出发日期不能小于第一出发日期！");
//			StartDate2.focus();
//			return false;}}
	}
 }
}

function scrollImg(){
    var posX=0;
    var posY=0;
    if (window.innerHeight) {
        posX = document.body.clientWidth-180;
        posY = window.pageYOffset;
    }
else if (document.documentElement && document.documentElement.scrollTop) {
posX = document.body.clientWidth-180;
posY = document.documentElement.scrollTop;
}
else if (document.body) {
posX = document.body.clientWidth-180;
posY = document.body.scrollTop;
    }
var ad=document.getElementById("floatDiv");
   ad.style.top=(posY+100)+"px";
    ad.style.left=posX+"px";
    setTimeout("scrollImg();",500);
}

function GetPrice(orderInfo,flightId){
	var flightDate = document.getElementById(flightId).value;
	orderInfo = flightDate+orderInfo;
	YDform.StrValue.value=orderInfo;
	 var s = orderInfo.split("$");
	 var pAdult=0,pChild=0,pBaby=0,pTax=0,pOil=0;
	 if(YDform.StrValue.value != ""){
		s = YDform.StrValue.value.split("$");
		pAdult += eval(s[11]);
		pChild += eval(GP(s[12]*0.5));
		pBaby += eval(GP(s[12]*0.1));
		pTax += eval(s[13]);
		pOil += eval(s[14]);
		}
	 YDform.AduPrice.value = pAdult;
	 YDform.ChiPrice.value = pChild;
	 YDform.InfPrice.value = pBaby;
	 YDform.TaxPrice.value = pTax;
	 YDform.OilPrice.value = pOil;
	 YDform.submit();
	}
function postSearching(searchInfo,s_city,e_city,s_date){
	searchForm.StrValue.value=searchInfo;
	searchForm.StartCity.value=s_city;
	searchForm.EndCity.value=e_city;
	searchForm.StartDate.value=s_date;
	searchForm.submit();
}

function ChgStr(){
	var str,fp;
	var r_one = document.getElementById('r_one');
	var r_two = document.getElementById('r_two');
	if(r_one.checked){
		str = 0;
		fp = 0;
	}
	if(r_two.checked){
		str = 1;
		fp = 1;
	}
	with(form1){
	 str += "$" + StartCity.value.split(",")[0];
	 str += "$" + EndCity.value.split(",")[0];
	 str += "$" + StartDate.value;
	 str += "$" + StartTime.value;
	 if(fp==1||fp==3)
	 {
	   str += "$" + BackDate.value;
	   str += "$" + BackTime.value;
	 }
	 if(fp==2)
	 { 
	   str += "$" + StartCity2.value.split(",")[0];
	   str += "$" + EndCity2.value.split(",")[0];
	   str += "$" + StartDate2.value;
	   str += "$" + StartTime2.value;
	 }
	 str += "$" + AirLine.value;
	    str += "$L";
	 StrValue.value = str;
	}
	}

function searchCheck(){
	var r_two = document.getElementById('r_two');
	with(form1){
	 if(form1.EndCity.value == form1.StartCity.value){
		alert("出发城市与到达城市不能相同！");
		EndCity.focus();
		return false;}
	 if(CheckDate(form1.StartDate.value)){
		alert("出发日期不能小于当前日期！");
		form1.StartDate.focus();
		return false;}
	if(r_two.checked)
	{
	 if(CheckDate(form1.BackDate.value)){
		alert("回程日期不能小于当前日期！");
		form1.BackDate.focus();
		return false;}
	 if(form1.BackDate.value < form1.StartDate.value){
		alert("回程日期不能小于出发日期！");
		form1.BackDate.focus();
		return false;}
		}
	 }
	 return true;
	}

function searchInit(){
	ACN(form1.StartCity,"SZX");
	ACN(form1.EndCity,"XMN");
	SV(form1.StartCity,"SZX,深圳");
	SV(form1.EndCity,"XMN,厦门");
	SV(form1.StartTime,"");	
	SV(form1.BackTime,"");	
}

function resetSearch(date){
	var str = searchForm.Istrue.value;
	var fp = str;
	 str += "$" + searchForm.StartCity.value.split(",")[0];
	 str += "$" + searchForm.EndCity.value.split(",")[0];
	 str += "$" + date;
	 str += "$" + searchForm.StartTime.value;
	 if(fp==1||fp==3)
	 {
	   str += "$" + searchForm.BackDate.value;
	   str += "$" + searchForm.BackTime.value;
	 }
	 if(fp==2)
	 { 
	   str += "$" + searchForm.StartCity2.value.split(",")[0];
	   str += "$" + searchForm.EndCity2.value.split(",")[0];
	   str += "$" + searchForm.StartDate2.value;
	   str += "$" + searchForm.StartTime2.value;
	 }
	 str += "$" + searchForm.AirLine.value;
	    str += "$F";
	    searchForm.StartDate.value = date;
	    searchForm.StrValue.value = str;
	    searchForm.submit();
	}

function resetSearchBack(date){
	var str = searchBackForm.Istrue.value;
	var fp = str;
	 str += "$" + searchBackForm.StartCity.value.split(",")[0];
	 str += "$" + searchBackForm.EndCity.value.split(",")[0];
	 str += "$" + searchBackForm.StartDate.value;
	 str += "$" + searchBackForm.StartTime.value;
	 if(fp==1||fp==3)
	 {
	   str += "$" + date;
	   str += "$" + searchBackForm.BackTime.value;
	 }
	 if(fp==2)
	 { 
	   str += "$" + searchBackForm.StartCity2.value.split(",")[0];
	   str += "$" + searchBackForm.EndCity2.value.split(",")[0];
	   str += "$" + searchBackForm.StartDate2.value;
	   str += "$" + searchBackForm.StartTime2.value;
	 }
	 str += "$" + searchBackForm.AirLine.value;
	    str += "$F";
	    searchBackForm.BackDate.value = date;
	    searchBackForm.StrValue.value = str;
	    searchBackForm.submit();
	}