﻿// JScript 文件
function setCheckInDate(d)
    {
	    document.getElementById("hdate1").value=d;
	    if(document.getElementById("hdate2").value.length==0)
	    {
		    showCalendar('hdate2',false,'hdate2','hdate1');
	    }
    }
    function SearchSubmitHotel()
		{
		    strHCNName = document.getElementById("HCNName").value;
		    strHAddress = document.getElementById("txtHAddress").value;
		    strStar = "";
		    for(var i=0;i<document.form1.Star.length;i++)
		    {
		        if(document.form1.Star[i].checked)
		        {
		            strStar = strStar + document.form1.Star[i].value + "|"
		        }
		    }
		    strPrice = document.getElementById("Price").value;
		    strPrice1 = document.getElementById("Price1").value;
		    strPrice = strPrice + "-" + strPrice1;
		    strRoomType = "";
		    for(var i=0;i<document.form1.RoomType.length;i++)
		    {
		        if(document.form1.RoomType[i].checked)
		        {
		            strRoomType = document.form1.RoomType[i].value;
		        }
		    }
		    strPdId = "";
		    for(var i=0;i<document.form1.PdId.length;i++)
		    {
		        if(document.form1.PdId[i].checked)
		        {
		            strPdId = document.form1.PdId[i].value;
		        }
		    }
		    strHAId = "";
		    for(var i = 0;i<document.form1.HAId1.options.length;i++)
		    {
		        if(document.form1.HAId1.options[i].selected)
		        {
		            strHAId = document.form1.HAId1.options[i].value;
		        }
		    }
		    if(strHAId == "")
		    {
		         for(var i = 0;i<document.form1.HAId.length;i++)
		        {
		            if(document.form1.HAId[i].checked)
		            {
		                strHAId = document.form1.HAId[i].value;
		            }
		        }
		    }
		    strStartDate = document.getElementById("StartDate").value;
		    if(strStartDate == "")
		    {
		        alert("请选择入住日期");
		        document.getElementById("StartDate").focus();
		        return false;
		    }
		    strEndDate = document.getElementById("EndDate").value;
		    if(strEndDate == "")
		    {
		        alert("请选择离店日期");
		        document.getElementById("EndDate").focus();
		        return false;
		    }
		    strADSL = "";
		    for(var i=0;i<document.form1.ADSL.length;i++)
		    {
		        if(document.form1.ADSL[i].checked)
		        {
		            strADSL = document.form1.ADSL[i].value;
		        }
		    }
		    strHNameType = "CN";
		    if(document.form1.HNameType[1].checked)
		    {
		       strHNameType = "EN";
		    }
		    location.href="/hotel/hotelsearchlist.aspx?HCNName=" + strHCNName + "&Stars=" + strStar + "&Price=" + strPrice + "&RoomType=" + strRoomType + "&PdId=" + strPdId + "&HAId=" + strHAId + "&StartDate=" + strStartDate + "&EndDate=" + strEndDate + "&HIsKuanDai=" +strADSL + "&HAddress=" + strHAddress + "&HNameType=" + strHNameType;
		    
		}
		function HAIdChange()
		{
		    for(var i = 0;i<document.form1.HAId1.options.length;i++)
		    {
		        document.form1.HAId1.options[i].selected = false;
		    }
		}
		function HAId1Change()
		{
		    for(var i = 0;i<document.form1.HAId.length;i++)
		    {
		        document.form1.HAId[i].checked = false;
		    }
		}
		function StarChange(strValue)
		{
		    if(strValue == "0")
		    {
		        for(var i=1;i<document.form1.Star.length;i++)
		        {
		            document.form1.Star[i].checked = false;
		        }
		    }
		    else
		    {
		         for(var i=1;i<document.form1.Star.length;i++)
		         {
		            if(document.form1.Star[i].checked)
		            {
		                document.form1.Star[0].checked = false;
		            }
		         }
		    }
		}
 mainLoop = function()
		{
			val = escape(queryField.value);				
			if (lastVal != val)
			{				
				var response = hotel_hotelsearch.getHAId(val);
				strResultArray = response.value;
				if(strResultArray.length == 1)
				{
				    if(strResultArray[0] == "1")
				    {
				        document.form1.txtHAddress.value = queryField.value;
				        alert("您好！您可以通过酒店地址来查询您所找的酒店");
				        document.form1.HAId1.options.length = 0;
				        document.form1.txtHAddress.focus();
				    }
				    else
				    {
				       if(strResultArray[0] == "0")
				       {
				         
				       } 
				       else
				       {
				            document.form1.HAId1.options.length = 1;
				            aryItem = strResultArray[0].split(",");
				            document.form1.HAId1.options[0].text = aryItem[1];
				            document.form1.HAId1.options[0].value = aryItem[0];
				            document.form1.HAId1.options[0].selected = true;
				       }
				    }
				}
				else
				{
				    document.form1.HAId1.options.length = strResultArray.length;
				    for(var i=0;i<strResultArray.length;i++)
				    {
				        aryItem = strResultArray[i].split(",");
				        document.form1.HAId1.options[i].text = aryItem[1];
				        document.form1.HAId1.options[i].value = aryItem[0];
				    }
				    document.form1.HAId1.options[0].selected = true;
				}
				lastVal = val;
			}				
			setTimeout('mainLoop()', 5);
			return true;
		}