var xmlhttp;
	
function setBarWidth( element, width )
{
	var maxWidth = element.parentNode.clientWidth;
	var newWidth = width/100 * maxWidth - 2;
	element.style.width = newWidth + "px";
}

function pollProcess( caller )
{
	//caller.disabled = true;
	
	var poll_id;
	var poll_choice;
	inputNodes = caller.parentNode.getElementsByTagName("input");
	for( var x in inputNodes)
	{
		if( inputNodes[x].name == "poll_id" )
		{
			poll_id = inputNodes[x].value;
		}
		if( inputNodes[x].name == "choice" && inputNodes[x].checked	== true )
		{
			poll_choice = inputNodes[x].value;
		}
	}
	
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP!");
	  }
	xmlhttp.onreadystatechange=handleReturn;
	var url = "includes/poll_process.php?";
	url = url+"id="+poll_id;
	url = url+"&choice="+poll_choice;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	//caller.disabled = false;
}

function handleReturn(){
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
		{
			if( xmlhttp.responseText == "" ){
				alert("no return");				
			}else{
				document.getElementById( "poll_container" ).innerHTML = xmlhttp.responseText;
			}
		}
		else
		{
			alert("Problem retrieving XML data");
		}
	}
	else if( xmlhttp.readyState == 1 )
	{
		document.getElementById( "poll_container" ).innerHTML = "Processing...";
	}
}