var xmlHttp;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					alert("Your browser does not support AJAX!");
						}
			}
		}
		xmlHttp.onreadystatechange= function() {
			if(xmlHttp.readyState == 4) {	
				if(xmlHttp.status==200) {
					if(xmlHttp.responseText != '' && xmlHttp.responseText != null) {
						
						pdiv = $$("poll_question").getElementsByTagName("div")[0];
						
						pdiv.removeChild(pdiv.childNodes[2]);
						pdiv.removeChild(pdiv.childNodes[1]);
						
						pdiv.innerHTML = pdiv.innerHTML + (xmlHttp.responseText);
							
					}
					else {
						alert("Invalid Response.");
					}
				}
				else {
					alert("Error during ajax request. Pleaes try again later.");
				}
			}
		}
		
		
function getCheckedValue(radioObj) {
	if(!radioObj)
		return false;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return false;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return false;
}


		
		
function send_poll(check_vals){
	
	if(check_vals == null){
		check_vals = true;
	}
	d = new Date;
	var rn = d.getTime();
	var parameters = "rn=" + encodeURI(rn);
	radios = document.forms['poll_question'].elements['vote_result'];
	
	resValue = false;
	resValue = getCheckedValue(radios);
	
	if(check_vals && !resValue){
		return false;
	}
	
	
	if(!check_vals){
		resValue = -1;
	} else {
		
		pdiv = $$("poll_question").getElementsByTagName("div")[0];
		pdiv.childNodes[1].innerHTML = "<table width='100%' border=0><tr><td valign='middle' align='center'><img src='images/loader.gif' style='padding: 30px 0px 30px' /></td></tr></table>";
		
	}	
	parameters += "&res="+resValue;
	
	var quid = document.getElementById("quid").value;
	
	parameters += "&quid="+quid;
	
	xmlHttp.open("POST","vote.php",true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
  	xmlHttp.setRequestHeader("Connection", "close");			
	xmlHttp.send(parameters);	
	return true;
}		

quid = $$("quid").value;

if(readCookie("vt_"+quid) == null){
	
	pdiv = $$("poll_question").getElementsByTagName("div")[0];
	pdiv.childNodes[2].style.display = "";
	pdiv.childNodes[1].style.display = "";
	
} else {
	send_poll(false);	
}

