


function validateFormProOnSubmit(theForm) {
	
	var reason = "";

	  reason += validateEmpty(theForm.company_name,'Company Name');
	  
	  reason += validateSelectBox(theForm.job_title,'Title');
	  
	  reason += validateEmpty(theForm.company_phone,'Phone Number');
	  
	  reason += validateEmpty(theForm.company_street,'Street Address');
	  
	  reason += validateEmpty(theForm.company_city,'City');
	  
	  reason += validateEmpty(theForm.company_state,'State / Province');
	  
	  reason += validateEmpty(theForm.company_zip,'Zip / Postal Code');
	  
	  reason += validateEmpty(theForm.company_country,'Country');
	 
	  if (reason != "") {
		alert("Some fields need correction:\n" + reason);
		return false;
	  }
	
	  return true;
}




function validateForm2OnSubmit(theForm) {
	

	
	var reason = "";
		
	  validateNotEmpty(theForm.subtype,'Sub Type');
	
	  reason += validateEmpty(theForm.name_first,'First Name');
	  
	  reason += validateEmpty(theForm.name_last,'Last Name');
	  
	  reason += validateEmpty(theForm.company_name,'Company Name');  
	  
	  reason += validateSelectBox(theForm.job_title,'Title');
	  
	  reason += validateEmpty(theForm.company_phone,'Phone Number');
	  
	  reason += validateEmpty(theForm.company_street,'Street Address');
	  
	  reason += validateEmpty(theForm.company_city,'City');
	  
	  reason += validateEmpty(theForm.company_state,'State / Province');
	  
	  reason += validateEmpty(theForm.company_zip,'Zip / Postal Code');
	  
	  reason += validateEmpty(theForm.company_country,'Country');
	 
	  if (reason != "") {
		alert("Some fields need correction:\n" + reason);
		return false;
	  }
	
	  return true;
}

function validateForm1OnSubmit(theForm) {
var reason = "";

  reason += validatePassword(theForm.password,theForm.password_verify);
  reason += validateEmail(theForm.email);
  
  
 
  if (reason != "") {
    alert("Unable to proceed because:\n" + reason);
    return false;
  }

 return true;
}


function validatePassword(fld,fld2) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
 	if (fld.value != fld2.value){
		fld.style.background = 'Yellow';
		fld2.style.background = 'Yellow';
        error = "The password fields do not match.\n";	
    } else if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password must be between 7 and 15 characters in length. \n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}


function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
	} else {
        fld.style.background = 'White';
    }
    return error;
}


function validateSelectBox(fld,fld_name) {
var error = "";

if (fld.selectedIndex==0) {
        fld.style.background = 'Yellow'; 
        error = "No option has been slected for "+fld_name+".\n"
    } else {
        fld.style.background = 'White';
    }
    return error;

}

function validateEmpty(fld,fld_name) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The "+fld_name+" field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}

function validateNotEmpty(fld,fld_name) {
    var error = "";
 
    if (fld.value.length > 0) {
        
		window.location="http://www.itoamerica.com/403.php";
    } else {
        fld.style.background = 'White';
    }
    return;  
}


function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}


// HTTP OBJECT SCRIPT BELOW THIS POINT 



var url = "email_check.php?email="; // The server-side script

function updateName() {
  // display a quick message while the script is being processed
  document.getElementById('response').innerHTML = "Checking Email Address ...";
  var name = document.getElementById('email_address').value;
  
	if (name == ""){
		results="Email can not be blank.";
		document.getElementById('response').innerHTML = '';
		alert(results);
		return;
	}
  
  http.open("GET", url + escape(name), true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function handleHttpResponse() {
  if (http.readyState == 4) {
    
		results = http.responseText;
		var email = document.getElementById("email_address").value;
		
		
		if(results == "" && email != "") {
			window.setTimeout('document.getElementById("response").innerHTML = "Email address OK !";', 1500);
			window.setTimeout('document.getElementById("response").innerHTML = "";', 3500);
			return;
		}
		
		alert(results);
		document.getElementById('response').innerHTML = '';
		document.getElementById('email_address').value = '';
		return;
  }
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object






  function dropInfo(blockId) {
	var blockNode = document.getElementById(blockId);
	if (blockNode.style.display == 'block'){
	  blockNode.style.display = 'none';
	} else {
	  blockNode.style.display='block';
	}
  }





