var xmlHttp = createXmlHttpRequestObject();
var id = null;


function createXmlHttpRequestObject()
{
  var xmlHttp;
  try
  {
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
    {
      try
      {
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      }
      catch (e) {}
    }
  }
  if (xmlHttp)
    return xmlHttp;
}



function submitForm()
{


	if(!xmlHttp)
	{
         
	return;
	
	}

	try{

	
	var name  =  document.getElementById("fName").value;
	var email = document.getElementById("fEmail").value;
	var phone = document.getElementById("fPhone").value;
	var body  = document.getElementById("fBody").value;
        var id =    tok;
	if(name == "" || body == "")
		{
			alert("Please include your name and a brief message.");
			return;
		}
	if(phone == "" && email == "")
		{
			alert("Please include your phone or email.");
			return;
		}
	
	if(body.length > 256)
		{
			var size = body.length - 256;
			alert("Your Message is " + size + " characters too long. The maximum size is 256 characters.");
			return;
		}

	if(phone == "")
		phone = -1;
	if(email == "")
		email = -1;

	
var pa = "&a="+id+"&b="+name+"&c="+email+"&d="+phone+"&e="+body;
      xmlHttp.open("GET", "/src/c/cont.php?" + pa, true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
      xmlHttp.send(null);



}
catch(e)
{
}




}





function handleRequestStateChange()
{

  if (xmlHttp.readyState == 4)
  {
    if (xmlHttp.status == 200)
    {
      try
      {
        handleServerResponse();
      }
      catch(e)
      {
      }
    }
    else
    {
    }
  }
}

function handleServerResponse()
{
  var xmlResponse = xmlHttp.responseXML;
  if (!xmlResponse || !xmlResponse.documentElement)
    throw("Invalid XML structure:\n" + xmlHttp.responseText);

  var rootNodeName = xmlResponse.documentElement.nodeName;
  if (rootNodeName == "parsererror")
    throw("Invalid XML structure:\n" + xmlHttp.responseText);
  xmlRoot = xmlResponse.documentElement;
  if (rootNodeName != "response" || !xmlRoot.firstChild)
    throw("Invalid XML structure:\n" + xmlHttp.responseText);
  responseText = xmlRoot.firstChild.data;



if(responseText = 1)
	goodResponse();
else
	goodResponse();
}

function goodResponse()
{
	var d = document.getElementById("contactForm");
	d.innerHTML = "<p><font color=\"green\"><strong>Thanks, your message has been recieved!</strong><br />We will contact you shortly</font></p>";

}



