// All part of the Dynamic Star Rating by Jordan Boesch!
// http://creativecommons.org/licenses/by-nc-nd/2.5/ca/
// PRE-LOAD IMAGES -----------------------------

if (document.images){
  pic1 = new Image(220,19); 
  pic1.src = "../images/rating_loading.gif"; 

  pic2 = new Image(25,75); 
  pic2.src = "../images/rating_star.gif"; 

  pic3 = new Image(25,75); 
  pic3.src = "../images/rating_star_2.gif"; 
  
  pic4 = new Image(16,13); 
  pic4.src = "../images/rating_tick.gif";
  
  pic5 = new Image(14,14); 
  pic5.src = "../images/rating_warning.gif";
}

// AJAX ----------------------------------------

var xmlHttp

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;

}

// Calculate the rating
function rate(rating,id)
{
	xmlhttp = GetXmlHttpObject()
	
	if(xmlhttp == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }
	
	var url="http://www.bocks.nl/rating/includes/rating_process.php";
	url=url + "?id="+id+"&rating="+rating;
	//url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=debug;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);

} 

function debug()
{
	if (xmlhttp.readyState == 4)
  	{
		//alert(xmlhttp.responseText);
		
		window.location.reload(true);
	}
}
