var pathname1 = document.location.pathname;
var pathname2 = pathname1.substring(pathname1.indexOf("/")+1,pathname1.length);
var ctxPath = "/" + pathname2.substring(0,pathname2.indexOf("/"));

/*
	This is javascript is used for Rating content
*/

function doRating(id, rating){
	var req = newXMLHttpRequest();
	req.onreadystatechange = getReadyStateHandlerForText(req, updateContents);
	req.open("POST", ctxPath + "/ratepage.form", true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send("component_id="+id+"&rating="+rating+"&doAction=save");
}

function updateContents(){
	return true;
}

function setRatingStars(componentId, count, callAction)
{
	for(var j=1;j<=7;j++){
		var obj = document.getElementById('star_img_' + j );
		if ( obj ) obj.className = "";
	}
	for(var i=1;i<=count;i++){
		var obj = document.getElementById('star_img_' + i );
		if ( obj ) obj.className = "starred";
	}
	if(callAction){
		currRating = count;	
		doRating(componentId, count);
	}
	document.getElementById('ratingUl').focus();
}