startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
function PostHTTPRequest(script, call, onreadystatechange) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		try {
			req.onreadystatechange = onreadystatechange;
			req.open("POST", script, true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			req.send(call);
		} catch (e) {
   	  		alert(e);
   		}
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = onreadystatechange;
			req.open("POST", script, true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			req.send(call);
		}
	}
}
function ShowBlock( Obj ){
	document.getElementById(Obj).style.display = "block";
}
function ShowInline( Obj ){
	document.getElementById(Obj).style.display = "inline";
}
function Hide( Obj ){
	document.getElementById(Obj).style.display = "none";
}
function Disable( Obj ) {
	document.getElementById(Obj).disabled = true;
}
function Enable( Obj ) {
	document.getElementById(Obj).disabled = false;
}
// Get element by ID
function GEBI( Obj ){
	return document.getElementById(Obj);
}

function CheckPostContactForm()
{
	if (document.contact.name.value == "")
  {
    alert("Please enter your full name in the \"Name\" field.");
    document.contact.name.focus();
    return (false);
  }
  
	if (document.contact.email.value == "")
  {
    alert("Please enter your email in the \"Email\" field.");
    document.contact.email.focus();
    return (false);
  }
	
	call = "HTTPRequests/contact_us.php";
	querystring = "Action=Submit&name=" + GEBI("name").value +"&email=" + GEBI("email").value + "&phone=" + GEBI("phone").value + "&cell=" + GEBI("cell").value + "&comment=" + GEBI("comment").value;
	PostHTTPRequest(call, querystring, CheckPostContactForm_ProcessStateChange);

}

function CheckPostContactForm_ProcessStateChange(){
	if (req.readyState == 4) {
		if (req.status == 200) {		
				Hide("contactusform");
				ShowBlock("contactusformmessage");
				GEBI("contactusresult").innerHTML = req.responseText;
		}
	}
}

function CheckPostClassifiedForm()
{
	if (document.directoryregistration.name.value == "")
  {
    alert("Please enter your full name in the \"Name\" field.");
    document.directoryregistration.name.focus();
    return (false);
  }
	
	if (document.directoryregistration.company.value == "")
  {
    alert("Please enter your company's name in the \"Company\" field.");
    document.directoryregistration.company.focus();
    return (false);
  }
	if (document.directoryregistration.email.value == "")
  {
    alert("Please enter your email in the \"Email\" field.");
    document.directoryregistration.email.focus();
    return (false);
  }
	
	call = "HTTPRequests/directory_registration.php";
	querystring = "Action=Submit&name=" + GEBI("name").value +"&company=" + GEBI("company").value +"&address=" + GEBI("address").value +"&city=" + GEBI("city").value + "&state=" + GEBI("state").value + "&zip=" + GEBI("zip").value + "&email=" + GEBI("email").value + "&phone=" + GEBI("phone").value + "&fax=" + GEBI("fax").value + "&businesstype=" + GEBI("businesstype").value + "&comment=" + GEBI("comment").value;
  
	PostHTTPRequest(call, querystring, CheckPostClassifiedForm_ProcessStateChange);

}

function CheckPostClassifiedForm_ProcessStateChange(){
	if (req.readyState == 4) {
		if (req.status == 200) {		
				Hide("directoryregistrationform");
				ShowBlock("directoryregistrationformmessage");
				GEBI("directoryregistrationresult").innerHTML = req.responseText;
		}
	}
}

function CheckPostClassifiedOrderForm()
{
	if (document.order.name.value == "")
  {
    alert("Please enter your full name in the \"Name\" field.");
    document.order.contact.focus();
    return (false);
  }
	
	if (document.order.company.value == "")
  {
    alert("Please enter your company's name in the \"Company\" field.");
    document.order.company.focus();
    return (false);
  }
	if (document.order.email.value == "")
  {
    alert("Please enter your email in the \"Email\" field.");
    document.order.email.focus();
    return (false);
  }
	for(i=0; i<=8; i++)
	{
	 		if(GEBI("Classification"+i).checked)
			{
			   if(i == 8)
				 {
				    Classification = GEBI("SubjectOther2").value;
				 }
			   else
				 {
				    Classification = GEBI("Classification"+i).value;
				 }
			}
	}
	for(j=0; j<=6; j++)
	{
	 		if(GEBI("Network"+j).checked)
			{
				    Network = GEBI("Network"+j).value;
			}
	}
	call = "HTTPRequests/classified_ad_order_form.php";
	querystring = "Action=Submit&contact=" + GEBI("contact").value +"&company=" + GEBI("company").value +"&address=" + GEBI("address").value +"&city=" + GEBI("city").value + "&state=" + GEBI("state").value + "&zip=" + GEBI("zip").value + "&email=" + GEBI("email").value + "&telephone=" + GEBI("telephone").value + "&fax=" + GEBI("fax").value + "&date_insertion=" + GEBI("date_insertion").value + "&Network=" + Network + "&Classification=" + Classification + "&ad_copy=" + GEBI("ad_copy").value;
	PostHTTPRequest(call, querystring, CheckPostClassifiedOrderForm_ProcessStateChange);

}

function CheckPostClassifiedOrderForm_ProcessStateChange(){
	if (req.readyState == 4) {
		if (req.status == 200) {		
				Hide("orderform");
				ShowBlock("classifiedorderformmessage");
				GEBI("classifiedorderformresult").innerHTML = req.responseText;
		}
	}
}
