
$(document).ready(function() {
	

	$('[class^=star_]').mouseenter(
        function() {
            if($(this).parent().data('selected') == undefined) {
                var selectedStar = $(this).parent().find('.hover').length - 1;
                $(this).parent().data('selected', selectedStar)
            }
            $(this).children().addClass('hover');
            $(this).prevAll().children().addClass('hover');
            $(this).nextAll().children().removeClass('hover');
        });

    $('[id^=rating_]').mouseleave(
        function() {
            var selectedIndex = $(this).data('selected')
            var $selected = $(this).find('img').eq(selectedIndex).addClass('hover').parent();
            $selected.prevAll().children().addClass('hover');
            $selected.nextAll().children().removeClass('hover');
    });

	$("[id^=rating_]").children("[class^=star_]").click(function() {

		
		var current_star = $(this).attr("class").split("_")[1];
		var rid = $(this).parent().attr("id").split("_")[1];

		$('#rating_'+rid).load('send.php', {rating: current_star, id: rid});

	});




});