var sMax;	//-- the maximum number of stars
var holder; //-- the holding pattern for clicked state
var preSet; //-- the PreSet value onces a selection has been made
var rated;
var sName=new Array();

//-- Star rollover
function rating(num, idx){
	if (!sMax){
		sMax = 0;	//-- determine number of stars
		preSet = 0;
		for(n=0; n<num.parentNode.childNodes.length; n++){
			if(num.parentNode.childNodes[n].nodeName == "A"){
				sName[n] = num.parentNode.childNodes[n].id;
				if (num.parentNode.childNodes[n].className == "on"){
					preSet++;
				}
				sMax++;	
			}
		}
	}
	
	if(!rated){
		s = idx; //-- get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById(sName[i]).className = "on";
				document.getElementById("xpRateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById(sName[i]).className = "";
			}
		}
	}
}

//-- Rolling off of all the stars
function off(me){
	if(!rated){
		rating(me, preSet);
	}
}

//-- Clicking on a star saves the value
function rateIt(me, idx){
	if(!rated){
		preSet = idx;
		rated=1;
		sendRate(me);
		rating(me, idx);
		//document.getElementById("xpUnratedText").style.display = "none";
	}
}

//-- Write the value on the back-end.
function sendRate(sel){
	//alert("Your rating was: "+sel.title); //-- this is the confirmation
}

