﻿document.write('<script type="text/javascript" src="../js/public.js"></script>');
document.write('<script type="text/javascript" src="../js/GetDateTime.js"></script>');
document.write('<script type="text/javascript" src="js/public.js"></script>');
document.write('<script type="text/javascript" src="js/GetDateTime.js"></script>');
document.write('<script type="text/javascript" src="../js/index.js"></script>');
function orderline(btn) {
    if (isorder) {
        alert("线路预定成功，请不要重复预定。");
        return false
    }
    var name = $("txtName");
    var rela = $("txtRelation");
    var phone = $("txtPhone");
    var qq = $("txtQQ");
    var msn = $("txtMSN");
    var email = $("txtEmail");
    var child = $("txtChild");
    var adult = $("txtAdult");
    var count = $("txtCount");
    var date = $("txtDate");
    var remark = $("txtRemark");
    if (rela.value.trim() == "") {
        alert("请输入联系人。");
        rela.focus();
        return false
    }
    if (phone.value == 0) {
        alert("请输入您的联系电话。");
        phone.select();
        return false
    }
    if (count.value.trim() == "") {
        alert("请输入行程人数。");
        count.focus();
        return false
    }
    if (date.value.trim() == "") {
        alert("请输入出发日期。");
        date.focus();
        return false
    }
    if (!/(?:[a-zA-Z]{4,20})|(?:[\u4e00-\u9fa5_]{2,10})/.test(rela.value)) {
        alert("姓名输入不合法，英文介于4-20之间，中文介于2-10个汉字之间。");
        rela.select();
        return false
    }
    if (phone.value != 0 && !/^\d{8,15}$/.test(phone.value)) {
        alert("电话号码的格式不正确，就介于8-15个数字。");
        phone.select();
        return false
    }
    if (qq.value != 0 && !/^\d{4,12}$/.test(qq.value)) {
        alert("QQ输入不正确。");
        qq.select();
        return false
    }
    if (msn.value != 0 && !/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,5}$/.test(msn.value)) {
        alert("msn输入不合法。");
        msn.select();
        return false
    }
    if (email.value != 0 && !/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,5}$/.test(email.value)) {
        alert("Email输入不合法。");
        email.select();
        return false
    }
    if (parseInt(count.value) > 1000) {
        alert("对不起，行程人数不能超过1000。");
        count.select();
        return false
    }
    if (remark.value.length > 100) {
        alert("对不起，您输入的内容过长，必须在100字以内。");
        remark.select();
        return false
    }
    var code = $("txtcode");
    if (code.value == 0) {
        alert("请输入验证码。");
        code.value = "";
        code.focus();
        return false
    }
    if (!getCookie(code.value)) {
        code.select();
        return false
    }
    var id = window.location.href.match(/order-(\d+)-\d+/)[1];
    alist_Orderline.OrderLines(btn.id, id, name.value, rela.value, phone.value, qq.value, msn.value, email.value, child.value, adult.value, count.value, date.value, remark.value, window.location.href, reback)
}
var isorder = false;
function reback(data) {
    switch (data.value) {
    case 0:
        alert("线路预定成功。");
        isorder = true;
        break;
    case 1:
        alert("对不起，一个IP一天只能预订单一份订单。\n为此对您造成的不便，敬请谅解。");
        break;
    case 2:
        alert("线路预定失败。");
        break
    }
}
function search2(name) {
    var _list = $(name);
    var lnk = window.location.href;
    var _s1 = lnk.split("/");
    var _s2 = _s1[_s1.length - 1];
    var _s3 = _s2.split("="); 
    var _s4 = _s3[_s3.length - 1];
    var _s5 = _s2.substr(0, _s2.lastIndexOf("=") + 1);
    var _s6 = _list.options[_list.selectedIndex].text;
    if (_s2.indexOf("p=") == -1) window.location = _s2 + "&p=" + _s6;
    else window.location = _s5 + _s6
}
function linelist2() {
    var lnk = window.location.href;
    if (lnk.getQuery("p") != null) {
        $("select3").options.selectedIndex = parseInt(lnk.getQuery("p")) - 1;
        $("select4").options.selectedIndex = parseInt(lnk.getQuery("p")) - 1
    }
}
function s2byname() {
    var lnk = window.location.href;
    var name = $("txtName1");
    if (lnk.indexOf("&n=") == -1) {
        window.location = lnk + "&n=" + escape(name.value.trim())
    } else {
        var _s1 = lnk.split("/");
        var _s2 = _s1[_s1.length - 1];
        var _s3 = _s2.split("&");
        var _s4 = _s3[0];
        window.location = _s4 + "&n=" + escape(name.value.trim())
    }
}
function linefind() {
    var from = $("txtFrom") == null ? "": $("txtFrom").value;
    var to = $("txtTo") == null ? "": $("txtTo").value;
    var name = $("txtName") == null ? "": $("txtName").value;
    var day = $("select1") == null ? "": $("select1").options[$("select1").selectedIndex].value;
    var price = $("select2") == null ? "": $("select2").options[$("select2").selectedIndex].value;
    window.location = "list?f=" + escape(from) + "&t=" + escape(to) + "&n=" + escape(name) + "&d=" + day + "&p=" + price
}
function the1(list) {
    var intext = list.options[list.selectedIndex].value;
    if (intext.trim() != "" && intext != null) {
        window.location = "the?i=" + intext
    }
}
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
    }
}
function orderhotel(hid, oid) {
    var sdate = $("txtsdate" + oid);
    var edate = $("txtedate" + oid);
    var room = $("txtroom" + oid);
    var person = $("txtps" + oid);
    var sndurl = "jdorder-" + hid + "-" + oid + "-" + sdate.value + "_" + edate.value + "_" + room.value + "-" + person.value + ".html";
    window.location = sndurl
}
var codechang = function(img) {
    img.src = "../Controls/ValidateCode.ashx?r=" + new Date().getTime()
}
var incode1 = function() {
    $("txtcode").focus();
}
var incode2 = function(txt) {
    if (txt.nextSibling.innerHTML.indexOf("<IMG") == -1) {
        txt.nextSibling.innerHTML = "<img alt=\"\" src=\"../Controls/ValidateCode.ashx?r=new Date().getTime()\" onclick=\"codechang(this)\" />";
    }
}

var orderalready = false;
function userohotel() {
    if (orderalready) {
        alert("您的订单已预订成功，请不要重复预定。");
        return false
    }
    var sdate = $("txtsdate");
    var edate = $("txtedate");
    var room = $("txtroom");
    var person = $("txtperson");
    var name = $("txtname");
    var home = $("txthome");
    var tell = $("txttell");
    var fax = $("txtfax");
    var email = $("txtemail");
    if (sdate.value.trim() == "") {
        alert("请选择您的入住日期。");
        sdate.focus();
        return false
    }
    if (edate.value.trim() == "") {
        alert("请选择您的离店日期。");
        edate.focus();
        return false
    }
    if (room.value.trim() == "") {
        alert("请输入您预定的房间数。");
        room.focus();
        return false
    }
    if (person.value.trim() == "") {
        alert("请输入您预定的人数。");
        person.focus();
        return false
    }
    if (name.value.trim() == "") {
        alert("请输入联系人。");
        name.focus();
        return false
    }
    if (home.value.trim() == "" && tell.value.trim() == "" && fax.value.trim() == "" && email.value.trim() == "") {
        alert("联系方式至少输入一种。");
        home.focus();
        return false
    }
    var hname = $("spname");
    var rname = $("sproom");
    alist_hotelorder.UserOrderHotel(hname.innerHTML, rname.innerHTML, sdate.value, edate.value, room.value, person.value, name.value, home.value, tell.value, fax.value, email.value, back_order)
}
function back_order(data) {
    if (data.value) {
        orderalready = true;
        alert("酒店预定成功。")
    } else alert("酒店预定失败。")
}
function hoverli(idx) {
    switch (idx) {
    case 1:
        $("dt1").style.display = "";
        $("dt2").style.display = "none";
        $("dt3").style.display = "none";
        break;
    case 2:
        $("dt1").style.display = "none";
        $("dt2").style.display = "";
        $("dt3").style.display = "none";
        break;
    case 3:
        $("dt1").style.display = "none";
        $("dt2").style.display = "none";
        $("dt3").style.display = "";
        break
    }
}
function settitles(intext) {
    var t = $("lt");
    if (t.Document.getElementById("ztly21") != null) t.Document.getElementById("ztly21").style.backgroundColor = "#" + t.name
}
var skipp = function(img) {
    var tgo = $("txtgo");
    if (parseInt(tgo.value).toString() == "NaN") {
        tgo.value = "";
        tgo.focus();
        return false
    }
    var _pcount = img.id;
    var _current = img.name;
    if (parseInt(tgo.value) <= 0 || parseInt(tgo.value) > parseInt(_pcount)) {
        alert("请输入正确的页数.");
        tgo.select();
        return false
    }
    var lnk = window.location.href;
    var patt = /(.*\/\w+)(-\d+)?.html$/;
    var pname = lnk.match(patt)[1];
    var snd = pname + "-" + tgo.value + ".html";
    window.location = snd
}
var theship = function(btn) {
    var tgo = $("txtgo");
    if (parseInt(tgo.value).toString() == "NaN") {
        tgo.value = "";
        tgo.focus();
        return false
    }
    var _pcount = btn.id;
    var _current = btn.name;
    if (parseInt(tgo.value) <= 0 || parseInt(tgo.value) > parseInt(_pcount)) {
        alert("请输入正确的页数.");
        tgo.select();
        return false
    }
    var lnk = window.location.href;
    var patt = /([^\?]*)(.*)/;
    var pname = lnk.match(patt);
    var snd;
    if (pname[2].indexOf("&p") == -1) {
        snd = pname[0] + "&p=" + tgo.value
    } else {
        var paralist = lnk.split("&p");
        snd = paralist[0] + "&p=" + tgo.value
    }
    window.location = snd
}
