// JavaScript Document

function showResult(divs,args){
	//This div to open div in complete report
    document.getElementById(divs).style.display = 'block';
	document.getElementById(divs).innerHTML = args;
}


function postData(url,params,resCont)
{
	var http = GetXmlHttpObject();
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		document.getElementById(resCont).innerHTML = "";
		{
			if(http.readyState == 4 && http.status == 200) 
			{ 
				if(http.responseText=='1')
					{
						window.location = "thank-you.html";
					}
				else
					{
						showResult(resCont,http.responseText)
					}
			}
		}
	}
	http.send(params);
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

