﻿var xmlHttp,historyXmlHttp;
var isHold;
function createXmlHttpRequest(){if(window.ActiveXObject){xmlHttp = new ActiveXObject("microsoft.XMLHttp");historyXmlHttp = new ActiveXObject("microsoft.XMLHttp");}else{xmlHttp = new XMLHttpRequest();historyXmlHttp= new XMLHttpRequest();}}
function callback()
{
    switch(xmlHttp.readyState)
    {
        case 4:
        {
            if(xmlHttp.status==200)
            {
                var rlist=eval(document.getElementById("allRoom").value);
                var rprice=eval(xmlHttp.responseText);
                for(var i=0;i<rlist.length;i++)
                {
                 document.getElementById("fp"+rprice[i][2]).innerHTML=rprice[i][0];
                 document.getElementById("rp"+rprice[i][2]).innerHTML=rprice[i][1];
                }
            }
            break;
        }
    }
}

function getRoomInfo(){createXmlHttpRequest();var hId = document.getElementById('hotelid').value;var url='/private/RoomPrices.aspx?id='+hId,st=$gUrl("starttime"),dt=$gUrl("deptime");
if(st!='') url+='&starttime='+st; if(dt!='') url+='&deptime='+dt;
xmlHttp.open('GET',url);xmlHttp.onreadystatechange = callback;xmlHttp.send(null);}





function getRoomListinfo()
{
    createXmlHttpRequest();
    var hl = document.getElementById('hotelid').value;
    var url="/web_serverCode/GetHotelRoominfo.aspx?hotelId="+hl;
    xmlHttp.open("GET",url,false);
    xmlHttp.onreadystatechange=RoomListinfoCallBack;
    xmlHttp.send(null);
}

function RoomListinfoCallBack()
{
    switch(xmlHttp.readyState)
    {
        case 4:
        {
            if(xmlHttp.status==200)
            {
            
               var RoomList=eval(xmlHttp.responseText);
               var R_HTML="";
               var hl = document.getElementById('hotelid').value;
               
               for(var i=0;i<RoomList.length;i++)
               {
                 R_HTML+='<ul class="fxxx2"> <li class="xing">'+RoomList[i].roomName+'</li>';
                 R_HTML+='<li class="msj">¥'+RoomList[i].StorePrices+'<li class="hyj">首日价   <span id="fp'+RoomList[i].id+'"> ¥ '+RoomList[i].Prices+' </span> ';
                 R_HTML+='<a class="blue"   onmouseover="showtooltip(\'rp'+RoomList[i].id+'\')"   onmouseout="hidetooltip(\'rp'+RoomList[i].id+'\')"  > [每日详细价格]</a> <div id="rp'+RoomList[i].id+'"  class="hprice" >'
                 R_HTML+='</div></li><li class="kd">免费<li class="sjj"><a href="/Order.aspx?id='+RoomList[i].id+'"><img src="/images/book.gif" /></a></li> </ul>';
               }
              
               
               document.getElementById('Hid'+hl).innerHTML=R_HTML;
            }
            break;
        }
    }
}








function GetRoomPrices()
{
var hId="";
try
{
   hId = document.getElementById('hotelid').value;
}
catch(err)
{
  return 
}


createXmlHttpRequest();
xmlHttp.open('GET','/web_serverCode/GetRoomDatePrices.aspx?id='+hId+'&starttime='+GetDateStr(0)+'&deptime='+GetDateStr(2),false);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}



function GetDateStr(AddDayCount)
{
var dd = new Date();
dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
var y = dd.getYear();
var m = dd.getMonth()+1;//获取当前月份的日期
var d = dd.getDate();
return y+"-"+m+"-"+d;
} 









function rcheck()
{
var per = document.getElementById('checkIn');
if(per.value=="")
{
$alert(per,$s2t("请输入入住日期"));
return false;
}
var post = document.getElementById('checkOut');
if(post.value=="")
{
$alert(post,$s2t("请输入离店日期"));
return false;
}
var s1 = new Date(post.value.replace(/-/g, "/"));
if(!post.value.isDateTime())
{
$alert(post,$s2t("离店日期格式不正确"));
return false;
}
var s2 = new Date(per.value.replace(/-/g, "/"));
if(s2 >= s1 )
{
$alert(post,$s2t("离店日期必须大于入住日期"));
return false;
}
var time= s1.getTime() - s2.getTime();
var days = parseInt(time / (1000 * 60 * 60 * 24));
var now = new Date();
if(parseInt((now-s2) / (1000 * 60 * 60 * 24)) > 0)
{
$alert(post,$s2t("入住日期必须大于今日"));
return false;}if(days > 28)
{
alert("如果您需要在酒店入住28天以上，请致电：020－28552299，我们会竭诚为您服务。");
return false;
}
var hId = document.getElementById('hotelid').value;
createXmlHttpRequest();
xmlHttp.open('GET','/web_serverCode/GetRoomDatePrices.aspx?id='+hId+'&starttime='+per.value+'&deptime='+post.value);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}














function $gUrl(){var Url=top.window.location.href;var u,g,StrBack='';if(arguments[arguments.length-1]=="#")u=Url.split("#");else u=Url.split("?");if(u.length==1) g='';else g=u[1];
if(g!=''){ gg=g.split("&"); var MaxI=gg.length; str = arguments[0]+"="; for(i=0;i<MaxI;i++){if(gg[i].indexOf(str)==0){StrBack=gg[i].replace(str,"");break;}}}return StrBack;}


function showtooltip(obj)
{
var ri=document.getElementById(obj);if(isHold!=null){isHold.className="hprice";}isHold=ri;ri.className="price";ri.onclick=function(){ri.className="hprice";}}
function hidetooltip(obj){document.getElementById(obj).className="hprice";}
function nextSibling(obj){var tempObj = obj;do{tempObj = tempObj.nextSibling;}
while(tempObj.nextSibling&&tempObj.nextSibling.nodeType&&(tempObj.nextSibling.nodeType!=1))return tempObj;}
function showRoomDetail(obj){var detailDiv = nextSibling(obj.parentNode.parentNode);detailDiv.style.display = detailDiv.style.display?"":"none";}
function hideRoomDetail(obj){var roomdetail = obj.parentNode.parentNode;roomdetail.style.display = "none";}
function history_show(obj){
var url = "";
if(obj=="read"){ createXmlHttpRequest(); url="/private/ViewHistory.aspx?id=read";}
else url="/private/ViewHistory.aspx?id="+document.getElementById("hotelid").value;
historyXmlHttp.open("GET",url);
historyXmlHttp.onreadystatechange=historycallback;historyXmlHttp.send(null);}
function historycallback(){
if(historyXmlHttp.readyState==4){
if(historyXmlHttp.status==200){
document.getElementById("history").innerHTML=historyXmlHttp.responseText;
}
}
}
