function clearText(control,originalvalue){
	if (control.value==originalvalue) control.value='';
}

function checkContactForm(theform){
	var msg="";
	if (theform.title.options.selectedIndex==0)    { msg+="Your title..\n"; }
	if (theform.firstname.value=="")   { msg+="Your first name..\n"; }
	if (theform.surname.value=="")   { msg+="Your surname..\n"; }
	//if (theform.country.selectedIndex==0) { msg+="Please choose a country..\n"; }
	
	//check contact method supplied
	switch (theform.contactmethod.selectedIndex){
		case 0:
			//check email
			email=theform.email.value;
			if (email.indexOf("@") == -1||email.indexOf(".") == -1) { 
				msg+="Your Email Address is either missing or in an invalid format...\n"; 
			}			
			break;
		case 1:
			//check phone
			if (theform.tel.value=="")   { msg+="Your tel no. (day)..\n"; }
			break;
		case 2:
			//check mobile
			if (theform.mobile.value=="")   { msg+="Your mobile..\n"; }
			break;
	}


	if (msg!="") { 
		msg="Some details are still required:\n\n"+msg+"\nPlease enter this information.";
		alert(msg);
		return false;			
		}
	else  { return true; }
}

function checkBookingForm(theform){
	var msg="";
	if (theform.title.options.selectedIndex==0)    { msg+="Your title..\n"; }
	if (theform.firstname.value=="")   { msg+="Your first name..\n"; }
	if (theform.surname.value=="")   { msg+="Your surname..\n"; }
	//if (theform.country.selectedIndex==0) { msg+="Please choose a country..\n"; }
	
	//check contact method supplied
	switch (theform.contactmethod.selectedIndex){
		case 0:
			//check email
			email=theform.email.value;
			if (email.indexOf("@") == -1||email.indexOf(".") == -1) { 
				msg+="Your Email Address is either missing or in an invalid format...\n"; 
			}			
			break;
		case 1:
			//check phone
			if (theform.tel.value=="")   { msg+="Your tel no. (day)..\n"; }
			break;
		case 2:
			//check mobile
			if (theform.mobile.value=="")   { msg+="Your mobile..\n"; }
			break;
	}

	if (!theform.accept_conditions[0].checked) { msg+="You must accept the booking terms and conditions..\n"; }

	//check party size
	var intadults = parseInt(theform.total_male_adults.options[theform.total_male_adults.selectedIndex].value,10) + parseInt(theform.total_female_adults.options[theform.total_female_adults.selectedIndex].value,10);
	var intmaxadults = parseInt(theform.maxadultoccupancy.value,10);
	var intchildren = parseInt(theform.total_male_children.options[theform.total_male_children.selectedIndex].value,10) + parseInt(theform.total_female_children.options[theform.total_female_children.selectedIndex].value,10);
	var intmaxchildren = parseInt(theform.maxchildoccupancy.value,10);
	var intoccupancytotal = parseInt(theform.maxtotaloccupancy.value,10);
	
	if((intchildren+intadults)<1) { msg+="Please complete the party details section..\n"; }
	if(intadults>intmaxadults) { msg+="This villa can only accommodate upto " + intmaxadults.toString() + " adults..\n"; }
	if(intchildren>intmaxchildren) { msg+="This villa can only accommodate upto " + intmaxchildren.toString() + " adults..\n"; }
	if((intchildren+intadults)>intoccupancytotal)  { msg+="This villa can only accommodate upto " + intoccupancytotal.toString() + " party members..\n"; }
	
	if (msg!="") { 
		msg="Some details are still required:\n\n"+msg+"\nPlease enter this information.";
		alert(msg);
		return false;			
		}
	else  { return true; }
}

function checkPropertyEnquiryForm(theform){
	var msg="";
	if (theform.title.options.selectedIndex==0)    { msg+="Your title..\n"; }
	if (theform.firstname.value=="")   { msg+="Your first name..\n"; }
	if (theform.surname.value=="")   { msg+="Your surname..\n"; }
	//if (theform.country.selectedIndex==0) { msg+="Please choose a country..\n"; }
	
	//check contact method supplied
	switch (theform.contactmethod.selectedIndex){
		case 0:
			//check email
			email=theform.email.value;
			if (email.indexOf("@") == -1||email.indexOf(".") == -1) { 
				msg+="Your Email Address is either missing or in an invalid format...\n"; 
			}			
			break;
		case 1:
			//check phone
			if (theform.tel.value=="")   { msg+="Your tel no. (day)..\n"; }
			break;
		case 2:
			//check mobile
			if (theform.mobile.value=="")   { msg+="Your mobile..\n"; }
			break;
	}

	//if (!theform.accept_conditions[0].checked) { msg+="You must accept the booking terms and conditions..\n"; }

	
	if (msg!="") { 
		msg="Some details are still required:\n\n"+msg+"\nPlease enter this information.";
		alert(msg);
		return false;			
		}
	else  { return true; }
}