// JavaScript Document
$(function(){ 
	$('#score').val('0');					  
						  
});
function applyRating(trgt,rate)
{
	for(var i=1; i<=rate; i++)
	{
		$('#'+trgt+i).removeClass('starOff').addClass('starOn');
	}
	for(i=parseInt(rate)+1; i<=10; i++)
	{
		$('#'+trgt+i).removeClass('starOn').addClass('starOff');
	}
}
/*function applyRating(rate)
{
	for(var i=1; i<=rate; i++)
	{
		$('#star'+i).removeClass('starOff').addClass('starOn');
		
		
	}
	for(i=parseInt(rate)+1; i<=10; i++)
	{
		$('#star'+i).removeClass('starOn').addClass('starOff');
	}
	if(parseInt(rate)>8)
	{
		document.getElementById('starText').innerHTML="Rave! Loved it";
	}
	else if(parseInt(rate)>6)
	{
		document.getElementById('starText').innerHTML="Rave! Really liked it";
	}
	else if(parseInt(rate)>4)
	{
		document.getElementById('starText').innerHTML="Okay";
	}
	else if(parseInt(rate)>2)
	{
		document.getElementById('starText').innerHTML="Not Rave. Didn't like it";
	}
	else if(parseInt(rate)>0)
	{
		document.getElementById('starText').innerHTML="Not Rave. Hated it";
	}
	else
	{
		document.getElementById('starText').innerHTML="";
	}
}*/
function fixedRating(trgt,rate)
{
	document.getElementById(trgt).value=rate;
	var sum = parseInt(document.getElementById('advise').value)+parseInt(document.getElementById('medical').value)+parseInt(document.getElementById('quality').value)+parseInt(document.getElementById('price').value)+parseInt(document.getElementById('selection').value)+parseInt(document.getElementById('clean').value);
	
	var total = sum/6;
	if(total>0.5 && total<1)
	{
		total = roundNumber(total,0);
	}
	else
	{
		total = parseInt(total);
	}
	document.getElementById('score').value=total;
	for(var j=1; j<=total; j++)
	{
		$('#score'+j).removeClass('starOff').addClass('starOn');
	}
	for(j=parseInt(total)+1; j<=10; j++)
	{
		$('#score'+j).removeClass('starOn').addClass('starOff');
	}
	applyRating(trgt,rate);
}
