function updateDiv(div_name,user_id){
	post_id=div_name.replace(/vote_count_/g,"");
	//alert("http://www.senisub.com/xml_interface.php?post_id="+post_id+"&user_id="+user_id);
	ajaxRead("xml_interface.php?post_id="+post_id+"&user_id="+user_id);
}

function getLatestVotes(){
	ajaxRead("xml_interface.php?latest_votes=1");
}

function createRequestObject() {
	var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{ ro = new XMLHttpRequest(); }
    return ro;
}

var xmlObj = createRequestObject();

function handleResponse(){			
	if(xmlObj.readyState == 4){
		<!--alert(xmlObj.responseText);-->
		if(xmlObj.responseXML.getElementsByTagName('vote_data').length > 0){
			parseLatestVotes(xmlObj);
		}else{
			counter=xmlObj.responseXML.getElementsByTagName('data')[0].firstChild.data;
			post_id=xmlObj.responseXML.getElementsByTagName('post_id')[0].firstChild.data;

			
			if(xmlObj.responseXML.getElementsByTagName('error').length > 0){
				alert("Notice: "+xmlObj.responseXML.getElementsByTagName('error')[0].firstChild.data);
			}

			div_name="vote_count_"+post_id;
			mydiv=document.getElementById(div_name);
			mydiv.innerHTML='<span class="vote_count_text">'+parseInt(counter)+'</span>';
		}
	}
}

function ajaxRead(file){
	xmlObj.open ('GET', file, true);
	xmlObj.onreadystatechange = handleResponse;
    xmlObj.send (null);
}
