﻿var xmlHttp,historyXmlHttp;
var isHold;

var isfullroom123;
var isfullroomx;

function createXmlHttpRequest()
{
      if(window.ActiveXObject)
      {
      xmlHttp = new ActiveXObject("microsoft.XMLHttp");
      historyXmlHttp = new ActiveXObject("microsoft.XMLHttp");
      }
      else
      {
      xmlHttp = new XMLHttpRequest();historyXmlHttp= new XMLHttpRequest();
      }
 }
 
 function ycallback()
{
    switch(xmlHttp.readyState)
    {
        case 4:
        {
        document.getElementById("yfdiv").style.display="none";
        document.getElementById("divtip").style.display="";
for(var i=0;i<1000;i++)
{

}

            if(xmlHttp.status==200)
            {
            var rlist=eval(document.getElementById("allRoom2").value);
            var rprice=eval(xmlHttp.responseText);
                for(var i=0;i<rlist.length;i++)
                {
                document.getElementById("yfp"+rlist[i]).innerHTML=rprice[i][0];
                document.getElementById("yrp"+rlist[i]).innerHTML=rprice[i][1];
                }  
        document.getElementById("yfdiv").style.display="";
        document.getElementById("divtip").style.display="none";    
            }
        break;
        }
    }
}
 
 
 
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"+rlist[i]).innerHTML=rprice[i][0];
                document.getElementById("rp"+rlist[i]).innerHTML=rprice[i][1];


         if (rprice[i][2]=='True')
                {
                  document.getElementById("yd"+rlist[i]).innerHTML="<a title='部分日期已满房,可修改日期重新预订' style=\"cursor:not-allowed\"><img src=\"/images/Full.gif\"/></a>";
                }
       else
                {
                 document.getElementById("yd"+rlist[i]).innerHTML="<a  href=\"/order.aspx?id=" +rlist[i] + "\"><img src=\"/images/ding.gif\"/></a>";
                
                }


                }
            }
       break;
    
        }
    }
}
function getRoomInfo()
{
createXmlHttpRequest();
var hId = document.getElementById('hotelid').value;
var url='/private/RoomPrices.aspx?id='+hId;
var st=$gUrl("starttime");
var dt=$gUrl("deptime");

    if(st!='')
    {
     url+='&starttime='+st;
    }
    
    if(dt!='')
    {
     url+='&deptime='+dt;
    }
xmlHttp.open('GET',url);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}



function yrcheck()
{



var per;

try 
{

  per = document.getElementById('checkIn2');
  per.value==""
} 
catch (e)
{
 return ;
}







    if(per.value=="")
    {
      $alert(per,$s2t("请输入入住日期"));
      return false;
    }
    
    
    
    
var post = document.getElementById('checkOut2');
    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','/private/YRoomPrices.aspx?id='+hId+'&starttime='+per.value+'&deptime='+post.value,false);
xmlHttp.onreadystatechange = ycallback;
xmlHttp.send(null);
}




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','/private/RoomPrices.aspx?id='+hId+'&starttime='+per.value+'&deptime='+post.value);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}

function GetRoominfo()
 {

var hId = document.getElementById('hotelid').value;
createXmlHttpRequest();

xmlHttp.open('GET','/private/GetHotelRoominfo.aspx?Hid='+hId,false);
xmlHttp.onreadystatechange = callback2;
xmlHttp.send(null);

 }
 
function callback2()
{
    switch(xmlHttp.readyState)
    {
        case 4:
        {
            if(xmlHttp.status==200)
            {
                document.getElementById('nspp').innerHTML=xmlHttp.responseText;
            
            }
         }
     }
 }
  








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 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
    {
     createXmlHttpRequest();
     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;
        }
    }
}



var cityXmlHttp;
function createCityXmlHttpRequest()
{
    if(window.ActiveXObject)
    {
    cityXmlHttp = new ActiveXObject("microsoft.XMLHttp");
    }
    else
    { cityXmlHttp = new XMLHttpRequest();
    }
}
function getCityHotelPriceList()
{
    createCityXmlHttpRequest();
    var hl=$ge("hotellist").value;var url="/private/RoomPriceList.aspx?hl="+hl;
    if($ge("checkIn").value!=""&&$ge("checkOut").value!="")
   {
    url+="&starttime="+$ge("checkIn").value+"&deptime="+$ge("checkOut").value;
   }
    cityXmlHttp.open("GET",url);
    
    
    cityXmlHttp.onreadystatechange=cityHotelPriceCallBack;
    cityXmlHttp.send(null);
}



function cityHotelPriceCallBack(){
    if(cityXmlHttp.readyState==4)if(cityXmlHttp.status==200){
        var hlp=eval(cityXmlHttp.responseText);
        for(var i=0;i<hlp.length;i++){
             for(var j=0;j<hlp[i].length;j++){
            $ge(hlp[i][j][0]).innerHTML=hlp[i][j][1];
            
        }
            
        }
    }
}





//核心对象变量
var xmlHttpR;
//区分浏览器创建XMLHttpRequest核心对象
function create(){
	if(window.XMLHttpRequset){
		xmlHttpR = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xmlHttpR = new ActiveXObject("Microsoft.XMLHTTP");
	}
}


  function  returnfun(room_id)
  {   
var per = document.getElementById('checkIn2');

    if(per.value=="")
    {
      $alert(per,$s2t("请输入入住日期"));
      return false;
    }
    
    
    
    
var post = document.getElementById('checkOut2');
    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 url="starttime="+per.value+"&deptime="+post.value+"&id="+room_id;
  create();
xmlHttpR.open("GET","/private/StateYRoomPrice.aspx?"+url,false);

xmlHttpR.onreadystatechange=StatechangeDateCallback;

xmlHttpR.send(null);

if (isfullroom123=="Full")
{
 return false;
}
else
{
return true;
}









}


function StatechangeDateCallback()
{
       if(xmlHttpR.readyState == 4)
        {
              if(xmlHttpR.status==200)
             {
             
             
           var  bbool = xmlHttpR.responseText;
           
                isfullroom123=bbool;
                if (bbool=='Full')
                {
                  alert('很抱歉,您选择的房型存在满房，请重新选择时间');
                 
                }
              
             }
     
          }
        
    }
    
    






function xreturnfun(id)
{
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;
    }


createXmlHttpRequest();
xmlHttp.open('GET','/private/StateRoomPrice.aspx?Id='+id+'&starttime='+per.value+'&deptime='+post.value,false);
xmlHttp.onreadystatechange = xStatechangeDateCallback;
xmlHttp.send(null);


if (isfullroomx=="Full")
{
 return false;
}
else
{
return true;
}





}

function xStatechangeDateCallback()
{
       if(xmlHttp.readyState == 4)
        {
              if(xmlHttp.status==200)
             {
             
             
           var  bbool = xmlHttp.responseText;
           
                isfullroomx=bbool;
                
                if (bbool=='Full')
                {
                  alert('很抱歉,您选择的房型存在满房，请重新选择时间');
                 
                }
              
             }
     
          }
        
    }
    
