﻿// JScript 文件

//首页查询选择项切换
function AirFlightClass()
{
}
var timestatefoucs=false;
var framestatefocus=false;
AirFlightClass.prototype.$ = function(str){return document.getElementById(str);}
AirFlightClass.prototype.$$ = function(str){return document.getElementsByName(str);}
var AirFlight = new AirFlightClass();
AirFlightClass.prototype.SetPageHome = function(obj,uri)
{
 
        try{ 
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(uri); 
        } 
        catch(e){ 
                if(window.netscape) { 
                        try { 
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); 
                        } 
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
                        prefs.setCharPref('browser.startup.homepage',uri); 
                 } 
        } 

}
AirFlightClass.prototype.SelectAnySearchBnt = function(bnt)
{
    var flight_search_bnt = this.$("flight_search_bnt");
    var hotel_search_bnt = this.$("hotel_search_bnt");
    var flight_search_main = this.$("flight_search_main");
    var hotel_srarch_main = this.$("hotel_srarch_main");
    var travel_srarch_main = this.$("travel_srarch_main");
    var travel_search_bnt = this.$("travel_search_bnt");
    if(bnt==1)
    {
        flight_search_bnt.className="i_main_one_search_head_flight";
        hotel_search_bnt.className="i_main_one_search_head_hotel";
        travel_search_bnt.className="i_main_one_search_head_hotel";
        flight_search_main.style.display="block";
        hotel_srarch_main.style.display="none";
        travel_srarch_main.style.display="none";
    }
    if(bnt==2)
    {
        flight_search_bnt.className="i_main_one_search_head_hotel";
        hotel_search_bnt.className="i_main_one_search_head_flight";
        travel_search_bnt.className="i_main_one_search_head_hotel";
        flight_search_main.style.display="none";
        travel_srarch_main.style.display="none";
        hotel_srarch_main.style.display="block";
    }
    if(bnt==3)
    {
        travel_search_bnt.className="i_main_one_search_head_flight";
        hotel_search_bnt.className="i_main_one_search_head_hotel";
        flight_search_bnt.className="i_main_one_search_head_hotel";
        flight_search_main.style.display="none";
        hotel_srarch_main.style.display="none";
        travel_srarch_main.style.display="block";
    }
}

AirFlightClass.prototype.SelectTravelCityCode = function(str,ct,fr)
{
	var box = window.parent.document.getElementById(ct);
	box.value=str;
	var frame=window.parent.document.getElementById(fr);
	frame.style.display="none";
}
AirFlightClass.prototype.FrameDocumentHeight = function(str,info,ct)
{
    
    var TravelFromFrame = window.parent.document.getElementById("TravelFromFrame");
     
    TravelFromFrame.style.height=(str+2)+"px";
    var box = window.parent.document.getElementById(ct);
    box.value=info;
}
AirFlightClass.prototype.SetFrameDefaultValue = function(box)
{
    var boxs = window.parent.document.getElementById(box);
    if(box=="hotelcity")
    {
        var tcf=document.getElementById('HotelCitysFrame');
        var twcf=window.frames.HotelCitysFrame;
        twcf.b=boxs.value;
        twcf.SetListInfo();
    }
    else
    {
        var tcf=document.getElementById('TravelTocityFrame');
        var twcf=window.frames.TravelTocityFrame;
        twcf.b=boxs.value;
        twcf.SetListInfo();
    }
}
AirFlightClass.prototype.ShowTravelCityFrame = function(frame,box)
{
    var tcf=document.getElementById(frame);
    if(frame=="TravelTocityFrame")
    {
        var twcf=window.frames.TravelTocityFrame;
        twcf.firstvalue="";
 	    twcf.b="";
    }
    if(frame=="HotelCitysFrame")
    {
        var twcf=window.frames.HotelCitysFrame;
        twcf.firstvalue="";
 	    twcf.b="";
    }
	tcf.onmouseover=function()
	{framestatefocus=true;} 
	tcf.onmouseout=function()
	{framestatefocus=false;} 
	this.SetOjbectWay(box,frame,100);
	tcf.style.display="block";
	framestatefocus=false;
}

AirFlightClass.prototype.ShowTicketAirPortsCityFrame = function(box,valuehidden)
{
    var tcf=document.getElementById("bcityFrame");
    var twcf=window.frames.bcityFrame;
    twcf.CityBox = box;
    twcf.CityCodeHidden = valuehidden;
    twcf.firstvalue="";
	twcf.firstcode="";
	twcf.b="";
    var boxs = this.$(box);
    twcf.SetListInfo();
	tcf.onmouseover=function()
	{framestatefocus=true;} 
	tcf.onmouseout=function()
	{framestatefocus=false;} 
	this.SetOjbectWay(box,"bcityFrame",100);
	tcf.style.display="block";
	framestatefocus=false;
}
AirFlightClass.prototype.HiddenTicketAirPortsCityFrame = function(box,valuehidden)
{
    var cf = document.getElementById("bcityFrame");
    var twcf=window.frames.bcityFrame;
	if(cf!=null)
	if(!framestatefocus)
	{
	    this.$(box).value=twcf.firstvalue;
	    this.$(valuehidden).value=twcf.firstcode;
		cf.style.display="none";
		twcf.firstvalue="";
		twcf.firstcode="";
		twcf.b="";
     }
}
AirFlightClass.prototype.SetAirPortsFrameDefaultValue = function(box)
{
    var box = this.$(box);
    var tcf=document.getElementById('bcityFrame');
    var twcf=window.frames.bcityFrame;
    twcf.b=box.value;
    twcf.SetListInfo();
}
AirFlightClass.prototype.SelectTicketAirPortsCityCode = function(str,code,ct,hidds,fr)
{
	var box = window.parent.document.getElementById(ct);
	var codes = window.parent.document.getElementById(hidds);
	box.value=str;
	codes.value=code;
	var frame=window.parent.document.getElementById(fr);
	frame.style.display="none";
}
AirFlightClass.prototype.HiddenTravelCityFrame = function(ff)
{
    var cf = document.getElementById(ff);
	if(cf!=null)
	if(!framestatefocus)
	{
		cf.style.display="none";
     }
}
AirFlightClass.prototype.HiddenTravelTCityFrame = function()
{
    var cf = document.getElementById("TravelTocityFrame");
    var twcf=window.frames.TravelTocityFrame;
	if(cf!=null)
	if(!framestatefocus)
	{
	    this.$("TravelTcity").value=twcf.firstvalue;
		cf.style.display="none";
     }
}
AirFlightClass.prototype.HiddenHotelCityFrame = function()
{
    var cf = document.getElementById("HotelCitysFrame");
    var twcf=window.frames.HotelCitysFrame;
	if(cf!=null)
	if(!framestatefocus)
	{
	    this.$("hotelcity").value=twcf.firstvalue;
		cf.style.display="none";
     }
}

AirFlightClass.prototype.changebuybntstyle = function(e,c)
{
	e.className=c;
}
AirFlightClass.prototype.openorderpage = function(page)
{

}
AirFlightClass.prototype.searchanyvalue = function(page)
{
   var startDate = this.$("startDate");
   var returnDate = this.$("returnDate");
   window.location=page+"&sdate="+startDate.value+"&edate="+returnDate.value;
}
AirFlightClass.prototype.SetOjbectWay = function(a,b,widths)
{
    var cf = this.$(b);
    var eT=0,eL=0,p=this.$(a);
    var sT=document.body.scrollTop,sL=document.body.scrollLeft;
    var eH=this.$(a).clientHeight,eW=this.$(a).clientWidth;
    while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
 
    cf.style.top=eT+eH+2+"px";
	cf.style.left=((document.body.clientWidth-(eL-sL)>=widths)?eL:eL+eW-widths)+"px";
}
AirFlightClass.prototype.SetDateTimeInfo = function(a)
{
	var tcf=document.getElementById("TimeCalFrame");
	var twcf=window.frames.TimeCalFrame;
	tcf.onmouseover=function()
	{timestatefoucs=true;} 
	tcf.onmouseout=function()
	{timestatefoucs=false;} 
	this.SetOjbectWay(a,"TimeCalFrame",122);
	tcf.style.display="block";
	twcf.timebox=a;
	
	timestatefoucs=false;
	tcf.style.width=125+"px";
	tcf.style.height=110+"px";
}

AirFlightClass.prototype.HiddenDateTimeInfo = function()
{
	var tcf=document.getElementById("TimeCalFrame");
 	if(!timestatefoucs)
	{
		 tcf.style.display="none";
	}
}


AirFlightClass.prototype.FlightSpecialCitySelect = function(indexnum,count,pagetype,citycode)
{
    for(var i=0;i<count;i++)
    {
        var li = this.$("fscitycodeid"+i);
        if(i==indexnum)
        {
           li.className="index_flight_special_head_select_city";
        }else{
            li.className="index_flight_special_head_noselect_city";
         }
    }
    var FlightAjax = new AjaxPro("flight_special_list_info");
    FlightAjax.Get("/flight/LoadFlightSpecialNum.aspx?citycode="+citycode+"&pagetype="+pagetype+"&rands="+Math.floor(Math.random()*100000+1));
}
AirFlightClass.prototype.HotelSpecialCityList = function()
{
    if(HotelSpecialCity.length>0)
    {
        var hotelspecialcity = this.$("hotelspecialcitylist");
        var hotelspecialcityli="";
        var citycount = HotelSpecialCity.length;
        for(var i=0;i<HotelSpecialCity.length;i++)
        {
            if(i==0)
            {
                hotelspecialcityli+=" <div class=\"i_main_three_hotel_head_city_select\" id=\"hotelfscitycodeid"+i+"\" onclick=\"AirFlight.HotelSpecialCitySelect("+i+","+citycount+",'"+HotelSpecialCity[i][1]+"');\">"+HotelSpecialCity[i][0]+"</div>";
             }else{
                hotelspecialcityli+="<div class=\"i_main_three_hotel_head_city_noselect\" id=\"hotelfscitycodeid"+i+"\" onclick=\"AirFlight.HotelSpecialCitySelect("+i+","+citycount+",'"+HotelSpecialCity[i][1]+"');\">"+HotelSpecialCity[i][0]+"</div>";
            }
        }
        hotelspecialcity.innerHTML=hotelspecialcityli;
    }
    
}
AirFlightClass.prototype.HotelSpecialCitySelect = function(indexnum,count,citycode)
{
    for(var i=0;i<count;i++)
    {
        var li = this.$("hotelfscitycodeid"+i);
        if(i==indexnum)
        {
           li.className="i_main_three_hotel_head_city_select";
 
        }else{
             
           li.className="i_main_three_hotel_head_city_noselect";
        }
    }
    var HotelAjax = new AjaxPro("hotelspecialinfolist");
    HotelAjax.Get("/hotel/Loadhotelspecialcity.aspx?citycode="+citycode+"&rands="+Math.floor(Math.random()*100000+1));
}


function delPassengers(index)
{
	if(intPassengersCount < 2) return;
	jQuery("#tablePassenger"+index).remove();
	intPassengersCount--;
	PassengersApply();
}
function PassengersApply()
{
	for(var n=0;n<TripItem.length;n++){}
	var mPrise = 0, mInsurance = 0;
	jQuery(".fPassengerType").each(function(i,n){
		if(i>0)
		{
			for(var x=0;x<TripItem.length;x++)
			{
				mPrise += n.value == 1 ? (parseInt(TripItem[x][63])+parseInt(TripItem[x][39])+parseInt(TripItem[x][42])) : (parseInt(TripItem[x][64])+parseInt(TripItem[x][40])+parseInt(TripItem[x][43]));
			}
			mInsurance += parseInt(jQuery("select[@name=fPassengerInsurance]")[i].value) * (n.value == 1 ? parseInt(TripItem[0][68]) : parseInt(TripItem[0][69]));
		}
	});
	
	jQuery("#spanTotalMoney").html(Math.round(mPrise *100) / 100 + "");
	jQuery("#spanTotalPassenger").html(intPassengersCount + "");
	jQuery("#spanTotalInsurance").html(mInsurance + "");
}
function SelectPassengerType(obj)
{
	PassengersApply();
}


AirFlightClass.prototype.ChangeDist = function(str,count,arrays)
{
    var divDist = this.$("divDist");
    var fDistCitySelect = this.$("fDistCity");
    var spanDistCityDes = this.$("spanDistCityDes");
     fDistCitySelect.options.length=0
    if(count>0)
    {
        divDist.style.display="block";
        
         
        for(var n=0;n<arrays.length;n++)
        {
            var oo=document.createElement('OPTION'); 
            oo.text=arrays[n][0]; 
            oo.value=arrays[n][0]+"|"+arrays[n][1]+"|"+arrays[n][2];
            fDistCitySelect.options.add(oo);
            if(n==0)
            {
                spanDistCityDes.innerHTML=arrays[n][2];
            }
        }

    }else{
       
        divDist.style.display="none";
    }
}
AirFlightClass.prototype.ChangeDistCity = function(e)
{
    var spanDistCityDes = this.$("spanDistCityDes");
    var str = e.value.split("|"); 
     spanDistCityDes.innerHTML = str[2];
}

