/*
	ValidateCountry.JS
*/
	function ValidateNoOfPeople(frmSearch)
	{
		//alert ( "ValidateNoOfPeople" );
		
		var totalPersons = 0;
		var noOfRooms = 0;
		
		if (frmSearch.noOfRooms == null) {
			noOfRooms = 1;
		}
		else {
			noOfRooms = frmSearch.noOfRooms.value;
		}
		
		//Check the numbers in the rooms
		if (noOfRooms == 1) 
			{
			//Check there is an adult in the room		
	  		if ( parseInt(frmSearch.adults.value ) == 0 )
		    		{
			    	alert("Please set the number of adults staying in room 1" );
			    	frmSearch.adults.focus() ;
			    	return false;
		    		}		
		
    			totalPersons = parseInt(frmSearch.adults.value) ;

				if ((typeof (frmSearch.children) != "undefined" ) 
				    && 
				    (typeof (frmSearch.children.value) != "undefined" ))
					totalPersons += parseInt(frmSearch.children.value);
					
				if ((typeof (frmSearch.infants) != "undefined" ) 
					&& 
				    (typeof (frmSearch.infants.value) != "undefined" ))
					totalPersons += parseInt(frmSearch.infants.value);

    	}
    	else 
    	if (noOfRooms > 1) 
    		{
     		//Multiple rooms means an array of items
     		
     		//Check there is an adult in each room		
	  		for(var i = 0; i < noOfRooms; i++) 
	   			{
		    	if ( parseInt(frmSearch.adults[i].value ) == 0 )
		    		{
			    	alert("Please set the number of adults staying in room " + (i+1) );
			    	frmSearch.adults[i].focus() ;
			    	return false;
		    		}
	    		}
     		
     		totalPersons = 0 ;
     		for(var i = 0; i < noOfRooms; i++) {
     		
				if (typeof (frmSearch.adults[i]) != "undefined" )
					totalPersons += parseInt(frmSearch.adults[i].value);
				
				if ((typeof (frmSearch.children) != "undefined" ) 
				    && 
				    (typeof (frmSearch.children[i]) != "undefined" )
				    && 
				    (typeof (frmSearch.children[i].value) != "undefined" ))
					totalPersons += parseInt(frmSearch.children[i].value);
					
				if ((typeof (frmSearch.infants) != "undefined" ) 
					&& 
					(typeof (frmSearch.infants[i]) != "undefined" )
					&& 
				    (typeof (frmSearch.infants[i].value) != "undefined" ))
					totalPersons += parseInt(frmSearch.infants[i].value);
    			}
	    	}
	    
		    if (totalPersons > maxPersons) 
		    {
                alert(maxPersonsMessage);
		    	return false;
		    }
	    
	    if (totalPersons > maxPersons) {	    	
	    	return false;
	    }
	    
	    return true;
	}
	
function OnChangeNumPassengers(elmDropList,bSubmitOnChange)
    {
   if ( ValidateNoOfPeople(elmDropList.form) )
    	{
    	if ( bSubmitOnChange ) 	elmDropList.form.submit();
    	}
    //else
    //	elmDropList.selectedIndex = 0 ;
    }

	
	