Shadowbox.init({
    players:    ["img","swf"],
    autoplayMovies: true,
    continuous: true,
	displayCounter: false,
	slideshowDelay: 4
});

var nav_index = 0; 
var nav_size = 11;

function enable_nav () {  
	var nav = $('#middle_l a');
	var my_nav_size = nav_size;
	if(nav_index > 0 && nav.length > nav_index + nav_size){
		my_nav_size--;
	}
	nav.each(function(i){ 
		if(i >= nav_index && i < nav_index + my_nav_size){
			$(this).show();
		}else{
			$(this).hide();	
		}
	});
}
function append_next () { 
	var nav = $('#middle_l a');    
	if(nav.length <= nav_index + nav_size) return; 
	
	var next = $("<li class='next'><a href='#'>next</a></li>").insertAfter($(nav[nav_index+nav_size]).parent());
	next.click(function(e){
		$('.next').remove();
		nav_index = nav_index + nav_size; 
		enable_nav(nav);
		append_next(nav);
		append_back(nav);  		  	
	});
}
function append_back () {
	var nav = $('#middle_l a');  	
	if(nav_index == 0) return;
	
	var back = $("<li class='back'><a href='#'>back</a></li>").insertBefore($(nav[nav_index]).parent());
   	back.click(function(e){
		$('.back').remove();  		
		nav_index = nav_index - nav_size;
		enable_nav(nav);
		append_back(nav);
		append_next(nav);
	});  	
}

$(document).ready(function(){
        $('#footer_l a').hide();
        $('#footer_r p').hide();
        
        
        $(window).load(function(){
            $('#gallery img').fadeTo('fast',0.5);
            $('#middle_r img').css('visibility', 'visible');
            $('#middle_r img:not(.play)').fadeIn('slow', function() {
                $(".play").fadeIn('slow', function() {
                    $(this).fadeOut(2000);
                });
            });
            $('#middle_l a').fadeIn('slow');
            $('#footer_l a').fadeIn('slow');
            $('#footer_r p').fadeIn('slow');
        });  

		//enable_nav();
		//append_next(); 
		//append_back();
        
        
        $('#middle_r a').hover(
                function (e) { 
                    $(".play").fadeIn('slow')  ;}, 
                function (e) { 
                    $(".play").fadeOut('fast') ;}
        );
        
        $('#gallery img').hover(
                function () { $(this).stop().fadeTo('fast', 1)  ;}, 
                function () { $(this).stop().fadeTo('fast', 0.5);}
        );
        $('#middle_l a:not(.active)').hover(
                function () {
                    $(this).stop().css({color: "black" , backgroundColor : "white"});
                }, 
                function () {
                    $(this).stop().animate({ color : "white", backgroundColor: "black"}, 200);
                }
        );
        $('#header_r a:not(.active)').hover(
                function () {
                    $(this).stop().css({color: "white" , backgroundColor : "black"});
                }, 
                function () {
                    $(this).stop().animate({ color : "black", backgroundColor: "white"}, 200);
                }
        );
});

