$(function () {
    
    var api = $(".gallery-images").scrollable({
        items: '.gallery-items' 
       ,speed: 400
       ,api: true
       ,size: 5
       ,clickable: false
       ,onBeforeSeek: function() { 
           this.getItems().fadeTo(300, 0.2);
       }
       ,onSeek: function() { 
           this.getItems().fadeTo(300, 1);
       }
    });
    
    
    $(".gallery-items img").mouseover(function() {
        $(".gallery-items img:not(" + $('.gallery-items img').index(this) + ")").removeClass().addClass('hidden');
        $(this).attr('src' , WEBROOT + '/media/photo-hover/' + $(this).attr('rel')).removeClass().addClass('hover');
    });
    
    $(".gallery-items img").mouseout(function() {
        $(".gallery-items img").removeClass();
        $(this).attr('src',WEBROOT + '/media/photo/' + $(this).attr('rel'));
    });
    
    $(".gallery-items div").click(function() {
        $('#gallery-preview').removeClass().addClass('gallery-preview-loading').html('');
        $.get(
             LANGROOT + "/gallery-preview/" + $(this).attr('rel') + "/"
            ,function(result){
                $('#gallery-preview').removeClass().addClass('gallery-preview').html(result);
		$('#gallery-preview div.gallery-preview-image a').lightBox();
		$('#gallery-preview img.close-gallery-preview').click(function(){ 
		    $('#gallery-preview').removeClass().html('');
                });
            }
        );
	
    });
    
    $f("player" , {
            src: WEBROOT + "/web/swf/flowplayer-3.1.2.swf",
            wmode: 'opaque'
        } , {
            plugins: { 
                controls: { 
                    playlist: true
                   ,url: WEBROOT + '/web/swf/flowplayer.controls-tube-3.1.2.swf'
                } 
            } 
    });
    $f("player").playlist("div.clips", {loop:false});
});
