﻿$(document).ready(function(){ResvGetCity("../ResvControl/ResvGetQueryConditon.ashx?Par=CityNprvCd&Time="+ new Date().getMinutes() + "");});
//$(document).ready(function(){GetPingJiaReSult();});

function ResvGetCity(url)
{
    //debugger;
    $.ajax({
               type: "GET",
               url: url,
               dataType:"xml",
               error: function(xml,txt,object){},//alert(xml);
               success: function(data)
               {

                   $('#head02Sel').empty();
                   
                   $(data).find("HtlCityTc").each(
                        function()
                        {                           
                            $('#head02Sel').append("<li><a href=\"#\" onclick=\"return ShowCity('head02','"+$(this).attr('drpt')+"',this,'"+$(this).attr('cd')+"')\" onmouseover=\"drop_mouseover('head');\" onmouseout=\"drop_mouseout('head02');\">"+$(this).attr('drpt')+"</a></li>")
                        }

                   ); 
                 }
             });    

}

function ResvGetHtl(url)
{
    $.ajax({
               type: "GET",
               url: url,
               dataType:"xml",
               error: function(xml,txt,object){},//alert(xml);
               success: function(data)
               {

                   $('#head03Sel').empty();
                   
                   $(data).find("Hotel").each(
                        function()
                        {                           
                            $('#head03Sel').append("<li><a href=\"#\" onclick=\"return ShowHtl('head03','"+$(this).attr('htlcd')+"',this)\" onmouseover=\"drop_mouseover('head');\" onmouseout=\"drop_mouseout('head03');\">"+$(this).attr('htlname')+"</a></li>")

                        }

                   ); 
                 }
             });

}



function ShowCity(pos,searchType,href,cityCd)
{
    document.getElementById("head03Slected").innerHTML="";
    document.getElementById("head03SearchType").value="";
    document.getElementById("head03SearchType").valuecd="";
    
    if(document.getElementById(pos+"SearchType").value.toString().replace(" ","")!=searchType.toString().replace(" ",""))
    {        
        document.getElementById("head02SearchType").value="";
        document.getElementById("head02Slected").innerHTML="- 请选择 -";
       
    }
    document.getElementById(pos+"SearchType").value=cityCd;//searchType;
    document.getElementById(pos+"SearchType").valuecd=cityCd; 
    document.getElementById(pos+"Sel").style.display="none";
    document.getElementById(pos+"Slected").innerHTML=href.innerHTML;
    
    //function(){GetHtl();}
    GetHtl();
    
    try
    {
        window.clearTimeout(timer);
    }
    catch(e)
    {}
    
    return false;
}


/////////////////////////

function SetHtlPara(CityCd)
{
    //debugger;
    ResvGetHtl("../ResvControl/ResvGetQueryConditon.ashx?Par=Htl&Time="+ new Date().getMinutes() + "&QueryPar="+CityCd);
}

function GetHtl()
{
    
    var input=document.getElementById("head02SearchType");
    
    if(input.valuecd!=null)
    {
        var CityCd = input.valuecd;        
        SetHtlPara(CityCd);       
    }
    else
    {
        document.getElementById("head03SearchType").value="";
        document.getElementById("head03Slected").innerHTML="- 请选择城市 -";
    }
          
}


function ShowHtl(pos,searchType,href)
{
    document.getElementById("head03Slected").innerHTML="";
    document.getElementById("head03SearchType").value="";
    document.getElementById("head03SearchType").valuecd="";
    
    if(document.getElementById(pos+"SearchType").value.toString().replace(" ","")!=searchType.toString().replace(" ",""))
    {        
        document.getElementById("head03SearchType").value="";
        document.getElementById("head03Slected").innerHTML="- 请选择 -";
       
    }
    document.getElementById(pos+"SearchType").value=searchType; 
    document.getElementById(pos+"Sel").style.display="none";
    document.getElementById(pos+"Slected").innerHTML=href.innerHTML;
    
    try
    {
        window.clearTimeout(timer);
    }
    catch(e)
    {}
    
    return false;
}


function CheckGvDate(StatDt,EddtDt,ExecBt)
{
    
    var  Stat = document.getElementById(StatDt).value;
    var  Eddt = document.getElementById(EddtDt).value;
    var  reg   = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/; 
    
    var execBt =  document.getElementById(ExecBt);
 

    if(!reg.test(Stat))
    {
        alert("日期格式不正确！");
        return false;
    }
    else
    {
       var arrDt = new Date(Stat.replace('-','/'));
       var dptDt = new Date(Eddt.replace('-','/'));
       
//       var Today = new Date(today.getFullYear()+'/'+(today.getMonth()+1)+'/'+today.getDate());       
//       if (arrDt<Today)
//       {
//           alert("入住日期不能小于今天");
//           return false;
//       }
//       else
//       {
//       }

        if (arrDt>dptDt)
        {
            alert("离期不能小于来期");
            return false;
        }
        else
        {
            if(execBt!=null)
            {
                execBt.click();
            }
            
            return true;
        }
    

       
    }
   
}


function openDiv() 
{     

    var ScreenDiv = document.getElementById("FullScreenDIV");
    var RoomInfoDiv =  document.getElementById("LogInDiv");
                      
    ScreenDiv.style.width =  Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px"; //document.body.scrollWidth;
    ScreenDiv.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";//document.body.scrollHeight;
    ScreenDiv.style.display = "block"; 
    
    RoomInfoDiv.style.left = (Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)/2-205) +"px";//"280px";//((document.body.offsetWidth - RoomInfoDiv.offsetWidth) / 2);
    RoomInfoDiv.style.top =  "250px";//(Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight)/2-90) + "px";//"440px"; //((document.body.offsetHeight - RoomInfoDiv.offsetHeight) / 2);      
    RoomInfoDiv.style.display = "block";
    
    
                        
}
  

function CloseDiv()
{
    var ScreenDiv = document.getElementById("FullScreenDIV");
    var RoomInfoDiv =  document.getElementById("LogInDiv");
    ScreenDiv.style.width = "0px";
    ScreenDiv.style.height = "0px";
    ScreenDiv.style.display = "none";    
    RoomInfoDiv.style.display = "none";
    
    return true;
}

function SubmitCloseDiv()
{
    var UserName = document.getElementById("ctl00_RightContext_ResvQueryUserControl1_tbPBacctnum");
    var PassWord = document.getElementById("ctl00_RightContext_ResvQueryUserControl1_tbPBpwd");
    
    if(UserName.value=="")
    {
        alert("请输入用户名");
        return false;
    }
    else if(PassWord.value=="")
    {
        alert("请输入密码");
        return false;
    }
    else
    {
        var ScreenDiv = document.getElementById("FullScreenDIV");
        var RoomInfoDiv =  document.getElementById("LogInDiv");
        ScreenDiv.style.width = "0px";
        ScreenDiv.style.height = "0px";
        ScreenDiv.style.display = "none";    
        RoomInfoDiv.style.display = "none";
           
        return true;       
    }   
}

function ViewPingJiaCommand(HtlCd)
{
    var height= Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight);
    var width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth);
        
    window.open ("../ResvPage/QuestionnaireView.aspx?htlcd="+ HtlCd, "", "height = "+ height +", width = "+ width +", toolbar =yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes");


}

function MorePicHtlCommand(HtlCd)
{
    var height= Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight);
    var width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth);
        
    window.open ("../ResvPage/HtlPictureInfo.aspx?htlcd="+ HtlCd, "", "height = "+ height +", width = "+ width +", toolbar =yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes");
}

function DetailInfoHtlCommand(HtlCd)
{
    var height= Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight);
    var width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth);

    window.open ("../ResvPage/HtlParticularInfo.aspx?htlcd="+ HtlCd, "", "height = "+ height +", width = "+ width +", toolbar =yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes");
    
}

//setInterval(function(){alert("kkk");},2000); //设定固定时间 循环扫描 执行函数。
//setTimeout(function(){alert("kkk");},2000);  //设定 一定时间后执行一次 以后便不执行

setInterval(
    function()
    {
        //var htlString = $("ctl00_RightContext_ResvQueryUserControl1_HiddHtlString").val();
        var htlString = document.getElementById("ctl00_RightContext_ResvQueryUserControl1_HiddHtlString").value;        
        //alert("w" + htlString);
        
        if(htlString!="")
        {
            //alert("N"+htlString);
            GetPingJiaValue(htlString);
        }
        else
        {            
        
        }
    
    },10000);

function GetPingJiaReSult()
{ 
   
    setTimeout(
        function()
        {
            var htlCd="";
            
            $("span[attributid='HtlPj']").each(
                function()
                {
                    htlCd = htlCd + $(this).attr("htlid")+",";                           
                }   
            );            
 
            GetPingJiaValue(htlCd);            
            
        },1000);               
}

function GetPingJiaValue(htlCd)
{
    var url="../ResvControl/ResvGetQueryConditon.ashx?Par=HtlPj&QueryPar="+ htlCd +"&Time="+ new Date().getMinutes() + ""    
    
    //alert(url);   
        
    $.ajax({
           type: "GET",
           url: url,
           dataType:"xml",
           error: function(xml,txt,object){},//alert(xml);
           success: function(data)
           {  
            
               $(data).find("HtlPingJia").each(
                                
                    function()
                    { 
                        //alert("w"+$(this).attr('HtlCd'));
                        var htl = $(this).attr('HtlCd');
                        var htlPv = $(this).attr('Pvalue');
                         
                        $("span[attributid='HtlPj']").each(
                            function()
                            {                                                                                       
                                if($.trim(htl)==$.trim($(this).attr('htlid')))
                                {
                                    //alert("n"+ $(this).attr("htlid"))                                  
                                    $("span[HtlId='"+ $(this).attr("htlid") +"']").html(htlPv);
                                }                                                          
                            }   
                        );                      
                    }

               ); 
             }
         }); 
                      
}



