﻿/*window.onload = function() { GetUrl(); }*/
function GetUrl() {
    var b;
    b = window.document.location.pathname.toLowerCase();

    var guilinsite = /.*guilinsite.*/g;
    var tour = /.*tour.*/g;

    if (guilinsite.test(b)) {
        document.getElementById("guilinsite_li").className = "mavitem";
    }
    else
        if (tour.test(b)) {
        document.getElementById("guilintour_li").className = "mavitem";
    }
}

function getByid(id) {
    if (document.getElementById) {
        return document.getElementById(id);
    }
    else if (document.all) {
        return document.all[id];
    }
    else if (document.layers) {
        return document.layers[id];
    }
    else {
        return null;
    }
}
function trim(str) {
    str = str.replace(/(^\s*)|(\s*$)/g, "");
    return str;
}
function isNum(s) {
    var patrn = /^[0-9]*[1-9][0-9]*$/;
    if (!patrn.test(s)) return false
    return true
}
// childname内容的id，childshow内容显示样式，childhide内容不可见样式，cursel当前数字，n总数字
// columnname栏目的id, colshow栏目显示的样式, colhide栏目隐藏的样式
function TDTab(childname, childshow, childhide, cursel, n, columnname, colshow, colhide) {
    for (i = 1; i <= n; i++) {
        var childmenu = document.getElementById(childname + i);
        var childcon = document.getElementById(childname + i);
        var columnmenu = document.getElementById(columnname + i);
        var columncon = document.getElementById(columnname + i);
        if (childcon) {
            childmenu.className = i == cursel ? childshow : childhide;
            childcon.style.display = i == cursel ? "block" : childhide;
        }
        if (columncon) {
            columnmenu.className = i == cursel ? colshow : colhide;
        }
    }
}
//计算线路价格
function CountTourPrice(span) {
    var NumObj = getByid("ctl00_CPH1_txtNumberPeople");
    /*检查人数是否为数字*/
    if (!isNum(trim(NumObj.value))) {
        //        alert("请输入一个正整数！");
        //        NumObj.value = "";
        //        NumObj.focus();
        return;
    }

    var TourStar = getByid("ctl00_CPH1_DropStar").options[getByid("ctl00_CPH1_DropStar").selectedIndex].value;
    var Price = getByid("span_" + TourStar).innerHTML;
    var totalprice = (Price * NumObj.value);
    getByid(span).innerHTML = totalprice;

}
function CheckInput() {
    var NumObj = getByid("ctl00_CPH1_txtNumberPeople");
    /*检查人数是否为数字*/
    if (!isNum(NumObj.value)) {
        alert("请输入预计人数！");
        NumObj.value = "";
        NumObj.focus();
        return false;
    }
}
//提交订单按钮----------------------- 开始
function SubmitOrder() {
    if (!CheckSubmit()) {
        return false;
    }
    if (stringToDate(document.getElementById("ctl00_CPH1_txtDepartureDate").value, true) < stringToDate(document.getElementById("ctl00_CPH1_txtArrivalDate").value, true)) {

        alert("离开日期不能早于到达日期!");
        document.getElementById("ctl00_CPH1_txtDepartureDate").value = "";
        document.getElementById("ctl00_CPH1_txtDepartureDate").focus();
        return false;
    }
    else {

        return true;
    }
}
function stringToDate(sDate, bIgnore) {

    var bValidDate, year, month, day;
    var iaDate = new Array(3);
    if (bIgnore)
        bValidDate = true;
    else
        bValidDate = isDateString(sDate);
    if (bValidDate) {
        iaDate = sDate.toString().split("-");
        year = parseFloat(iaDate[0]);
        month = parseFloat(iaDate[1]) - 1;
        day = parseFloat(iaDate[2]);
        return (new Date(year, month, day));
    }
    else
        return (new Date(1900, 1, 1));
}
function isDateString(sDate) {
    var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var iaDate = new Array(3);
    var year, month, day;
    if (arguments.length != 1)
        return false;
    iaDate = sDate.toString().split("-");
    if (iaDate.length != 3)
        return false;
    if (iaDate[1].length > 2 || iaDate[2].length > 2)
        return false;
    if (isNaN(iaDate[0]) || isNaN(iaDate[1]) || isNaN(iaDate[2]))
        return false;

    year = parseFloat(iaDate[0]);
    month = parseFloat(iaDate[1]);
    day = parseFloat(iaDate[2]);

    if (year < 1900 || year > 2100)
        return false;
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1] = 29;
    if (month < 1 || month > 12)
        return false;
    if (day < 1 || day > iaMonthDays[month - 1])
        return false;
    return true;
}
//提交订单按钮----------------------- 结束

//酒店详细页 房型图片---开始
function AddaLink(photo, name) {
    if (trim(photo) == "")
        document.write("<a>");
    else {
        document.write("<a href=\"#\" onmousemove=\"show('" + name + "',1,'" + photo + "')\" onmouseout=\"show('" + name + "',0)\" >");
    }
}
function show(tips, flag, url) {
    var my_tips = document.getElementById("mytips");
    if (flag) {
        my_tips.style.display = "";
        if (url != null) { my_tips.innerHTML = "<img src='" + url + "' align=left width=550>"; }
        my_tips.style.left = event.clientX - 20;
        my_tips.style.top = event.clientY +20;
    }
    else {
        my_tips.style.display = "none";
    }
}
//酒店详细页 房型图片---结束

//酒店详细页 房型价格鼠标移动事件
function MM_showHideLayers() { //v9.0
    var i, p, v, obj, args = MM_showHideLayers.arguments;
    for (i = 0; i < (args.length - 2); i += 3)
        with (document) if (getElementById && ((obj = getElementById(args[i])) != null)) {
        v = args[i + 2];
        if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
        obj.visibility = v;
    }
}
 
