jQuery(document).ready( function() {
	
	// Fade
    jQuery('.thumbs img').fadeTo('normal', '0.4');
    jQuery('.thumbs li').hover( function() {
        jQuery(this).children().next().children().fadeTo('fast', '1');
        jQuery(this).children('span').css('background-color', '#000');
        jQuery(this).children('span').children('a').css('color', '#fff');
        jQuery(this).children('span').css('opacity', '0.4');
        jQuery(this).children('span').css('filter', 'alpha(opacity=40)');
        jQuery(this).children('span').css('-moz-opacity', '0.4');
    }, function() {
    	jQuery(this).children().next().children().fadeTo('fast', '0.4');
        jQuery(this).children('span').css('background-color', 'transparent');
        jQuery(this).children('span').children('a').css('color', '#666');
        jQuery(this).children('span').fadeTo('fast', '1');
    });
    
    // Slide
    jQuery('.go-right').click( function() {
	    jQuery('.thumbs').stop().animate({left:'-'+(parseFloat(jQuery('.thumbs').width())-parseFloat(jQuery(window).width()))+'px'},{queue:false,duration:300});
	    jQuery(this).fadeTo('normal', 0.20);
	    jQuery('.go-left').show();
	    jQuery('img.go-left').fadeTo('normal', 1.0);
	    return false;
    });
    jQuery('.go-left').click( function() {
	    jQuery('.thumbs').stop().animate({left:'0'},{queue:false,duration:300});
	    jQuery(this).fadeTo('normal', 0.20);
	    jQuery('.go-right').show();
	    jQuery('img.go-right').fadeTo('normal', 1.0);
	    return false;
    });
    
    // Scroll
    jQuery('.home-thumbs').mousedown( function(event) {
        jQuery(this).data('down', true).data('x', event.clientX).data('scrollLeft', this.scrollLeft);
        return false;
    }).mouseup( function(event) {
        jQuery(this).data('down', false);
    }).mousemove( function(event) {
        if (jQuery(this).data('down') == true)
            this.scrollLeft = jQuery(this).data('scrollLeft') + jQuery(this).data('x') - event.clientX;
    }).mousewheel( function(event, delta) {
        this.scrollLeft -= (delta * 30);
    }).css({
        'overflow' : 'hidden',
        'cursor' : '-moz-grab'
    });
});

jQuery(window).mouseout( function(event) {
    if ( jQuery('.home-thumbs').data('down'))
    {
        try
        {
            if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML')
                jQuery('.home-thumbs').data('down', false);
        } catch (e) {}
    }
});