$(document).ready(function(){
    var speedAccessoriesSlide = 200;
    var maxItemsView = 5;
    var iDhideItem = 0;
    // ON CLICK
    $('.accessories_direction').click( function() {
		var category = $(this).parent().parent().parent().parent('.accessories_category').attr('id');
        var direction = $(this).attr('alt');
        var next;
        //if right
        if(direction == 'next') {
            if($('.accessories_item:visible').length > maxItemsView) {
                //hide the first element wich is display
                var showNext = $('#'+category+' .accessories_item:visible:first');
                iDhideItem = showNext.attr('id').split('item_')[1];
                //hide item
                showNext.hide(speedAccessoriesSlide);
            }
        }else {
            $('#'+category+' #accessories_item_'+iDhideItem).show(speedAccessoriesSlide);
            iDhideItem--;
        }
    });

    $('.accessories_item').hover( function() {
        //show information
        var idToShow = '#'+$(this).attr('id')+'_info';
        var pos = $(this).offset();
       
        $(idToShow).css('left', pos.left+153);
        $(idToShow).show();
    }, function() {
        //hide information
        var idToShow = '#'+$(this).attr('id')+'_info';
        $(idToShow).hide();
    });

});

