$(document).ready(function() {


    // Front page Animation
    $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };

    $.fn.customFade = function(duration) {
        this.animate(
            { 
                opacity: 1.0
            }, 
            duration);
    };

    var fadeIn = function() {
        $('#cell1 img').wait(3000).customFade(3000);
        $('#cell2 img').wait(500).customFade(2000);
        $('#cell3 img').wait(1000).customFade(2000);
        $('#cell4 img').wait(0).customFade(1000);
        $('#cell5 img').wait(1500).customFade(2500);
        $('#cell7 img').wait(2000).customFade(3000);
        $('#cell8 img').wait(2000).customFade(3000);
        $('#cell9 img').wait(1000).customFade(3000);
    };


    // Front page hover effect
    $('#cell9').hover(
        function(){
            $(this).css("background-color", "#ccd6cf");
        },
        function(){
            $(this).css("background-color", "#bbc4bc");    
        }
    );

    // Front page menu
    $('#nav_menu div').hover(
        function(){
            $(this).css("background-color", "#ff3d00");
        },
        function(){
            $(this).css("background-color", "#c83000");    
        }
    );

    $('#nav_menu div').click(function(){
        window.location=$(this).attr("id") + ".html"
    });


    // Sub page menu
    $('#nav_list img').hover(
        function(){
            if(window.location.pathname.match($(this).attr("id")) == null) {
                $(this).attr("src", "assets/navigation/" + $(this).attr("id") + "_on.gif");
            }
        },
        function(){
            if(window.location.pathname.match($(this).attr("id")) == null) {
                $(this).attr("src", "assets/navigation/" + $(this).attr("id") + "_off.gif");
            }
        }
    );


    $('#nav_list img').each(function() {    
        if(window.location.pathname.match($(this).attr("id")) != null) {
            $(this).attr("src", "assets/navigation/" + $(this).attr("id") + "_on.gif");
        }
    });










    fadeIn();

 });
 
 
