﻿document.write('<script type="text/javascript" src="js/public.js"></script>');
document.write('<script type="text/javascript" src="../js/public.js"></script>');

// pagehead 选项卡切换
function nTabs(thisObj, Num) {
    if (thisObj.className == "active") return;
    var tabObj = thisObj.parentNode.id;
    var tabList = $(tabObj).getElementsByTagName("li");
    for (i = 0; i < tabList.length; i++) {
        if (i == Num) {
            thisObj.className = "active";
            $('Text1').value = Num;
        } else {
            tabList[i].className = "normal";
        }
    }
}

function chatLoad() {
    var chat = TraAgens_ChatRoom.PageLoad();
    $("chatText").value = chat.value;
    $("chatText").scrollTop = $("chatText").scrollHeight;
    setTimeout(chatLoad, 1000);
}

function chatSend() {
    var intext = $("inText");
    if (intext.value.trim() == "") {
        alert("请输入您所要发送的内容。");
        intext.focus();
        intext.select();
        return false;
    }
    if (!TraAgens_ChatRoom.sendMessage(intext.value).value) {
        alert("信息发送失败。\\n您可能未登陆或登陆已超时。");
    } else {
        intext.value = "";
        intext.focus();
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length,
        a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) {
            d.MM_p[j] = new Image;
            d.MM_p[j++].src = a[i];
        }
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (! (x = d[n]) && d.all) x = d.all[n];
    for (i = 0; ! x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; ! x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0,
    x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3) if ((x = MM_findObj(a[i])) != null) {
        document.MM_sr[j++] = x;
        if (!x.oSrc) x.oSrc = x.src;
        x.src = a[i + 2];
    }
}

function linefind() {
    var from = $("txtFrom");
    var to = $("txtTo");
    var name = $("txtName");
    var day = $("select1");
    var price = $("select2");

    window.location = (window.location.href.indexOf("alist/") == -1 ? "alist/" : "") + "list?f=" + escape(from.value) + "&t=" + escape(to.value) + "&n=" + escape(name.value) 
    + (day ? "&d=" + day.options[day.selectedIndex].value : "") 
    + (price ? "&p=" + price.options[price.selectedIndex].value : "")
}

function lineheadtab(idx) {
    var lnk = window.top.location.href;
    var patt = /(\/alist|)\/\w+-(\d+)(?=\.html)/;
    var filename = lnk.match(patt);
    if (filename == null) return;
    window.top.location = {
        1 : ".."+ filename[1] + "/line-" + filename[2] + ".html",
        2 : ".."+ filename[1] + "/line2-" + filename[2] + ".html",
        3 : ".."+ filename[1] + "/line3-" + filename[2] + ".html"
    } [idx]
}
var scenictab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/\w+-([^\.]+)(?=\.html)/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/fjms-" + filename[1] + ".html";
        break;
    case 2:
        window.top.location = "../alist/fjms2-" + filename[1] + ".html";
        break;
    case 3:
        window.top.location = "../alist/fjms3-" + filename[1] + ".html";
        break;
    }
}
var zbtab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/([a-zA-Z]+)[23]?(-[^\.]*)?\.html$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/" + filename[1] + filename[2] + ".html";
        break;
    case 2:
        window.top.location = "../alist/" + filename[1] + "2" + filename[2] + ".html";
        break;
    case 3:
        window.top.location = "../alist/" + filename[1] + "3" + filename[2] + ".html";
        break;
    }
}
var hoteltab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/\w+-([^\.]+)(?=\.html)/;
    var filename = lnk.match(patt);
    if (filename == null) {
        //验证是否为酒店搜索页面
        patt = /\/jdlist[23]?\?(.*)$/;
        filename = lnk.match(patt);
        if (filename == null) return;
        switch (idx) {
        case 1:
            window.top.location = "../alist/jdlist?" + filename[1];
            break;
        case 2:
            window.top.location = "../alist/jdlist2?" + filename[1];
            break;
        case 3:
            window.top.location = "../alist/jdlist3?" + filename[1];
            break;
        }
    } else {
        switch (idx) {
        case 1:
            window.top.location = "../alist/jdinfo-" + filename[1] + ".html";
            break;
        case 2:
            window.top.location = "../alist/jdinfo2-" + filename[1] + ".html";
            break;
        case 3:
            window.top.location = "../alist/jdinfo3-" + filename[1] + ".html";
            break;
        }
    }
}
var visatab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/\w+-([^\.]+)(?=\.html)/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/visa-" + filename[1] + ".html";
        break;
    case 2:
        window.top.location = "../alist/visa2-" + filename[1] + ".html";
        break;
    case 3:
        window.top.location = "../alist/visa3-" + filename[1] + ".html";
        break;
    }
}
var list2tab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/name[23]?\?(.*)$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/name?" + filename[1];
        break;
    case 2:
        window.top.location = "../alist/name2?" + filename[1];
        break;
    case 3:
        window.top.location = "../alist/name3?" + filename[1];
        break;
    }
}
var list2headload = function() {
    $("jdbg1").style.backgroundColor = "#" + window.frameElement.name;
}
var list1tab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/list[23]?\?(.*)$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/list?" + filename[1];
        break;
    case 2:
        window.top.location = "../alist/list2?" + filename[1];
        break;
    case 3:
        window.top.location = "../alist/list3?" + filename[1];
        break;
    }
}
var landtab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/land[23]?\?(.*)$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/land?" + filename[1];
        break;
    case 2:
        window.top.location = "../alist/land2?" + filename[1];
        break;
    case 3:
        window.top.location = "../alist/land3?" + filename[1];
        break;
    }
}
var playtab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/paly[23]?\?(.*)$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/paly?" + filename[1];
        break;
    case 2:
        window.top.location = "../alist/paly2?" + filename[1];
        break;
    case 3:
        window.top.location = "../alist/paly3?" + filename[1];
        break;
    }
}
var themetab = function(idx) {
    var lnk = window.top.location.href;
    var patt = /\/the[23]?\?(.*)$/;
    var filename = lnk.match(patt);
    if (filename == null) return;

    switch (idx) {
    case 1:
        window.top.location = "../alist/the?" + filename[1];
        break;
    case 2:
        window.top.location = "../alist/the2?" + filename[1];
        break;
    case 3:
        window.top.location = "../alist/the3?" + filename[1];
        break;
    }
}

var iscity = function(list) {
    var intext = list[list.selectedIndex].value;
    index.getCityByScenic(intext,
    function(data) {
        bakscity(data, intext)
    });
}
var bakscity = function(data, idx) {
    var dt = data.value;
    var list2 = $("scity2");
    list2.options.length = 1;
    for (var i = 0; i < dt.Rows.length; i++) {
        if (idx == 1) list2.add(new Option(dt.Rows[i]["pr_Name"], dt.Rows[i]["pr_ID"]));
        else list2.add(new Option(dt.Rows[i]["wo_Name"], dt.Rows[i]["wo_ID"]));
    }
}
var iscenic = function() {
    var list1 = $("scity1");
    var list2 = $("scity2");
    var name = $("txtsname");
    var sndtext = "alist/fjms?area=" + escape(list2.selectedIndex == 0 ? "": list2[list2.selectedIndex].text) + "&name=" + escape(name.value) + "&type=" + list1[list1.selectedIndex].value;
    window.open(sndtext, "scenic");
}

var cjcity1 = function(list) {
    index.getProvince(list[list.selectedIndex].value, bakjcity1);
}
var bakjcity1 = function(data) {
    var dt = data.value;
    var list1 = $("jcity2");
    var list2 = $("jcity3");
    list1.options.length = 1;
    list2.options.length = 1;
    for (var i = 0; i < dt.Rows.length; i++) {
        list1.add(new Option(dt.Rows[i]["pr_Name"], dt.Rows[i]["pr_ID"]));
    }
}
var cjcity2 = function(list) {
    index.getProvince(list[list.selectedIndex].value, bakjcity2);
}
var bakjcity2 = function(data) {
    var dt = data.value;
    var list1 = $("jcity3");
    list1.length = 1;
    for (var i = 0; i < dt.Rows.length; i++) {
        list1.add(new Option(dt.Rows[i]["pr_Name"], dt.Rows[i]["pr_ID"]));
    }
}

var submitjd = function() {
    var list1 = $("jcity1");
    var list2 = $("jcity2");
    var list3 = $("jcity3");
    var price = $("jsprice");
    var star = $("jsstar");
    var name = $("txtjname");

    var city = (list1.selectedIndex == 0 ? "": list1[list1.selectedIndex].text) + (list2.selectedIndex == 0 ? "": "," + list2[list2.selectedIndex].text) + (list3.selectedIndex == 0 ? "": "," + list3[list3.selectedIndex].text);

    var sndtext = "alist/jdlist?area=&city=" + escape(city) + "&price=" + escape(price[price.selectedIndex].value) + "&star=" + escape(star[star.selectedIndex].value) + "&name=" + escape(name.value) + "&address=" + escape(city.replace(/\,/g, ""));
    window.open(sndtext, "shotel");
}


var sitocity = function(list) {
    index.getkeyId(list.value == "" || list.value == "0" ? "": list[list.selectedIndex].text, stccall);
}
var stccall = function(data){
    if (data.value) {
        var snd = "alist/list?f=&t=" + data.value + "&n=&d=&p=";
        window.open(snd, "_blank");
    }
}
var siday = function(list) {
    var snd = "alist/list?f=&d=" + (list.value == "" || list.value == "0" ? "": list.value);
    window.open(snd, "_blank");
}
var siprice = function(list) {
    var snd = "alist/list?f=&p=" + (list.value == "" || list.value == "0" ? "": list.value);
    window.open(snd, "_blank");
}
var sitheme = function(list) {
    var snd = "alist/the?i=" + (list.value == "" || list.value == "0" ? "": list.value);
    window.open(snd, "_blank");
}

/*首页地图*/
var loaddcity = function() {
    var lnk = window.top.location.href;
    var patt = /^http:\/{2}.*\/$/;
    if (lnk.indexOf("/index.") == -1 && !patt.test(lnk)) return;
    var dcity = window.top.document.getElementById("dcity");
    var clist = dcity.getElementsByTagName("div");

    for (var i = 0; i < clist.length; i++) {
        if (window.attachEvent) {
            clist[i].attachEvent("onmouseover", mover(clist[i]));
            clist[i].attachEvent("onmouseout", mout(clist[i]));
            clist[i].attachEvent("onclick", mclick(clist[i]));
        } else {
            clist[i].addEventListener("mouseover", mover(clist[i]), true);
            clist[i].addEventListener("mouseout", mout(clist[i]), true);
            clist[i].addEventListener("click", mclick(clist[i]), true);
        }
    }
}
var zidx;
var mover = function(div) {
    return function() {
        var _t, _l, _w, _h;
        with(div.style) {
            _t = parseInt(top);
            _l = parseInt(left);
            _w = parseInt(div.offsetWidth);
            _h = parseInt(div.offsetHeight);

            top = (_t - 5) + "px";
            left = (_l - 5) + "px";
            width = div.innerHTML.length > 2 ? "50px": "40px";
            height = "18px";
            lineHeight = "18px";
            fontSize = "14px";
            color = "#f00";
            zidx = zIndex;
            zIndex = 9999;
        }
    }
}
var mout = function(div) {
    return function() {
        var _t, _l, _w, _h;
        with(div.style) {
            _t = parseInt(top);
            _l = parseInt(left);
            _w = parseInt(div.offsetWidth);
            _h = parseInt(div.offsetHeight);

            top = (_t + 5) + "px";
            left = (_l + 5) + "px";
            width = div.innerHTML.length > 2 ? "35px": "25px";
            height = "12px";
            lineHeight = "12px";
            fontSize = "10px";
            color = "#000";
            zIndex = zidx;
        }
    }
}
var mclick = function(div) {
    return function() {
        index.getkeyId(div.innerHTML, mccall);
    }
}
var mccall = function(data){
    if (data.value){
        var snd = "alist/list?f=&t=" + data.value;
        window.open(snd, "_blank");
    }
}

window.onresize = function() {
    if (dcity) dcity.style.left = icity.offsetLeft - 1;
}
var dcity;
var icity;
var sitecity = function() {
    dcity = $("dcity1");
    icity = $("icity");
    //alert(icity.clientLeft);

    dcity.style.left = icity.offsetLeft - 1;
    if (window.attachEvent) {
        icity.attachEvent("onmouseover", imover(icity));
        dcity.attachEvent("onmouseover", imover(dcity));
        dcity.attachEvent("onmouseout", imout(dcity));
    } else {
        icity.addEventListener("mouseover", imover(icity), true);
        dcity.addEventListener("mouseover", imover(dcity), true);
        dcity.addEventListener("mouseout", imout(dcity), true);
    }
    var lilist = dcity.getElementsByTagName("li");
    for (var i = 0; i < lilist.length; i++) {
        if (window.attachEvent) {
            lilist[i].attachEvent("onmouseover", limover(lilist[i]));
            lilist[i].attachEvent("onmouseout", liout(lilist[i]));
        } else {
            lilist[i].addEventListener("mouseover", limover(lilist[i]), true);
            lilist[i].addEventListener("mouseout", liout(lilist[i]), true);
        }
    }
}
var imover = function(img) {
    return function() {
        $("dcity1").style.visibility = "visible";
    }
}
var imout = function(img) {
    return function() {
        var evt = window.event || arguments.callee.caller.arguments[0] || e;
        var src = evt.srcElement || evt.target;
        if (src.tagName.toUpperCase() == "DIV") $("dcity1").style.visibility = "hidden";
    }
}

var limover = function(li) {
    return function() {
        li.style.backgroundColor = "#ffc953";
    }
}
var liout = function(li) {
    return function() {
        li.style.backgroundColor = "";
    }
}

window.onload = function() {
    if (window.location.href.indexOf("index.html") > -1 || /^http:\/{2}[^\/]+\/?$/.test(window.location.href) || window.location.href.indexOf("index.aspx") > -1){
        loaddcity();
    }
    sitecity();
}

function the1(list) {
    var intext = list.options[list.selectedIndex].value;
    var s1 = window.location.href;
    var s2 = s1.split("/");
    var s3 = s2[s2.length - 1].split("&");
    var s4 = s3[0];
    if (intext.trim() != "" && intext != null) {
        window.location = s4 + "&i=" + intext
    } else {
        window.location = s4
    }
}
function the2(list) {
    var intext = list.options[list.selectedIndex].value;
    var s1 = window.location.href;
    var s2 = s1.split("/");
    var s3 = s2[s2.length - 1].split("&");
    var s4 = s3[0];
    if (intext.trim() != "" && intext != null) {
        window.location = s4 + "&d=" + intext
    } else {
        window.location = s4
    }
}
function the3(list) {
    var intext = list.options[list.selectedIndex].value;
    var s1 = window.location.href;
    var s2 = s1.split("/");
    var s3 = s2[s2.length - 1].split("&");
    var s4 = s3[0];
    if (intext.trim() != "" && intext != null) {
        window.location = s4 + "&t=" + escape(intext)
    } else {
        window.location = s4
    }
}
