// -----------------------------------------------------------------------
// Init
// -----------------------------------------------------------------------

var isSafari = (navigator.appVersion.indexOf("Safari")!=-1) ? true : false;
var isMSIE   = (navigator.appVersion.indexOf("MSIE")!=-1) ? true : false;
var isMac	= (navigator.platform.indexOf("Mac")!=-1) ? true : false;

var browserVersion = 0;
var browserBuild   = 0;
if (isMSIE) {
	browserVersion = parseFloat(navigator.userAgent.replace(/.*?MSIE ([0-9\.]+).*/,'$1'));
} else if (isSafari) {
	browserBuild = parseFloat(navigator.userAgent.replace(/.*?Safari\/([0-9]+)\..*/,'$1'));
} else {
	browserVersion = navigator.appVersion;
}

// -----------------------------------------------------------------------
// Height Dispatcher
// -----------------------------------------------------------------------

heightDispatcher = function(){

	$('#content').height('');
	var bodyHeight =  $('body').height();
	var realHeight =  $('#content').height();
	var minimumHeight =  window.innerHeight-$('#footer').height()-$('#content').position().top;
	if (isMSIE) {
		$('#canvasRight').height(bodyHeight);
		$('#shadowRight').height(bodyHeight);
	}
	 // 60+50+6 = padding 60+6
	 
	var padding = 60+10+6;
	if (realHeight<minimumHeight) {
		if (realHeight+padding<minimumHeight)
			minimumHeight -= padding;
		$('#content').height(minimumHeight);
	}

	var resizeTimer = null;
	$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(heightDispatcher, 100);
	});

}

// -----------------------------------------------------------------------
// MAIN
// -----------------------------------------------------------------------

$(document).ready(function() {
	if (isMSIE && browserVersion==6) {
		DD_belatedPNG.fix('#glassbox div.page');
		DD_belatedPNG.fix('#glassbox div.reference');
		DD_belatedPNG.fix('#glassbox form');
		DD_belatedPNG.fix('#glassbox  .footer');
		DD_belatedPNG.fix('#glassbox img');
		DD_belatedPNG.fix('#shadowRight');
	}
	heightDispatcher();
	$('a.zoomable').fancyZoom({scaleImg: true, closeOnClick: true, directory:'lib/fancyzoom/images'});

});
