﻿function selSinDou(type){
    document.getElementById('tiBa').style.visibility = document.getElementById('deBa').style.visibility = type == 1 ? '' : 'hidden';
    if (type == 1) {
        document.getElementById("bottontype").value = type;
    }
}
function nTabs(thisObj,Num){
    if(thisObj.className == "active") return;
    var tabObj = thisObj.parentNode.id;
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for(i=0; i <tabList.length; i++){
        if(i == Num){
            thisObj.className = "sel01"; 
            document.getElementById(tabObj+"_Content"+i).style.display = "block";
            document.getElementById('more_'+i).style.display = "block";
        }else{
            tabList[i].className = "sel02"; 
            document.getElementById(tabObj+"_Content"+i).style.display = "none";
            document.getElementById('more_'+i).style.display = "none";
        }
    } 
}
function QueryFlight() {
    var cfld = new Date();
    var StrCfld = cfld.getYear() + "-" + (cfld.getMonth() + 1) + "-" + cfld.getDate();
    var oc = document.getElementById("ddlOrgCity").value;
    var dc = document.getElementById("ddlDesCity").value;
    var re = new RegExp("(^[\\s]*)|([\\s]*$)", "g");
    if(oc.replace(re,"")=="" || oc=="点击选择城市")
    {
        alert("请选择出发城市!");
        document.getElementById('ddlOrgCity').click();
        return false;
    }
    if(dc.replace(re,"")=="" || dc=="点击选择城市")
    {
        alert("请选择到达城市!");
        document.getElementById('ddlDesCity').click();
        return false;
    }
    if(oc.replace(re,"").replace("首都","").replace("南苑","").replace("虹桥","").replace("浦东","") == dc.replace(re,"").replace("首都","").replace("南苑","").replace("虹桥","").replace("浦东","")){
        alert('出发城市和抵达城市不能相同！');
        return false;
    }
    var sd = document.getElementById("txtStartDate").value;
    if (sd == "" || sd == 'yyyy-MM-dd' || sd == '时间/日期') {
        alert("请选择出发日期!");
        event.cancelBubble = true;
        showCalendar("txtStartDate", false, "txtStartDate", '', '', StrCfld, '', '', '', '', 'text', '');
	    return false;
    }
    if (document.getElementById("rdoDou").checked) {
        var rd = document.getElementById("txtReturnDate").value;
        if (rd == "" || rd == 'yyyy-MM-dd' || rd == '时间/日期') {
            alert("请选择返程日期!");
            event.cancelBubble = true;
            showCalendar("txtReturnDate", false, "txtReturnDate", '', '', StrCfld, '', '', '', '', 'text', '');
	        return false;
	    }
	    if (reg.CompareDate(sd.value.Trim(), rd.value.Trim()))
	    {
	        alert("出发日期不能早于返回日期!");
	        return false;
	    }
    }
    return true;
}
//--------图片切换的脚本-----
var $d = document;
function $i(s){return $d.getElementById(s);}
var _jsc = {};
_jsc.client = (function(){	
    var t = {};
    var b = navigator.userAgent.toLowerCase();
    t.isOpera = (b.indexOf('opera')>-1);
    t.isIE = (!t.isOpera && b.indexOf('msie')>-1);
    t.isFF = (!t.isOpera &&!t.isIE&&b.indexOf('firefox')>-1);
    return t;
})();
_jsc.util = (function(){
    var t={};
    t.addEvent = function(o,c,h){
        if(_jsc.client.isIE) o.attachEvent('on'+c,h);
        else o.addEventListener(c,h,false);
        return true;
    };
    return t;
})();
_jsc.evt = (function(){
    var t = {};
    t.gTar = function(oe){
        if(_jsc.client.isIE) return oe.srcElement;
        else return oe.target;
    };
    return t;
})();
function tabswitch(c,config){
    this.config = config ? config : {start_delay:3000,delay:1500};
    this.container = $i(c);
    this.pause = false;
    this.nexttb = 1;
    this.tabs = this.container.getElementsByTagName('dt');
    var _this = this;
    if(this.tabs.length<1)this.tabs = this.container.getElementsByTagName('li');
    for(var i = 0; i < this.tabs.length; i++){
        var _ec = this.tabs[i].getElementsByTagName('span');
        if(_ec.length<1)_ec = this.tabs[i].getElementsByTagName('a');
        if(_ec.length<1) _ec = this.tabs[i];
        else _ec = _ec[0];
        _ec.onmouseover = function(e){
	        _this.pause = true;
	        var ev = !e ? window.event : e;
	        _this.start(ev, false, null);
        };
        _ec.onmouseout = function(){
	        _this.pause = false;
        };
        try{
	        $i(this.tabs[i].id + '_body_1').onmouseover = function(){_this.pause = true;};
	        $i(this.tabs[i].id + '_body_1').onmouseout = function(){_this.pause = false;};
        }catch(e){}
    }
    if ($i(c + '_sts')){
        var _sts = $i(c + '_sts');
        var _step = _sts.getElementsByTagName('li');
        if(_step.length<1)_step = _sts.getElementsByTagName('div');
        _step[0].onclick = function(){
	        if (_this.tabs[_this.tabs.length-1].className.indexOf('current') > -1){_this.nexttb = _this.tabs.length + 1;};
	        _this.nexttb = _this.nexttb - 2 < 1 ? _this.tabs.length : _this.nexttb - 2;
	        _this.start(null, null, _this.nexttb);
        };
        _step[1].onclick = function(){
	        _this.nexttb = _this.nexttb < 1 ? 1 : _this.nexttb;
	        _this.start(null, null, _this.nexttb);
        };
    };
    this.start = function(e,r,n){
        if(_this.pause && !e)return;
        if(r){curr_tab = $i(_this.container.id+'_'+rand(4));}
        else{
	        if(n){curr_tab = $i(_this.container.id+'_'+_this.nexttb);}
	        else{curr_tab = _jsc.evt.gTar(e);if(curr_tab.id=="")curr_tab = curr_tab.parentNode;}
        }
        var tb = curr_tab.id.split("_");
        for(var i = 0; i < _this.tabs.length;i++){
	        if(_this.tabs[i]==curr_tab){_this.tabs[i].className="hot Selected current";try{$i(_this.tabs[i].id + '_body_1').style.display = "block";}catch(e){}}
	        else{_this.tabs[i].className="";try{$i(_this.tabs[i].id + '_body_1').style.display = "none";}catch(e){}}
        }
        _this.nexttb = parseInt(tb[tb.length-1]) >= _this.tabs.length ? 1 : parseInt(tb[tb.length-1]) + 1;
    };
}
function init_imh(){
    var _lis = document.getElementsByTagName('li');
    for(var i=0;i<_lis.length;i++){
        if(_lis[i].getAttribute('jpe') == 'linkto:a'){
	        _lis[i].onclick = function(e){
		        var ev = !e ? window.event : e;
		        var _target = _jsc.evt.gTar(ev);
		        while(_target.tagName.toLowerCase() != 'li'){_target = _target.parentNode;}
		        location.href = _target.getElementsByTagName('a')[0].getAttribute('href');
		        return false;
	        };
        }
    }
}
var banners,new_trans,super_rec,crazy_buy,star,bargain_scroll,buy_ok_div;
_jsc.util.addEvent(window, 'load', function(){
    if ($i('banners')){banners = new tabswitch('banners', {});setInterval("banners.start(null, null, 1);", 5000);}
});

function GetPointsPos(el)
{ 
    var leftPos=0;
    var topPos=0;
    while(el!=null)
    {		
        leftPos+=el.offsetLeft;
        topPos+=el.offsetTop;
        el=el.offsetParent;
    }
    return leftPos.toString()+"&"+topPos.toString();
}
function mouse_move(select)
{
   select.style.color="#FE9900";
   select.style.textDecoration="underline";
}
function mouse_out(select)
{
   select.style.color="#E82C00";
   select.style.textDecoration="";
}
function price_click(url)
{
    window.open(url);
}

function showfindwindow(select,orgcityname,descityname)
{
   var div_findwindow = document.getElementById('div_findwindow');
   div_findwindow.style.display = "inline";
   var zb=GetPointsPos(select);
   div_findwindow.style.left=zb.split('&')[0];
   div_findwindow.style.top=zb.split('&')[1]-0+15;
   document.getElementById('hi_orgcity').value = orgcityname;
   document.getElementById('hi_descity').value = descityname;
}

function ShowSpans(Num){
    for(i=0; i <3; i++)
    {
       if(document.getElementById("span_"+i))
       {
           document.getElementById("span_"+i).className ="list_out"+i;
       }
       if(document.getElementById("span_"+i+"_c_"+i))
       {
           document.getElementById("span_"+i+"_c_"+i).style.display = "none";
       }
       if(document.getElementById("pic_"+i))
       {
           document.getElementById("pic_"+i).style.display = "none";
       }
    }
   if(document.getElementById("span_"+Num))
   { 
       document.getElementById("span_"+Num).className = "list_at"+Num;
   } 
   if(document.getElementById("span_"+Num+"_c_"+Num))
   {
       document.getElementById("span_"+Num+"_c_"+Num).style.display = "block";
   }
   if(document.getElementById("pic_"+Num))
   {
       document.getElementById("pic_"+Num).style.display = "block";
   }

}

function sectrtd(listddName,listspanname,i,j,n)
    {

       for (var z=0;z<n;z++)
       {
        document.getElementById(listspanname+"_"+i+"_"+z).style.display="none";
        document.getElementById(listddName+"_"+i+"_"+z).className="";
       }
        document.getElementById(listspanname+"_"+i+"_"+j).style.display="block";

        document.getElementById(listddName+"_"+i+"_"+j).className="li_here";
    }
 function Text_OnClick(id)
{ 
   var ie=navigator.appName=="Microsoft Internet Explorer" ? true : false;
   if(ie)
   {
       document.getElementById(id).click();
   }
   else
   {
       var a=document.createEvent('MouseEvents');
       a.initEvent('click', true, true);
       document.getElementById(id).dispatchEvent(a);
   }
}
 function nTabs(thisObj, Num) {
    if (thisObj.className == "active") return;
    var tabObj = thisObj.parentNode.id;
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for (i = 0; i < tabList.length; i++) {
        if (i == Num) {
            thisObj.className = "active";
            document.getElementById(tabObj + "_c_" + i).style.display = "block";
        } else {
            tabList[i].className = "normal";
            document.getElementById(tabObj + "_c_" + i).style.display = "none";
        }
    }
}
function ShowStep(num)
{
    for(var i=1;i<=3;i++)
    {
        document.getElementById('step'+i).style.display="none";
    }
    document.getElementById('step'+num).style.display="block";

}       
function call(param)
{
    var paramlist=new Array();   
    paramlist=param.split("*");
    var url;
    if(paramlist.length==3)//单程
    {
        url = "/flight/ajaxcn.ashx?type=call&orgportcode="+paramlist[0]+"&desportcode="+paramlist[1]+"&orgdate="+paramlist[2]+"&linetype=1";
    }
    if(paramlist.length==4)//返程
    {
        url = "/flight/ajaxcn.ashx?type=call&orgportcode="+paramlist[0]+"&desportcode="+paramlist[1]+"&orgdate="+paramlist[2]+"&desdate="+paramlist[3]+"&linetype=2";
    }
    else if(paramlist.length==5)//联程
    {
        url = "/flight/ajaxcn.ashx?type=call&orgportcode="+paramlist[0]+"&zzportcode="+paramlist[1]+"&desportcode="+paramlist[2]+"&orgdate="+paramlist[3]+"&desdate="+paramlist[4]+"&linetype=3";
    }
    AjaxFunction(url,gotopage);
}
function gotopage(response)
{
    if (response!='') 
    {
        window.open(response);
    }
}
function AjaxFunction(url, callback) {
    var xmlHttp = false;
    try {
        xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
        try { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); }
        catch (e) { xmlHttp = false; }
    }
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
        xmlHttp = new XMLHttpRequest();
    }
    xmlHttp.open('post', url, true);
    xmlHttp.onreadystatechange = callBack_CheckUserName;
    xmlHttp.send(null);
    function callBack_CheckUserName() {
        if (xmlHttp.readyState == 4) {
            var responseText = xmlHttp.responseText;
            if (callback) {
                try {
                    callback(responseText);
                } catch (e) { }
            }
        }
    }
}
