var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	var xmlHttp;
		
	if(window.ActiveXObject)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			xmlHttp = false;
		}
	}
	else
	{
		try
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch(e)
		{
			xmlHttp = false;
		}
	}
		
	if(!xmlHttp)
	{
		return false;
	}
	else
	{
		return xmlHttp;
	}
}

function updateTestimonial()
{
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{	
		var postString = "go=1&key=I2hc5F9G";
		
		xmlHttp.open("POST", "testimonial.php", true);
		xmlHttp.onreadystatechange = handleServerResponse;
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		xmlHttp.send(postString);
	}
	else
	{
		setTimeout("updateTestimonial()", 1000);
	}
	
}

function handleServerResponse()
{
	//try
	{
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status == 200)
			{
				xmlResponse = xmlHttp.responseXML;
				xmlDocumentElement = xmlResponse.documentElement;
				
				testimonial = xmlResponse.getElementsByTagName("testimonial")[0].firstChild.data;
				document.getElementById("testimonial_testimonial").innerHTML = testimonial.replace(/_/, "");
				
				customer = xmlResponse.getElementsByTagName("name")[0].firstChild.data;
				document.getElementById("testimonial_name").innerHTML = customer.replace(/_/, "");
				
				city = xmlResponse.getElementsByTagName("city")[0].firstChild.data;
				document.getElementById("testimonial_city").innerHTML = city.replace(/_/, "");
			}
			else
			{
				return false;
			}
			
		}
		
	}
	//catch(e)
	{
		//document.getElementById("testimonial_city").innerHTML = "";
	}
	
}