﻿function HotelClass()
{
}
var timestatefoucs=false;
var framestatefocus=false;
HotelClass.prototype.$ = function(str){return document.getElementById(str);}
HotelClass.prototype.$$ = function(str){return document.getElementsByName(str);}
var HotelCs = new HotelClass();
HotelClass.prototype.SetSelectListInfo = function(selectid,arrays,parentstr,def)
{
    var sele = HotelCs.$(selectid);

    sele.options.length=0
   var ooo=document.createElement('OPTION'); 
    ooo.text="-----"+def+"-----"; 
    ooo.value="";
    sele.options.add(ooo);
    var hotelcitycodeletter = HotelCs.$(parentstr).value;
	if(hotelcitycodeletter!="")
	{
		for(var i=0;i<arrays.length;i++)
		{
			if(arrays[i][1]==hotelcitycodeletter)
			{
				var oo=document.createElement('OPTION'); 
				oo.text=arrays[i][0]; 
				oo.value=arrays[i][2];
				sele.options.add(oo);
			}
		}
	}
	
}
HotelClass.prototype.GoSearchHotel_Page = function()
{
    this.$("hotelkeyword").value=this.$("hotelkeywords").value;
    this.$("hotelcitycodeletter").value=this.$("hotelcitycodeletters").value;
    this.$("Landmarks").value=this.$("Landmarkss").value;
    this.$("locations").value=this.$("locationss").value;
    this.$("hotelsave").value=this.$("hotelsaves").value;
    this.$("hotelout").value=this.$("hotelouts").value;
    this.$("hotelprice").value=this.$("hotelprices").value;
    this.$("hotelStartClass").value=this.$("hotelStartClasss").value;  
    this.$("gosearch").submit();
}
HotelClass.prototype.SelectTravelCityCode = function(str,ct,fr,code,codehidden)
{
	var box = window.parent.document.getElementById(ct);
	box.value=str;
	var hotelcitycodeletter = window.parent.document.getElementById(codehidden);
	hotelcitycodeletter.value=code;
	if(window.parent.document.getElementById("Landmarks")!=null)
	{
	HotelCs.ChdSetSelectListInfo('Landmarks',window.parent.CityLandArray,'hotelcitycodeletter','地标');
	HotelCs.ChdSetSelectListInfo('Locatios',window.parent.CityAreaArray,'hotelcitycodeletter','行政区');
	}
	var frame=window.parent.document.getElementById(fr);
	frame.style.display="none";
}
HotelClass.prototype.ChdSetSelectListInfo = function(selectid,arrays,parentstr,def)
{
    var sele = window.parent.document.getElementById(selectid);

    sele.options.length=0
     var ooo=document.createElement('OPTION'); 
    ooo.text="-----"+def+"-----"; 
    ooo.value="";
    sele.options.add(ooo);
    var hotelcitycodeletter = window.parent.document.getElementById(parentstr).value;
    for(var i=0;i<arrays.length;i++)
    {
        if(arrays[i][1]==hotelcitycodeletter)
        {
            var oo=document.createElement('OPTION'); 
            oo.text=arrays[i][0]; 
            oo.value=arrays[i][2];
            sele.options.add(oo);
        }
    }
}
HotelClass.prototype.ShowTravelCityFrame = function(frame,box,valuehidden)
{
    var tcf=document.getElementById(frame);
   
    var twcf = eval("window.frames."+frame);
    twcf.firstvalue="";
 	twcf.b="";
 	twcf.citycode="";
	tcf.onmouseover=function()
	{framestatefocus=true;} 
	tcf.onmouseout=function()
	{framestatefocus=false;} 
	this.SetOjbectWay(box,frame,100);
	tcf.style.display="block";
	framestatefocus=false;
}
HotelClass.prototype.ShowTravelCityFrame = function(frame,box,valuehidden)
{
    var tcf=document.getElementById(frame);
   
    var twcf = eval("window.frames."+frame);
    twcf.firstvalue="";
 	twcf.b="";
 	twcf.citycode="";
	tcf.onmouseover=function()
	{framestatefocus=true;} 
	tcf.onmouseout=function()
	{framestatefocus=false;} 
	this.SetOjbectWay(box,frame,100);
	tcf.style.display="block";
	framestatefocus=false;
}
HotelClass.prototype.SetOjbectWay = function(a,b,widths)
{
    var cf = this.$(b);
    var eT=0,eL=0,p=this.$(a);
    var sT=document.body.scrollTop,sL=document.body.scrollLeft;
    var eH=this.$(a).clientHeight,eW=this.$(a).clientWidth;
    while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
 
    cf.style.top=eT+eH+2+"px";
	cf.style.left=((document.body.clientWidth-(eL-sL)>=widths)?eL:eL+eW-widths)+"px";
}
HotelClass.prototype.HiddenHotelCityFrame = function()
{
    var cf = document.getElementById("HotelCitysFrame");
    var twcf=window.frames.HotelCitysFrame;
	if(cf!=null)
	if(!framestatefocus)
	{
	    this.$("hotelcity").value=twcf.firstvalue;
	    this.$("hotelcitycodeletter").value=twcf.citycode;
	    try{
	    HotelCs.SetSelectListInfo('Landmarks',CityLandArray,'hotelcitycodeletter','地标');HotelCs.SetSelectListInfo('Locatios',CityAreaArray,'hotelcitycodeletter','行政区');
	 } catch(err)
	 {}  
		cf.style.display="none";
     }
}
HotelClass.prototype.SetFrameDefaultValue = function(box)
{
    var boxs = document.getElementById(box);
    var tcf=document.getElementById('HotelCitysFrame');
    var twcf=window.frames.HotelCitysFrame;
    twcf.b=boxs.value;
    twcf.SetListInfo();
    
}
HotelClass.prototype.HotelSpecialCitySelectIndex = function(indexnum,count,pagetype,citycode)
{
    for(var i=0;i<count;i++)
    {
        var li = this.$("hotelcitycodeid"+i);
         if(i==indexnum)
        {
           li.className="flight_special_cityhead_cityli_select";
        }else{
            li.className="flight_special_cityhead_cityli_noselect";
         }
    }
    var loddiv = "<div class=\"spacelinfo_load_wait\">正在加载数据....</div>";
    this.$("hotel_special_list_info").innerHTML = loddiv;
    var FlightAjax = new AjaxPro("hotel_special_list_info");
    FlightAjax.Get("/hotel/LoadIndexHotelSpecialNum.aspx?citycode="+citycode+"&pagetype="+pagetype+"&rands="+Math.floor(Math.random()*100000+1));
}
HotelClass.prototype.HotelIndexSpecialCityList = function(pagetype)
{
    if(HotelSpecialCity.length>0)
    {
        var flightspecialcity = this.$("hotelspecialcity");
        var flightspecialcityli="";
        var citycount = HotelSpecialCity.length;
        for(var i=0;i<HotelSpecialCity.length;i++)
        {
            if(i==0)
            {
                flightspecialcityli+=" <div class=\"flight_special_cityhead_cityli_select\" id=\"hotelcitycodeid"+i+"\" onclick=\"HotelCs.HotelSpecialCitySelectIndex("+i+","+citycount+","+pagetype+",'"+HotelSpecialCity[i][0]+"');\">"+HotelSpecialCity[i][1]+"</div>";
             }else{
                flightspecialcityli+="<div class=\"flight_special_cityhead_cityli_noselect\" id=\"hotelcitycodeid"+i+"\" onclick=\"HotelCs.HotelSpecialCitySelectIndex("+i+","+citycount+","+pagetype+",'"+HotelSpecialCity[i][0]+"');\">"+HotelSpecialCity[i][1]+"</div>";
            }
        }
        flightspecialcity.innerHTML=flightspecialcityli;
    }
}

HotelClass.prototype.HotelPageSpecialCityList = function(pagetype)
{
    if(HotelSpecialCity.length>0)
    {
        var flightspecialcity = this.$("hotelspecialcity");
        var flightspecialcityli="";
        var citycount = HotelSpecialCity.length;
        for(var i=0;i<HotelSpecialCity.length;i++)
        {
            if(i==0)
            {
                flightspecialcityli+=" <li class=\"hotel_page_special_city_select\" id=\"hotelcitycodeid"+i+"\" onclick=\"HotelCs.HotelPageSpecialCitySelectIndex("+i+","+citycount+","+pagetype+",'"+HotelSpecialCity[i][0]+"');\">"+HotelSpecialCity[i][1]+"</li>";
             }else{
                flightspecialcityli+="<li class=\"hotel_page_special_city_noselect\" id=\"hotelcitycodeid"+i+"\" onclick=\"HotelCs.HotelPageSpecialCitySelectIndex("+i+","+citycount+","+pagetype+",'"+HotelSpecialCity[i][0]+"');\">"+HotelSpecialCity[i][1]+"</li>";
            }
        }
        flightspecialcity.innerHTML="<ul>"+flightspecialcityli+"</ul>";
    }
}
HotelClass.prototype.HotelPageSpecialCitySelectIndex = function(indexnum,count,pagetype,citycode)
{
    for(var i=0;i<count;i++)
    {
        var li = this.$("hotelcitycodeid"+i);
         if(i==indexnum)
        {
           li.className="hotel_page_special_city_select";
        }else{
            li.className="hotel_page_special_city_noselect";
         }
    }
    var loddiv = "<div class=\"spacelinfo_load_wait\">正在加载数据....</div>";
    this.$("hotel_special_list_info").innerHTML = loddiv;
    var FlightAjax = new AjaxPro("hotel_special_list_info");
    FlightAjax.Get("/hotel/LoadHotelPageSpecialList.aspx?citycode="+citycode+"&pagetype="+pagetype+"&rands="+Math.floor(Math.random()*100000+1));
}
HotelClass.prototype.GoSearchHotel = function()
{
    var hotelcitycodeletter = this.$("hotelcitycodeletter");
    if(hotelcitycodeletter.value=="")
    {
        alert("请选择目的城市!");
        this.$("hotelcity").focus();
        return false;
    }
    var checkdate =/^[0-9]{4}[-][0-9]{1,2}[-][0-9]{1,2}$/;
    if(!checkdate.exec(this.$("HotelstartDate").value))
    {
        alert("请选择入住日期");
        this.$("HotelstartDate").focus();
        return false;
    }
    if(!checkdate.exec(this.$("HotelreturnDate").value))
    {
        alert("请选择离店日期");
        this.$("HotelreturnDate").focus();
        return false;
    }
    
//    var liveouttime = this.$("HotelreturnDate").value;
//     var arr1=liveouttime.split("-");   
//     var outdate = new Date(arr1[0],arr1[1],arr1[2]);
//     
//      var liveintime = this.$("HotelstartDate").value;
//      var inarr1=liveintime.split("-");   
//     var indate = new Date(inarr1[0],inarr1[1],inarr1[2]);
//     
//     var DateLong = (parseInt((outdate - indate)  /  1000  /  60  /  60  /24));
//  
//     if(DateLong>29)
//     {
//        alert("入住日期与离店日期不能超过28天!");
//        return false;
//     }
//    if(DateLong<=0)
//     {
//        alert("入住日期不能超过或等于离店日期!");
//        return false;
//     }
  
    var hname = this.$("hotelname");
        
    var Landmarks = this.$("Landmarks");
    var Locatios = this.$("Locatios");
     

    var hotelprice = "";
    if(this.$("hotelprice")!=null)
    {
        hotelprice =this.$("hotelprice").value;
    }
    var hotelStartClass = this.$("hotelstar");
     
    var Locatiosinfo="";
    if(Locatios!=null)
    {
        Locatiosinfo=Locatios.value;
    }
    var Landmarksinfo="";
    if(Landmarks!=null)
    {
        Landmarksinfo=Landmarks.value;
    }
    
     
     window.location ="/hotel/hotelsearch.aspx?hotelkeyword=" + hname.value + "&hotelcitycodeletter=" + hotelcitycodeletter.value + "&Landmarks=" + Landmarksinfo + "&locations=" + Locatiosinfo + "&hotelsave=" + this.$("HotelstartDate").value + "&hotelout=" + this.$("HotelreturnDate").value + "&hotelprice=" + hotelprice + "&hotelStartClass=" + hotelStartClass.value;
}
HotelClass.prototype.SetSearchHotelInfoBaseUri = function(cityid,cityname,fromdate,todate)
{
 this.$("hotelcitycodeletter").value = cityid;
     this.$("HotelstartDate").value = fromdate;
   this.$("HotelreturnDate").value = todate;
   this.$("hotelcity").value=cityname;
}

HotelClass.prototype.ShowHotelInfoDatePrice = function(f,e,a)
{
    var datepriceinfos=this.$("datepriceinfos");
    var widths=160;
    var eT=0,eL=0,p=this.$(a);
    var sT=document.body.scrollTop,sL=document.body.scrollLeft;
    var eH=this.$(a).clientHeight,eW=this.$(a).clientWidth;
    while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
    datepriceinfos.style.top=eT+eH+"px";
	datepriceinfos.style.left=((document.body.clientWidth-(eL-sL)>=widths)?eL:eL+eW-widths)-220+"px";
    if(f==0)
    {
            datepriceinfos.style.display="block";
            var DateListInfos="";
            var dateitem = e.split('|');
            var table="<div class=\"hotel_datepriceli\"><div class=\"hotel_datepriceli_head\"></div><div class=\"hotel_datepriceli_center\"><div class=\"hotel_datepriceli_center_main\"><div class=\"hotel_datepriceli_center_dayli\"><div class=\"hotel_datepriceli_center_weeks_count\"></div><div class=\"hotel_datepriceli_center_weeks_info\">周一</div><div class=\"hotel_datepriceli_center_weeks_info\">周二</div><div class=\"hotel_datepriceli_center_weeks_info\">周三</div><div class=\"hotel_datepriceli_center_weeks_info\">周四</div><div class=\"hotel_datepriceli_center_weeks_info\">周五</div><div class=\"hotel_datepriceli_center_weeks_info\">周六</div><div class=\"hotel_datepriceli_center_weeks_info\">周日</div></div>";
            
            var endtable="</div></div><div class=\"hotel_datepriceli_end\"></div></div>";
            var tditem="";
            var tds="";
            var nm=1;
            for(var i=1;i<dateitem.length;i++)
            {
               var infoitem = dateitem[i].split('^');
               var from = infoitem[0];
               var oneprice =infoitem[1];
                
               if(infoitem[2]=="0")
               { 
                    tditem+="<div class=\"hotel_datepriceli_center_dayinfo\"><span class=\"hotel_search_info_dateprice_li_price_span\">"+oneprice+"</span><br />"+infoitem[3]+"</div>";
               }else{
                    tditem+="<div class=\"hotel_datepriceli_center_dayinfo\"><span class=\"hotel_search_info_dateprice_li_price_span\">"+oneprice+"-"+infoitem[2]+"</span><br />"+infoitem[3]+"</div>";
               }
               if(i%7==0)
               {
                    tds+="<div class=\"hotel_datepriceli_center_dayli\"><div class=\"hotel_datepriceli_center_weeks_count\" style=\"line-height:40px;\">第&nbsp;"+nm+"&nbsp;周</div>"+tditem+"</div>";
                    tditem="";
                    nm++;
               }
                
            }
            DateListInfos = table+tds+endtable;
            datepriceinfos.innerHTML = DateListInfos;
       }else{
            datepriceinfos.style.display="none";
       }
}
HotelClass.prototype.ShowHotelInfoRoomdesc = function(v,id,s)
{
    var datepriceinfos=this.$("datepriceinfos2");
    var widths=290;
    var eT=0,eL=0,p=this.$(id);
    var sT=document.body.scrollTop,sL=document.body.scrollLeft;
    var eH=this.$(id).clientHeight,eW=this.$(id).clientWidth;
    while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
    datepriceinfos.style.top=eT+eH+"px";
    datepriceinfos.style.left=((document.body.clientWidth-(eL-sL)>=widths)?eL:eL+eW-widths)+"px";
    if(v==0)
    {
        datepriceinfos.style.display="block";
        var DateListInfos="";
        if(s=="")s="暂无介绍";
        var table="<div class=\"hotel_infoalt_li\"><div class=\"hotel_infoalt_li_head\"></div><div class=\"hotel_infoalt_li_center\"><div class=\"hotel_infoalt_li_center_main\">"+s;
            
            var endtable="</div></div><div class=\"hotel_infoalt_li_end\"></div></div>";
           
            DateListInfos = table+endtable;
            datepriceinfos.innerHTML = DateListInfos;
    }else{
        datepriceinfos.style.display="none";
    }
}
HotelClass.prototype.ShowModifyHotelInfoRoomDatedesc = function(id)
{
    var datepriceinfos=this.$("datepriceinfos3");
    var widths=290;
    var eT=0,eL=0,p=this.$(id);
    var sT=document.body.scrollTop,sL=document.body.scrollLeft;
    var eH=this.$(id).clientHeight,eW=this.$(id).clientWidth;
    while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
    datepriceinfos.style.top=eT+eH+"px";
    datepriceinfos.style.left=((document.body.clientWidth-(eL-sL)>=widths)?eL:eL+eW-widths)+"px";
    
    datepriceinfos.style.display="block";
    
}
HotelClass.prototype.CloseModifyHotelInfoRoomDatedesc = function()
{
    var datepriceinfos=this.$("datepriceinfos3");
    datepriceinfos.style.display="none";
}
HotelClass.prototype.GoHotelBuyPage = function(hotelid,roomid,fromdate,todate,str,md)
{
    this.$("hotelid").value=hotelid;
    this.$("roomid").value=roomid;
    this.$("start").value=fromdate;
    this.$("end").value=todate;
    this.$("dayprice").value=str;
    this.$("md").value=md;
    this.$("gobuy").submit();
}
HotelClass.prototype.GoHotelBuyPageChangeDate = function()
{
    this.$("hotelid").value=this.$("HotelPId").value;
    this.$("roomid").value=this.$("RoomPId").value;
    this.$("start").value=this.$("hotelstartdates").value;
    this.$("end").value=this.$("hotelenddate").value;
    
    var liveouttime = this.$("hotelenddate").value;
     var arr1=liveouttime.split("-");   
     var outdate = new Date(arr1[0],arr1[1],arr1[2]);
     
      var liveintime = this.$("hotelstartdates").value;
      var inarr1=liveintime.split("-");   
     var indate = new Date(inarr1[0],inarr1[1],inarr1[2]);
     
     var DateLong = (parseInt((outdate - indate)  /  1000  /  60  /  60  /24));
  
     if(DateLong>29)
     {
        alert("入住日期与离店日期不能超过28天!");
        return false;
     }
    if(DateLong<=0)
     {
        alert("入住日期不能超过或等于离店日期!");
        return false;
     }
    this.$("dayprice").value=this.$("DayPrices").value;
    this.$("md").value=this.$("Mds").value;
    this.$("gobuyform").submit();
}
HotelClass.prototype.LoadHotelInfoDatePrice = function()
{
var datepriceinfos=this.$("datepriceinfos");
    var DatePrices = this.$("DayPrices").value;
    var table="<div class=\"Hotel_buy_dateprice_li\">";
        table+="<div class=\"Hotel_buy_dateprice_li_head\">";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\"></div>";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\">周一</div>";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\">周二</div>";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\">周三</div>";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\">周四</div>";
        table+=" <div class=\"Hotel_buy_dateprice_li_weekhead\">周五</div>";
        table+="<div class=\"Hotel_buy_dateprice_li_weekhead\">周六</div>";
        table+=" <div class=\"Hotel_buy_dateprice_li_weekhead\">周日</div>";
        table+=" </div>";
        table+="";
     var DateListInfos="";
     var dateitem = DatePrices.split('|');
     var endtable="</div>";
     var tditem="";
     var TdValue="";
     var nm=1;
     
     for(var i=1;i<dateitem.length;i++)
     {
       var infoitem = dateitem[i].split('^');
       var from = infoitem[0];
       if(infoitem[2]=="0")
       {
            tditem+="<div class=\"Hotel_buy_dateprice_li_weekhead\">"+infoitem[1]+"<br />"+infoitem[3]+"</div>";
       }else{
            tditem+="<div class=\"Hotel_buy_dateprice_li_weekhead\">"+infoitem[1]+"-"+infoitem[2]+"<br />"+infoitem[3]+"</div>";
       }
       if(i%7==0)
       {
            TdValue+="<div class=\"Hotel_buy_dateprice_li_info\"><div class=\"Hotel_buy_dateprice_li_info_left\">第&nbsp;"+nm+"&nbsp;周</div><div class=\"Hotel_buy_dateprice_li_info_right\">"+tditem+"</div></div>";
            nm++;
            tditem="";
       }
     }
      DateListInfos = table+TdValue+endtable;
     datepriceinfos.innerHTML = DateListInfos;
}
HotelClass.prototype.AddHotelBuyRoom = function()
{
    var RoomCount=this.$("RoomCount");
    var rommlist = this.$("rommlist");
   
    var RoomCountvalue=parseInt(RoomCount.value)+1;
    var roomendcount=this.$("roomendcount");
    var oneprices = this.$("oneprices").value;
    var sumprices = this.$("sumprices");
    if(RoomCountvalue>10)
    {
        alert("一个订单最多添加10间房间!");
    }else{
    var html="<div class=\"hotel_buy_addroom_passenger\" id=\"roompassengerlist"+RoomCountvalue+"\">";
        html+="<div class=\"hotel_buy_addroom_passenger_roomindex\">房间<span id=\"cont"+RoomCountvalue+"\">"+RoomCountvalue+"</span></div>";
        html+="<div class=\"hotel_buy_addroom_passenger_str\">";
        html+="入住人姓名1：<span class=\"hotel_buy_in_godatetime_redstar\">*</span></div>";
        html+="<div class=\"hotel_buy_addroom_passenger_control\">";
        html+="<input id=\"passegner1"+RoomCountvalue+"\" maxlength=\"30\" name=\"passegner1\" type=\"text\" class=\"hotel_buy_in_passenger_textbox\"/>";
        html+="</div>";
        html+="<div class=\"hotel_buy_addroom_passenger_str\">入住人姓名2：</div>";
        html+="<div class=\"hotel_buy_addroom_passenger_control\">";
        html+="<input id=\"passegner2"+RoomCountvalue+"\" maxlength=\"30\" name=\"passegner2\" type=\"text\" class=\"hotel_buy_in_passenger_textbox\"/></div>";
        html+="<div class=\"hotel_buy_addroom_removebnt\" id=\"remove"+RoomCountvalue+"\" onclick=\"HotelCs.RemoveHotelBuyRoom(this)\"></div>";
        html+="</div>";
   
    RoomCount.value=RoomCountvalue;
    roomendcount.innerHTML = RoomCountvalue;
    sumprices.innerHTML=(RoomCountvalue*oneprices);
    rommlist.innerHTML += html;
   }
}
HotelClass.prototype.RemoveHotelBuyRoom = function(e)
{
    var RoomCount=this.$("RoomCount");
    var RoomCountvalue=parseInt(RoomCount.value);
    var id=parseInt(e.id.replace("remove",""));
    var roomendcount=this.$("roomendcount");
    var oneprices = this.$("oneprices").value;
    var sumprices = this.$("sumprices");
    if(RoomCountvalue>1)
    {
        var div=this.$("roompassengerlist"+id);   
        this.$("rommlist").removeChild(div);
        for(var i=1;i<=RoomCountvalue;i++)
        {
            if(i<id)
            {
                var remove = this.$("remove"+i);
                remove.id="remove"+i;
                var ldiv = this.$("roompassengerlist"+i);
                ldiv.id="roompassengerlist"+i;
                var contdiv = this.$("cont"+i);
                contdiv.innerHTML=i;
                contdiv.id="cont"+i;
                var passegner1 =this.$("passegner1"+i);
                passegner1.id="passegner1"+i;
                var passegner2 = this.$("passegner2"+i);
                passegner2.id="passegner2"+i;                
            }
            if(i>id)
            {
                var idindex=(i-1);
                var remove = this.$("remove"+i);
                remove.id="remove"+idindex;
                var ldiv = this.$("roompassengerlist"+i);
                ldiv.id="roompassengerlist"+idindex;
                var contdiv = this.$("cont"+i);
                contdiv.innerHTML=idindex;
                contdiv.id="cont"+idindex;
                var passegner1 = this.$("passegner1"+i);
                passegner1.id="passegner1"+idindex;
                var passegner2 = this.$("passegner2"+i);
                passegner2.id="passegner2"+idindex;  
            }
        }
        roomendcount.innerHTML = (RoomCountvalue-1);
        sumprices.innerHTML=((RoomCountvalue-1)*oneprices);
        RoomCount.value=(RoomCountvalue-1);
    }
    
}
HotelClass.prototype.ChangeLivedate = function()
{
     var livestarttime = this.$("livestarttime").value+":00";
     var GoInDate = this.$("GoInDate").value;
     var arr=livestarttime.split(" ");   
     var arr1=arr[0].split("-");   
     var arr2=arr[1].split(":"); 
     var date = new Date(arr1[0],arr1[1],arr1[2],arr2[0],arr2[1],arr2[2]);
     var hour = date.getHours()+3;
     var seconds = date.getMinutes();
     var hoursum = hour+3;
     if(hoursum>24)hoursum=24;
     var liveendtime = this.$("liveendtime");
     liveendtime.options.length=0
     var ooo=document.createElement('OPTION'); 
     ooo.text="请选择"; 
     ooo.value="";
     liveendtime.options.add(ooo);
     for(var i=hour;i<hoursum;i++)
     {
		
		if(seconds==30)
		{
		var oo=document.createElement('OPTION'); 
		    var hourstr=""+i;
		    if(i.length==1)hourstr="0"+i;
		    oo.text=GoInDate+" "+hourstr+":30"; 
		    oo.value=GoInDate+" "+hourstr+":30"; 
		    liveendtime.options.add(oo);
		    var oo2=document.createElement('OPTION'); 
		    var hor=i+1;
		    if(hor<24)
		    {
		   
		     if(hor.length==1)hor="0"+i;
		      oo2.text=GoInDate+" "+hor+":00"; 
		    oo2.value=GoInDate+" "+hor+":00"; 
		    liveendtime.options.add(oo2);
		    }
     
		}else{
		var oo=document.createElement('OPTION'); 
		var oo2=document.createElement('OPTION'); 
		var hourstr=""+i;
		if(i.length==1)hourstr="0"+i;
		oo2.text=GoInDate+" "+hourstr+":00"; 
		oo2.value=GoInDate+" "+hourstr+":00"; 
		liveendtime.options.add(oo2);
		
		oo.text=GoInDate+" "+hourstr+":30"; 
		oo.value=GoInDate+" "+hourstr+":30"; 
		liveendtime.options.add(oo);
		}
     }
}
HotelClass.prototype.SendBuyHotel = function()
{
//     var liveouttime = this.$("GoOutDate").value;
//     var arr1=liveouttime.split("-");   
//     var outdate = new Date(arr1[0],arr1[1],arr1[2]);
//     
//      var liveintime = this.$("GoInDate").value;
//      var inarr1=liveintime.split("-");   
//     var indate = new Date(inarr1[0],inarr1[1],inarr1[2]);
//     
//     var DateLong = (parseInt((outdate - indate)  /  1000  /  60  /  60  /24));
//  
//     if(DateLong>29)
//     {
//        alert("入住日期与离店日期不能超过28天!");
//        return false;
//     }
//    if(DateLong<=0)
//     {
//        alert("入住日期不能超过或等于离店日期!");
//        return false;
//     }
    
    var SendUri="";
    var RoomCount=this.$("RoomCount");
    var RoomCountvalue = parseInt(RoomCount.value);
    
    if(RoomCountvalue<1)
    {
        alert("房间数不能小于1间！");
        return false;
    }
    if(RoomCountvalue>10)
    {
        alert("房间数不能大于10间！");
        return false;
    }
    
    var LiveMember="|";
    for(var i=1;i<=RoomCountvalue;i++)
    {
        var passegner1 =this.$("passegner1"+i);
        if(passegner1.value=="")
        {
            alert("第"+i+"间房入住人姓名不能为空！");
            passegner1.focus();
            return false;
        }
        LiveMember+=passegner1.value+"#"+this.$("passegner2"+i).value+"|";
    }
   
    var livestarttime = this.$("livestarttime");
    
    var liveendtime = this.$("liveendtime");
    if(liveendtime.value=="")
    {
        alert("请选择最晚到达时间！");
        return false;
    }
    
    var TouchNameTxt = this.$("TouchNameTxt");
    if(TouchNameTxt.value=="")
    {
        alert("请输入联系人姓名！");
        TouchNameTxt.focus();
        return false;
    }
    var TouchMobile = this.$("TouchMobile");
    if(TouchMobile.value=="")
    {
        alert("请输入联系人手机号！");
        return false;
    }
    var noSmoke = 0;
    var bigBed=0;
    if(this.$("noSmoke").checked) noSmoke=1;
    if(this.$("bigBed").checked) bigBed=1;
    SendUri="RoomCount="+RoomCountvalue;
    SendUri+="&LiveMember="+LiveMember;
    SendUri+="&livestarttime="+livestarttime.value+"&liveendtime="+liveendtime.value;
    SendUri+="&TouchNameTxt="+TouchNameTxt.value+"&TouchMobile="+TouchMobile.value+"&TouchTel="+this.$("TouchTel").value+"&TouchMail="+this.$("TouchMail").value;
    
    SendUri+="&HotelPId="+this.$("HotelPId").value+"&RoomPId="+this.$("RoomPId").value+"&Mds="+this.$("Mds").value+"&Mds2="+this.$("Mds2").value;
    SendUri+="&GoInDate="+this.$("GoInDate").value+"&GoOutDate="+this.$("GoOutDate").value;
    
    SendUri+="&noSmoke="+noSmoke+"&bigBed="+bigBed+"&Postulate="+this.$("Postulate").value;
    
   HotelCs.showpopupbg();
   var pleasewaiting = this.$("WriteOrderWait");
   var clientWidth = document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
   pleasewaiting.style.left=(clientWidth-485)/2+"px";
   
   var eT=0,eL=0,p=this.$("passengerlispanforwaitli");
   var sT=document.body.scrollTop,sL=document.body.scrollLeft;
   var eH=p.clientHeight,eW=p.clientWidth;
   while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
 
   pleasewaiting.style.top=eT+eH-40+"px";
   
   pleasewaiting.style.display="block";
   var Ajax = new AjaxPro("WriteOrderWait");
   AjaxReturnType = 1;
   AjaxCommand = HotelCs.ShowThisOrderInfo;
   Ajax.Post("CreateOrder.aspx",SendUri);
}
HotelClass.prototype.ShowThisOrderInfo = function(id)
{
    if(id=="err")
    {
    window.location="hotelerror.aspx";
    }else
    {
    window.location=id;
    }
}
HotelClass.prototype.showpopupbg = function()
{
    var bgobj = HotelCs.$("WaitBackground");
    var clientWidth = document.body.clientWidth;
    var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;

    var swidth,sheight;
    swidth=document.body.offsetWidth+document.body.offsetLeft*2;
    if(document.body.clientHeight<screen.height)
        sheight=screen.height;
    else
        sheight=document.body.clientHeight+document.body.offsetTop*2;
    
    bgobj.style.display="block";
    if(document.all)
    {
        bgobj.style.filter="progid:dximagetransform.microsoft.alpha(opacity=25)";
    }else{
        bgobj.style.MozOpacity="0.25";  
    }
    bgobj.style.width=swidth+"px";
    bgobj.style.height=sheight+"px";
    bgobj.style.zIndex = 998;
    bgobj.oncontextmenu=function(){return false;}
    bgobj.ondragstart=function(){return false;}
    bgobj.onselectstart=function(){return false;}
}
