// JavaScript Document
	var whitespace = " \t\n\r";
// Function to check whether the value in a Text Field is Null
	function isEmpty(s)
	{  return ((s == null) || (s.length == 0))
	}
// Function to check whether the value in a Text Field is a WhiteSpace
	function isWhitespace (s)
	{  var i;
 	  // Is s empty?
 	  if (isEmpty(s)) return true;
 	   // Search through string's characters one by one
 	   // until we find a non-whitespace character.
 	   // When we do, return false; if we don't, return true.
 	   for (i = 0; i < s.length; i++)
 	   {   
 	  // Check that current character isn't whitespace.
 	  var c = s.charAt(i);
 	  if (whitespace.indexOf(c) == -1) return false;
 	   }
 	   // All characters are whitespace.
	  return true;
	}
// Function to ensure that the email address is in proper format
	function isEmail (s)
  	{
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
	  // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
    }
 function isWebsite (s)
  	{
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
    }
  function isCharsInBag (s, bag)
  {  
  var i;
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if (bag.indexOf(c) == -1)
	 return false;
  }
  return true;
  }
function validatecontact()
	{
		var name= document.contact_form.name.value;
		if(name=="")
		{
			alert( "Please enter  name");
			document.contact_form.name.focus( );
			return false;
		}

		var email = document.contact_form.emailaddress.value;
		if(email=="")
		{
			alert("Please enter the Email Address");
			document.contact_form.emailaddress.focus( );
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email address in the proper Format");
				document.contact_form.emailaddress.focus( );	
				return false;
			}
		}
		var description= document.contact_form.description.value;
		if(description=="")
		{
			alert( "Please enter description");
			document.contact_form.name.focus( );
			return false;
		}
	}
function validatetellus()
{
	var email = document.tell_us_form.emailid.value;
		if(email=="")
		{
			alert("Please enter the Email Id");
			document.tell_us_form.emailid.focus( );
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email Id in the proper Format");
				document.tell_us_form.emailid.focus( );	
				return false;
			}
		}
}
function validatesignin()
{
	var email = document.sign_in_form.email.value;
		if(email=="")
		{
			alert("Please enter the Email Id");
			document.sign_in_form.email.focus();
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email Id in the proper Format");
				document.sign_in_form.email.focus();	
				return false;
			}
		}
	var password = document.sign_in_form.password.value;
	if(password=="")
	{
			alert("Please enter the Password");
			document.sign_in_form.password.focus();
			return false;
	}
}
function validateagentreg()
{
		var name= document.agent_registration_form.txtCompanyName.value;
		if(name=="")
		{
			alert( "Please enter Company name");
			document.agent_registration_form.txtCompanyName.focus( );
			return false;
		}
		var contactPerson= document.agent_registration_form.txtContactPerson.value;
		if(contactPerson=="")
		{
			alert( "Please enter Contact Person");
			document.agent_registration_form.txtContactPerson.focus( );
			return false;
		}
		var email = document.agent_registration_form.email.value;
		if(email=="")
		{
			alert("Please enter the Email Address");
			document.agent_registration_form.email.focus( );
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email address in the proper Format");
				document.agent_registration_form.email.focus( );	
				return false;
			}
		}
		var address= document.agent_registration_form.address.value;
		if(address=="")
		{
			alert( "Please enter Address");
			document.agent_registration_form.address.focus( );
			return false;
		}
		var city= document.agent_registration_form.city.value;
		if(city=="")
		{
			alert( "Please enter City");
			document.agent_registration_form.city.focus( );
			return false;
		}
}
function validateregistration()
{
	var name= document.registration_form.name.value;
		if(name=="")
		{
			alert( "Please enter  name");
			document.registration_form.name.focus( );
			return false;
		}

		var email = document.registration_form.email.value;
		if(email=="")
		{
			alert("Please enter the Email Address");
			document.registration_form.email.focus( );
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email address in the proper Format");
				document.registration_form.email.focus( );	
				return false;
			}
		}
		var password = document.registration_form.password.value;
	if((password=="") || (password.length<6))
	{
		alert("Please enter the Password.");
		document.registration_form.password.focus( );
		return false;
	}
	var confirm_password = document.registration_form.confirm_password.value;
	if(confirm_password!=password)
	{
	  alert("Password & Confirm Password are not same");
	  document.registration_form.confirm_password.focus();
	  return false;
	}
	
		var address1= document.registration_form.address1.value;
		if(address1=="")
		{
			alert( "Please enter Address1");
			document.registration_form.address1.focus( );
			return false;
		}
		var city= document.registration_form.city.value;
		if(city=="")
		{
			alert( "Please enter City");
			document.registration_form.city.focus( );
			return false;
		}
}

function validateprivilegeregistration()
{
	var name= document.registration_form_privilege.name.value;
		if(name=="")
		{
			alert( "Please enter  name");
			document.registration_form_privilege.name.focus( );
			return false;
		}

		var email = document.registration_form_privilege.email.value;
		if(email=="")
		{
			alert("Please enter the Email Address");
			document.registration_form_privilege.email.focus( );
			return false;
		}
		else{
		if (!isEmail(email))
			{
				alert("Please enter the Email address in the proper Format");
				document.registration_form_privilege.email.focus( );	
				return false;
			}
		}
		var password = document.registration_form_privilege.password.value;
	if (password=="")
	{
		alert("Please enter the Password.");
		document.registration_form_privilege.password.focus( );
		return false;
	}
	if((password!="") && (password.length<6))
	{
		alert("Password should not be less than 6 characters.");
		document.registration_form_privilege.password.focus( );
		return false;
	}
	var confirm_password = document.registration_form_privilege.confirm_password.value;
	if(confirm_password!=password)
	{
	  alert("Password & Confirm Password are not same");
	  document.registration_form_privilege.confirm_password.focus();
	  return false;
	}
	
		var address1= document.registration_form_privilege.address1.value;
		if(address1=="")
		{
			alert( "Please enter Address1");
			document.registration_form_privilege.address1.focus( );
			return false;
		}
		var city= document.registration_form_privilege.city.value;
		if(city=="")
		{
			alert( "Please enter City");
			document.registration_form_privilege.city.focus( );
			return false;
		}
		var state= document.registration_form_privilege.state.value;
		if(state=="")
		{
			alert( "Please enter State");
			document.registration_form_privilege.state.focus( );
			return false;
		}
		var postalcode= document.registration_form_privilege.postalcode.value;
		if(postalcode=="")
		{
			alert( "Please enter Postal Code");
			document.registration_form_privilege.postalcode.focus( );
			return false;
		}
		var mobile= document.registration_form_privilege.mobile.value;
		if(mobile=="")
		{
			alert( "Please enter Mobile no");
			document.registration_form_privilege.mobile.focus( );
			return false;
		}
		var phone= document.registration_form_privilege.phone.value;
		if(phone=="")
		{
			alert( "Please enter Phone no");
			document.registration_form_privilege.phone.focus( );
			return false;
		}
		var cardtype= document.registration_form_privilege.cardtype.value;
		if(cardtype=="" || cardtype=="0")
		{
			alert( "Please select Card type");
			document.registration_form_privilege.cardtype.focus( );
			return false;
		}
		var cardvalidity= document.registration_form_privilege.cardvalidity.value;
		if(cardvalidity=="" || cardvalidity=="0")
		{
			alert( "Please select Card validity");
			document.registration_form_privilege.cardvalidity.focus( );
			return false;
		}
		var pmttype= document.registration_form_privilege.pmttype.value;
		if(pmttype=="" || pmttype=="0")
		{
			alert( "Please select Payment type");
			document.registration_form_privilege.pmttype.focus( );
			return false;
		}
}
function validatesearchform()
{
		myOption = -1;
		for (i=document.search_form.City_Id.length-1; i > -1; i--)
		{
				if (document.search_form.City_Id[i].checked) {
					myOption = i; i = -1;
				}
		}
		if (myOption == -1) {
			alert("Please select location");
			return false;
		}
	var bedType= document.search_form.bedTypeId.value;
		if(bedType=="")
		{
			alert( "Please select type");
			document.search_form.bedType.focus( );
			return false;
		}
	var check_in= document.search_form.check_in.value;
		if(check_in=="")
		{
			alert( "Please select check in date");
			document.search_form.check_in.focus( );
			return false;
		}
		var check_out=document.search_form.check_out.value;
		if(check_out=="")
		{
			alert( "Please select check out date");
			document.search_form.check_out.focus( );
			return false;
		}	
		if(check_in==check_out)
		{
			alert( "Please select check out date greater than check in");
			document.search_form.check_out.focus( );
			return false;
		}	
		document.search_form.submit();
}
