		function charsonly(cntrl_name, cntrl_org_name) {
	if(document.getElementById(cntrl_name).value.length > 0) {
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. "
		var ok = "yes";
		var str = document.getElementById(cntrl_name).value;
		var temp;
		for (var i=0; i<str.length; i++) {
			temp = "" + str.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			Err="Please enter a valid " + cntrl_org_name;
        		alert(Err);
			document.getElementById(cntrl_name).focus();
		  	return false;
	        }
	}
	return true;
}

function ValidateEmailID(cntrl_name)
 {
   if(document.getElementById(cntrl_name).value.length > 0) {
    var str = document.getElementById(cntrl_name).value;
    var re = /^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
	if (!str.match(re)) 
	{
		alert('Your email address is not in valid format')
		document.getElementById(cntrl_name).focus();
		return false;
	}
   }
  return true;
}

function Counter(field, maxlimit) {
	  if (document.getElementById(field).value.length != maxlimit)
      {
		alert("Number of characters must be: "+maxlimit);
		document.getElementById(field).focus();
		return false;
	  }
		return true;
	}

function digitsonly(cntrl_name, cntrl_org_name) {
     if(document.getElementById(cntrl_name).value.length > 0) {
	var valid = "0123456789.-+ "
	var ok = "yes";
	var temp;
	var field = document.getElementById(cntrl_name);
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") {
		Err="Please enter a valid " + cntrl_org_name;
        	alert(Err);
		document.getElementById(cntrl_name).focus();
		return false;
	}
     }
     return true;
}



function CheckExtentions(file) 
{
	extArray = new Array(".doc", ".pdf");
	allowSubmit = false;
	
	if (file.length > 0) {
		
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);

	ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; 
			break; }
		}

	if (allowSubmit == false) {
		alert("Please only upload files that end in types:  " 
			+ (extArray.join("  ")) + "\nPlease select a new "
			+ "file to upload and submit again.");
		return false;
	}
   }
	return true;
}

function validateForm()
{

if (document.forms[0].txtName.value == ""){
	alert('Please input Name!');
	document.forms[0].txtName.focus();
	return false;

	}
/*if(!charsonly('txtName','Name')) return false;*/

if (document.forms[0].txtCompany.value == ""){
	alert('Please input Company!');
	document.forms[0].txtCompany.focus();
	return false;
	}

/*if(!charsonly('txtCompany','Company')) return false;*/

if (document.forms[0].emailFrom.value == ""){
	alert('Please input EMail!');
	document.forms[0].emailFrom.focus();
	return false;
	}

if(!ValidateEmailID('emailFrom')) return false;

if (document.forms[0].txtPhone.value == "") {
	alert('Please input Phone !');
	document.forms[0].txtPhone.focus();
	return false;
	}

if(!digitsonly('txtPhone', 'Phone')) return false;
/*if (!Counter('txtPhone1', 2)) return false;*/


/*
emailMsg =  "Name: " +  document.forms[0].txtName.value + "; "
emailMsg += "Company: " +  document.forms[0].txtCompany.value + "; "
emailMsg += "Phone: " +  document.forms[0].txtPhone.value + "; "

if (document.forms[0].txtAddress1.value != "")
	emailMsg += "Address: " +  document.forms[0].txtAddress1.value + "; "

if (document.forms[0].txtAddress2.value != "")
	emailMsg += "Address: " +  document.forms[0].txtAddress2.value + "; "

if (document.forms[0].txtCity.value != "")
	emailMsg += "City: " +  document.forms[0].txtCity.value + "; "

if (document.forms[0].txtState.value != "")
	emailMsg += "State: " +  document.forms[0].txtState.value + "; "

if (document.forms[0].txtZip.value != "")
	emailMsg += "Zip: " +  document.forms[0].txtZip.value + "; "

if (document.forms[0].txtZip.value != "")
	emailMsg += "Zip: " +  document.forms[0].txtZip.value + "; "

if (document.forms[0].txtComment.value != "")
	emailMsg += "Comment: " +  document.forms[0].txtComment.value + ";"
	

msg = "Mail?emailMsg=" + emailMsg + "&emailTo=support@optionable.com" + "&emailSubject=Request from Get Started Form&emailFrom=" + document.forms[0].emailFrom.value + "&redirectUrl=getstarted_sub.html"
*/

document.forms[0].action = "getsent.jsp";
document.forms[0].submit();

}


