var xmlHttp

//called from rate.php

function new_rating(str,rtg){ 
	
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){
  		alert ("Sorry your browser does not support our ratings!"); //AJAX!
  		return;
  	}

	//var url="scripts/add-vote.php?rid="+str+"&rating="+rtg; //old
	
	var url="scripts/add_vote_3.php?rating="+rtg; //updated - removed rid
	//url=url+"&sid="+Math.random(); ?not sure what this is
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function stateChanged(){ 
	if(xmlHttp.readyState==4){ 
		//innerhtml is non standard and might be causing the image errors!
		//document.getElementById("txtHint").innerHTML=xmlHttp.responseText; //replaces whats inside txtHint div on page!
		
		obj = document.getElementById("txtHint");
		
		//document.getElementById("txtHint").innerHTML=""; //clear innerHTML is bad!
		
		//better dom
		while(obj.firstChild){
			obj.removeChild(obj.firstChild);
		}
		
		//this works but still no images?
		

		
		//see also http://slayeroffice.com/articles/innerHTML_alternatives/
		
		//instead try dom method aproved by w3c from http://domscripting.com/blog/display/99
		var newdiv = document.createElement("div");
		newdiv.innerHTML = xmlHttp.responseText;
		
		var container = document.getElementById("txtHint");
		container.appendChild(newdiv);

		//not sure if this take html? only text
	}
}


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;
}


