/**
 * eZ Star Rating : Rating extension for eZ Publish 4.x
 * Created on     : <02-Nov-2009 00:00:00 ar>
 * 
 * This piece of code depends on jQuery and eZJSCore ( jQuery.ez() plugin ).
 *
 * @copyright Copyright (c) 1999-2010, eZ Systems AS
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2.0
 * @package eZ Starating extension for eZ Publish
 *
 */
(function( $ )
{
    $(document).ready( function()
    {
        $('ul.ezsr-star-rating').each( function(){
            var node = $( this );
            if ( !node.hasClass('ezsr-star-rating-disabled') )
                   node.addClass('ezsr-star-rating-enabled');
        });
        $('ul.ezsr-star-rating-enabled li a').click( _rate );
    });

    function _rate( e )
    {
        e.preventDefault();
        var args = $(this).attr('id').split('_');
        /*$('#ezsr_rating_' + args[1]).removeClass('ezsr-star-rating-enabled');*/
        $('#ezsr_rating_percent_' + args[1]).css('width', (( args[3] * 20 ) + '%' ) );
        $("input#rating_" + args[1]).attr( "value" , args[3] );
        return false;
    }
    
})(jQuery);
