var countStars = 0;
var viewallprods = false;
var staron = "staron.gif";
var staroff = "staroff.gif";
var gpath = 'reviews/';

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

function checkRateForm(thisform)
{
	var title = thisform.title;
	var name = thisform.name;
	var review = thisform.review;
	var stateCountry = thisform.stateCountry;
    
	starC = thisform.star[0].checked || thisform.star[1].checked || thisform.star[2].checked || thisform.star[3].checked || thisform.star[4].checked;
	if (!starC) {
	  alert('Please enter your rating');
	  return false;
	}
    
	if(name.value == '') {
		alert('Please enter your initials');
		name.focus();
		return false;
	}
	
	if(stateCountry.value == '') {
		alert('Please enter your State/Country');
		stateCountry.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, gid, gname)
{
	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=720,height=450');
	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 + "psite-rating.php?theid=" + theid + "&thename=" + escape(gname);
	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();
}
