/*
Author: Addam M. Driver
Date: 10/31/2006
*/

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;
var bs;

// Rollover for image Stars //
function rating(num){
		
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	if(!rated){
		
		bs = num.id.split("_");
						
		s = bs[1];
		
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById(bs[0]+"_"+i).className = "on";
				holder = a+1;
				a++;
			}else{
				document.getElementById(bs[0]+"_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){
	if(!rated){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById(bs[0]+"_"+i).className = "";
			}
		}else{
			rating(preSet);
		}
	}
}

// When you actually rate something //
function rateIt(me){
	if(!rated){
		preSet = me;
		sendRate(me);
		rating(me);
	}
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
	document.getElementById(bs[0]+'_rating').innerHTML="<input type='hidden' name='" + bs[0] + "_rating' value='" + s + "' />"
}



<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=220');");
}
// End -->
