$(document).ready(function () {
   	 starGreyClicked = false;			
	$('a.starGrey').hover (
		function () {			
	 		currentStarHover = $('a.starGrey').index(this);
			jQuery.each($('a.starGrey'), function(i) {
				if (i <= currentStarHover) {
					 $(this).addClass('full');
				}
				else {
					$(this).removeClass('full');
				}
			});
		}, 
		function () {
			if (!starGreyClicked) {
				$('a.starGrey').removeClass('full');
			}
		}
		
	);
	
	$('a.starGrey').click (
		function () {			
	 		starGreyClicked = true;			
			currentStarHover = $('a.starGrey').index(this);
			jQuery.each($('a.starGrey'), function(i) {
				if (i <= currentStarHover) {
					 $(this).addClass('full');
				}
			});
		}				
	);
	
	getStarCount = function () {
		return $('a.starGrey.full').length;
	}
	
	$("#opinionNew").submit(function() {
		
		$('#starRating').val(getStarCount());
		if ( checkReportForm() === true)
		{
			 return true;
		}
		else
		{
			return false;
		}
		
		/* for debugging only: */ 
		
	});
	
	
});
