// JavaScript Document
var myxmlhttp;
function voteset(){
	if(document.getElementById('rd_value').value==""){
		alert('من فضلك قم باختيار الرأي المناسب');
		return false;
	}
	var rd_value = document.getElementById('rd_value').value;
	doRequest('voteAjax.php?action=set&ch='+rd_value);
}
function doRequest (url) {
	myxmlhttp = CreateXmlHttpReq(resultHandler);
	if (myxmlhttp) {
		XmlHttpGET(myxmlhttp, "templates/includes/ar/"+url);
	} else {
		alert("An error occured while attempting to process your request.");
	}
}

function resultHandler () {
	if (myxmlhttp.readyState == 4) {
		if(myxmlhttp.status == 200) {
			document.getElementById("vote_div").innerHTML = myxmlhttp.responseText;
		}else{
			alert("There was a problem retrieving the data:\n" + req.statusText);
		}
	}
}

function CreateXmlHttpReq(handler) {
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			//alert('we found this exception: '+e);
		}
	}
	if (xmlhttp){
		xmlhttp.onreadystatechange =handler;
	}
	return xmlhttp;
}
function XmlHttpGET(xmlhttp, url) {
	try {
		xmlhttp.open("GET", url, true);
		xmlhttp.send(null);
	}catch(e){
		//alert('we found this exception: '+e);
	}
}


