/** Used to enable/disable the menu navigation */
var isAnimated = false;
/**
 * Window beforeunload binding (bugfix)
 */
 $(window).bind('beforeunload',function(){
    // Flash/IE ExternalInterface page unload fix
    window.__flash__removeCallback = (function() {
        return function(instance, name) {
            if (instance) instance[name] = null;
        }; // IE 6 dangling semicolon needed
    })(); // force another closure to prevent IE memory leaks
});
/**
 * DOM ready
 */
$(document).ready(function() {
    var body = $('body,html');
    $('#navbar a').each(function() {
        var anchor = $(this);
        var target = $(anchor.attr('href'));
        anchor.bind('click', function(evt) {
            if (!isAnimated) {
                var offset = target.position();
                var padding = parseInt($('#content').css('paddingTop').replace(/px/, ''));
                var position = offset.top-padding;
                body.stop().animate({'scrollTop':position}, 800, 'easeOutCubic');
            }
            evt.preventDefault();
        });
    });
});
/**
 * ExternalInterface function called by the masthead which signals the beginning of video playback.
 */
function startVideoPlayback() {
    isAnimated = true;
    $('#content').animate({ 'paddingTop':'617px' }, 'fast', 'easeOutQuad');
    $('#navbar').animate({ 'top':'590px' }, 'fast', 'easeOutQuad');
    $('#header').animate({ 'height':'617px' }, 'fast', 'easeOutQuad', function() {
        $('#masthead').css({ 'height':'590px' });
        try {
            swfobject.getObjectById('masthead').loadVideo();
        } catch(e){}
        isAnimated = false;
    });
}
/**
 * ExternalInterface function called by the masthead which signals the end of video playback.
 */
function stopVideoPlayback() {
    isAnimated = true;
    $('#content').animate({ 'paddingTop':'277px' }, 'fast', 'easeOutQuad');
    $('#navbar').animate({ 'top':'250px' }, 'fast', 'easeOutQuad');
    $('#header').animate({ 'height':'277px' }, 'fast', 'easeOutQuad', function() {
        $('#masthead').css({ 'height':'250px' });
        try {
            swfobject.getObjectById('masthead').loadStage();
        } catch(e){}
        isAnimated = false;
    });
}
