var	oldH = -1,
	newH = 0;

$(document).ready(function(){

	var mobileBrowsers = [
		"iPhone",
		"iPod",
		"iPad",
		"Android",
		"Blackberry",
		"Palm"
	];

	var isMobile = false;
	var ua = navigator.userAgent.toLowerCase();
	for( var i = 0; i < mobileBrowsers.length; i++ ) {
		if( ua.indexOf( mobileBrowsers[i].toLowerCase() ) > -1 ) {
			isMobile = true;
			break;
		}
	}

	if( !isMobile ) {
		$("body").css("overflow","hidden");
		resizeContent();
		$(window).resize( function() {
			resizeContent();
		})
		setInterval( function() {
			if( (newH = $("#topnav").outerHeight(true)) != oldH ) {
				oldH = newH;
				resizeContent();
			}
		}, 200 );
		$('a.fancybox').fancybox({
			titlePosition: 'inside'
		});
	} else {
//		$("body").css("background-color","yellow");
		$("#topnav").css({
			"font-size":"160%",
			"padding-top":"10px",
			"padding-bottom":"10px"
		});
		var h = $("div#contents").height();
		$("div#leftpanel").css("height", h);
	}

});

function resizeContent() {
	var	wH = $(window).height(),
		hH = $("#header").outerHeight(),
		bH = $("#bottom").parent().outerHeight(true),
		cH = wH - hH;
	$("#leftpanel").css("height",(cH-bH)+"px");
	$("#contents").css({"overflow-y":"auto","height":cH+"px"});
}
