function GetCountDay(){
	sStartDate = getV('sStartDate');
	sEndDate = getV('sEndDate');
	sTime = getV('sStartTime');
	//alert(sStartDate);
	//alert(sEndDate);
	arSDate = sStartDate.split('.');
	arEDate = sEndDate.split('.');
	//alert(arSDate);
	var SDate = new Date(arSDate[2],arSDate[1] - 1,arSDate[0]);
	var EDate = new Date(arEDate[2],arEDate[1] - 1,arEDate[0]);
	var workday = 0;
	var weekend = 0;
	msPerDay = 24 * 60 * 60 * 1000;
	RDate = (EDate.getTime() - SDate.getTime())/msPerDay+0;
	//alert(RDate);
	RDate = Math.round(RDate);
  var arResRoomID = '';
  var sRoomId = '';
  for (i=0;i<arRoomId.length;i++){
    for (j=0;j<arRoomId[i].length;j++){
      sRoomId += arRoomId[i][j]+':';
    }
  }
  arResRoomID = sRoomId;
		
	//alert(RDate);
	
	if (RDate == 0){
	  day = SDate.getDay();
		workday = 0;
		weekend = 0;
		if (day >=5 && day <= 6)
		  weekend++;
		else
		  workday++;		
		var sw = workday+':'+weekend;
		//alert(sw);
		return sw
	}
	else {
		//alert(RDate);
		if (RDate >= 5){
		  //alert('Цены как за будни');
		  //xajax_GetNewPrice2(RDate, sRoomId);
		  workday = RDate;
		  weekend = 0;
		  var sw = workday+':'+weekend;
		  return sw
      }
    else {
		  for (i=1;i<=RDate;i++){
		    //alert(SDate.getDay());
		    
		    day = SDate.getDay();	    
		    
		    month = SDate.getMonth();
		    month++;
		    
		    day2 = SDate.getDate();
		    if (day2 < 10)
		    	day2 = '0'+day2;
		    	
		    format_day = day2+'.';
		    
		    if (month > 10)
          format_day +=month+'.';
        else
          format_day += '0'+month+'.';
        //alert(SDate.getYear());

        var ua = navigator.userAgent.toLowerCase();
        if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
          format_day += parseInt(SDate.getYear());
        }
        else if (ua.indexOf("opera") != -1) {
          format_day += parseInt(SDate.getYear());
        }
        // Gecko = Mozilla + Firefox + Netscape
        else {
          format_day += parseInt(1900)+parseInt(SDate.getYear());
        }          
		    
		    //alert(format_day);
		    if (day == 5 || day == 6)
		      weekend++;
		    else
		      workday++;
		    
		    for (k=0;k<arBudni.length;k++){
		      if (arBudni[k] == format_day){
		        workday++;
		        weekend--;		                
		      }
		    }
		    //alert(arVih);
		    for (k=0;k<arVih.length;k++){
          //alert(arVih[k]+'_'+ format_day);
		      if (arVih[k] == format_day){
		        workday--;
		        weekend++;	        
		      }
		    }		    
        
        if (workday < 0 && weekend > 0){
          weekend = weekend + workday;
          workday = 0;
        }
        else if (workday > 0 && weekend < 0){
          workday = weekend + workday;
          weekend = 0;        
        }
        
		    SDate.setDate(SDate.getDate()+1);
        }
      //alert(arRoomId);
      //alert(arResRoomID);
      var sw = workday+':'+weekend;
      //alert(sw);
      return sw;
      
      }
		}
	}
	
	function GetNumberList(iRoomId, iTypeNum, iCnt, id, arr, stat){
	 val = document.getElementById(id).value;
	 iCnt = parseInt(iCnt);
	 //alert(iCnt);
	 document.getElementById(id).value = iCnt;
	 iFreeCnt = getV('hFreePlace_'+iRoomId);
	 iSum = 0;
	 hNumSum = getV('hNumSum_'+iRoomId);
	 hSum = getV('hRPrice');
	 iSum = hSum - hNumSum; 
	 //iFreeCnt = 0;
	 if (iCnt == 0){
	   setHtml('divDetail_'+iRoomId, '');
     setHtml('sRPrice',iSum);
     setV('hRPrice',iSum);	   
     }
	 else if (isNaN(iCnt)){
	   if (val.length > 0){
	     document.getElementById(id).value = '';
       setHtml('divDetail_'+iRoomId, '');
       setHtml('sRPrice',iSum);
       setV('hRPrice',iSum);       
       }
      else {
        document.getElementById(id).value = '';
        setHtml('divDetail_'+iRoomId,'');
        ShowDetail(iRoomId, 1);        
        setHtml('sRPrice',iSum);
        setV('hRPrice',iSum);        
        }  
     }
	 else if (iCnt < 0 || iCnt > iFreeCnt){
	   if (iFreeCnt == 0)
	     alert('Все номера заняты');
	   else
	     alert('Свободно: '+iFreeCnt);
	   setV(id, iFreeCnt);
	   GetNumberList(iRoomId, iTypeNum, iFreeCnt, id, arr, stat)
     }
   else {
     if (iCnt > 0){
       document.getElementById('divDetail_'+iRoomId).style.fontWeight = 'normal';
       document.getElementById('divDetail_'+iRoomId).style.color = 'green';
       
       //xajax_GetNumberList(iRoomId);
       jsCalc = '';
       htmlNumList = '<table id="tblDetail" width="100%">';
         htmlNumList += '<tr>';
         htmlNumList += '<td width="" class="head">Номер</td>';
         htmlNumList += '<td width="" class="head">Кол-во людей</td>';
         htmlNumList += '<td width="" class="head">Кол-во детей</td>';
         htmlNumList += '<td width="" class="head">Цена</td>';         
         htmlNumList += '</tr>';
                           
       if (!stat){    
       for (i=0;i<iCnt;i++){
         
         iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
         iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
         //alert(iFreePlace);
         //alert(iCnt+':'+iFreeCnt);
         htmlNumList += '<tr>';
         //RoomName = getV('hFreePlaceIDName_'+iRoomId+'['+i+']');
         if (is_a){
           if (iCnt == iFreeCnt){
             RoomName = getV('hFreePlaceIDName_'+iRoomId+'['+i+']');
           }         
           else {
             RoomName = '<select name="sel'+iRoomId+'" onChange="ChangeField(this.value, '+iTypeNum+', '+i+')">';
             for (j=i;j<iFreePlace;j++){
               name = getV('hFreePlaceIDName_'+iRoomId+'['+j+']');
               if (name != 0){
                 RoomName += '<option id="'+j+'" value="'+iRoomId+'_'+j+'">';
                 RoomName += name; 
                 RoomName += '</option>';           
               } else break;
             }
             RoomName += '</select>';         
           }
         }
         else {
           RoomName = getV('hFreePlaceIDName_'+iRoomId+'['+i+']');
         }  
         htmlNumList += '<td width="">'+RoomName+'</td>';
         htmlNumList += '<td width=""><div id="divPeople_'+iRoomId+'_'+i+'"><input value="'+iMaxCnt+'" type="text" size="1" id="cntPeople_'+iRoomId+'['+i+']'+'" name="cntPeople_'+iRoomId+'['+i+']" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 0)"></div></td>';
         htmlNumList += '<td width=""><div id="divCheckBoxChild_'+iRoomId+'_'+i+'"><input type="checkbox" name="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" class="checkbox" id="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" onClick="showChildBlock(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iFreePlace+'\')">&nbsp;Есть дети';
         htmlNumList += '<div id="divChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" style="display:none;">';
         htmlNumList += '<table id="tblDetailChild"><tr><td>до&nbsp;3 (бесплатно)</td><td><input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
         htmlNumList += '<tr><td>от&nbsp;4&nbsp;до&nbsp;7 (-15%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
         htmlNumList += '<tr><td>от&nbsp;8&nbsp;до&nbsp;12(-10%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\' ,\''+iFreePlace+'\',this.value, this.id, 1)"></td></tr>';
         htmlNumList += '</table></div></div></td>';
         htmlNumList += '<td width=""><div id="divPriceNum_'+iRoomId+'_'+i+'"><input value="0" type="hidden" size="2" name="hPriceNum_'+iFreePlace+'" id="hPriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'"><span id="span_PriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'">0</span>&nbsp;руб.</td></td>';         
         htmlNumList += '</tr>';
         //eval('alert(\''+i+'\')');
         jsCalc += 'Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,\''+iMaxCnt+'\','+'\'cntPeople_'+iRoomId+'['+i+']'+'\', 0);';
         }
       }//if (!stat)
       else {
       for (i=0;i<iCnt;i++){
         iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
         iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
         if (in_array(iFreePlace, arSetRoomID2)){
           htmlNumList += '<tr>';
           htmlNumList += '<td width="">'+getV('hFreePlaceIDName_'+iRoomId+'['+i+']')+'</td>';
           htmlNumList += '<td width=""><input value="'+iMaxCnt+'" type="text" size="1" id="cntPeople_'+iRoomId+'['+i+']'+'" name="cntPeople_'+iRoomId+'['+i+']" onChange="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 0)"></td>';
           htmlNumList += '<td width=""><input type="checkbox" name="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" class="checkbox" id="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" onClick="showChildBlock(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iFreePlace+'\')">&nbsp;Есть дети';
           htmlNumList += '<div id="divChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" style="display:none;">';
           htmlNumList += '<table id="tblDetailChild"><tr><td>до&nbsp;3</td><td><input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" size="1" value="0" onChange="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
           htmlNumList += '<tr><td>от&nbsp;4&nbsp;до&nbsp;7</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" size="1" value="0" onChange="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
           htmlNumList += '<tr><td>от&nbsp;8&nbsp;до&nbsp;12</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" size="1" value="0" onChange="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\' ,\''+iFreePlace+'\',this.value, this.id, 1)"></td></tr>';
           htmlNumList += '</table></div></td>';
           htmlNumList += '<td width=""><input value="0" type="hidden" size="2" name="hPriceNum_'+iFreePlace+'" id="hPriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'"><span id="span_PriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'">0</span>&nbsp;руб.</td>';         
           htmlNumList += '</tr>';
           jsCalc += 'Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,\''+iMaxCnt+'\','+'\'cntPeople_'+iRoomId+'['+i+']'+'\', 0);';
           }
         }
       }
       htmlNumList += '<tr><td colspan="3">&nbsp;</td><td><span id="span_NumSum_'+iRoomId+'" style="font-weight: bold;">0</span>&nbsp;руб.<input size="5" type="hidden" id="hNumSum_'+iRoomId+'"" value="0"></td></tr>';
       htmlNumList += '</table>';

       setHtml('divDetail_'+iRoomId,htmlNumList);
       ShowDetail(iRoomId, 1);
       eval(jsCalc);       
       } 
    }
  }
  
  function ChangeField(value, iTypeNum, j){
  	//i = OptionID[k];
  	//alert(value);
  	arr = value.split('_');
  	//alert(arr);
  	iRoomId = arr[0];
  	i = arr[1];
  	//alert(iRoomId+'_'+iTypeNum+'_'+j+'_'+i);
    SetDivPeople(iRoomId, iTypeNum, j, i);
    SetDivChild(iRoomId, iTypeNum, j, i);
    SetDivPriceNum(iRoomId, iTypeNum, j, i);    
  }
  
  function SetDivPeople(iRoomId, iTypeNum, j, i){
    iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
    iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
    div = '<input value="'+iMaxCnt+'" type="text" size="1" id="cntPeople_'+iRoomId+'['+i+']'+'" name="cntPeople_'+iRoomId+'['+i+']" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 0)">';   
    document.getElementById('divPeople_'+iRoomId+'_'+j).innerHTML = div;
    
  }
  
  function SetDivChild(iRoomId, iTypeNum, j, i){
    iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
    div = '<input type="checkbox" name="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" class="checkbox" id="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" onClick="showChildBlock(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iFreePlace+'\')">&nbsp;Есть дети';
    div += '<div id="divChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" style="display:none;">';
    div += '<table id="tblDetailChild"><tr><td>до&nbsp;3 (бесплатно)</td><td><input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
    div += '<tr><td>от&nbsp;4&nbsp;до&nbsp;7 (-15%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
    div += '<tr><td>от&nbsp;8&nbsp;до&nbsp;12(-10%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" size="1" value="0" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\' ,\''+iFreePlace+'\',this.value, this.id, 1)"></td></tr>';
    div += '</table></div>';    
    document.getElementById('divCheckBoxChild_'+iRoomId+'_'+j).innerHTML = div;
    
  }

  function SetDivPriceNum(iRoomId, iTypeNum, j, i){
    iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
    iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
    div = '<input value="0" type="hidden" size="2" name="hPriceNum_'+iFreePlace+'" id="hPriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'"><span id="span_PriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'">-0</span>&nbsp;руб.';
              
    document.getElementById('divPriceNum_'+iRoomId+'_'+j).innerHTML = div;
    
    jsCalc = 'Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iRoomId+'\',\''+iFreePlace+'\' ,\''+iMaxCnt+'\','+'\'cntPeople_'+iRoomId+'['+i+']'+'\', 0, 1, '+i+');';
    eval(jsCalc);
    
  }
      
  function in_array(v, arr){
    if (v in arr){return true;}
    else{return false;}
  } 
  
  
  function GetNumList(){
    arCntRoomId = new Array();
    arCntRoomId[11]=1;arCntRoomId[12]=1;arCntRoomId[13]=1;arCntRoomId[14]=1;
    arCntRoomId[15]=32;arCntRoomId[16]=8;arCntRoomId[17]=8;arCntRoomId[18]=8;
    arCntRoomId[19]=4;arCntRoomId[23]=4;
    arTypeNumRoomId = new Array();
    arTypeNumRoomId = new Array();
    arTypeNumRoomId[11]=1;arTypeNumRoomId[12]=1;arTypeNumRoomId[13]=1;
		arTypeNumRoomId[14]=1;arTypeNumRoomId[15]=2;arTypeNumRoomId[16]=2;
    arTypeNumRoomId[17]=2;arTypeNumRoomId[18]=3;arTypeNumRoomId[19]=3;
    arTypeNumRoomId[23]=2;
    arShowRoom = new Array();
    arShowTypeNum = new Array();
    arI = new Array();
    //alert(arSetRoomID.length);
    //alert(arSetRoomID);
    //alert(arSetRoomID2);
    jsCalc = '';
    jsAlert = '';
    for (j=11;j<=23;j++){
    	//start for debug
      //if ((j >=12 && j <= 14) || (j > 19 && j < 23)) continue;
      if ((j >=12 && j <= 14) || (j > 19 && j < 23)) continue;
      //start for debug
      htmlNumList = '<table id="tblDetail" width="100%">';  
      iRoomId = j;
      iCnt = arCntRoomId[j];
      iTypeNum = arTypeNumRoomId[j];
      b_add_arr = false;
      for (i=0;i<iCnt;i++){
      //alert('iCnt='+iCnt);

      //alert('hFreePlaceID_'+iRoomId+'['+i+']');
        iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
        //alert(arSetRoomID2);
        //alert('hFreePlaceID_'+iRoomId+'['+i+']');
        iMaxCnt = 0;
        if (in_array(iFreePlace, arSetRoomID2)){
        	
          b_add_arr = true;        
          //alert(iFreePlace);
          iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
          //iCntPlace = 0;
          iMaxCount = COUNT_P[iFreePlace][0];
          if (iMaxCount == 0)
          	iMaxCount = iMaxCnt;
          iMaxCnt = iMaxCount;
          
          child3 = COUNT_P[iFreePlace][1];
          child4 = COUNT_P[iFreePlace][2];
          child8 = COUNT_P[iFreePlace][3];
          //alert(child3+'_'+child4+'_'+child8);
          //alert('COUNT_P['+iFreePlace+'][1]');
          //alert('COUNT_P['+iFreePlace+'][2]');
          //alert('COUNT_P['+iFreePlace+'][3]');
          
          htmlNumList += '<tr>';
          htmlNumList += '<td width="">'+getV('hFreePlaceIDName_'+iRoomId+'['+i+']')+'</td>';
          htmlNumList += '<td width=""><input value="'+iMaxCnt+'" type="text" size="1" id="cntPeople_'+iRoomId+'['+i+']'+'" name="cntPeople_'+iRoomId+'['+i+']" onKeyUp="Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 0)"></td>';
          htmlNumList += '<td width=""><input type="checkbox" name="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" class="checkbox" checked id="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" onClick="showChildBlock(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iFreePlace+'\')">&nbsp;Есть дети';
          htmlNumList += '<div id="divChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" style="">';
          htmlNumList += '<table id="tblDetailChild"><tr><td>до&nbsp;3</td><td><input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" size="1" value="'+child3+'" onKeyUp="Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
          htmlNumList += '<tr><td>от&nbsp;4&nbsp;до&nbsp;7</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" size="1" value="'+child4+'" onKeyUp="Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
          htmlNumList += '<tr><td>от&nbsp;8&nbsp;до&nbsp;12</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" size="1" value="'+child8+'" onKeyUp="Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\' ,\''+iFreePlace+'\',this.value, this.id, 1)"></td></tr>';
          htmlNumList += '</td>';
          htmlNumList += '</table></div></td>';
          htmlNumList += '<td width=""><input value="0" type="hidden" size="2" name="hPriceNum_'+iFreePlace+'" id="hPriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'"><span id="span_PriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'">0</span>&nbsp;руб.</td>';         
          htmlNumList += '</tr>';
          
          //alert(htmlNumList);
          
          jsCalc += 'Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,\''+iMaxCnt+'\','+'\'cntPeople_'+iRoomId+'['+i+']'+'\', 1);';                  
          } 
                           
        }
      if (b_add_arr){
        arShowRoom.push(iRoomId);
        arI.push(i);
        arShowTypeNum.push(iTypeNum);
                
        }
      
			//alert(iRoomId);
			  
      htmlNumList += '<tr><td colspan="3">&nbsp;</td><td><span id="span_NumSum_'+iRoomId+'" style="font-weight: bold;">0</span>&nbsp;руб.<input size="5" type="hidden" id="hNumSum_'+iRoomId+'"" value="0"></td></tr>';
      htmlNumList += '</table>';        
      setHtml('divDetail_'+iRoomId,htmlNumList);
      //ShowDetail(iRoomId, 1);      
      }   
     //alert(arShowRoom); 
     for (j=0;j<arShowRoom.length;j++){
     	
      ShowDetail(arShowRoom[j], 1);
      
      //SetCntPeople(arShowRoom[j], arShowTypeNum[j], arI[j]);
      }
     //alert(jsCalc);
     eval(jsCalc);
     eval(jsAlert);
  }
  
  
  function GetNumSelectList() {
    arCntRoomId = new Array();
    arCntRoomId[11]=1;arCntRoomId[12]=1;arCntRoomId[13]=1;arCntRoomId[14]=1;
    arCntRoomId[15]=32;arCntRoomId[16]=8;arCntRoomId[17]=8;arCntRoomId[18]=8;
    arCntRoomId[19]=4;arCntRoomId[23]=4;
    
    arTypeNumRoomId = new Array();
    arTypeNumRoomId = new Array();
    
    arTypeNumRoomId[11]=1;arTypeNumRoomId[12]=1;arTypeNumRoomId[13]=1;
		arTypeNumRoomId[14]=1;arTypeNumRoomId[15]=2;arTypeNumRoomId[16]=2;
    arTypeNumRoomId[17]=2;arTypeNumRoomId[18]=3;arTypeNumRoomId[19]=3;
    arTypeNumRoomId[23]=2;
    
    arShowRoom = new Array();
    
    arShowTypeNum = new Array();
    
    arI = new Array();

    jsCalc = '';
    jsAlert = '';
    for (j=11;j<=23;j++){
    	//start for debug
      if ((j >=12 && j <= 14) || (j > 19 && j < 23)) continue;
      //start for debug
      htmlNumList = '<table id="tblDetail" width="100%">';  
      iRoomId = j;
      iCnt = arCntRoomId[j];
      iTypeNum = arTypeNumRoomId[j];
      b_add_arr = false;
      for (i = 0; i < iCnt; i++) {
        iFreePlace = getV('hFreePlaceID_'+iRoomId+'['+i+']');
        iMaxCnt = 0;
        if (in_array(iFreePlace, arSetRoomID2)){
          b_add_arr = true;        
          iMaxCnt = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
          iMaxCount = COUNT_P[iFreePlace][0];
          
          if (iMaxCount == 0)
          	iMaxCount = iMaxCnt;
          iMaxCnt = iMaxCount;
          
          child3 = COUNT_P[iFreePlace][1];
          child4 = COUNT_P[iFreePlace][2];
          child8 = COUNT_P[iFreePlace][3];
					OptionID = new Array();
					RoomName = '<select name="sel'+iRoomId+'" onChange="ChangeField(this.value, '+iTypeNum+', '+i+')">';
					for (k = i; k < iFreePlace; k++) {
						
						name = getV('hFreePlaceIDName_'+iRoomId+'['+k+']');
            if (name != 0) {
            	RoomName += '<option id="'+k+'" value="'+iRoomId+'_'+k+'">';
              RoomName += name; 
              RoomName += '</option>';           
            }
						else
							break;
          }
					RoomName += '</select>';    
          
         	htmlNumList += '<td width="">'+RoomName+'</td>';
         	htmlNumList += '<td width=""><div id="divPeople_'+iRoomId+'_'+i+'"><input value="'+iMaxCnt+'" type="text" size="1" id="cntPeople_'+iRoomId+'['+i+']'+'" name="cntPeople_'+iRoomId+'['+i+']" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 0)"></div></td>';
         	htmlNumList += '<td width=""><div id="divCheckBoxChild_'+iRoomId+'_'+i+'"><input type="checkbox" checked name="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" class="checkbox" id="chIsChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" onClick="showChildBlock(\''+iRoomId+'\',\''+iTypeNum+'\',\''+iFreePlace+'\')">&nbsp;Есть дети';
         	htmlNumList += '<div id="divChild_'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'" style="">';
         	htmlNumList += '<table id="tblDetailChild"><tr><td>до&nbsp;3 (бесплатно)</td><td><input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'to3" size="1" value="'+child3+'" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
         	htmlNumList += '<tr><td>от&nbsp;4&nbsp;до&nbsp;7 (-15%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from4to7" size="1" value="'+child4+'" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,this.value, this.id, 1)"></td></tr>';
         	htmlNumList += '<tr><td>от&nbsp;8&nbsp;до&nbsp;12(-10%)</td><td> <input type="text" id="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" name="child'+iRoomId+'_'+iTypeNum+'_'+iFreePlace+'from8to12" size="1" value="'+child8+'" onKeyUp="Calc(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\' ,\''+iFreePlace+'\',this.value, this.id, 1)"></td></tr>';
         	htmlNumList += '</table></div></div></td>';
         	htmlNumList += '<td width=""><div id="divPriceNum_'+iRoomId+'_'+i+'"><input value="0" type="hidden" size="2" name="hPriceNum_'+iFreePlace+'" id="hPriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'"><span id="span_PriceNum_'+getV('hFreePlaceID_'+iRoomId+'['+i+']')+'">0</span>&nbsp;руб.</td></td>';         
         	htmlNumList += '</tr>';

          jsCalc += 'Calc2(\''+iRoomId+'\',\''+iTypeNum+'\',\''+i+'\',\''+iFreePlace+'\' ,\''+iMaxCnt+'\','+'\'cntPeople_'+iRoomId+'['+i+']'+'\', 1);';                  
        }                   
      }
      
      if (b_add_arr){
        arShowRoom.push(iRoomId);
        arI.push(i);
        arShowTypeNum.push(iTypeNum);          
			}
      			  
      htmlNumList += '<tr><td colspan="3">&nbsp;</td><td><span id="span_NumSum_'+iRoomId+'" style="font-weight: bold;">0</span>&nbsp;руб.<input size="5" type="hidden" id="hNumSum_'+iRoomId+'"" value="0"></td></tr>';
      htmlNumList += '</table>';        
      setHtml('divDetail_'+iRoomId, htmlNumList);      
    }   
 
		for (j=0; j < arShowRoom.length; j++) {
			ShowDetail(arShowRoom[j], 1);
		}
		
		eval(jsCalc);
  }  
  
  function SetCntPeople(iRoomId, iTypeNum){
    hCntPlace = getV('hCntPlace_'+iRoomId+'_'+iTypeNum);
    //alert('cntPeople_'+iRoomId+'['+i+']');
    //setV('cntPeople_'+iRoomId+'['+i+']', hCntPlace);
  }
  
function GetCountAllDay(){
	sStartDate = getV('sStartDate');
	sEndDate = getV('sEndDate');

	arSDate = sStartDate.split('.');
	arEDate = sEndDate.split('.');
	//alert(arSDate);
	var SDate = new Date(arSDate[2],arSDate[1],arSDate[0]);
	var EDate = new Date(arEDate[2],arEDate[1],arEDate[0]);
	var workday = 0;
	var weekend = 0;
	msPerDay = 24 * 60 * 60 * 1000;
	RDate = (EDate.getTime() - SDate.getTime())/msPerDay+0;
	RDate = Math.round(RDate);	
	if (isNaN(RDate)){
	  RDate = '<span style="color:red">Не верный формат даты</span>';
    }
  else {
	  if (RDate <= 0)
		  document.getElementById('cnt_day').innerHTML='<span style="color:red">Дата заезда должна быть меньше даты выезда</span>';
	  else{
      RDate = 'Кол-во дней: '+RDate; 
      document.getElementById('cnt_day').innerHTML=RDate;
      }    
    }
	//alert(RDate);

	//setTimeout(GetCountAllDay,1000);
	}  
	
	function ShowButCancel(this_id, iRoomId, iTypeNum, iCnt, id, arr, stat){
      html = '<input type="button" value="Отменить" onClick="GetNumberList(\''+this_id+'\', \''+iTypeNum+'\', 1, \'cntNum_'+this_id+'\');ShowButOrder('+this_id+', \''+iTypeNum+'\', 1, \'cntNum_'+this_id+'\')">';
      document.getElementById('bOrder_'+this_id).innerHTML = html;
	}
	
	function ShowButOrder(this_id, iRoomId, iTypeNum, iCnt, id, arr, stat){
      html = '<input type="button" value="Заказать" onClick="GetNumberList(\''+this_id+'\', \''+iTypeNum+'\', 1, \'cntNum_'+this_id+'\');ShowButCancel('+this_id+', \''+iTypeNum+'\', 0, \'cntNum_'+this_id+'\')">';
      document.getElementById('bOrder_'+this_id).innerHTML = html;
	}	
