function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function trim(inputString) {
   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) { // trim for multiple spaces within the string
	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
   }
   return retValue; 
}
function IsValidEmail(e) {
	if (document.frmMain) {
	char_first = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	char_second = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(char_first) && e.match(char_second)) {	return (-1); } 
	}
}
function IsValid(frm){
	if (trim(frm.name.value)==""){alert("Please enter your full name.");frm.name.focus();return false;}
	else if (trim(frm.name.value)=="Name"){alert("Please enter your full name.");frm.name.focus();return false;}
	else if (trim(frm.company.value)==""){alert("Please enter your Company.");frm.company.focus();return false;}
	else if (trim(frm.company.value)=="Company"){alert("Please enter your Company.");frm.company.focus();return false;}
	else if (trim(frm.url.value)==""){alert("Please enter your URL.");frm.url.focus();return false;}
	else if (trim(frm.url.value)=="URL"){alert("Please enter your URL.");frm.url.focus();return false;}
	else if (trim(frm.phone.value)==""){alert("Please enter your Phone Number.");frm.phone.focus();return false;}
	else if (trim(frm.phone.value)=="Phone"){alert("Please enter your Phone Number.");frm.phone.focus();return false;}
	else if (!IsValidEmail(trim(frm.email.value))){alert("Please enter a valid Email Address.");frm.email.focus();return false;}
	else{
		MM_openBrWindow('about:blank','formtarget','width=350,height=350');
		return true;
	}
}

