$(document).ready(function(){
    $("#main-menu ul li a").click(function(){
       
        loadPage($(this).attr("id"));
       
        return false;
    });
    $("#homelink").click(function(){
        loadPage("homelink");
        return false;
    });
});

Shadowbox.init();

$(window).load(function(){
    $("body").height($(window).height()).width($(window).width());
});
$(window).resize(function(){
    $("body").height($(window).height()).width($(window).width());
});

jQuery(function($){
				
    $.supersized({
				
        // Functionality
        slide_interval          :   6000,		// Length between transitions
        transition              :   1, 			// 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
        transition_speed		:	700,		// Speed of transition
															   
        // Components							
        slide_links				:	'blank',	// Individual links for each slide (Options: false, 'num', 'name', 'blank')
        slides 					:  	[			// Slideshow Images
        {
            image : 'bg_pics/1.jpg', 
            title : 'Image Credit: Yuri Catania'
        },

        {
            image : 'bg_pics/2.jpg', 
            title : 'Image Credit: Yuri Catania'
        },  

        {
            image : 'bg_pics/3.jpg', 
            title : 'Image Credit: Yuri Catania'
        },

        {
            image : 'bg_pics/4.jpg', 
            title : 'Image Credit: Yuri Catania'
        },

        {
            image : 'bg_pics/5.jpg', 
            title : 'Image Credit: Yuri Catania'
        }
        ]
					
    });
});

function loadPage(destPage){
    
    $("#main-menu ul li a:not(#"+destPage+")").removeClass("active");
    if(destPage == "homelink"){
        destPage = destPage.replace("-load", "");
        $(".standard-content").fadeTo(400 , 0, function(){
            $(".standard-content").hide();
        });
        destPage= "index";
    }else {
        $("#"+destPage).addClass("active");
        destPage = destPage.replace("-load", "");
        $(".standard-content:not(#"+destPage+")").removeClass("active-content").fadeTo(200 , 0, function(){
            $(".standard-content:not(#"+destPage+")").hide();
        });
        $("#"+destPage).addClass("active-content").fadeTo(450 , 1);
    }
    section = destPage.replace("-", "_")+".php";
    if(typeof window.history.pushState == 'function') {
        window.history.pushState("", section, section);
    }
}
function menuTrigger(){
    showMenu();
    var $_this = $("body");
    var newTimeout = setTimeout(function(){
        hideMenu();			
    },5000);
    clearTimeout($_this.data("toHide"));
    $_this.data("toHide",newTimeout);
}
function hideMenu(){
    $("#main-menu,.active-content").stop().fadeTo(500,0,function(){
        $(this).hide();
    });
}
function showMenu(){
    var $menu = $("#main-menu, .active-content");
    if($menu.css('opacity')!=1)
        $menu.stop().show().fadeTo(300,1);
}
$(window).load(function(){
    menuTrigger();
});
$("html").live("mousemove",function(e){
    menuTrigger();	
})
