function validate(theForm){
	
	if(!theForm){
		theForm = document.formReserv;
	}else{
		theForm = document.reserv; 
	}
	//---------------------check year--------------------------
	today = new Date();
	todayDay = today.getDate()
	todayYear = today.getFullYear();
	todayMonth = today.getMonth() + 1;
	
	if(theForm.monthfrom.value >= todayMonth){
		theForm.yearfrom.value = todayYear;
	}else if(theForm.monthfrom.value < todayMonth){
		theForm.yearfrom.value = parseInt(todayYear) + 1;
	}
	if(theForm.monthend.value >= todayMonth){
		theForm.yearend.value = todayYear;
	}else if(theForm.monthend.value < todayMonth){
		theForm.yearend.value = parseInt(todayYear) + 1;
	}
	
	//------------------check room, no of adult, noofchildren-----------------
	tf = true;
	message = "";
	
	rooms = parseInt(theForm.rooms.value);
	adults = parseInt(theForm.adults.value);
	children = parseInt(theForm.children.value);
	
	if(adults < rooms){
		tf = false;
		message += "No. of adults is less than mimimum required";
		theForm.adults.focus();
	}
	
	if(adults > ((rooms * 2) + rooms)){
		tf = false;
		message += "No. of adults exceeds maximum capacity";
		theForm.adults.focus();
	}

	if(children > (rooms * 2)){
		tf = false;
		message += "No. of Children exceeds maximum capacity";
		theForm.children.focus();
	}
	
	if(tf == false){
		alert(message);
	}
	
	return tf;
}
