// pollAJAX initialization

// Create AJAX object based on browser
if (navigator.appName == "Microsoft Internet Explorer") {
	pollajax = new ActiveXObject("Microsoft.XMLHTTP");
} else {
	pollajax = new XMLHttpRequest();
}

// Initialize
pollajax.abort();

function poll_vote(q,a) {

	// Resets state
	pollajax.abort();

	// Send command
	// PROBLEM : THE FULL URL DOES NOT WORK ON PRODUCTION SITE
	//pollajax.open("GET","{/literal}{$siteconfig->pnw->puburl}{literal}/polls/index.php?q="+q+"&a="+a);
	pollajax.open("GET","/polls/index.php?q="+q+"&a="+a);

	// Create input trapping function
	pollajax.onreadystatechange=function() {
		if (pollajax.readyState == 4) {
			eval(pollajax.responseText);
		}
	}

	// Send output
	pollajax.send("");
}
function poll_answer(question) {
	var answers = '';
	for (var i=0; i < document.forms['poll_container_'+question].poll.length; i++) {
		if (document.forms['poll_container_'+question].poll[i].checked) {
			answers = answers + '-' + document.forms['poll_container_'+question].poll[i].value;
		}
	}

	poll_vote(question, answers);
}
