
//This function is used to trim any string value using javascript.
function trimString (str) {
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//This function is used for email validation
function isValid(str) {
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(str.match(emailFilter))) { 
        return false;
	}
	else {
		return true;
	}

}

function isEmailUnwantedChars(emailId){
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]\']/
	if (emailId.match(illegalChars)) {
		return true;
	}else{
		return false;
	}
}



//This function is used for Numeric values
function isNumeric(str) {
	var numFilter=/^[1-9][0-9]*$/;
	if (!(str.match(numFilter))) { 
        return false;
	}
	else {
		return true;
	}
}


//registration page Validations
//This function validate the following fields only. Please modify if adding more
  
function regValidate(docStr) {
	
	if( trimString(docStr.name.value) == "")	{
		alert("Please enter name!");
		docStr.name.focus();
		return false;
	}
	else if( trimString(docStr.address.value) == "")	{
		alert("Please enter address!");
		docStr.address.focus();
		return false;
	}
	else if( trimString(docStr.phoneNo.value) == "")	{
		alert("Please enter phoneNo!");
		docStr.phoneNo.focus();
		return false;
	}
	else if( trimString(docStr.parkCapacity.value) == "")	{
		alert("Please enter parkind capacity!");
		docStr.parkCapacity.focus();
		return false;
	}
//	else if( !docStr.condo.checked)	{
//		alert("Please select the condo checkbox  !");
//		docStr.condo.focus();
//		return false;
//	}
//	else if( !docStr.firePlace.checked)	{
//		alert("Please select the firePlace checkbox  !");
//		docStr.firePlace.focus();
//		return false;
//	}
//	else if( !docStr.basement.checked)	{
//		alert("Please select the basement checkbox  !");
//		docStr.basement.focus();
//		return false;
//	}
//	else if( !docStr.heating.checked)	{
//		alert("Please select the heating checkbox  !");
//		docStr.heating.focus();
//		return false;
//	}
//	else if( !docStr.cooling.checked)	{
//		alert("Please select the cooling checkbox  !");
//		docStr.cooling.focus();
//		return false;
//	}
//	else if( !docStr.sewerAndWater.checked)	{
//		alert("Please select the sewerAndWater checkbox  !");
//		docStr.sewerAndWater.focus();
//		return false;
//	}
	else if( trimString(docStr.rooms.value) == "" )	{
		alert("Please select the rooms !");
		docStr.rooms.focus();
		return false;
	}
	else if( trimString(docStr.bedRooms.value) == "" )	{
		alert("Please select the bedrooms  !");
		docStr.bedRooms.focus();
		return false;
	}
	else if( trimString(docStr.bathRooms.value) == "" )	{
		alert("Please select the bathrooms  !");
		docStr.bathRooms.focus();
		return false;
	}
//	else if( !docStr.waterFront.checked )	{
//		alert("Please select the waterfront checkbox !");
//		docStr.waterFront.focus();
//		return false;
//	}
//	else if( !docStr.beach.checked )	{
//		alert("Please select the beach checkbox !");
//		docStr.beach.focus();
//		return false;
//	}
	else if( trimString(docStr.livingLevel.value) =="" )	{
		alert("Please select the living level !");
		docStr.livingLevel.focus();
		return false;
	}
	else if( trimString(docStr.unitLevel.value) =="" )	{
		alert("Please enter the unit level !");
		docStr.unitLevel.focus();
		return false;
	}	
	else if( trimString(docStr.unitsInComplex.value) =="" )	{
		alert("Please enter the units In Complex !");
		docStr.unitsInComplex.focus();
		return false;
	}
	else if( trimString(docStr.desc.value) =="" )	{
		alert("Please enter the description !");
		docStr.desc.focus();
		return false;
	}
	else if( trimString(docStr.regDate.value) == "")	{
		alert("Please select any date!");
		return false;
	}
	
	else if( trimString(docStr.email.value) == "")	{
		alert("Please enter email ID!");
		docStr.email.focus();
		return false;
	}
	else if( !isValid( trimString(docStr.email.value) ) )	{
		alert("Please enter valid email ID!");
		docStr.email.focus();
		return false;
	}
	else {
		return true;
	}



}