jQuery(function(){

// ------ The settings for scrolling using the localScroll/scrollTo plugin 
	
	/*
	* Robert Penner's Easing Equation http://www.robertpenner.com/easing/
	* You can use any easing function(for the slide effect) from http://gsgd.co.uk/sandbox/jquery/easing/ (Hint: view source)
	*/
	jQuery.easing.easeOutExpo = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};
	
	// ------ This function selects the current nav and adds a class of "selected"
    function selectNav() {
        jQuery(this)
            .parents('#navMain:first')
                .find('a')
                    .removeClass('selected')
                .end()
            .end()
            .addClass('selected');
    }

    jQuery('#navMain').find('a').click(selectNav);
    // go find the navigation link that has this target and select the nav
    function trigger(data) {
        var el = jQuery('#navMain').find('a[href$="' + data.id + '"]').get(0);
        selectNav.call(el);
    }
    if (window.location.hash) {
        trigger({ id : window.location.hash.substr(1) });
    } else {
        jQuery('#navMain a:first').click();
    }
	
	// ------ The final configuration 
	jQuery.localScroll.defaults.axis = 'y';
	jQuery.localScroll({
		queue:true,
		duration:1000,
		hash: false,
		easing: 'easeOutExpo',
		onAfter: trigger
	});
	
	// ------ Configuration for the Top link. 
	jQuery('.top').click(function(){
	jQuery.scrollTo( 'body', 'normal' );
	});
});

$(function() {
            var offset = $("#navside").offset();
            var topPadding = 1;
            $(window).scroll(function() {
                if ($(window).scrollTop() > offset.top) {
                    $("#navside").stop().animate({
                        marginTop: $(window).scrollTop() - offset.top + topPadding
                    });
                } else {
                    $("#navside").stop().animate({
                        marginTop: 1
                    });
                };
            });
        });
		
$('.closealertie').click(function() {
    $('.alertie').slideUp("slow");
});
