var xmlHttp = createXmlHttpObject();

function QCsubmit()
{



	if (document.getElementById("Name").className == "inputTextError" || document.getElementById("Name").value == "Name")
	{
		document.getElementById("Name").className = "inputTextError";
	} 
	else
	{
		var name = document.getElementById("Name").value;
	}	

	if (document.getElementById("Email").className == "inputTextError" || document.getElementById("Email").value == "Email")
	{
		document.getElementById("Email").className = "inputTextError";
	} 
	else
	{
		var email = document.getElementById("Email").value;
	}	

	if (document.getElementById("Phone").className == "inputTextError" || document.getElementById("Phone").value == "Phone")
	{
		document.getElementById("Phone").className = "inputTextError";
	} 
	else
	{
		var phone = document.getElementById("Phone").value;
	}	

	if (document.getElementById("Contact_Reason").value == "")
	{
		document.getElementById("showReason").className = "showReasonError";
	} 
	else
	{
		var reason = document.getElementById("Contact_Reason").value;
		document.getElementById("showReason").className = "showReason";
	}	

	if (typeof(name) != "undefined" && typeof(email) != "undefined" && typeof(phone) != "undefined")
	{

		var data = "action=submit&name=" + name + "&email=" + email + "&phone=" + phone + "&reason=" + reason ;

		if (xmlHttp)
		{
			try
			{ 
				document.body.style.cursor = "wait";
				xmlHttp.open("POST", "/proc/quickconnect.php", true);
				xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xmlHttp.onreadystatechange = handleQC;
				xmlHttp.send(data);
			}
			catch(e)
			{
				alert("Failed to connect to server: " + e.toString());
			}
		}
	}
}


function createXmlHttpObject()
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		}
		catch(e) { }
	}
	if (!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else
		return xmlHttp;
}

function handleQC()
{
	if (xmlHttp.readyState == 4)
	{
		if (xmlHttp.status == 200)
		{
			try
			{
				handleQCResponse();
			}
			catch(e)
			{
				alert("Error reading the response: " + e.toString());
			}
		}
		else
		{
			alert("There was a problem retrieving the data: " + xmlHttp.statusText);
		}
	}
}

function handleQCResponse()
{
	response = xmlHttp.responseText;

	target = document.getElementById("quickconnectform");
	if (response == 0)
	{
		target.innerHTML = "<br><br><p>Your request has been submitted to Xecunet. You will be contacted shortly.</p>";
	} 
	document.body.style.cursor = "default";
}



