// JavaScript Document
/*
Author: Addam M. Driver
Date: 10/31/2006
*/

var sMax1;	// Isthe maximum number of stars
var holder1; // Is the holding pattern for clicked state
var preSet1; // Is the preSet1 value onces a selection has been made
var rated1;

// Rollover for image Stars //
function rating1(num){
	sMax1 = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax1++;	
		}
	}
	
	if(!rated1){
		s = num.id.replace("1_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax1; i++){		
			if(i<=s){
				document.getElementById("1_"+i).className = "on";
				holder1 = a+1;
				a++;
			}else{
				document.getElementById("1_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off1(me){
	if(!rated1){
		if(!preSet1){	
			for(i=1; i<=sMax1; i++){		
				document.getElementById("1_"+i).className = "";
			}
		}else{
			rating1(preSet1);
		}
	}
}

// When you actually rate something //
function rateIt1(me){
	if(!rated1){
		preSet1 = me;
		rated1=1;
		sendRate(me);
		rating1(me);
	}
}

var sMax2;	// Isthe maximum number of stars
var holder2; // Is the holding pattern for clicked state
var preSet2; // Is the preSet1 value onces a selection has been made
var rated2;

function rating2(num){
	sMax2 = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax2++;	
		}
	}
	
	if(!rated2){
		s = num.id.replace("2_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax2; i++){		
			if(i<=s){
				document.getElementById("2_"+i).className = "on";
				holder2 = a+1;
				a++;
			}else{
				document.getElementById("2_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off2(me){
	if(!rated2){
		if(!preSet2){	
			for(i=1; i<=sMax2; i++){		
				document.getElementById("2_"+i).className = "";
			}
		}else{
			rating2(preSet2);
		}
	}
}

// When you actually rate something //
function rateIt2(me){
	if(!rated2){
		preSet2 = me;
		rated2=1;
		sendRate(me);
		rating2(me);
	}
}

var sMax3;	// Isthe maximum number of stars
var holder3; // Is the holding pattern for clicked state
var preSet3; // Is the preSet1 value onces a selection has been made
var rated3;

function rating3(num){
	sMax3 = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax3++;	
		}
	}
	
	if(!rated3){
		s = num.id.replace("3_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax3; i++){		
			if(i<=s){
				document.getElementById("3_"+i).className = "on";
				holder3 = a+1;
				a++;
			}else{
				document.getElementById("3_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off3(me){
	if(!rated3){
		if(!preSet3){	
			for(i=1; i<=sMax3; i++){		
				document.getElementById("3_"+i).className = "";
			}
		}else{
			rating3(preSet3);
		}
	}
}

// When you actually rate something //
function rateIt3(me){
	if(!rated3){
		preSet3 = me;
		rated3=1;
		sendRate(me);
		rating3(me);
	}
}

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


