var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet = new Array(30); // Is the PreSet value once a selection has been made. Max of 30 items
var rated = new Array(30);  // Max of 30 items to rate
for (i=0; i<30; i++) { rated[i]=0; }
for (i=0; i<30; i++) { preSet[i]=0; }

// Rollover for image Stars //
function rating(num){
	sMax = 0;	// Is the maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}			
	parentNum = num.parentNode.id.replace("rateMe", "");
	if(!rated[parentNum]){
		s = num.id.split("_")[1]; // Get the selected star
		//alert("num=" + num + ", s (selected star) = " +s);
		a = 0;
		for(i=1; i<=sMax; i++) {
			starName = parentNum + "_" + i;		
			if(i<=s){				
				//alert("Star: " + nodeName);
				document.getElementById(starName).className = "on";
				holder = a+1;
				a++;
			}else{
				document.getElementById(starName).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){	    
	parentNum = me.parentNode.id.replace("rateMe", "");	
	if(!rated[parentNum]){		
		if(!preSet[parentNum]){		
		    for(i=1; i<=sMax; i++){		
			    document.getElementById(parentNum + "_"+i).className = "";				
			}
		}else{
			rating(preSet[parentNum]);			
		}
	}
}

// When you actually rate something //
function rateIt(me){
	parentNum = me.parentNode.id.replace("rateMe", "");
	if(!rated[parentNum]){		
		preSet[parentNum] = me;				
		rated[parentNum]=1;		
		sendRate(me);
		rating(me);
	}	
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
	//alert("Your rating was: "+sel.title);
}

function googleWide(){
    window.scroll(0, 20000);
}


