function ajaxFunction(){
 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){
       xmlHttp = "false";
     }
   }
 }
 return xmlHttp;
}
function vote(vote_id,content_id,name){
	xmlHttp = ajaxFunction();
	if (vote_id == 1){
		writeto = document.getElementById("left_vote_button");	
		writeto.innerHTML = "<img alt='Processing' src = 'http://www.whowasbest.com/images/indicator-black.gif'></img>";		
		writeto = document.getElementById("right_vote_button");	
		writeto.innerHTML = "<img alt='Processing' src = 'http://www.whowasbest.com/images/indicator.gif'></img>";		
	}else{
		writeto = document.getElementById("left_vote_button");	
		writeto.innerHTML = "<img alt='Processing' src = 'http://www.whowasbest.com/images/indicator-black.gif'></img>";		
		writeto = document.getElementById("right_vote_button");	
		writeto.innerHTML = "<img alt='Processing' src = 'http://www.whowasbest.com/images/indicator.gif'></img>";		
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			if (xmlHttp.responseText == "-1"){
				writeto = document.getElementById("left_vote_button");	
				writeto.innerHTML = "Already voted.";	
				writeto = document.getElementById("right_vote_button");	
				writeto.innerHTML = "Already voted.";	
			}else{
				temp = xmlHttp.responseText.split(',');
				for (m=0;m<8;m+=2){
					writeto = document.getElementById(temp[m]);
					writeto.innerHTML = temp[m+1];
				}
				writeto = document.getElementById("left_vote_button");	
				writeto.innerHTML = "Voted for <br /><strong>" +name+ "</strong>";	
				writeto = document.getElementById("right_vote_button");	
				writeto.innerHTML = "Voted for <br /><strong>" +name+ "</strong>";
			}
        	}
      	}
	mystring = "http://www.whowasbest.com/scripts/js/js_votes.php?id=" +content_id + "&vote_id=" + vote_id;
	xmlHttp.open("GET",mystring,true);
	xmlHttp.send(null);
}