function checkForm(theform)
{	
				if (!empty(theform.vchFirstName,"Please enter the First Name.")) return false;
		if (!empty(theform.vchLastName,"Please enter the Last Name.")) return false;
		if(!checkLetters( trim(theform.vchFirstName.value),"First name can have only alphabets (A-Z)." ))
		{	
			theform.vchFirstName.focus();
			return false;
		}
		if (!empty(theform.vchLastName,"Please enter the last name.")) return false;
		if(!checkLetters( trim(theform.vchLastName.value),"Last name can have only alphabets (A-Z)." ))
		{	
			theform.vchLastName.focus();
			return false;
		}
		if (!empty(theform.vchAddress1,"Please enter the Address.")) return false;
		if (!empty(theform.vchCity,"Please enter the City.")) return false;
		if (theform.intStateID.options[theform.intStateID.selectedIndex].value =="")
				{
				alert("Please select the state name.");
				theform.intStateID.focus();
				return false;
				}
		if(validateZIP(theform.vchZip.value)==false)
		{
			theform.vchZip.focus();
			return false;
		}
		if (!(onlyAlphaNum(theform.vchZip,"Zip code can have alphanumeric values only.")))  return false;
		if (!(Zipcheck(theform.zip,"Zip code can not contain all alphabets.")))  return false;
		var phone1=theform.eveningphone1.value+"-"+theform.eveningphone2.value+"-"+theform.eveningphone3.value;		
		if(!checkphone(phone1,theform.eveningphone1) ) return false ;
		var phone2=theform.dayphone1.value+"-"+theform.dayphone2.value+"-"+theform.dayphone3.value;		
		if(!checkphone(phone2,theform.dayphone1) ) return false ;
		if (!empty(theform.emailID,"Please enter the email address.")) return false;
		if (!emailcheck(theform.emailID,"Please enter valid email address.")) return false;

		if (theform.strBestContactTime.options[theform.strBestContactTime.selectedIndex].value =="")
			{
				alert("Please select the Best Time to Call.");
				theform.strBestContactTime.focus();
				return false;
			}
return true;
}
//-----------------------------------------------------------------------------------
function empty(object,str)
{
	var value=trim(object.value);
	if (value=="")
	 {
		alert(str);
		object.focus();
		return false;
	 }
	str1=trim(object.value);
	x=0
	for(var i=0;i<str1.length;i++)
	{	
		if (str1.charAt(i)!=" ") { x=1 }
	
	}
	if (x==0)
	{
		alert(str);
		object.value=""
		object.focus();
		return false;
	}
	str1=trim(object.value);
	x=0
	y=0
	len=str1.length;
	for(var i=0;i<str1.length;i++)
	{	
		if ((str1.charAt(i)=="\r") && (str1.charAt(i+1)=="\n")) { y++; }
	
	}
	if (y==(len/2))
	{
		alert(str);
		object.value=""
		object.focus();
		return false;
	}
	
	 return true;
}
function checkLetters( str,message )
   {
     var i, val;
     var msg = str.split("") ;
	 for (  i = 0 ; i < str.length ; i ++ )
     {
       if ( ( (msg[i] <= "Z") && (msg[i] >= "A") ) || ( (msg[i] <= "z") && (msg[i] >= "a") )|| ( msg[i].indexOf("'")>-1 ));
       else
       {
         val = 1;
         break ;
       }        
     }
     if ( val == 1 )
     {
       alert (message) ;
      return false;
     }
 
	 return true;
   }
function is_alphanumeric(str,message)
{
	//var
	var asstr=trim(str.value);

	var asstr=asstr.replace("\"","'");
	var alphaCount=0;
	var alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,'";
	var sizechar=asstr.length;

    for (var i=0; i<sizechar; i++) {
        if (alph_valid.indexOf(asstr.charAt(i)) < 0) {
            alphaCount++
        }
    }
    
    if(alphaCount>0)
	{		
		alert(message);
		str.focus();
    	return false;
	}
    else
    	return true;
 
}
function trim(str)
{
  return( (""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
}
function checkphone(x,y)
{
					var regexp=/^(\d{3}-\d{3}-\d{4}|\d{10}|\(\d{3}\)\d{3}-\d{4}|\d{6}|\d{7}|\d{8})$/;
						x = trim(x);
						if(!(regexp.test(x)))
						{
							var msg = "";
							msg = "Please enter the correct phone number.";
							msg = msg +  "\n The correct forms are : ";
							msg = msg + "\n xxx-xxx-xxxx";
							msg = msg + "\n (xxx)xxx-xxxx";
							msg = msg + "\n xxxxxxxxxx (10 digited Mobile no)";
							msg = msg + "\n xxxxxx (6 digits no)";
							msg = msg + "\n xxxxxxx (7 digits no)";
							msg = msg + "\n xxxxxxxx (8 digits no)";
							alert(msg);
						    y.focus();
							return false; 
					}
					return true;
}
function checkfax(x,y)
{
					var regexp=/^(\d{3}-\d{3}-\d{4}|\d{10}|\(\d{3}\)\d{3}-\d{4}|\d{6}|\d{7}|\d{8})$/;
						x = trim(x);
						if(!(regexp.test(x)))
						{
							var msg = "";
							msg = "Please enter the correct fax number.";
							msg = msg +  "\n The correct forms are : ";
							msg = msg + "\n xxx-xxx-xxxx";
							msg = msg + "\n (xxx)xxx-xxxx";
							msg = msg + "\n xxxxxxxxxx (10 digited Mobile no)";
							msg = msg + "\n xxxxxx (6 digits no)";
							msg = msg + "\n xxxxxxx (7 digits no)";
							msg = msg + "\n xxxxxxxx (8 digits no)";
							alert(msg);
						    y.focus();
							return false; 
					}
					return true;
}
function emailcheck(object,str)
{
var email=object.value;
var matcharray=email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z]+)*\.[A-Za-z]+$/) 
	if(matcharray==null){
	alert(str);
	 	object.focus();
		object.select();
	return false;
	}
	else 
		return true;
}
/*	function validateURL(url){
	
	// This function is used to validate a given 
	// address for the proper syntax
	url="http://"+url;
	var re;
	re = new RegExp("(http|ftp|https)://[-A-Za-z0-9._/]+");
	if (re.test(url)==false)
		return false;

	posOfAtSign = url.indexOf(".")

	if (posOfAtSign == -1){
		return false;
	}
	return true;
}*/
function textCounter(field,maxlimit) {
if (eval(field.value.length) > maxlimit) 
field.value = field.value.substring(0, maxlimit);
}
function numericcheck(object,str)
{
	var value=object.value;
	if (isNaN(value)==true)
	{
		alert(str);
		object.focus();
		object.select();
		return false;
	}
	else return true;	
}
function checkFirstName(theform,value)
{
	if (!empty(theform.value,"Please enter the first name.")) return false;
	if(!checkLetters( trim(theform.firstname.value),"First name can have only alphabets (A-Z)." ))
	{	
		theform.firstname.focus();
		return false;
	}
}

function isvalidSubdomain(obj,msg)
{
	var chk="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789";
	var str=obj.value;
	var allvalid=1;
	for (i = 0;i<str.length;  i++)
	 {
		ch = str.charAt(i);
		if(chk.indexOf(ch)==-1)
		{
			allvalid=0;
		}	
	}	
  if (allvalid==0)
  {
    alert(msg+" cannot have special characters.");
    obj.focus();
	obj.select();
	return false;
  }
return true;
}
function validatedomain(myobject)
{
	var strURL = myobject.value;
	if (strURL!="")
	{
		var is_protocol_ok=strURL.indexOf('www');
		var is_dot_ok=strURL.indexOf('.');
		if (((is_protocol_ok==-1) && (is_dot_ok!=-2)) || ((is_protocol_ok!=-1) && (is_dot_ok==-1)))
		{ 
		 alert("Please enter correct DOMAIN. \n www.test.com");
		 myobject.focus();
		 return false;
		}

	}
	return true;
}
function validateURL(myobject)
{
	// This function is used to validate a given 
	// address for the proper syntax
	url="http://"+myobject.value;
	//alert(url);
	var re;
	//re = new RegExp("(http|ftp|https)://[-A-Za-z0-9._/]+");
	re = new RegExp("(http|ftp|https)://[-A-Za-z0-9_/]+[.][-A-Za-z0-9._/]+");

	if (re.test(url)==false){
		alert("Please enter valid website.");
		myobject.focus();
		return false;
	}
	posOfAtSign = url.indexOf(".")

	if (posOfAtSign == -1){
		alert("Please enter valid website.");
		myobject.focus();
		return false;
	}
	return true;
}
function CheckFileFormat(sFilePath ) 
	{

              if (sFilePath.replace(/\s/g, '') != '') 
				 {
                   var iLastIndex = sFilePath.lastIndexOf('.', sFilePath.length - 1);
                   var sFileExtension = sFilePath.substr(iLastIndex + 1);
                   if (sFileExtension != 'xls')  
				   {
                        alert('Please select a excel file.');

                        return false;
                   }
				 }
			return true;
}
//###########################################################################
function onlyAlphaNum(object,str)
{
 var valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 for (var i=0; i<object.value.length; i++)
 {
  if(valid.indexOf(object.value.charAt(i)) < 0) 
  {
   alert(str);
   object.focus();
   return false
  }
 }
 return true
}
//#############################################################################
 
function Zipcheck(object,str)
{
 var zip=object.value;
 var allvalid=0;
 var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 for (var i=0; i<object.value.length; i++)
 {
  if(valid.indexOf(object.value.charAt(i)) < 0) 
  {
	allvalid=1;
  }
 }
 if (allvalid==0)
 {
  alert(str);
   object.focus();
  object.select();
 return false;
 }
 else
	 return true;
}

function validateZIP(field) 
{
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}
function checkTestimonial(theform)
{	
	if (!empty(theform.sendername,"Please enter your Name.")) return false;
	if (!empty(theform.senderstate,"Please enter your State.")) return false;
	if (!empty(theform.senderservice,"Please enter, when did you use our service?")) return false;
	if (!empty(theform.sendercomment,"Please enter the Comments.")) return false;
}
function checkForm(theform)
{		
	if (!empty(theform.name,"Please enter the name.")) return false;
	if (!empty(theform.email,"Please enter the email.")) return false;
	if (!empty(theform.verifyemail,"Please verify the email.")) return false;
	if(theform.email.value!=theform.verifyemail.value)
	{
			alert("Please enter the correct email address.");
			theform.verifyemail.focus();
			return false;
	}
	if (!empty(theform.arrival_date,"Please enter the arrival date.")) return false;
	if (!empty(theform.size_of_accommodations,"Please enter the Accomodation Size.")) return false;
	if (!empty(theform.departure_date,"Please enter the departure date.")) return false;
	if (!empty(theform.occupants,"Please enter the number of occupants.")) return false;
  var temp=0;
		for (i=0; i<theform.accommodation_type.length; i++)
		{
			if (theform.accommodation_type[i].checked==true) temp=1;
			
		}
			if(temp==0)
			{
				alert("Please select the accommodation type.");
				//theform.accommodation_type.focus();
				return false;
			}

	
}