var countStars = 0;
var viewallprods = true;
var staron = "images/staron.gif";
var staroff = "images/staroff.gif";

function getStar(off){
var toprate = 5;
	for(i = 0; i < off; i++){
		document.write('<img src="'+gpath+staron+'" />');
	}
	for(n = 0; n < (toprate-off); n++){
		document.write('<img src="'+gpath+staroff+'" />');
	}
}

function checkRateForm(thisform)
{
	var title = thisform.title;
	var name = thisform.name;
	var review = thisform.review;

	if(title.value == '') {
		alert('Please enter a title for your review');
		title.focus();
		return false;
	}
	if(name.value == '') {
		alert('Please enter your name');
		name.focus();
		return false;
	}
	if(review.value == '') {
		alert('Please enter your review');
		review.focus();
		return false;
	}
}

function Init()
{
	for (i=1; i<=5; i++)
		document["star" + i].src = gpath + staroff;
}
function Activate(pos)
{
	if (pos > 5) return;
	for (i=1; i<=pos; i++)
		document["star" + i].src = gpath + staron;
}
function openPopup(pos)
{
	countStars = pos;
	var addr = gpath + "stars-popup.php?stars=" + countStars + "&theid=" + gid + "&thename=" + escape(gname);
	var popUpWin=0;
	if(popUpWin){
		if(!popUpWin.closed)
			popUpWin.close();
	}
	popUpWin = open(addr,'reviewwin','scrollbars=no,resizable=no,top=0,left=0,width=600,height=300');
	popUpWin.focus();
}

function viewall(obj)
{
	if (viewallprods)
	{
		document.getElementById("reviews").style.display = "none";
		viewallprods = false;
		obj.innerHTML = "view ratings";
	} else {
		document.getElementById("reviews").style.display = "block";
		viewallprods = true;
		obj.innerHTML = "hide ratings";
	}		
}

function showallreviews (theid)
{
	var addr = gpath + "viewall.php?theid=" + theid;
	var showall=0;
	if(showall){
		if(!showall.closed)
			showall.close();
	}
	showall = open(addr,'reviewwin','scrollbars=yes,resizable=yes,top=0,left=0,width=438,height=470');
	showall.focus();
}