var xmlHttp

// Function to make an asyncronis call to display poll question & results.
function getPoll(pid, aid, http)
{
/*
ARGUMENTS:
pid
  Required. Id of the poll to display.
aid
  Required. Id of the answer given.
http
  Required. Hypertext Transfer Protocol and Uniform Resource Locator to use.
*/
    xmlHttp = getXmlHttpObject()
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return
	}
	var url = http + "polls/ajax_poll.asp"
	url = url + "?pid=" + pid
	url = url + "&aid=" + aid
	
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
	
    var image = http + "images/common/polls/poll_load.gif"
    document.getElementById("poll").innerHTML = '<div class="mgnt10 tac" style="padding: 88px 0; background: #f5f5f5"><img src=' + image + ' width="31" height="31" alt="" /></div>';
} 

// Function to create an XML HTTP Request Object
function getXmlHttpObject()
{ 
	var objXMLHttp = null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

// Function to check the state of the HTTP request
function stateChanged() 
{
    // Load is complete
	if (xmlHttp.readyState == 4)
	{
	    //document.getElementById("poll").innerHTML = xmlHttp.responseText;
		
		// Url exists
        if (xmlHttp.status == 200)
        {
            // Delay displaying results to show loading image
            setTimeout('displayResults()', 0);
        }
	}
}

// Function to display poll on page
function displayResults()
{
	document.getElementById("poll").innerHTML = xmlHttp.responseText;
}

