function SearchMe(e){
	if(e.keyCode == 13){
		if(document.frmsearch.txtsearch.value==""){
			alert("Enter Search Value");
			return false;
		}
		return true;
	}
}

function isEmpty(strval) {
    if (strval == "" || strval == null || !isNaN(strval) || strval.charAt(0) == ' ')
    {
    return false;
    }
	else
	return true;
  }

//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = strEmail;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
     return false;
    } 
    return true; 
}

function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function frmQuickContactValidate()  {
	var err="";	
	if(!isEmpty(document.QuickContact.name.value)  || document.QuickContact.name.value == "Name:")
		err+="Name\n";	
	if(!isEmpty(document.QuickContact.email.value) || document.QuickContact.email.value == "E-mail:")
		err+="Email Address\n";
	else if(!isValidEmail(document.QuickContact.email.value))
		err+="Invalid Email Address!\n";
	if(!isEmpty(document.QuickContact.phone.value) || document.QuickContact.phone.value == "Phone:")
		err+="Phone\n";
	if(!isEmpty(document.QuickContact.comments.value) || document.QuickContact.comments.value == "Question/Comments")
		err+="Question/Comments\n";	
	if(!isEmpty(document.QuickContact.vercode.value) || document.QuickContact.vercode.value == "Enter Code:")
		err+="Enter Code above:\n";	
	if(err!="") {
		alert("Following field(s) are required!\n----------------------------\n"+err);
		return false;
	}
	return true;
}

function frmContactUsValidate()  {
	var err="";	
	if(!isEmpty(document.EmailForm.name.value))
		err+="Name\n";	
	if(!isEmpty(document.EmailForm.email.value))
		err+="Email Address\n";
	else if(!isValidEmail(document.EmailForm.email.value))
		err+="Invalid Email Address!\n";
	if(!isEmpty(document.EmailForm.reason.value))
		err+="Why are you getting in touch with us?\n";	
	if(!isEmpty(document.EmailForm.message.value) )
		err+="Comments\n";	
	if(!isEmpty(document.EmailForm.vercode.value) )
		err+="Verification Code\n";		
	if(err!="") {
		alert("Following field(s) are required!\n----------------------------\n"+err);
		return false;
	}
	return true;
}

function is_valid_url(urlz) {
     var theurl=urlz;
     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(theurl))
     {
         return true;
     }
     else
     {
         return false; 
     }
}

function frmLinkUsValidate()  {
	var err="";	
	if(!isEmpty(document.eLinkForm.fname.value))
		err+="Full Name\n";	
	if(!isEmpty(document.eLinkForm.bizname2.value))
		err+="Business Name\n";
	else if(!is_valid_url(document.eLinkForm.url.value))
		err+="Invalid URL\n";
	if(!isEmpty(document.eLinkForm.email.value))
		err+="Email Address\n";
	else if(!isValidEmail(document.eLinkForm.email.value))
		err+="Invalid Email Address!\n";
		
	if(err!="") {
		alert("Following field(s) are required!\n----------------------------\n"+err);
		return false;
	}
	return true;
}
