// JavaScript Document\var thisDiv = "";
var current_classes = new Array();
var i = 1;
var k = 1;
var myDivNum = 1;

function getCurrentClasses(){
	i = 1;
	for (i=1; i<=5; i++){
		thisDiv = "#rating_" + i;
		if($(thisDiv).hasClass('ratingDiv_null')) {
			current_classes[i - 1] = "ratingDiv_null";				
		}else if ($(thisDiv).hasClass('ratingDiv_half')) {
			current_classes[i - 1] = "ratingDiv_half";				
		}else if ($(thisDiv).hasClass('ratingDiv_full')) {
			current_classes[i - 1] = "ratingDiv_full";				
		}			
	}
}


function removeClasses(){
	i = 1;	
	for (i=1; i<=5; i++){
		thisDiv = "#rating_" + i;
		if($(thisDiv).hasClass('ratingDiv_full')) {
			$(thisDiv).removeClass('ratingDiv_full');
			$(thisDiv).addClass('ratingDiv_null');
		}else if ($(thisDiv).hasClass('ratingDiv_half')) {
			$(thisDiv).removeClass('ratingDiv_half');
			$(thisDiv).addClass('ratingDiv_null');			
		}
	}		
}

function highlight(myDivNum){		
	k = 1;		
	for (k=1; k<=myDivNum; k++){
		thisDiv = "#rating_" + k;
		$(thisDiv).removeClass('ratingDiv_null');
		$(thisDiv).addClass('ratingDiv_full');
	}
}

function restoreClasses(){
	i = 1;
	for (i=1; i<=5; i++){
		thisDiv = "#rating_" + i;
		if($(thisDiv).hasClass('ratingDiv_null')) {
			$(thisDiv).removeClass('ratingDiv_null');
			$(thisDiv).addClass(current_classes[i - 1]);								
		}else if ($(thisDiv).hasClass('ratingDiv_half')) {
			$(thisDiv).removeClass('ratingDiv_half');
			$(thisDiv).addClass(current_classes[i - 1]);
		}else if ($(thisDiv).hasClass('ratingDiv_full')) {
			$(thisDiv).removeClass('ratingDiv_full');
			$(thisDiv).addClass(current_classes[i - 1]);
		}			
	}
}

$(document).ready(function(){
	$("#rating_1").mouseover(function(){
		$(this).css("cursor", "pointer");
		getCurrentClasses();	
		removeClasses();							
		highlight(1);
		$("#rating_msg").html("Poor");			
	});
	
	$("#rating_1").mouseout(function(){
		$(this).css("cursor", "default");
		restoreClasses();	
		$("#rating_msg").html("");
	});
	
	$("#rating_2").mouseover(function(){
		$(this).css("cursor", "pointer");
		getCurrentClasses();	
		removeClasses();							
		highlight(2);
		$("#rating_msg").html("Nothing Special");
	});
	
	$("#rating_2").mouseout(function(){
		$(this).css("cursor", "default");
		restoreClasses();
		$("#rating_msg").html("");
	});
	
	$("#rating_3").mouseover(function(){
		$(this).css("cursor", "pointer");
		getCurrentClasses();	
		removeClasses();							
		highlight(3);
		$("#rating_msg").html("Worth Watching");
	});
	
	$("#rating_3").mouseout(function(){
		$(this).css("cursor", "default");
		restoreClasses();
		$("#rating_msg").html("");
	});
	
	$("#rating_4").mouseover(function(){
		$(this).css("cursor", "pointer");
		getCurrentClasses();	
		removeClasses();							
		highlight(4);
		$("#rating_msg").html("Pretty Cool");
	});
	
	$("#rating_4").mouseout(function(){
		$(this).css("cursor", "default");
		restoreClasses();
		$("#rating_msg").html("");
	});
	
	$("#rating_5").mouseover(function(){
		$(this).css("cursor", "pointer");
		getCurrentClasses();	
		removeClasses();							
		highlight(5);
		$("#rating_msg").html("Awesome!");
	});
	
	$("#rating_5").mouseout(function(){
		$(this).css("cursor", "default");
		restoreClasses();
		$("#rating_msg").html("");
	});		
});