var NextcalendarAirName="calendarAir2";
var NextInputName="RETURN_DATE";
var national_if=1;

var searchImg=new Array(
new Array("http://resource.elong.com/en/home/images/search_flight_on.gif","http://resource.elong.com/en/home/images/search_flight.gif",""),
new Array("http://resource.elong.com/en/home/images/search_hotel_on.gif","http://resource.elong.com/en/home/images/search_hotel.gif",""),
new Array("http://resource.elong.com/en/home/images/search_vacation_on.gif","http://resource.elong.com/en/home/images/search_vacation.gif","")
);

function searchDisplay(j)
{
	switch(j)
	{
		case 0:
		  idObj("flightTable").style.display="";
		  idObj("FlightSetIn").style.display="";
		  idObj("hotelTable").style.display="none";
		  idObj("HotelSetIn").style.display="none";
			document.forms[0].isnative[0].checked=true; //Domestic: value==1
			document.forms[0].FLY_TYPE[1].checked=true; //One way: value==1
			isInerCheck(1); //Domestic
			WriteHotelCookie();
			ReadAirCookie();
			break;
			
		case 1:
			idObj("flightTable").style.display="none";
		idObj("FlightSetIn").style.display="none";
			idObj("hotelTable").style.display="";
			idObj("HotelSetIn").style.display="";
			document.forms[0].radiobutton[0].checked=true;
			WriteAirCookie();
			ReadHotelCookie();
			break;
	}
}

function setSearch(i)
{  
	for(var j=0;j<=1;j++)
	{
		if(j==i)
		{
			setImg("shimg"+j,searchImg[j][0],searchImg[j][2]);
		}
		else
		{
			setImg("shimg"+j,searchImg[j][1],searchImg[j][2]);
		}
	}
	searchDisplay(i);
}

function setImg(idName,imgURL,altText)
{
	theobj=idObj(idName);
	theobj.src=imgURL;
	//theobj.alt=altText;
}

function flightType(j)
{
	switch(j)
	{
		case 0:
			idObj("flightCityDp1").innerHTML="Departure City: ";
			idObj("flightCity1").innerHTML="Destination City: ";
			idObj("flightDateDiv").innerHTML="Departure Date: ";
			idObj("returnDiv").style.display="none";
			idObj("flightCityDp2").style.display="none";
			idObj("flightCityTr").style.display="none";
			idObj("flightDateDiv2").style.display="none";
			idObj("flightDateDiv2").style.display="none";
			//isFlightDouble(false);
			NextcalendarAirName="";
			NextInputName="";
			break;
			
		case 1:
			idObj("flightCityDp1").innerHTML="Departure City: ";
			idObj("flightCity1").innerHTML="Destination City: ";
			idObj("flightDateDiv").innerHTML="Departure Date: ";
			idObj("returnDiv").style.display="";
			idObj("flightCityDp2").style.display="none";
			idObj("flightCityTr").style.display="none";
			idObj("flightDateDiv2").style.display="none";
			idObj("flightDateDiv2").style.display="none";
			//isFlightDouble(false);
			NextcalendarAirName="calendarAir2";
			NextInputName="RETURN_DATE";
			break;
		
		case 2:
			idObj("flightCityDp1").innerHTML="Departure City #1: ";
			idObj("flightCity1").innerHTML="Destination City #1: ";
			idObj("flightDateDiv").innerHTML="Departure Date #1: ";
			
			idObj("returnDiv").style.display="none";
			idObj("flightCityDp2").style.display="";
			idObj("flightCityTr").style.display="";
			idObj("flightDateDiv2").style.display="";
			idObj("flightDateDiv2").style.display="";
			//isFlightDouble(true);
			NextcalendarAirName="calendarAir3";
			NextInputName="FLY_DATE2"			
			
			
			break;
	}
	//alert(NextcalendarAirName);
	//alert(NextInputName)
}

function isFlightDouble(isTrue)
{
	if(isTrue)
	{
		idObj("flightCity1").innerHTML="Destination City #1: ";
		
		if(isIE())
		{
			idObj("flightCityTr").style.display="";
		}
		else
		{
			idObj("flightCityTr").style.display="table-row";
		}
		
		idObj("flightDateDiv").style.display="";
		idObj("flightTable").className="flightTable2";
	}
	else
	{
		idObj("flightCity1").innerHTML="Destination City: ";
		idObj("flightCityTr").style.display="none";
		idObj("flightDateDiv").style.display="none";
		idObj("flightTable").className="flightTable";
	}
}

function idObj(theIdName) {
    return document.getElementById(theIdName);
}

function isInerCheck(i)
{
	var interPannel=document.getElementById("isInter");
	//var PersonType=document.getElementById("PersonType");
	
	/*if(i==1) //Domestic: value==1
	{
		interPannel.style.visibility="visible";
		PersonType.innerHTML="&nbsp;&nbsp;Infants(age 0-2):";
		document.forms[0].g.value="result"
	}
	else //International: value==0
	{
		interPannel.style.visibility="hidden";
		PersonType.innerHTML="&nbsp;&nbsp;Students:";
		document.forms[0].g.value="result2"
	}
	*/
	
	document.forms[0].FLY_TYPE[1].checked=true; //One way: index==1
	flightType(0); //One Way: value==0
	//=========================
	national_if=i;
	
	
	var DEPART_CITY = document.getElementById('DEPART_CITY');
	var DEST_CITY = document.getElementById('DEST_CITY');
	
	ClearDropDownList(DEPART_CITY);
	ClearDropDownList(DEST_CITY);


	if (national_if == 1) {
	
	
	    if (idObj("flyDeliveryCity") != null) {
	        idObj("flyDeliveryCity").style.display = "";
	    }
	    var DEPART_CITY2 = document.getElementById('DEPART_CITY2');
	    var DEST_CITY2 = document.getElementById('DEST_CITY2');
	    interPannel.style.display = "";

	    ClearDropDownList(DEPART_CITY2);
	    ClearDropDownList(DEST_CITY2);
	    InitSelCity('DEPART_CITY', 'DEPART_CITY', 'BJS');
	    InitSelCity('DEPART_CITY2', 'DEPART_CITY2', 'SHA');
	    InitSelCity('DEST_CITY', 'DEST_CITY', 'SHA');
	    InitSelCity('DEST_CITY2', 'DEST_CITY2', 'CAN');

	    InitDeleverCity();
	}
	else{
	    if (idObj("flyDeliveryCity") != null) {
	        idObj("flyDeliveryCity").style.display = "none";
	    }
	    interPannel.style.display = "none";
	    //		InitInternationalCity('DEPART_CITY');
	    //		InitInternationalReturnCity('DEPART_CITY');

	    InitInternationalGlobalDepartCity('DEPART_CITY');
	    InitInternationalGlobalDestCity('DEST_CITY');
	    InitInternationalDeleverCity();
		
	}
	
	
	//=========================
}


function CheckCity(CityValue)
{
	if(national_if==0)
	{
		var opts =null;
		var DEST_CITY = document.getElementById('DEST_CITY');
		ClearDropDownList(DEST_CITY);
		var IntDestArray=null;	
		
		IntDestArray = eval("city_"+CityValue);
		for(var i=0;i<IntDestArray.length ;i++)
		{
			var opt=new Option();
			opt.value = IntDestArray[i][0];
			opt.text = IntDestArray[i][1];
			DEST_CITY.options[i] = opt;
			DEST_CITY.selectedIndex=0
		}		
	}

}
	
function ChangeGuests(Rooms) {
    //首页搜索框已经去掉了房间数的人数,如果对其它地方有影响,再做处理
//add by minjiang 09-6-30
//	var opts =null;
//	var PersonNum = document.getElementById('PersonNum');
//	var GuestsArray_1=new Array(new Array("1","1"),new Array("2","2"),new Array("3","3"),new Array("4","4"));
//	var GuestsArray_2=new Array(new Array("2","2"),new Array("3","3"),new Array("4","4"),new Array("5","5"),new Array("6","6"),new Array("7","7"),new Array("8","8"));
//	var GuestsArray_3=new Array(new Array("3","3"),new Array("4","4"),new Array("5","5"),new Array("6","6"),new Array("7","7"),new Array("8","8"),new Array("9","9"),new Array("10","10"),new Array("11","11"),new Array("12","12"));
//	var GuestsArray_4=new Array(new Array("4","4"),new Array("5","5"),new Array("6","6"),new Array("7","7"),new Array("8","8"),new Array("9","9"),new Array("10","10"),new Array("11","11"),new Array("12","12"),new Array("13","13"),new Array("14","14"),new Array("15","15"),new Array("16","16"));
//	var GuestsArray_5=new Array(new Array("5","5"),new Array("6","6"),new Array("7","7"),new Array("8","8"),new Array("9","9"),new Array("10","10"),new Array("11","11"),new Array("12","12"),new Array("13","13"),new Array("14","14"),new Array("15","15"),new Array("16","16"),new Array("17","17"),new Array("18","18"),new Array("19","19"),new Array("20","20"));
//	ClearDropDownList(PersonNum);
//	GuestsArray = eval("GuestsArray_"+Rooms);

//	for(var i=0;i<=Rooms*4-Rooms;i++)
//	{
//		var opt=new Option();
//		opt.value = GuestsArray[i][0];
//		opt.text = GuestsArray[i][1];
//		PersonNum.options[i] = opt;
//	}
}
//===============================

function chkHotelForm( today )
{
	WriteHotelCookie();
	
	var objForm = document.forms[0];
	
	var cityNameValue = objForm.raCityName.value;
	//var priceTypeValue = document.getElementById("priceType").value;
	//var priceUsdValue = document.getElementById("price_usd").value;
	//var priceRmbValue = document.getElementById("price_rmb").value;
	var starValue = document.getElementById("Star").value;
	var checkInValue = document.getElementById("CheckInDate").value;
	var checkOutValue = document.getElementById("CheckOutDate").value;
//	var roomNumValue = document.getElementById("RoomNum").value;
	//	var personNumValue = document.getElementById("PersonNum").value;
	//去掉房间数和人数 add by minjiang 09-6-25
	var roomNumValue = 1;
	var personNumValue = 1;
	//var hotelNameValue = document.getElementById("HotelName").value;

	if (objForm.raCityName.value=="") 
	{
		alert("Please enter the city name!");
		objForm.raCityName.focus();
		return false;
	}

	if (/[^\x00-\xff]/g.test(objForm.raCityName.value))
	{
		alert(" Invalid city name!");
		objForm.raCityName.focus();
		return false;
	}
	if (CheckName(objForm.raCityName.value)==false)
	{
		objForm.raCityName.focus();
		alert("Invalid city name!");
		return false;
	}
	if (! isDateString(newDate(objForm.CheckInDate.value))) {
		alert('Please enter a valid check-in date!');
		objForm.CheckInDate.focus();
		return false;
	}
	if (! isDateString(newDate(objForm.CheckOutDate.value))) {
		alert('Please enter a valid check-out date!');
		objForm.CheckOutDate.focus();
		return false;
	}
	if (! CheckDate(today,newDate(objForm.CheckInDate.value))) {
		alert('The check-in date can not be earlier than today!');
		objForm.CheckInDate.focus();
		return false;
	}	
	if (! CheckDate1(newDate(objForm.CheckInDate.value),newDate(objForm.CheckOutDate.value))) {
		alert('The check-out date can not be earlier than the check-in date!');
		objForm.CheckInDate.focus();
		return false;
	}
	var intInDays20 = 20;
var intInDays60 = 60;
//从配置文件中读取 开始 add by minjiang 09-12-3
try {
    intInDays20 = parseInt(document.getElementById("IntervallCheckInAndChekOut").value);
    intInDays60 = parseInt(document.getElementById("IntervallCheckInAndNow").value);
}
catch (e)
	{ }
//从配置文件中读取 结束
//	if (compareDate(newDate(objForm.CheckInDate.value),newDate(objForm.CheckOutDate.value)))
//	{
//		alert('Your reservation period is more than 20 nights,Please contact our booking center by calling 86-10-58299309  or 4006-171717 !');
//		objForm.CheckInDate.focus();
//		return false;
	//	}
	if (compareDate(newDate(objForm.CheckInDate.value), newDate(objForm.CheckOutDate.value), intInDays20)) {
	    alert('Your reservation period is more than '+intInDays20 .toString ()+' nights,Please contact our booking center by calling 86-10-58299309  or 4006-171717 !');
	    objForm.CheckInDate.focus();
	    return false;
	}
//	if (compareDateB(today,newDate(objForm.CheckInDate.value),'60'))
//	{
//		alert('Reservations cannot be made online more than 60 days in advance. Please call 86-10-58299309  or 4006-171717  to make this reservation.');
//		objForm.CheckInDate.focus();
//		return false;
	//	}
	if (compareDateB(today, newDate(objForm.CheckInDate.value), intInDays60.toString())) {
	    alert('Reservations cannot be made online more than '+intInDays60.toString ()+' days in advance. Please call 86-10-58299309  or 4006-171717  to make this reservation.');
	    objForm.CheckInDate.focus();
	    return false;
	}
	if (objForm.HotelName.value!="")
	{
		if (CheckName(objForm.HotelName.value)==false){
			objForm.HotelName.focus();
			alert("Invalid hotel name！");
			return false;
		}
	}
   var hotelNameValue = (document.getElementById("HotelName").value=="")?"":document.getElementById("HotelName").value;
	var url ="http://www.elong.net/hotels/TSearch.aspx?raCityName="+ cityNameValue + "&CheckInDate="+checkInValue+"&CheckOutDate="+checkOutValue+"&Star="+starValue+"&HotelName="+hotelNameValue+"&RoomNum="+roomNumValue+"&PersonNum="+personNumValue ;
	
	document.location.href = url ;
}
function compareDate(strDate1, strDate2, days) {
    var tmp1 = strDate1.split('-');
    var tmp2 = strDate2.split('-');
    var date1 = eval('new Date(' + tmp1[0] + ',' + tmp1[1] + ',' + tmp1[2] + ')');
    var date2 = eval('new Date(' + tmp2[0] + ',' + tmp2[1] + ',' + tmp2[2] + ')');
    var _days = parseInt(days);
    if ((date2.valueOf() - date1.valueOf()) >= _days * 24 * 60 * 60 * 1000) {
        return true;
    }
    else {
        return false;
    }
}
function chkFlightForm(today)
{
	var objForm = document.forms[0];
	
	var datestr = '/';
	var to_day_year = stringToDateFly(today,datestr).getUTCFullYear()+1;
	var to_day_month = stringToDateFly(today,datestr).getMonth() + 1;	
	var to_day_day = stringToDateFly(today,datestr).getDate()-1;
	
	var end_day = to_day_month + datestr + to_day_day + datestr + to_day_year;// MM/dd/yyyy
	
	WriteAirCookie();
	
	var Result = objForm.g.value;
	var FCY = objForm.FCY.value;
	var CURRENCY_TYPE = 'RMB';
	var DEPART_CITY = objForm.DEPART_CITY.value;
	var DEPART_CITY2 = objForm.DEPART_CITY2.value;
	var DEST_CITY = objForm.DEST_CITY.value;
	var DEST_CITY2 = objForm.DEST_CITY2.value;
	var FLY_DATE = objForm.FLY_DATE.value;
	var FLY_DATE2 = objForm.FLY_DATE2.value;
	var RETURN_DATE = objForm.RETURN_DATE.value;
	var DELEVER_CITY = DEPART_CITY;
	
	var isNative =  objForm.isnative.value;
	var FLY_TYPE = 0;//单程
	
	for(var i=0;i<objForm.isnative.length;i++){
		if(objForm.isnative[i].checked==true){
			isNative=objForm.isnative[i].value;
			break;
		}
	}
	
	for(var j=0;j<objForm.FLY_TYPE.length;j++){
		if(objForm.FLY_TYPE[j].checked==true){
			FLY_TYPE = objForm.FLY_TYPE[j].value;
			break;
		}
	}
	
	//var url = "http://www.elong.net/flights/TSearch.aspx?g=" + Result + "&isnative=" + isNative + "&DIRECT_TYPE=ALL" + "&FLY_TYPE=" + FLY_TYPE + "&FCY=" + FCY + "&CURRENCY_TYPE=" + CURRENCY_TYPE.toUpperCase() + "&FLY_DATE=" + FLY_DATE + "&DEPART_CITY=" + DEPART_CITY + "&DEST_CITY=" + DEST_CITY;
	var url = "http://www.elong.net/flights/TSearch.aspx?g=" + Result + "&isnative=" + isNative + "&FLY_TYPE=" + FLY_TYPE + "&FCY=" + FCY + "&FLY_DATE=" + FLY_DATE + "&DEPART_CITY=" + DEPART_CITY + "&DEST_CITY=" + DEST_CITY + "&FLY_TIME=&RETURN_TIME=" + "&DELEVER_CITY=" + DELEVER_CITY;
		
	if(isNative==1)//国内机票
	{
		if(FLY_TYPE==0)//国内单程
		{
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY.value){
				alert("Destination city cannot be the same as the departure city.\n Please specify another destination.");
				objForm.DEST_CITY.focus();
				return false;
			}
			if (! isDateString(newDate(objForm.FLY_DATE.value))) {
				alert('Please enter a valid departure date!');
				objForm.FLY_DATE.focus();
				return false;
			}

			if (CompareFlyDate(today,objForm.FLY_DATE.value)>0) {
				alert('The departure date can not be earlier than today!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.FLY_DATE.value)<0) { 
				alert('The departure date cannot be later than limit date!');
				objForm.FLY_DATE.focus();
				return false;
			}			
		}
		else if(FLY_TYPE==1)//国内返程
		{
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY.value){
				alert("Destination city cannot be the same as the departure city.\n Please specify another destination.");
				objForm.DEST_CITY.focus();
				return false;
			}
			if (! isDateString(newDate(objForm.FLY_DATE.value))) {
				alert('Please enter a valid departure date!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (! isDateString(newDate(objForm.RETURN_DATE.value))) {
				alert('Please enter a valid return date!');
				objForm.RETURN_DATE.focus();
				return false;
			}
			if (CompareFlyDate(today,objForm.FLY_DATE.value)>0) {
				alert('The departure date can not be earlier than today!');
				objForm.FLY_DATE.focus();
				return false;
			}
			
			if (CompareFlyDate(end_day,objForm.FLY_DATE.value)<0) { 
				alert('The departure date cannot be later than limit date!');
				objForm.FLY_DATE.focus();
				return false;
			}
			
			if (CompareFlyDate(end_day,objForm.RETURN_DATE.value)<0) { 
				alert('The return date cannot be later than limit date!');
				objForm.RETURN_DATE.focus();
				return false;
			}
			if (CompareFlyDate(objForm.FLY_DATE.value,objForm.RETURN_DATE.value)>0) {
				alert('The return date can not be earlier than the departure!');
				objForm.RETURN_DATE.focus();
				return false;
			}
			
			url = url + "&RETURN_DATE=" + RETURN_DATE;
		
		}
		else//国内联程
		{
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY.value){
				alert("Destination city cannot be the same as the departure city.\n Please specify another destination.");
				objForm.DEST_CITY.focus();
				return false;
			}
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY2.value){
				alert("The second destination cannot be the same as your departure city.\n Please specify another destination, or choose our roundtrip ticket.");
				objForm.DEST_CITY2.focus();
				return false;
			}
			if(objForm.DEST_CITY.value==objForm.DEST_CITY2.value){
				alert("The first and the second destination cannot be the same city.\n Please specify another destination.");
				objForm.DEST_CITY2.focus();
				return false;
			}				
			if (! isDateString(newDate(objForm.FLY_DATE.value))) {
				alert('Please enter a valid departure date #1!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.FLY_DATE.value)<0) { 
				alert('The departure date of flight 1 cannot be later than the limit date!');
				objForm.FLY_DATE.focus();
				return false;
			}	
			if (! isDateString(newDate(objForm.FLY_DATE2.value))) {
				alert('Please enter a valid departure date #2!');
				objForm.FLY_DATE2.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.FLY_DATE2.value)<0) { 		
				alert('The departure date of flight 2 cannot be later than the limit date!');
				objForm.FLY_DATE2.focus();
				return false;
			}
			if (CompareFlyDate(today,objForm.FLY_DATE.value)>0) {			
				alert('The departure date #1 can not be earlier than today!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(objForm.FLY_DATE.value,objForm.FLY_DATE2.value)>0) {				
				alert('The departure date #2 can not be earlier than the departure date #1!');
				objForm.FLY_DATE2.focus();
				return false;
			}
			
			url = url + "&FLY_DATE2=" + FLY_DATE2 + "&DEPART_CITY2=" + DEPART_CITY2 + "&DEST_CITY2=" + DEST_CITY2;
		
		}
		
		
		
	}
	else//国际机票
	{
		if (FLY_TYPE==0)//国际单程
		{
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY.value){
				alert("Destination city cannot be the same as the departure city.\n Please specify another destination.");
				objForm.DEST_CITY.focus();
				return false;
            }
            if (objForm.DEST_CITY.value == "") {
                alert("Please enter a valid destination city!");
                objForm.DEST_CITY.focus();
                return false;
            }
			if (! isDateString(newDate(objForm.FLY_DATE.value))) {
				alert('Please enter a valid departure date!');
				objForm.FLY_DATE.focus();
				return false;
			}

			if (CompareFlyDate(today,objForm.FLY_DATE.value)>0) {
				alert('The departure date can not be earlier than today!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.FLY_DATE.value)<0) { 
				alert('The departure date cannot be later than limit date!');
				objForm.FLY_DATE.focus();
				return false;
            }
            //国际城市,出发城市和到达城市不能同为中国大陆城市 
            if (!ValiadateInternationalCity(objForm.DEPART_CITY.value, objForm.DEST_CITY.value, "1")) {
                alert('Either the departure or arrival city should be out of mainland China.');
                return false;
            }			

		}
		else//国际返程
		{
			if(objForm.DEPART_CITY.value==objForm.DEST_CITY.value){
				alert("Destination city cannot be the same as the departure city.\n Please specify another destination.");
				objForm.DEST_CITY.focus();
				return false;
            }
            if (objForm.DEST_CITY.value == "") {
                alert("Please enter a valid destination city!");
                objForm.DEST_CITY.focus();
                return false;
            }		
			if (! isDateString(newDate(objForm.FLY_DATE.value))) {
				alert('Please enter a valid departure date!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (! isDateString(newDate(objForm.RETURN_DATE.value))) {
				alert('Please enter a valid return date!');
				objForm.RETURN_DATE.focus();
				return false;
			}
			if (CompareFlyDate(today,objForm.FLY_DATE.value)>0) {
				alert('The departure date can not be earlier than today!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.FLY_DATE.value)<0) { 
				alert('The departure date cannot be later than limit date!');
				objForm.FLY_DATE.focus();
				return false;
			}
			if (CompareFlyDate(end_day,objForm.RETURN_DATE.value)<0) { 
				alert('The return date cannot be later than limit date!');
				objForm.RETURN_DATE.focus();
				return false;
			}			
			if (! CheckDate(newDate(objForm.FLY_DATE.value),newDate(objForm.RETURN_DATE.value))) {
				alert('The return date can not be earlier than the departure date!');
				objForm.RETURN_DATE.focus();
				return false;
            }
            //国际城市,出发城市和到达城市不能同为中国大陆城市 
            if (!ValiadateInternationalCity(objForm.DEPART_CITY.value, objForm.DEST_CITY.value, "1")) {
                alert('Either the departure or arrival city should be out of mainland China.');
                return false;
            }	
			
			url = url + "&RETURN_DATE=" + RETURN_DATE;
			
		}	
		
	}

//	var isValid = CheckSelect(); //tianpu.gao add
	
	document.location.href = url;

}

//国际城市,出发城市和到达城市不能同为国内城市
function ValiadateInternationalCity(departcity, destcity, isInternational) {
    if (isInternational == "1") {
        var cityset = getCitySet();
        var isDepartDometic = false;
        var isDestDometic = false;
        for (var i = 0; i < cityset.length; i++) {
            if (cityset[i].CityCode == departcity || cityset[i].CityName.toLowerCase() == departcity.toLowerCase()) {
                isDepartDometic = true;
            }
            if (cityset[i].CityCode == destcity || cityset[i].CityName.toLowerCase() == destcity.toLowerCase()) {
                isDestDometic = true;
            }
        }
        if (isDepartDometic && isDestDometic) {
            return false;
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}

//tianpu.gao add
function CheckSelect()
{
	var objForm = document.forms[0];
	var DELEVER_CITY = objForm.DELEVER_CITY.value;
	if(DELEVER_CITY=="0")		
		return false ;
	else
		return true ;
}

	var strShow = 'show';
	var strHide = 'close';
	var strRtl = '';
	var iflag = 0;

	function go(url)
	{
		window.open(url, "_self");
	}

	function OpenInNewWindow(url)
	{
		go(url);
	}
	function ControlLegs2(theDivName)
	{
		if(theDivName.style.display == "block")
		{
			theDivName.style.display = "none";
			
		}
		else
		{
			theDivName.style.display = "block";
			
		}
	}

	function IniDiv(iID,ispackage)
	{
		var spans = document.body.getElementsByTagName("span");
		for (i=0; i < spans.length; i++)
		{
			if(spans[i].id.indexOf("ok" + ispackage + iID) >= 0)
			{
				
				document.all["ChangeLegDiv" + ispackage + iID].innerHTML += spans[i].innerHTML;
			}
		}
	}

	function ControlItinerary(theDivName,ying)
	{
		if(ying.checked)
		{
			var mydivs = document.body.getElementsByTagName("div");
			var k = mydivs.length;
			var i = 0;
			while(i < k)
			{
				if(mydivs[i].id.indexOf("myDiv") >= 0)
				{
					document.all[mydivs[i].id].style.display = "none";
				}
				i ++;
			}
			theDivName.style.display = "block";
		}
	}
	function ControlLegs(sourceDivName,targetDivname,ying)
	{
		//targetDivname.innerHTML = sourceDivName.innerHTML;
		ControlItinerary(sourceDivName,ying);
	}
	function IniDivs(sourceDivName,targetDivname)
	{
		if(iflag == 0)
		{
			targetDivname.innerHTML = sourceDivName.innerHTML;
		}
	}


function ExpandDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; var theDiv = allDivsInPage[theDivName]; if (null == theDiv || typeof(theDiv) == "undefined") return;
	theDiv.style.display = "block";

	var thePic = allImagesInPage[theDivName + "_img"];
	if (null != thePic && typeof(thePic) != "undefined")
		{
		thePic.src = "images/none.gif";
		thePic.alt = strHide;
		}
}

function CollapseDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; var theDiv = allDivsInPage[theDivName]; if (null == theDiv || typeof(theDiv) == "undefined") return;
	theDiv.style.display = "none";

	var thePic = allImagesInPage[theDivName + "_img"];
	if (null != thePic && typeof(thePic) != "undefined")
		{
		thePic.src = "images/block" + strIsRtl + ".gif";
		thePic.alt = strShow;
		}
}

function ToggleDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; var theDiv = allDivsInPage[theDivName]; if (null == theDiv || typeof(theDiv) == "undefined") return;

	if (theDiv.style.display.toUpperCase() != "BLOCK")
		ExpandDiv(theDivName);
	else
		CollapseDiv(theDivName);
}

function AlterAllDivs(displayStyle)
{
	InitializeGlobalData();

	if (null == allDivsInPage || typeof(allDivsInPage) == "undefined")
		return;

	if (typeof(allDivsInPage["divShowAll"]) != "undefined" &&
		typeof(allDivsInPage["divHideAll"]) != "undefined")
		{
		if (displayStyle == "block")
			{
			allDivsInPage["divShowAll"].style.display = "none";
			allDivsInPage["divHideAll"].style.display = "block";
			}
		else
			{
			allDivsInPage["divShowAll"].style.display = "block";
			allDivsInPage["divHideAll"].style.display = "none";
			}
		}

	AlterAllDivsSpans(document.body.getElementsByTagName("DIV"), displayStyle);
	AlterAllDivsSpans(document.body.getElementsByTagName("SPAN"), displayStyle);
}

function ToggleAllDivs()
{
	InitializeGlobalData();

	if (fExpandedAssistance)
		AlterAllDivs("none");
	else
		AlterAllDivs("block");

	fExpandedAssistance = !fExpandedAssistance;
}

function ToggleAll()
{
	InitializeGlobalData();
	ToggleAllDivs();
}

function InitializeGlobalData()
{
	if ('undefined' != typeof(strRtl))
		strIsRtl = strRtl;

	var divs = document.body.getElementsByTagName("DIV");
	var spans = document.body.getElementsByTagName("SPAN");

	var countDiv = 0;
	var countSpan = 0;
	if (typeof(divs) != "undefined" && null != divs)
		countDiv = divs.length;

	if (typeof(spans) != "undefined" && null != spans)
		countSpan = spans.length;

	allDivsInPage = new Array();
	for (i=0; i < countDiv; i++)
		if (typeof(divs[i].id) != "undefined" &&
			null != divs[i].id &&
			divs[i].id.length > 0)
			allDivsInPage[divs[i].id] = divs[i];

	for (i=0; i < countSpan; i++)
		if (typeof(spans[i].id) != "undefined" &&
			null != spans[i].id &&
			spans[i].id.length > 0)
			allDivsInPage[spans[i].id] = spans[i];

	allImagesInPage = document.body.getElementsByTagName("IMG");
}

function OnSeeAlsoClicked()
{
	InitializeGlobalData();

	if (null == allDivsInPage || typeof(allDivsInPage) == "undefined")
		return;

	if (typeof(allDivsInPage["divSeeAlsoShowBullet"]) != "undefined" &&
		typeof(allDivsInPage["divSeeAlsoHideBullet"]) != "undefined")
		{
		if (allDivsInPage["divSeeAlsoShowBullet"].style.display.toUpperCase() == "INLINE")
			{
			allDivsInPage["divSeeAlso"].style.display = "block";
			allDivsInPage["divSeeAlsoShowBullet"].style.display = "none";
			allDivsInPage["divSeeAlsoHideBullet"].style.display = "inline";
			}
		else
			{
			allDivsInPage["divSeeAlso"].style.display = "none";
			allDivsInPage["divSeeAlsoShowBullet"].style.display = "inline";
			allDivsInPage["divSeeAlsoHideBullet"].style.display = "none";
			}
		}
}

function compareDateB(strDate1,strDate2,Days)
{
 var tmp1=strDate1.split('-');
 var tmp2=strDate2.split('-');
 var Days = Days;
 
 var date1 =strDate1.replace("-","/");
 date1 = date1.replace("-","/");
 var date2 =strDate2.replace("-","/");
 date2 = date2.replace("-","/");


 if (!isNaN(Date.parse(date1 ))) {
 var s = new Date(Date.parse(date1)) ;
 }


 if (!isNaN(Date.parse( date2 ))) {
 var e = new Date(Date.parse(date2)) ;
 }

 var temp =suycDateDiff( s, e, 'd', true ) ;

 if (temp >= Days)
 {
 return true;
 }
 else
 {
 return false;
 }
}

function suycDateDiff( start, end, interval, wholedays ) {

    var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    /*var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
		
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;*/

    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( end ) ;
    	
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        //alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        //alert( intervalMsg ) ;
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(wholedays) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(wholedays) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(wholedays) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(wholedays) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        //alert(intervalMsg) ;
        return null ;
    }
    
    
    return iOut ;
}








