var xmlHttp
var poll
var vote

window.onload = function () {
	form2();
}

function form2(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="poll.php"
	xmlHttp.onreadystatechange=getstatechange 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function sendvote(poll,vote){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="poll.php"
	url += "?poll=" + poll;
	url += "&vote=" + vote;
	xmlHttp.onreadystatechange=getstatechange 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}	


function getstatechange() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('poll').innerHTML = xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml.XMLHTTP");
		}
	 	catch (e)
	 	{
	 	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	 	}
	}
	return xmlHttp;
}