function checkCheckBoxes() {
	if (document.myform.hotelRoom.checked == false && document.myform.yachtBerthing.checked == false)
		{
		alert ('You didn\'t choose any of the checkboxes!');
		return false;
		}
	else
		{
		return true;
		}
}


function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
 
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert( helperMsg);
 elem.focus();
		return false;
	}
}

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
        elem.focus(); 
		return true;
	}
	return false;
}


function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,3}$/;
	if(elem.value.match(emailExp)){
		return false;
	}else{
		alert(helperMsg);
 elem.focus(); 
		return true;
	}
}

function validateform()
{
	if(isEmpty(document.getElementById("txtname"),"Please enter your name"))
	return false;
	if(document.getElementById("txtname").value=="Name")
	{
	alert("Please enter your name");
	return false;
	}	
	
	if(isEmpty(document.getElementById("txtadd"),"Please enter your communication address"))
	return false;
	if(document.getElementById("txtadd").value=="Address")
	{
	alert("Please enter your communication address");
	return false;
	}
	
	if(isEmpty(document.getElementById("txtcontact"),"Please enter your contact number"))
	return false;
	if(document.getElementById("txtcontact").value=="Contact Number")
	{
	alert("Please enter your contact number");
	return false;
	}
	
	if(isEmpty(document.getElementById("txtmail"),"Please enter a vaild email address"))
	return false;
	if(document.getElementById("txtmail").value=="Email address")
	{
	alert("Please enter a valid email address");
	return false;
	}
	
	if(!CheckToday(document.getElementById("myDate").value))
	{
	alert("The check-in date should be a future date starting from today.");
	return false;
	}
	if(!CheckToday(document.getElementById("myDate2").value))
	{
	alert("The check-out date should be a future date starting from the check-in date");
	return false;
	}
	if(!CheckFromToDate(document.getElementById("myDate").value,document.getElementById("myDate2").value))
	{
	alert("Check-out date should be greater than check-in date");
	return false;
	}
	document.myform.submit();
}
function validateBerth()
{
	if(isEmpty(document.getElementById("txt_owner"),"Please enter your name"))
	return false;
		
	if(isEmpty(document.getElementById("txt_add"),"Please enter your communication address"))
	return false;
		
	if(isEmpty(document.getElementById("txt_contact"),"Please enter your contact number"))
	return false;
		
	if(isEmpty(document.getElementById("txt_email"),"Please enter your email address"))
	return false;
		
	if(!CheckToday(document.getElementById("arrDt").value))
	{
	alert("The arrival date should be a future date starting from today");
	return false;
	}
	if(!CheckToday(document.getElementById("despDt").value))
	{
	alert("The departure date should be a future date starting from the arrival date");
	return false;
	}
	if(!CheckFromToDate(document.getElementById("arrDt").value,document.getElementById("despDt").value))
	{
	alert("The departure date should be greater than arrival date");
	return false;
	}
	document.myform.submit();
}

function cleartxt(elem)
{
	if(elem.value==elem.title)
	elem.value="";
}
function puttext(elem)
{
	if(elem.value=="")
	elem.value=elem.title;
}
function CheckToday(input)
	{
		var ipdate=input.split("-");
		var FromDate = new Date(ipdate[0]+"/"+ipdate[1]+"/"+ipdate[2]);
		var date3 = new Date();
 		if(FromDate<date3)
			return false;
		else
		return true;
	}
function CheckFromToDate(input1,input2)
	{
		var ipdate1=input1.split("-");
		var ipdate2=input2.split("-");
		var FromDate = new Date(ipdate1[0]+"/"+ipdate1[1]+"/"+ipdate1[2]);
		var ToDate = new Date(ipdate2[0]+"/"+ipdate2[1]+"/"+ipdate2[2]);
		if(FromDate>ToDate)
			return false;
		else
		return true;
	}
