jQuery(function(){

        
    var galleries = jQuery('.ad-gallery').adGallery({
        width: 500,
        height: 333,
        slideshow: {
            enable: false
        },
        effect: 'fade',
        thumb_opacity: 0.4
    });
    
    var scrollers = jQuery('ul.imageSlider').hoverscroll({
        
        width:  500,
        height: 230,
        fixedArrows: true
    }).each(function(){
        jQuery(this).parents('.imageSliderBox:first').addClass('scrollerLoaded');
    });
    
    jQuery('.hoverscroll').unbind('mousemove mouseleave');

    if (window.elmMobile)
    {
        jQuery('.hoverscroll').bind('scrollerMove', function(){
            if (jQuery(this)[0].stepsMoved > 6)
            {
                var scroller = jQuery(this).find('ul.imageSlider');
                scroller[0].stopMoving();
                          
            }
        });
    }
   
    scrollers.each(function(){
        var scroller = this;
        var scrollerBox = jQuery(this).parents('.hoverscroll:first');

        if (window.elmMobile)
        {
            scrollerBox.find('.fixed-arrow').bind('click', function()
            {
                var direction = jQuery(this).hasClass('left') ? -1 : 1;  
                scroller.startMoving( direction, 50 );     

            });        
        }
        else
        {
            scrollerBox.find('.fixed-arrow').bind('mousedown', function()
            {
                var direction = jQuery(this).hasClass('left') ? -1 : 1;
                
                scroller.startMoving( direction, 50 );
            });
            scrollerBox.find('.fixed-arrow').bind('mouseup', function(){
                
                scroller.stopMoving();
                
            });        
        }
    });
    

});



