function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
    {
      return true;
    }
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
        var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
        if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function cntValidation(frm){
 var charpos = trim(document.forms[frm].Name.value).search("[^A-Za-z0-9 ]"); 
 
 if(trim(document.forms[frm].Name.value) == "" ){
    alert("Please Enter Name");
	document.forms[frm].Name.focus();
	return false;
 }else  if(trim(document.forms[frm].Name.value).length > 0 &&  charpos >= 0){
    alert("Please Enter Only Alphanumerics For Name");
	document.forms[frm].Name.focus();
	return false;
 }else if(trim(document.forms[frm].email.value) == "" ){
    alert("Please Enter Email");
	document.forms[frm].email.focus();
	return false;
 }else if(!validateEmailv2(trim(document.forms[frm].email.value))){
    alert("Please Enter Valid Email");
	document.forms[frm].email.focus();
	return false;
 }else if(trim(document.forms[frm].subject.value) == ""){
    alert("Please Enter Subject");
	document.forms[frm].subject.focus();
	return false;
 }else if(trim(document.forms[frm].message.value) == ""){
    alert("Please Enter Message");
	document.forms[frm].message.focus();
	return false;
 }
return true;
 //return false;

}
function openPopUr1(url){
	//alert(url);
	newwindow=window.open(url,'name','height=800,width=800');
	if (window.focus) {newwindow.focus()}
	return false;
}