$(function(){

        /* Prepare Movie */
        /*
        $('#background-overlay').hide();
        $('#background-sequence').cycle({timeout: 800, delay:0}).hide(); 
        $('#smallprint').hide();
        $('#nav').hide();
        $('h1').hide(); 
        $('a#skip-movie').hide();
        $('div#movie').hide();
        $('h1').fadeIn('slow', function(){
            $('a#skip-movie').fadeIn('slow');
            $('div#movie').fadeIn('slow');
        });
        */
        /* End Prepare Movie */        
        
        /* Skip Movie Link */
        /*
        $('a#skip-movie').click(function(){
            $('#background-sequence').cycle({timeout: 800, delay:0}).hide(); 
            $('a#skip-movie').hide();
            $('div#movie').hide();
            $('#background-sequence').cycle('pause').cycle(0).fadeIn();
            $('#nav').fadeIn(1000, function(){
                $('#background-overlay').fadeIn();
                $('#smallprint').fadeIn('slow');
            });
        });
        */
        /* End Skip Movie Link */
        
        /* Until Movie */
            $('#background-sequence').cycle({timeout: 800, delay:0}).hide(); 
            $('#background-overlay').hide();
            $('#smallprint').hide();
            $('#nav').hide();
            //$('h1').hide(); 
            $('a#skip-movie').hide();
            $('div#movie').hide();
            $('#background-overlay').fadeIn();
            $('#nav').fadeIn(1000, function(){
				$('#background-sequence').cycle('pause').cycle(0).fadeIn('slow');
                $('#smallprint').fadeIn('slow');
            });
        /* End Until Movie */
        
        $('#nav > li > a').click(function(){
            if ($(this).next('div').css({'opacity':'0.2'}).hasClass('expanded')) {
                $(this).next('div').slideUp('slow').removeClass('expanded');
                $(this).parent().removeClass('current');
            } else {
                $('#nav > li > div.expanded').css({'opacity':'0.2'}).slideUp('slow').removeClass('expanded').fadeOut('slow');
                $('#nav > li').removeClass('current');
                $(this).next('div').slideDown('slow').addClass('expanded').css({'opacity':'1'});   
                $(this).parent().addClass('current');
                if ($(this).parent().hasClass('style-scrollable')) {
                    //$('#background-overlay').hide();
                    $('div#style-scroller').smoothDivScroll({ scrollingSpeed: 8, mouseDownSpeedBooster: 3, visibleHotSpots: 'always', hiddenOnStart: false });
                    $("div#style-scroller div.scrollingHotSpotRight").show(); //20110222
                    $(window).trigger('resize'); //20110222
                    $('#background-sequence').cycle(2);
                    $('#scrollableArea a').mouseout(function(){
        $('#scrollableArea').css({'opacity':'0.1'});
    });
                } else if ($(this).parent().hasClass('collection-scrollable')) {
                    $("div#contact-sheet-scrollable").smoothDivScroll({});
                    $("div#contact-sheet-scrollable div.scrollingHotSpotRight").show(); //20110222
                    $(window).trigger('resize'); //20110222
                    $('#background-sequence').cycle(3);
                } else {
                    $('#background-sequence').cycle($(this).parent().index()+1);
                    $('#background-overlay').fadeIn();
                }
            }
        });
        
        $('.scrollableArea a').click(function(){
            if ($('#background-overlay').is(':visible')) {$('#background-overlay').fadeOut();}
        });
        
        
			
		$('.inner-film-upper a').hover(function(){$(this).children(':first-child').fadeTo('fast', 0.8)}, function(){$(this).children(':first-child').hide()});
    	$('.inner-film-lower a').hover(function(){$(this).children(':first-child').fadeTo('fast', 0.8)}, function(){$(this).children(':first-child').hide()});
        /*
        var showhash = window.location.hash ? '[hash=' + window.location.hash + ']' : '';
        if (showhash != '') {
            $('#nav a').filter(showhash).click();
            $(window).trigger('resize');
        }
        */    
        
        $('a.flareable').hover(
    		function () {
    			if (!($(this).parent().hasClass('flare'))) {
    				$(this).wrap('<div class="flare"></div>');
    			}
    		}, 
    		function () {
    			if (($(this).parent().hasClass('flare'))) {
    				$(this).unwrap();
    			}
    		}
    	);
    	
    	setupZoom();
    });
    
    function bringStyle(obj,num) {
        $(obj).parent().children().fadeTo('fast', 0.1);$(obj).css({'cursor':'default'});$('#background-sequence').cycle(num);
    }
