$(document).ready(function(){
    
    // Adds a class of 'focus' to focused skip links
	$('ul#nav_access li a').focus(function(){
		$(this).addClass('focus');
	});
	$('ul#nav_access li a').blur(function(){
		$(this).removeClass('focus');
	});
	
	
	
	$('div.logo img').center_logo();
	
	
	
	// DEALS WITH THE FADING IN OF THE BACKGROUND IMAGE TO AVOID JUMPY EFFECT
	$("div#body_background img").addClass("hidden").fadeTo(750, 0, function() {
    	$(this).removeClass("hidden").show();
    }).fadeTo(1000, 1);
	
	
	
	// HOMEPAGE COUNTER
	$("#home_counter p").everyTime(1000,function(i) {
        var start_date = new Date('March 22, 2010, 17:30:00');
        var date = new Date();
        var time = (date.getTime() - start_date.getTime());
        var t = '';
        t = time / 1000;
        var seconds = t % 60;
        t /= 60;
        var minutes = Math.floor(t % 60);
        t /= 60;
        var hours = Math.floor(t % 24);
        t /= 24;
        days = Math.floor(t);
        $(this).html('<strong>'+days+'</strong> days <strong>'+hours+'</strong> hours <strong>'+minutes+'</strong> minutes');
    });
    
    
    
});



$(window).bind("resize", function(){
    $("div#body_background").ezBgResize();
});



$(window).load(function() {
    $("div#body_background").ezBgResize();
});



/**
    * CENTER LOGOS
    * Vertically centering the logo within container
    * ----
*/
$.fn.center_logo = function()
{
	$(this).each(function(i){
	
		var margin_height = $(this).parent().height() - $(this).height();
    	var final_height = margin_height / 2;
    	
    	$(this).css({marginTop: final_height});
	
	});
}