window.li_width = "0px";

function star_rating(rating, user_id, type, type_id, window, rerating, hash)
{
	if (window.ActiveXObject) // for IE
	{
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) // for other browsers
	{
		httpRequest = new XMLHttpRequest();
	}
	
	var url = "/rating_acceptor.jsp?user_id=" + user_id + "&type=" + type + "&type_id=" + type_id + "&rating=" + rating + "&rerating=" + rerating + "&hash=" + hash;
	
	httpRequest.open("GET", url, true);
	httpRequest.send(null);
}

/**
	This method ensures that only gold stars are shown when hovering. Has no effect on gold-rated elements.
*/
function processMouseOver(id)
{	
	var li_parent = document.getElementById(id);
	window.li_parent = li_parent;
	window.li_width = li_parent.style.width;
	
	if (li_parent.className == "red-rating")
	{	
		li_parent.style.width = "0px";
	}
}

function processMouseOut()
{
	window.li_parent.style.width = window.li_width;
}

function stylechange(rating, parentID)
{
	var li_parent = document.getElementById(parentID);
	li_parent.style.background = "url(/images/ratings/star_rating_gold.gif) left bottom";
	var newWidth = (rating*17)+"px";
	li_parent.style.width = newWidth;
	window.li_width = newWidth;
}

function setRating(fieldId, value){
	var ratingField = document.getElementById(fieldId);
	ratingField.value = value;
}
