 function ltrim(str) { 
					for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
					return str.substring(k, str.length);
				}
				function rtrim(str) {
					for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
					return str.substring(0,j+1);
				}
				function trim(str) {
					return ltrim(rtrim(str));
				}
				function isWhitespace(charToCheck) {
					var whitespaceChars = " \t\n\r\f";
					return (whitespaceChars.indexOf(charToCheck) != -1);
				}
function validate(frm)
 { 
 
 //alert(document.getElementById("interestid").length);
 if(trim(frm.name.value)=="")
     {
       alert("Please fill name");
       frm.name.focus();
	    return false;
     }
	
	  if(frm.email.value=="")
        {   alert("Please Enter Your Email Address.");
	        frm.email.focus();
	         return false;
	    }
      else 
        {    var emailStr=frm.email.value;
            // checks if the e-mail address is valid
            var emailPat = /^(\".*\"|[A-Za-z]\w*|[A-Za-z]\w*(\.?\w*))@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
            var matchArray = emailStr.match(emailPat);
            if (matchArray == null) {
              alert("Your email address seems incorrect.  Please try again (check the '@' and '.'s in the email address)");
			  frm.email.focus();
               return false;   
		     }				
			
         }
  if(GetSelectedItem(document.getElementById("interestid"))=="")
     {
       alert("Please select interest");
        document.getElementById("interestid").focus();
	    return false;
     }
    if(trim(frm.company.value)=="")
     {
       alert("Please fill the company name");
       frm.company.focus();
	    return false;
     }
    if(trim(frm.country.value)=="")
     {
       alert("Please fill the country name");
       frm.country.focus();
	    return false;
     } 
    if(trim(frm.message.value)=="")
     {
       alert("Please write message");
       frm.message.focus();
	    return false;
     }
  if(trim(frm.verify.value)=="")
     {
       alert("Please enter the verification code given below");
       frm.verify.focus();
	    return false;
     }
	
 	
 }

function GetSelectedItem(list)
  {
  var  len = list.length
		
    i = 0
  var  val= "";

   for (i = 0; i < len; i++)
	{
       if (list[i].selected)
	    {
		   val+=list[i].value;
        } 
    }

 
 return val;
} 


function validate_business(frm)
 {       
 if(trim(frm.firstname.value)=="")
     {
       alert("Please fill name");
       frm.firstname.focus();
	    return false;
     }    
  else if(trim(frm.Title.value)=="")
     {
       alert("Please fill the job title");
       frm.Title.focus();
	    return false;
     }    
  else if(trim(frm.company.value)=="")
     {
       alert("Please fill the company name");
       frm.company.focus();
	    return false;
     }
  else if(trim(frm.phone.value)=="")
     {
       alert("Please enter the phone number");
       frm.phone.focus();
	    return false;
     }
  else if(trim(frm.interest.value)=="")
     {
       alert("Please write interest");
       frm.interest.focus();
	    return false;
     } 
    else 
	{ 
	  if(frm.email.value=="")
        {   alert("Please Enter Your Email Address.");
	        frm.email.focus();
	         return false;
	    }
      else 
        {    var emailStr=frm.email.value;
            // checks if the e-mail address is valid
            var emailPat = /^(\".*\"|[A-Za-z]\w*|[A-Za-z]\w*(\.?\w*))@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
            var matchArray = emailStr.match(emailPat);
            if (matchArray == null) {
              alert("Your email address seems incorrect.  Please try again (check the '@' and '.'s in the email address)");
			  frm.email.focus();
               return false;   
		     }				
			
         }	 
	
	}	
	 if(trim(frm.verify.value)=="")
     {
       alert("Please enter the verification code given below");
       frm.verify.focus();
	    return false;
     }
	
	
 }


