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;
}
			
function pollRequest() { 
	if (xmlHttp.readyState==1){				
		document.getElementById("content_inquiry").innerHTML="<div style=\"width:60px; text-align: center; margin: 0 auto;margin-top: 50px;\"><img src=\"./images/loading.gif\" /><br /> Loading ...</div>";		
	}
	if (xmlHttp.readyState==4){				
		document.getElementById("content_inquiry").innerHTML=xmlHttp.responseText;		
	}		
}
			
function vote(answer_id,poll_id){
		
	
	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Your browser does not support AJAX!");
			return;
	}
	
	var url="poll.php";
	url=url+"?answer="+answer_id + "&poll_id="+poll_id;
	xmlHttp.onreadystatechange=pollRequest;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function votePoll() {
	var radioButtons = document.pollForm.elements['myvote'];
	var radioLength = radioButtons.length;
	
	if(radioLength == undefined) {
		if(radioButtons.checked) {
			return radioButtons.value;		
		}
	}
	
	for(var i = 0; i < radioLength; i++) {
		if(radioButtons[i].checked) {
			vote(radioButtons[i].value,document.pollForm.poll_id.value);
		}
	}	
}

function showResPoll() {
	vote("",document.pollForm.poll_id.value)
}
