// Initiate xmlhttp
var xmlhttp = false;
var response="";
//Check if we are using IE.
try {
	//If the javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e) {
	//If not, then use the older active x object.
	try {
		//If we are using IE.
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (E) {
		//Else we must be using a non-IE browser.
		xmlhttp = false;
	}
}
//If we are using a non-IE browser, create a JavaScript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}
// End initiate xmlhttp

// Check required fields form - General
function checkFields (form) {
	// Create page variable that will verify captcha value, and response variable that will hold response of the page
	form.submit.disabled=true;
	var page="verify.php";
	var params="00N30000001Mrpt="+document.getElementById('00N30000001Mrpt').value+"&oid="+form.oid.value+"&sfga"+form.sfga.value+"&00N30000001AByk="+document.getElementById('00N30000001AByk').value+"&retURL="+form.retURL.value+"&salutation="+form.salutation.value+"&first_name="+form.first_name.value+"&last_name="+form.last_name.value+"&title="+form.title.value+"&company="+form.company.value+"&URL="+form.URL.value+"&email="+form.email.value+"&phone="+form.phone.value+"&fax="+form.fax.value+"&mobile="+form.mobile.value+"&street="+form.street.value+"&city="+form.city.value+"&state="+form.state.value+"&zip="+form.zip.value+"&country="+form.country.value+"&industry="+form.industry.value+"&audience="+document.getElementById('audience').value+"&criteria="+document.getElementById('criteria').value+"&about="+document.getElementById('about').value+"&captcha="+form.captcha.value;
	var response="";
	// Send request to that page
	xmlhttp.open("POST", page, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange = statechanged;
	function statechanged () {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			response = xmlhttp.responseText;
			if (response.substring(0, 13)=="The following") {
				document.getElementById('errors').style.visibility="visible";
				document.getElementById('errors').innerHTML=response;
				form.submit.disabled=false;
				scroll(0,0);
			}
			else {
				document.getElementById('errors').style.visibility="visible";
				document.getElementById('errors').innerHTML="Plase wait while processing";
				window.location.href ='http://www.e-healthcaresolutions.com/new/success_a.php';
			}
		}
	}
	xmlhttp.send(params);
	return false;
}

// Check required fields form - LWW Sales Rep
function checkFieldsLWWSalesRep (form) {
	// Create page variable that will verify captcha value, and response variable that will hold response of the page
	form.submit.disabled=true;
	var page="verifylwwsalesrep.php";
	// Construct interests variable
	var interests="";
	if (document.contactForm.Client_Interest.options[0].selected)
		interests+="Advertising";
	if (document.contactForm.Client_Interest.options[1].selected)
		interests+=";Roadblocks";
	if (document.contactForm.Client_Interest.options[2].selected)
		interests+=";eTocs";
	var params="00N30000001Mrpt="+document.getElementById('00N30000001Mrpt').value+"&oid="+form.oid.value+"&00N30000001AByk="+document.getElementById('00N30000001AByk').value+"&retURL="+form.retURL.value+"&salutation="+form.salutation.value+"&first_name="+form.first_name.value+"&last_name="+form.last_name.value+"&title="+form.title.value+"&company="+form.company.value+"&URL="+form.URL.value+"&email="+form.email.value+"&phone="+form.phone.value+"&fax="+form.fax.value+"&mobile="+form.mobile.value+"&street="+form.street.value+"&city="+form.city.value+"&state="+form.state.value+"&zip="+form.zip.value+"&country="+form.country.value+"&industry="+form.industry.value+"&audience="+document.getElementById('audience').value+"&criteria="+document.getElementById('criteria').value+"&about="+document.getElementById('about').value+"&captcha="+form.captcha.value+"&Sales_Rep="+form.Sales_Rep.value+"&Journal="+form.Journal.value+"&Client_Interest="+interests;
	var response="";
	// Send request to that page
	xmlhttp.open("POST", page, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange = statechanged;
	function statechanged () {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			response = xmlhttp.responseText;
			if (response.substring(0, 13)=="The following") {
				document.getElementById('errors').style.visibility="visible";
				document.getElementById('errors').innerHTML=response;
				form.submit.disabled=false;
				scroll(0,0);
			}
			else {
				document.getElementById('errors').style.visibility="visible";
				document.getElementById('errors').innerHTML="Plase wait while processing";
				window.location.href ='http://www.e-healthcaresolutions.com/new/success_a.php';
			}
		}
	}
	xmlhttp.send(params);
	return false;
}

