$(document).ready(function(){
    $(window).load(stickyFooter).resize(stickyFooter);
    
    if (Modernizr.input.placeholder) {
        // your placeholder text should already be visible!
    } else { 
        var $input = $('#enews .text input');
        var placeholder = $input.attr('placeholder');
        $input.val(placeholder).addClass('placeholder');
        
        $input.focus(function(){
            if($input.val() == placeholder){
                $input.val('').removeClass('placeholder');
            };
        }).blur(function(){
            if($input.val() == ''){
                $input.val(placeholder).addClass('placeholder');
            };
        });
    }
    
    $('.flash-media').media({
        width: 405,
        height: 24,
        bgColor: '#ebe5df'
    });
    
    $('.video-clip').media({
        width: 480,
        height: 360,
        bgColor: '#ebe5df'
    });
    
    $('.sh-trigger').click(function(){
        $(this).next('.sh-content').toggle();
    });
    
    $('.sh-content').hide();
    
    $('.sh-close').click(function(){
        $(this).parents('.sh-content').hide();
    });
    
    
    $('#dismiss-message').live('click', function(e){
    	e.preventDefault();
    	$(this).parents('#subscribe-message').remove();
    });
});

function stickyFooter(){
    var viewportHeight = $(window).height();
    var contentBottom = $('div#content').offset().top + $('div#content').height();
    var footerTop = $('footer.global').offset().top;
    
    if(viewportHeight > contentBottom){
        $('footer.global').addClass('sticky');
        $('div#content').css('padding-bottom', 74);
    };
    
    if(viewportHeight < contentBottom + 74){
        $('footer.global').removeClass('sticky');
        $('div#content').css('padding-bottom', 0);
    };
};


$.fn.media.defaults.flvPlayer = '/lib/swf/player.swf';
$.fn.media.defaults.mp3Player = '/lib/swf/player.swf';
