var $url = document.location.pathname;

$(function(e) {
	//if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit
	var ios = (navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod');
	var bby = navigator.userAgent.toLowerCase().indexOf('blackberry') > -1;
	var adr = navigator.userAgent.toLowerCase().indexOf('android') > -1;
	if(ios || bby || adr) { $('#footer').hide(); }
	         

    $('#sidebar li a').each(function(i,e) {
    	if($(e).attr('href') == $url) {
    		$(e).addClass('current');
    		//break; // break out the loop
    	}
    });
    
    $('#background').load(resizeBackground);
    $(window).resize(resizeBackground);
});


/* background resizable */    
function resizeBackground(){ 
	var element = $('#background');
	var image_width = $(element).width(); 
	var image_height = $(element).height();     

	var over = image_width / image_height; 
	var under = image_height / image_width; 

	var body_width = $(window).width(); 
	var body_height = $(window).height(); 
     
    if(body_width / body_height >= over) { 
		$(element).css({ 
			'width': body_width + 'px', 
			'height': Math.ceil(under * body_width) + 'px', 
			'left': '0px', 
			'top': Math.abs((under * body_width) - body_height) / -2 + 'px' 
		});
	} 
    else { 
		$(element).css({ 
			'width': Math.ceil(over * body_height) + 'px', 
			'height': body_height + 'px', 
			'top': '0px', 
			'left': Math.abs((over * body_height) - body_width) / -2 + 'px' 
		}); 
	}
} 
