﻿
//--<FOR CALENDAR> --------------------------------------------------------------    
    var tmpDate = new Date()
    var maxAvailableDays = 320; 
    var CalS = parseInt(tmpDate.getMonth() + 1).toString() + "/" + tmpDate.getDate() + "/" + tmpDate.getFullYear(); // '12/25/2006'; 
    tmpDate = new Date(tmpDate.setDate(maxAvailableDays))
    var CalE = parseInt(tmpDate.getMonth() + 1).toString() + "/" + tmpDate.getDate() + "/" + tmpDate.getFullYear(); // '01/16/2007';
//--</FOR CALENDAR> --------------------------------

    function OpenHotelCalendar(obj){
		event.cancelBubble=true; 	
		hw('1');
		
//		if (obj == 'fdtHotelTo')
//		{
//		  var  daysAdd = 7 ; 
//          var _fromDate =document.getElementById('fdtHotelFrom').value;  
//          var _toDate =document.getElementById(obj).value;   
//          if (_toDate == "" && _fromDate!= "")
//          {
//             document.getElementById(obj).value = GetDateFormat(_fromDate,daysAdd);
//          }
//		}
		
		SC(document.getElementById(obj));
	}
	
//hadle onclick for destination part. open destination logic dialog window		
		function openHotelDestinationDialog(controlclientid)
		{
			var ret = new Array();
			var style = "dialogHeight:350px; dialogWidth:250px;dialogTop:px;dialogLeft:px;edge:Raised;center:Yes;help:no;resizable:No;status:No;scroll:no;";
	
			ret = window.showModalDialog(DestinationUrl,"",style);
			try
			{ 
				document.getElementById(controlclientid+"txtDestination").innerText =ret[0]; 	
				document.getElementById(controlclientid+"inputDestination").value=ret[1];
			}
			catch(e)
			{ }
			finally
			{ }		
		}

//render num of children selection
		function RenderChildrenSection(tableIndex , sumOfKids,controlclientid)
		{
			switch(Number(sumOfKids))
			{
				case 0 : 
			    	//window.document.getElementById("nothingRoom" +tableIndex ).style.display="none"; 
					//window.document.getElementById("lblAgesRoom" +tableIndex).style.display="none"; 
					window.document.getElementById("lblFirstChildRoom" +tableIndex).style.display="none"; 
					window.document.getElementById(controlclientid + "ddlFirstChildAge_Room" +tableIndex).style.display="none"; 
					window.document.getElementById("lblSecondChildRoom" +tableIndex).style.display="none"; 
					window.document.getElementById(controlclientid + "ddlSecondChildAge_Room" +tableIndex).style.display="none"; 
				    break; 
				
			    case 1 : 
			        // window.document.getElementById("nothingRoom" +tableIndex).style.display="block"; 	
			         //window.document.getElementById("lblAgesRoom" +tableIndex).style.display="block"; 	
			         window.document.getElementById("lblFirstChildRoom" +tableIndex).style.display="block"; 
					 window.document.getElementById(controlclientid + "ddlFirstChildAge_Room" +tableIndex).style.display="block"; 
				     window.document.getElementById("lblSecondChildRoom" +tableIndex).style.display="none"; 
					 window.document.getElementById(controlclientid + "ddlSecondChildAge_Room" +tableIndex).style.display="none"; 
				     break; 
			    
			    case 2 : 
			         //window.document.getElementById("lblAgesRoom"+tableIndex).style.display="block"; 	
			        // window.document.getElementById("nothingRoom"+tableIndex ).style.display="block"; 			
			         window.document.getElementById("lblFirstChildRoom"+tableIndex).style.display="block"; 
					 window.document.getElementById(controlclientid + "ddlFirstChildAge_Room"+tableIndex).style.display="block";
					 window.document.getElementById("lblSecondChildRoom"+tableIndex).style.display="block"; 
					 window.document.getElementById(controlclientid + "ddlSecondChildAge_Room"+tableIndex).style.display="block"; 
					 break;
			
			 }
		}
		
		//handle onchange for num of children selection
		function RenderChildrenSectionForTable(tableIndex,controlclientid)
		{
			var sumOfKids = window.document.getElementById(controlclientid + "ddlChildCount_Room" + tableIndex).value ; 
			RenderChildrenSection(tableIndex, sumOfKids,controlclientid );
		
		}
		function ConvertStringToDateObject(str)
		{
				var objDate = new Date();
				var arrDate = null ; 
				arrDate = str.split("/");
				objDate = new Date( Number(arrDate[2]) ,Number(arrDate[1])-1, Number(arrDate[0]));
				
				return objDate ; 	
		}
		function GetArrivalDepartureDiff(ArrivalDate,DepartureDate)
	    {
		var datesDiff ; 

		var objArrivalDate = ConvertStringToDateObject(ArrivalDate);
		var objDepartureDate = ConvertStringToDateObject(DepartureDate);
		datesDiff = (objDepartureDate - objArrivalDate)/(24*60*60*1000) ;
		
		return datesDiff ; 
	    }
		function CheckLegalInput(controlclientid)
			{
			
			var errDatesMsg = "תאריך היציאה מהמלון נדרש להיות מאוחר\n.מיום הכניסה למלון לפחות ביום אחד";
	        var datefrom = document.getElementById("fdtHotelFrom").value;      
	        var dateto = document.getElementById("fdtHotelTo").value;  
	        var datesDiff ;
	        var errDatesBigRangeMsg = "תאריך היציאה אינו יכול להיות יותר מ 30 יום מתאריך הכניסה"
	        
	        if (datefrom == "")
	        {
	            alert("נא למלא תאריך כניסה")
	            return false;
	        }
	        if (dateto == "")
	        {
	            alert("נא למלא תאריך יציאה")
	            return false;
	        }
	       
	        datesDiff = GetArrivalDepartureDiff(datefrom,dateto);
		    if (datesDiff<=0)
			{
				alert(errDatesMsg);
				return false ; 
			}
			if (datesDiff>30)
			{
			    alert(errDatesBigRangeMsg);
			    return false;
			}
	        
            document.getElementById(controlclientid+"hdn_hoteldatefrom").value = datefrom;
            document.getElementById(controlclientid+"hdn_hoteldateto").value = dateto;
	         return true;
			}

 