var docRoot = "";
//var docRoot = "/_dev";
/*
//#########################################
// Name: rating.js
// Version: 1.0
// Programmer: Kwan Yu Ng
// Create Date: 06/08/2007
// Last Modifly: 06/08/2007
//
// Summary:
// This program is use for calling the XmlHttpObject(The core of Ajax)
// Note: It will execute from the php program thought URL (exeRating.php)
//       Look at line 27,28
//#########################################
*/
var xmlHttp

function clickRatingBar(content_id,user_id,rate,unit,unitWidth){ 
	xmlHttp=myXmlHttpObject();
	if (xmlHttp==null){
  	alert ("Your browser does not support AJAX!");
  	return;
  }
  
  // Display the loading image
	document.getElementById('unit_ul'+content_id).innerHTML = '<div class="loading">Loading...</div>';   
	
	var url=docRoot+"/classes/RATING/exeRating.php";
	url=url+"?r="+rate+"&id="+content_id+"&uid="+user_id+"&u="+unit+"&uw="+unitWidth;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.send(null);
}

function clickRatingBarWithoutUpdate(rate,unit,unitWidth){ 
	document.getElementById('current_rating').style.width=parseInt(rate*unitWidth)+"px";
	document.getElementById('Review_rate').value=rate;
}

function myXmlHttpObject(){
	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;
}

function stateChanged() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById("inner").innerHTML=xmlHttp.responseText;
	}
}

