// JavaScript Document
//function to chk for valid email
  function isValidEmail(VarEmail)
   {
    if(VarEmail.value == "" || VarEmail.length == 0)
	{
     //alert("Please enter Email Address");
     //VarEmail.focus();
	 return false;
	}	
	if(VarEmail.value!="")
    {
     if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(VarEmail.value)))
     {
	  //alert("Invalid Email address!")
      //VarEmail.focus();
      return false;
     }
    } 
   return true;
  }	
  
 function ChkEmpty(fld,Name)
	{
		if  ( !isNotEmpty( fld.value, Name ))
		{	
		 //fld.focus();
		 return false;
		}
		else
		 return true;		
	}

 function isNotEmpty(field, name)
	{
		if (field =="")
		{
			//alert("The " + name + " field is empty. Please enter the " + name + 			".");			
			return false;
		}
		
		for (var i=0;i < field.length;i++)
		{
			if (field.substring(i,i+1) != " ")
			{
			  return true;
			}
		}
		//alert("The " + name + " field is empty. Please enter the " + name + "." );
		return false
	}

 //function to validate phone number
 function isValidPhone(element, msg)
	{	
		var VarPhone = element.value;
		if (VarPhone != "")
		{
			var Phno;
			Phno=VarPhone;
			var valid = "-0123456789()";
			var hyphencount = 0;
			for (var i=0; i < Phno.length; i++) 
			{
				temp = "" + Phno.substring(i, i+1);
				if (valid.indexOf(temp) == "-1")
				{
					//alert("Invalid characters in your "+msg+". Please try again.");
					//element.focus();
					return false;
				}
			}
		 } 
		 return true;      
	}
	
	
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

