$(document).ready(function(){
	
	function ratingAction(obj, rating){
		/* EXAMPLE:
		 * alert("You've rated "+rating+" on:\n"+$(obj).parent().find('.rlocked-item-content-middle').text())
		 */
	}
	
	$('#page-header').append(
		$('<img/>')
			.attr('id', 'header-logo-hover')
			.fadeTo(0,0)
			.attr('src', $('#header-logo').attr('src').replace(/\/[^\/]+$/, '/top-logo-hover.png'))
	)
	$('#header-logo, #header-logo-hover')
			.hover(
				function(){
					$('#header-logo-hover').stop(true, false).fadeTo(150,1)
				}, 
				function(){
					$('#header-logo-hover').stop(true, false).fadeTo(150,0)
				}
			)
	
	$('ul.rate').each(function(){
		stars = $(this).find('li')
		if($(this).is('[rating]')){
			r = parseInt($(this).attr('rating'))
			if(r>0){
				for(i=0;i<r;i++){
					$(stars[i]).addClass('active')
				}
			}
		}
		stars.find('a').click(function(e){
			e.preventDefault()
			stars = $(this).parent().parent().children('li')
			r = $(this).parent().index()
			stars.each(function(){
				if($(this).index()<=r){
					$(this).addClass('active')
				}
				else{
					$(this).removeClass('active')
				}
			})
			ratingAction(stars.parent(), r+1)
		})
	})
	
}) 

