﻿
var overAllSign = 0;
document.onkeydown = GetKey;

function ToRegister()
{
    window.location.href = document.getElementById("RegisterURL").value;
}

function SetoverAllSign()
{
    overAllSign = 1;
}

function GetKey(e)
{
    if (overAllSign == 1)
    {
        overAllSign = 0;
        return;
    }

    if (!e) e = window.event;
    
    if (document.all)
    {
        Key = e.keyCode;
    }
    else
    {
        Key = e.which;
    }
    
    if (Key == 13)
    {
        var btnNextControl=document.getElementById("ctl00_MainContentPlaceHolder_LoginAndInputOrder1_btnLogin");
        var btnNext =document.getElementById("ctl00_MainContentPlaceHolder_BtnNext");
        
        if(btnNext != null && document.getElementById("NextBtn").style.display != "none")
        {
            btnNext.click();
            return false;
        }
        
        if (btnNextControl != null && document.getElementById("LoginWindow").style.display != "none")
        {
            btnNextControl.click();
            return false;
        }
    }
}


function crafttype(sUrl)
{
    window.open(sUrl,"","resizable=no,scrollbars=1,width=560,height=150,titlebar=no,menubar=0,toolbar=0,left=100,right=0,screenX=300,screenY=200",true)
}

function openksubclass()
{
		var surl="http://www.ctrip.com/supermarket/sharesub/flight/k_subclassinfo.asp"
		window.open(surl,"","resizable=no,scrollbars=1,width=560,height=150,titlebar=no,menubar=0,toolbar=0,left=100,right=0,screenX=300,screenY=200",true)
}

function ShowGiftPage(GiftType,GiftNum,Description)
{
	var surl="Auxi/Bonus.aspx?GiftType="+GiftType+"&GiftNum="+GiftNum+"&Description="+Description
	window.open(surl,"礼品","resizable=no,scrollbars=1,width=560,height=150,titlebar=no,menubar=0,toolbar=0,left=100,right=0,screenX=300,screenY=200",true)
}

function Flyer(sUrl)
{
    window.open(sUrl,"","resizable=no,scrollbars=1,width=500,height=250,titlebar=no,menubar=0,toolbar=0,left=100,right=0,screenX=300,screenY=200",true)
}

function GoReturnRule(nonrer,nonref,nonend,rernote,refnote,endnote,remarks)
{
    window.open("Auxi/ShowRules.aspx?nonrer="+nonrer+
    "&nonref="+nonref+
    "&nonend="+nonend+
    "&rernote="+rernote+
    "&refnote="+refnote+
    "&endnote="+endnote+
    "&remarks="+remarks);       
}

function posX(d){
  var s_el=0;el=d;while(el){s_el=s_el+el.offsetLeft;el=el.offsetParent;}; return s_el
  };
function posY(d){
  var s_el=0;el=d;while(el){s_el=s_el+el.offsetTop ;el=el.offsetParent;}; return s_el
  };

function Show_altlayerE(input_obj)
{
    var x=posX(input_obj);
    var y=posY(input_obj);
    document.getElementById('altlayerE').style.left=x - 390;
    document.getElementById('altlayerE').style.top=y - 100;
    document.getElementById('altlayerE').style.display='block';
}

function Show_altlayerP(input_obj)
{
    var x=posX(input_obj);
    var y=posY(input_obj);
    document.getElementById('altlayerP').style.left=x - 390;
    document.getElementById('altlayerP').style.top=y - 100;
    document.getElementById('altlayerP').style.display='block';
}

function Close_altlayerE()
{
    document.getElementById('altlayerE').style.display='none';
}

function Close_altlayerP()
{
    document.getElementById('altlayerP').style.display='none';
}

function GoSubClassPage(sign,flight,subclass,dtime,price,rate,iscorp,needapp)//modify by wangxiang 添加k位隐藏值
{
    document.getElementById("Flight"+sign).value=flight;
    document.getElementById("SubClass"+sign).value=subclass;
    document.getElementById("DepartTime"+sign).value=dtime;
    document.getElementById("Price"+sign).value=price;
    document.getElementById("PriceRate"+sign).value=rate;
    document.getElementById("CorpFee"+sign).value=iscorp;
    document.getElementById("NeedApp"+sign).value=needapp;//修改

    CheckReasonCode("onSubClassBtnClick");
    ClearCheckedRadioValues();
    
    document.forms[0].action = "ShowSubClass.aspx";
    document.forms[0].submit();
}

function ClearCheckedRadioValues()
{
    document.getElementById("RadioValues").value = "";
    
    obj = document.getElementsByName("myradiogroup");
    if (obj.length > 0)
    {
        if (obj.length == 1)
        {
            obj.checked = false;
        }
        else
        {
            for(var i=0;i<obj.length;i++)
            {
                if (obj[i].checked)
                {
                    obj[i].checked = false;
                }
            }
        }
    }
}

function getstops(flight,date,dport,aport,stops)
{
	var sUrl
	sUrl = "http://www.ctrip.com/supermarket/sharesub/flight/GetStopCity.asp?flight=" + flight + "&sDate=" + date + "&dcity=" + dport + "&stops=" + stops + "&acity=" + aport
	window.open(sUrl, "","scrollbars=yes,statusbar=no,resizable=no,status=no,width=500,height=150,left=100,top=20"); 		
}

//使用XMLHTTP异步获取URL指定的数据
function GetAsynData(url)
{ 
    var xmlhttp_request = false;
    try
    {
        if( window.ActiveXObject )
        { 
            for( var i = 5; i; i--)
            {
                try
                {
                    if( i == 2 )
                    {
                        xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );
                    }
                    else
                    {
                        xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
                        xmlhttp_request.setRequestHeader("Content-Type","text/html");
                        xmlhttp_request.setRequestHeader("Content-Type","gb2312");
                    }
                    break;
                } 
                catch(e)
                {
                    xmlhttp_request = false;
                } 
            } 
        }
        else if( window.XMLHttpRequest )
        {
            xmlhttp_request = new XMLHttpRequest();
            if (xmlhttp_request.overrideMimeType) 
            {
                xmlhttp_request.overrideMimeType('text/html');
            }
        }
    }
    catch(e)
    {
        xmlhttp_request = false;
    }
    
    try
    {
        xmlhttp_request.open("GET",url,false);
        xmlhttp_request.send(null);
    }
    catch(e)
    {
        return "ERROR";        
    }
    if (xmlhttp_request.status==200)
    {
        return xmlhttp_request.responseText;
    }
    else 
    {
        return "ERROR";
    }
}

//用户直接手机预订 created by whwang on 20070412  
function LoginByMobilePhone()
{   
    document.getElementById("signin_uid").value="";
    document.getElementById("signin_pwd").value="";
    var mobilestring=document.getElementById("MobilePhone").value;
    var CurrentDomain = document.getElementById("CurrentDomain").value;
    if(mobilestring == "" )
    {
         checkinfo('MobilePhone','直接预订必须输入手机号码!!');
         return false;
    }
    else
    { 
        if(!isInteger(mobilestring)) 
        {	
            checkinfo('MobilePhone','手机号码只能为数字!');
            return false;
        }    
        if (isValidMobile(mobilestring) == false) 
        {			
            checkinfo('MobilePhone','非13或15开头的手机号码或号码位数不对!');
            return false;
        }             
      
    }
    
    if (PostBackFares())
    {
        var checkresult;
		var ook;
		
		checkresult=GetAsynData("Auxi/CheckUser.aspx?uid=" + mobilestring);
		if(checkresult.indexOf("check fail")>=0)
			ook = 0;
	    else
	        ook = 1;
				
		if (ook == 1)
		{
            document.getElementById("signin_logintype").value="LOGINNOSINGUP";  
            document.getElementById("signin_mobilephone").value=mobilestring; 	              
            document.forms[0].submit();
		}
		else
		{
			document.getElementById("ctl00_MainContentPlaceHolder_LoginAndInputOrder1_signin_uid_notice_m").value = mobilestring;
			document.getElementById("ctl00_MainContentPlaceHolder_LoginAndInputOrder1_signin_pwd").focus();
			
			if (confirm("您的手机号已在携程注册，请在会员区登录。\n是否需要将您的登录密码发送到您手机上？"))
				window.open("http://" + CurrentDomain + "/Member/ConfirmName.asp?hdnUid="+mobilestring+"&hdnSendMode=SMS","tipForm","width=800,height=500,top=0,left=0");
		}
    }
}

if (!$interface) var $interface = {};


//航班排序方法(出发时间)
$interface.sortFlightByDepartTime = function(a, b)
{
    var d1 = parseInt(FlightList[a].departTime,10);
        d2 = parseInt(FlightList[b].departTime,10);
    return d1 == d2 ? 0 : (d1 > d2 ? 1 : -1);
};
//航班排序方法(到达时间)
$interface.sortFlightByArriveTime = function(a, b)
{
    var a1 = parseInt(FlightList[a].arriveTime,10);
        a2 = parseInt(FlightList[b].arriveTime,10);
    return a1 == a2 ? 0 : (a1 > a2 ? 1 : -1);
};
//航班排序方法(价格)
$interface.sortFlightByPrice = function(a, b)
{
    var p1 = parseInt(FlightList[a].price, 10), 
        p2 = parseInt(FlightList[b].price, 10);
    return p1 == p2 ? 0 : (p1 > p2 ? 1 : -1);
};									
