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 frmContactUsValidate()  {
	var err="";	
	if(!isEmpty(document.eContactusForm.fullname.value))
		err+="Full Name\n";	
	if(!isEmpty(document.eContactusForm.emailaddress.value))
		err+="Email Address\n";
	else if(!isValidEmail(document.eContactusForm.emailaddress.value))
		err+="Invalid Email Address!\n";
	if(!isEmpty(document.eContactusForm.comments.value) || document.eContactusForm.comments.value=="(please type in your comments):")
		err+="Comments\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;
}
