function getRandom(min, max)
{		
	var randomNum = Math.random() * (max-min); 

// Round to the closest integer and return it
	return(Math.round(randomNum) + min); 
}

//Get_Cookie
//Set_Cookie( name, value, expires, path, domain, secure )

$(function() {
	//$('.testimonials').append('<div class="testi_q">Was this review helpful to you? <a href="#">Yes</a>/<a href="#">No</a>');
	
	//Set_Cookie( 'is_update', '1', '1', '/', '', '' );
	
	$('.testimonials').append('<div class="testi_rating"><span>Customer rating:</span><ul class="star-rating">\
								  <li><a href="#" class="star1" id="one_star">1</a></li>\
								  <li><a href="#" class="star2" id="two_stars">2</a></li>\
								  <li><a href="#" class="star3" id="three_stars">3</a></li>\
								  <li><a href="#" class="star4" id="four_stars">4</a></li>\
								  <li><a href="#" class="star5" id="five_stars">5</a></li>\
								</ul>\
								<span class="tesim_rate">4 of 5</span>\
							</div>');
								
	$.each($('.testimonials'), function(key, val)
	{
		if(!Get_Cookie('tesimonials_'+key))
		{
			var rate = getRandom(4, 5);
			Set_Cookie('tesimonials_'+key, rate, '1', '/', '', '' );
		} else
		{
			var rate = Get_Cookie('tesimonials_'+key);
		}
		
		$(this).find('span[class="tesim_rate"]').text(rate+' of '+5);
		$(this).find('a[class="star'+rate+'"]').addClass('active');
		
		for($i=1; $i <= rate; $i++)
		{
			$(this).find('a[class="star'+$i+'"]').addClass('hover');
		}
	});
	
	$('.testimonials ul li a').click(function(){
		$(this).parent().parent().parent().text('Ths for your vote');
		return false;
	});
	
});

	
