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

function Rating(containerID, scale, url, imgStarMouseover)
{
	this.url = url;
	this.containerID = containerID;
	this.scale = scale;
	this.imgStarMouseover = imgStarMouseover;
	
	this.imgSrc = new Array()
	
	for (i = 0; i < this.scale; i++)
	{
		imgID = this.containerID + '_' + i;
		img = document.getElementById(imgID);
		this.imgSrc[i] = img.src;
	}
}

Rating.prototype.mouseover = function(n)
{
	for (i = 0; i <= n; i++)
	{
		document.getElementById(this.containerID + '_' + i).src = this.imgStarMouseover;
	}
}

Rating.prototype.mouseout = function(n)
{
	rating = this.rating;
	for (i = 0; i <= n; i++)
	{
		document.getElementById(this.containerID + '_' +i).src = this.imgSrc[i]; 
	}
}


Rating.prototype.rate = function(rating)
{
	xmlHttp = getXmlHttpObject();
	if(xmlHttp == null)
	{
		return;
	}
	xmlHttp.onreadystatechange = this.ratedone;
	url = this.url + '&rating=' + rating;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

Rating.prototype.ratedone = function()
{
	if (xmlHttp.readyState == 4)
	{
		temp = new Array();
		temp = xmlHttp.responseText.split('~');
		document.getElementById(temp[0]).innerHTML = temp[1];
		tempContainerID = null;
	}
}

