jQuery(function( $ ){
    
    
    var target = $('#slider').get(0);//the scrolled div
    target.scrollLeft = target.scrollTop = 0;
    $.localScroll.hash({
        target: target, 
        axis:'xy',
        queue:true,
        duration:1500
    });
    
    var $last = $([]);//save last link
    
    $.localScroll({
        target: target,
        axis:'xy',
        queue:true,
        duration:1200,
        hash:false,
        onBefore:function( e, anchor, $target ){
            this.blur();
            
        }
    });

            //by default, the scroll is only done vertically ('y'), change it to both.
            $.scrollTo.defaults.axis = 'xy';            
            //this one is important, many browsers don't reset scroll on refreshes
            $('div#overlay').scrollTo( 0 );//reset all scrollable panes to (0,0)
            $.scrollTo( 0 );//reset the screen to (0,0)
            
            var $paneTarget = $('#overlay');    
            
            $('#content_about').click(function(){
                $paneTarget.stop().scrollTo( '0', 1000, {});
            });
            

            $('#content_creed').click(function(){
                $paneTarget.stop().scrollTo( '495px', 1000, {});
            });

            $('#content_projects').click(function(){
                $paneTarget.stop().scrollTo( '990px', 1000, {});
            });
            
            $('#content_media').click(function(){
                $paneTarget.stop().scrollTo( '1485px', 1000, {});
            });
            
            $('#content_news').click(function(){
                $paneTarget.stop().scrollTo( '1980px', 1000, {});
            });
            
            $('#content_contact').click(function(){
                $paneTarget.stop().scrollTo( '2475px', 1000, {});
            });
            
            // PNG hack
            $(document).pngFix();
            
            // Controls the full screen mode
            $("a.fullsize").click(function(){
            $("div#overlay").slideToggle("fast");
            $(this).toggleClass("active");
                return false;
            });
            
            $('.clearme').example(function() {
             return $(this).attr('title'); 
            });
            

    /**
     *   FOOTER/NABAR FADE EFFECTS
     */

     $("#navbar").fadeTo(1,0);
     $("#footer").fadeTo(1,0);
     $("#navbar").fadeTo("slow",1);
     $("#footer").fadeTo("slow",1);


    /**
     *   NAVBAR-BUTTON FADE EFFECTS
     */

     /*
$("#content_about").click(
        function(){
            $("#content_about").fadeTo("slow", 0.6);
            $("#content_creed").fadeTo("slow", 1);
            $("#content_projects").fadeTo("slow", 1);
            $("#content_media").fadeTo("slow", 1);
            $("#content_news").fadeTo("slow", 1);
            $("#content_contact").fadeTo("slow", 1);
        }   
    );
    
     $("#content_creed").click(
        function(){
            $("#content_about").fadeTo("slow", 1);
            $("#content_creed").fadeTo("slow", 0.6);
            $("#content_projects").fadeTo("slow", 1);
            $("#content_media").fadeTo("slow", 1);
            $("#content_news").fadeTo("slow", 1);
            $("#content_contact").fadeTo("slow", 1);
        }   
    );
*/
    
    $("#content_projects").click(
        function () { 
            $("#wrapper").fadeOut(1000, function() { 
            window.location.href = "projects.html"; 
        }); 
    }); 
    
/*
    $("#content_projects").click(
        function(){
            $("#content_about").fadeTo("slow", 1);
            $("#content_projects").fadeTo("slow", 0.6);
            $("#content_media").fadeTo("slow", 1);
            $("#content_news").fadeTo("slow", 1);
            $("#content_contact").fadeTo("slow", 1);    
        }   
    );
*/
    
   /*
  $("#content_media").click(
        function(){
            $("#content_about").fadeTo("slow", 1);
            $("#content_creed").fadeTo("slow", 1);
            $("#content_projects").fadeTo("slow", 1);
            $("#content_media").fadeTo("slow", 0.6);
            $("#content_news").fadeTo("slow", 1);
            $("#content_contact").fadeTo("slow", 1);
        }   
    );
    
    $("#content_news").click(
        function(){
            $("#content_about").fadeTo("slow", 1);
            $("#content_creed").fadeTo("slow", 1);
            $("#content_projects").fadeTo("slow", 1);
            $("#content_media").fadeTo("slow", 1);
            $("#content_news").fadeTo("slow", 0.6);
            $("#content_contact").fadeTo("slow", 1);
        }   
    );
    
        $("#content_contact").click(
        function(){
            $("#content_about").fadeTo("slow", 1);
            $("#content_creed").fadeTo("slow", 1);
            $("#content_projects").fadeTo("slow", 1);
            $("#content_media").fadeTo("slow", 1);
            $("#content_news").fadeTo("slow", 1);
            $("#content_contact").fadeTo("slow", 0.6);
        }   
    );
*/


    
    /**
     *   CONTROL NEWS
     * 
     */
     $("#overlay_news div").css({ opacity: 0 });
     $("#overlay_news h3 a").click(
        function(){
            $(this).addClass("news_active");
            $(this).parent().siblings("h3").children("a").removeClass("news_active");
            $(this).parent().siblings("div").animate({ opacity: 0}, 100 );
            $(this).parent().next("div").animate({ opacity: 0.8}, 400 );
            return false;
        }
    );
    
    /**
     *   CONTROL Projects
     * 
     */ 
     $("#overlay_projects div").css({ opacity: 0 });
     $("#overlay_projects h3 a").click(
        function(){
            $(this).addClass("projects_active");
            $(this).parent().siblings("h3").children("a").removeClass("projects_active");
            $(this).parent().siblings("div").animate({ opacity: 0}, 100 );
            $(this).parent().next("div").animate({ opacity: 0.8}, 400 );
            return false;
        }
    );
    
});