﻿
function CreateXmlHttp() {
    var xmlhttp;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp = new XMLHttpRequest();
        }
    }
    return xmlhttp;
}
/*=====================今日热点数据==========================================*/
function showLongdate(n) {
    var uom = new Date();
    uom.setDate(uom.getDate() + n);
    uom = uom.getFullYear() + "-" + (uom.getMonth() + 1) + "-" + uom.getDate(); 
    return uom;
}

function showdate(n) {
    var uom = new Date();
    uom.setDate(uom.getDate() + n);
    uom = uom.getDate();
    return uom;
}

function HotToDay_Soffer(type) {
    var xmlhttp = CreateXmlHttp();
    var url = "ajax/HotToday_Soffer.aspx";
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { OnReadyStateChng(xmlhttp, "divHotToDay", type); }
    xmlhttp.send(null);
}
/*========================首页超低特价推荐=============================*/
function LowestPrice(type) {
    var xmlhttp = CreateXmlHttp();
    var url = "ajax/ajaxLowestPrice.aspx?id=0";
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChng(xmlhttp, "divLowestPrice", type);
    }
    xmlhttp.send(null);
}
function OnReadyStateChng(xmlhttp, divMessage, type) {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            var obj = xmlhttp.responseText;
            document.getElementById(divMessage).innerHTML = obj;
        }
        else {
            alert("数据请求失败"+xmlhttp.status);
         }
    }
 }
 /*======================国内机票一级页面超低特价数据=============================*/
 function CnLowestSpecial() {
     var xmlhttp = CreateXmlHttp();
     var url = "../ajax/ajaxLowestPrice.aspx?id=1";
     xmlhttp.open("GET", url, true);
     xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp, "divLowestSpecail", 1);
     }
     xmlhttp.send(null);
 }
/*======================国内机票一级页面特价城市组数据==================*/
function LowestPriceSearch() {
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxLowestPriceSearch.aspx";
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp, "divTicketGroup",2,0);
    }
    xmlhttp.send(null);
}
/*======================国内机票一级页面特价城市组下的特价数据==================*/
function GetCityGroupPrice(id) {
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxLowestPriceSearch.aspx?id="+id;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp, "divCityGroupPrice", 3,id);
    }
    xmlhttp.send(null);
}
/*=============================================================*/
function OnReadyStateChina(xmlhttp, div, type,id) {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            var obj = xmlhttp.responseText;
            if (type == 2) {
                document.getElementById(div).innerHTML = obj.split('@')[0];
//                var id = obj.split('@')[1];
            }
            else if (type == 3) {
                document.getElementById("divLoadSpecial").style.display = "none";
                document.getElementById(div).innerHTML = obj.split('@')[0];
//                var parm = obj.split('@')[1];
//                var fromcity = parm.split('|')[0];
//                var tocity = parm.split('|')[1];
//                var fromdate = parm.split('|')[2];                
            }
            else {
                document.getElementById(div).innerHTML = obj;
            }
        }
    }
    else {
        if (type == 1) { //超低特价格
            
        }
        else if (type == 2) { //特价城市组
        
        }
        else if (type == 3) { //城市组的价格数据
            var divLoadSpecial = document.getElementById("divLoadSpecial");
            divLoadSpecial.style.display = "";
            divLoadSpecial.innerHTML = "<img src='../images_index/point.gif' alt='' />";
        }
    }
}

 /*==============================七天特价数据===========================================*/
//function LoadWeekLowest(fcode, tcode, sdate, id) {
//    xmlhttp = CreateXmlHttp();
//    var url = "../ajax/ajaxWeekLowest.aspx?fcode=" + fcode + "&tcode=" + tcode + "&sdate=" + sdate+"&id="+id;
//    xmlhttp.open("GET", url, true);
//    xmlhttp.onreadystatechange = function() {
//        var divWeekLowest = document.getElementById("divWeekLowest");
//        var divWeekLoad = document.getElementById("divWeekLoad");
//        if (xmlhttp.readyState == 4) {
//            if (xmlhttp.status == 200) {
//                var obj = xmlhttp.responseText;
//                divWeekLowest.innerHTML = obj;
//                if (divWeekLoad == null) return false;
//                divWeekLoad.style.display = "none";
//            }
//        }
//        else {
//            if (divWeekLoad == null) return false;

//            divWeekLoad.style.display = "";
//            divWeekLoad.innerHTML = "<img src='../images_index/point.gif' alt='' />";

//        }
//    }
//    
//    xmlhttp.send(null);
//}
function LoadWeekLowest(fcode, tcode, sdate) {
    xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxWeekLowest.aspx?fcode=" + fcode + "&tcode=" + tcode + "&sdate=" + sdate;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
    var divWeekLowest = document.getElementById("divWeekHtml");
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                var obj = xmlhttp.responseText;
                divWeekLowest.innerHTML = obj; 
            }
        }
    }
    xmlhttp.send(null);
}

function Load_WeekLowest(fcode, tcode, sdate) {
    xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxWeekLowest_news.aspx?fcode=" + fcode + "&tcode=" + tcode + "&sdate=" + sdate;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
    var divWeekLowest = document.getElementById("vod_info1");
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                var obj = xmlhttp.responseText;
                divWeekLowest.innerHTML = obj; 
            }
        }
    }
    xmlhttp.send(null);
}
/*==============================显示飞机简介=========================================*/
function ShowAirInfo(e,name) {
    xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxPlaneModel.aspx?model=" + name;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                var obj = xmlhttp.responseText;
                if (obj == "") {
                    HidAirModel();
                    return false;
                }
                var offsetPos = getAbsolutePos(e);
                var divElement = document.getElementById("divElement");
                if (!divElement) {
                    var divElement = document.createElement("DIV");
                    divElement.id = "divElement";
                    divElement.style.marginLeft = 30;
                    divElement.style.marginTop = -5;
                    divElement.style.height = 100;
                    divElement.style.width = 200;
                    divElement.style.textAlign = "left";
                    divElement.style.position = "absolute";
                    divElement.style.fontSize = "12px";
                    divElement.style.border = "1px #bfbfbf solid";
                    divElement.style.backgroundColor = "#f3f3f3";
                }
                divElement.style.display = "";
                divElement.innerHTML = obj;
                e.appendChild(divElement);
            }
        }
    }
    xmlhttp.send(null);
}
//隐藏飞机型号
function HidAirModel() {
    var divElement = document.getElementById("divElement");
    if (divElement) divElement.style.display = "none";
}
/*=========================显示退改签信息===============================================*/
function ShowCarrierVisa(e, code, bunk, fullprice) {
    
    xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCarrierVisa.aspx?carrier=" + code + "&bunk=" + bunk + "&fullprice=" + fullprice;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                var obj = xmlhttp.responseText;
                if (obj == "") {
                    HidAirModel();
                    return false;
                }
                var offsetPos = getAbsolutePos(e);
                var divElement = document.getElementById("divElement");
                if (!divElement) {
                    var divElement = document.createElement("DIV");
                    divElement.id = "divElement";
                    divElement.style.marginLeft =48;
                    divElement.style.marginTop = -5;
                    divElement.style.position = "absolute";
                    divElement.style.fontSize = "12px";
                    divElement.style.border = "1px #bfbfbf solid";
                    divElement.style.backgroundColor = "#f3f3f3";
                }
                divElement.style.display = "";
                divElement.innerHTML = obj;
                e.appendChild(divElement);
            }
        }
    }
    xmlhttp.send(null);
}

//返回显示窗体的坐标位置
function getAbsolutePos(el) {
    var r = { x: el.offsetLeft, y: el.offsetTop };
    if (el.offsetParent) {
        var tmp = getAbsolutePos(el.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
    }
    return r;
}
//
function reinitIframe(iframe) {
    try {
        var bHeight = iframe.contentWindow.document.body.scrollHeight;
        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
        var height = Math.max(bHeight, dHeight);
        iframe.height = height;
    } catch (ex) { }
}
/*======================新国内酒店一级页面连锁酒店数据==================*/
function ChainHotel(city) {
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCommon.aspx?id=0&_c="+city;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp, "chainhotel",0,0);
    }
    xmlhttp.send(null);
}
/*======================国际机票二级页面特别限制数据===================*/
function  ShowDetailed(f_id,obj)
{
   var xmlhttp = CreateXmlHttp();
   var url="../ajax/ajaxCommon.aspx?id=4&f_id="+f_id;
   xmlhttp.open("GET",url,true);
   xmlhttp.onreadystatechange=function(){
   OnReadyStateChina(xmlhttp,obj,0,0);
   }
       xmlhttp.send(null);
}
/*======================新国内酒店一级页面连锁酒店数据==================*/
function ShowPriceDetail(rt_id,obj,_t)
{
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCommon.aspx?id=1&_rt=" + rt_id + "&t=" + _t;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp,obj,0,0);
    }
    xmlhttp.send(null);
}
function ShowHkPriceDetail(id, obj,checkI,checkO) {
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCommon.aspx?id=5&_id=" + id+"&_ci="+checkI+"&_co="+checkO;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp, obj, 0, 0);
    }
    xmlhttp.send(null);
}
/*======================首页地理位置数据(行政区/地标)==================*/
function ShowLocation(c_id)
{
    show_position(c_id);
    show_area(c_id);
}
function show_position(c_id)
{    
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCommon.aspx?id=2&_cid="+c_id;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp,"c_position",0,0);
    }
    xmlhttp.send(null);
}
function show_area(c_id)
{
    var xmlhttp = CreateXmlHttp();
    var url = "../ajax/ajaxCommon.aspx?id=3&_cid="+c_id;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        OnReadyStateChina(xmlhttp,"c_area",0,0);
    }
    xmlhttp.send(null);    
}
