//
// SEND A VOTE REQUEST
//
function poll_vote(form){
	//attempt to create a XmlHttp object
	if ((http_conn = GetXmlHttpObject()) == null) {
		alert('Your browser does not support AJAX!');
		return;
	}
	
	//make a http post request
	if (navigator.appName.indexOf('Microsoft') != -1) {
		url  = 'pages/rm_poll.php';
	} else {
		url  = document.getElementsByTagName('base')[0].href;
		url += 'pages/rm_poll.php';
	}		
	url += '?poll_option=' + escape(get_checked_option(form.poll_option));
	url += '&s_id=' + Math.random();
	
	//set the function that will handle the http request
	http_conn.onreadystatechange = function(){
		if (http_conn.readyState == 4) {
			document.getElementById('poll').innerHTML = http_conn.responseText;
		} else {
			document.getElementById('poll').innerHTML = '<img src="images/icon_loading.gif" alt="Loading"/ >';
		}
	}

	http_conn.open('GET', url, true);
	http_conn.send(null);
	return;
}

//
//CREATE A XmlHttpObject
//
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;
}

//
// GET WHICH RADIO BUTTON I SELECTED
//
function get_checked_option(radio_array){
	for (i = 0; i < radio_array.length; i++) {
		if (radio_array[i].checked) {
			return radio_array[i].value;
		}
	}
	return false;
}