function GetObj(objName) {
    if (document.getElementById) {
        return eval('document.getElementById("' + objName + '")');
    } else if (document.layers) {
        return eval("document.layers['" + objName + "']");
    } else {
        return eval('document.all.' + objName);
    }
}
function objLeft(e) {
    var l = e.offsetLeft;
    while (e = e.offsetParent) {
        l += e.offsetLeft;
    }
    return l;
}
function objTop(e) {
    var l = e.offsetTop;
    while (e = e.offsetParent) {
        l += e.offsetTop;
    }
    return l;
}
function ViewRoomIntroduction(RoomId) {
    var ff = !(document.all);
    var NowState = GetObj("Room-Introduction-" + RoomId);
    if (NowState.className == "Hidden-Room-Introduction") {
        if (ff) {
            NowState.className = "View-Room-Introduction-ff";
        } else {
            NowState.className = "View-Room-Introduction";
        }
    } else {
        NowState.className = "Hidden-Room-Introduction";
    }
}
function CloseDiv(DivName, obj) {
    GetObj(DivName).style.display = "none";
}
function CloseDivAll() {
    this.DivName.style.display = "none";
}
function nextSibling(obj) {
    var tempObj = obj;
    do {
        tempObj = tempObj.nextSibling;
    } while ( tempObj . nextSibling && tempObj . nextSibling . nodeType && ( tempObj . nextSibling . nodeType != 1 )) return tempObj;
}
function ViewHiddenRoom(id) {
    if ($.browser.msie && $.browser.version <= 6) {
        if ($(".hidden-Room" + id)[0].style.display == "none") {
            for (var i = 0; i < $(".hidden-Room" + id).length; i++) {
                $(".hidden-Room" + id)[i].style.display = "block";
            }
            $(".AllRoom" + id)[0].className = "AllRoom" + id + " HiddenRooms";
        } else {
            for (var i = 0; i < $(".hidden-Room" + id).length; i++) {
                $(".hidden-Room" + id)[i].style.display = "none";
            }
            $(".AllRoom" + id)[0].className = "AllRoom" + id + " Viewrooms";
        }
    } else {
        if ($(".hidden-Room" + id).css("display") == "none") {
            $(".hidden-Room" + id).css("display", "table-row");
            $(".AllRoom" + id).addClass("HiddenRooms");
            $(".AllRoom" + id).removeClass("Viewrooms");
        } else {
            $(".hidden-Room" + id).css("display", "none");
            $(".AllRoom" + id).addClass("Viewrooms");
            $(".AllRoom" + id).removeClass("HiddenRooms");
        }
    }
}
function Change_Favorites(obj, hotelid, divid) {
    var ajax = new AJAXRequest;
    var Favorites = obj;
    var hotelid = hotelid;
    var divid = divid;
    alert('已加入常住酒店!');
    ajax.get("/member/Favorites/Add_Favorites.asp?hotelid=" + hotelid,
    function(obj) {});
}

function Submit1() {
    if (stringToDate(document.form1.startdate.value) < stringToDate(document.form1.today.value)) {
        alert("入住日期不能早于今日！");
        document.form1.startdate.focus();
        return (false);
    }
    if (stringToDate(document.form1.startdate.value) >= stringToDate(document.form1.enddate.value)) {
        alert("离店日期应大于入住日期！");
        document.form1.enddate.focus();
        return (false);
    }
    if (daysBetween(document.form1.startdate.value, document.form1.enddate.value) > 28) {
        alert("入住时间段不能超过28天");
        document.form1.enddate.focus();
        return (false);
    }
    if (daysBetween(document.form1.today.value, document.form1.enddate.value) > 90) {
        alert("如需查询三个月后的房价，请拨打电话 400-686-9999，谢谢！");
        document.form1.enddate.focus();
        return (false);
    }
    document.form1.submit();
    return (true);
}
function daysBetween(DateOne, DateTwo) {
    var OneMonth = DateOne.substring(5, DateOne.lastIndexOf('-'));
    var OneDay = DateOne.substring(DateOne.length, DateOne.lastIndexOf('-') + 1);
    var OneYear = DateOne.substring(0, DateOne.indexOf('-'));
    var TwoMonth = DateTwo.substring(5, DateTwo.lastIndexOf('-'));
    var TwoDay = DateTwo.substring(DateTwo.length, DateTwo.lastIndexOf('-') + 1);
    var TwoYear = DateTwo.substring(0, DateTwo.indexOf('-'));
    var cha = ((Date.parse(OneMonth + '/' + OneDay + '/' + OneYear) - Date.parse(TwoMonth + '/' + TwoDay + '/' + TwoYear)) / 86400000);
    return Math.abs(cha);
}
function setCheckInDate(d) {
    document.getElementById("startdate").value = d;
    showCalendar('imageCalendar2', false, 'enddate', 'startdate');
}
$(document).ready(function() {
    $(".hotelabo span a").click(function() {
        return false;
    });
});

function ListRoomIntroduction(Elong_id, RoomId) {
    var thisDHtml = "<p align='center'><img src='/imgs/loading.gif'/></p><p align='center'>请稍后，正在为您查询！</p>";
    $("#Room-Introduction-" + Elong_id + "-" + RoomId + " div").html(thisDHtml);
    var ff = !(document.all);
    var NowState = GetObj("Room-Introduction-" + Elong_id + "-" + RoomId);
    if (NowState.className == "Hidden-Room-Introduction") {
        if (ff) {
            NowState.className = "View-Room-Introduction-ff";
        } else {
            NowState.className = "View-Room-Introduction";
        }
        var thisUrl = "/hotel/get_RoomIntro.asp?roomid=" + RoomId + "&Elong_id=" + Elong_id;
        $.ajax({
            type: "get",
            timeout: "1000",
            dataType: "html",
            url: thisUrl,
            beforeSend: function(XMLHttpRequest) {},
            success: function(data, textStatus) {
                $("#Room-Introduction-" + Elong_id + "-" + RoomId + " div").html(data);
            },
            error: function(a, b, c) {
                thisDHtml = "无法获取数据，请稍后再试";
                $("#Room-Introduction-" + Elong_id + "-" + RoomId + " div").html(thisDHtml);
            }
        });
    } else {
        NowState.className = "Hidden-Room-Introduction";
    }
}

