// Hotel javascript
function doSubmitHotel(){

	if(validateFormHotel()){
		document.searchForm.submit();
	}
}

function validateFormHotel(){
	 var obj = document.searchForm;
	var formCheck= true;
	strPopUp = "nChild0="+obj.nChild0.selectedIndex+"&nChild1="+obj.nChild1.selectedIndex;

		if(obj.nAdult0.selectedIndex == 0){
			obj.nAdult0.focus();
			alert("The first room must have at least one adult");
			return false;
		}

		if(obj.nAdult1.selectedIndex == 0 && obj.nChild1.selectedIndex >0){
			obj.nAdult1.focus();
			alert("The second room must have at least one adult");
			return false;
		}

		if(obj.nChild2){
			strPopUp = strPopUp + "&nChild2="+obj.nChild2.selectedIndex;
			if(obj.nAdult2.selectedIndex == 0 && obj.nChild2.selectedIndex >0){
				obj.nAdult2.focus();
				alert("The third room must have at least one adult");
				return false;
			}
		}

		if(obj.nChild3){
			strPopUp = strPopUp + "&nChild3="+obj.nChild3.selectedIndex;
			if(obj.nAdult3.selectedIndex == 0 && obj.nChild3.selectedIndex >0){
				obj.nAdult3.focus();
				alert("The fourth room must have at least one adult");
				return false;
			}
		}

		doPopUp = false;

		if(obj.cAge1.value =="" && obj.nChild0.selectedIndex>0){
				doPopUp = true;
				formCheck = false;

		 }

		 if(obj.cAge2.value =="" && obj.nChild1.selectedIndex >0){
			 doPopUp = true;
			 formCheck = false;
		 }
		 if(obj.nChild2){
			 if(obj.cAge3.value =="" && obj.nChild2.selectedIndex >0){
				doPopUp = true;
				formCheck = false;
			 }
		 }
		 if(obj.nChild3){
			 if(obj.cAge4.value =="" && obj.nChild3.selectedIndex >0){
				 doPopUp = true;
				 formCheck = false;
			 }
		 }
			if(doPopUp){

				formCheck = false;
				url = "/select_child_age.php?"+strPopUp;

				window.open(url,'_blank','location=no,menubar=no,scrollbars=yes,width=300,height=300,screenX=0,screenY=0,top=100,left=100');
				return false;
			}


		return formCheck;


}

