// JavaScript Document


// Drop down menu fix for IE
<!--//--><![CDATA[//><!--
sfHover = function() {
	var sfEls = document.getElementById('mainMenu').getElementsByTagName('LI');
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=' sfhover';
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(' sfhover\\b'), '');
		}
	}
}
if (window.attachEvent) window.attachEvent('onload', sfHover);
//--><!]]>


// Get window height
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}


// Set content height
function setContentHeight() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var containertHeight = document.getElementById('container').offsetHeight;
			var headertHeight = document.getElementById('header').offsetHeight;
			var contentHeight = document.getElementById('content').initHeight;
			var footertHeight = document.getElementById('footer').offsetHeight;
			var contentElement = document.getElementById('content');
			
			if (windowHeight - (headertHeight + 40 + contentHeight + footertHeight) >= 0) {
				var newHeight = (windowHeight - 40 - (headertHeight+footertHeight)) + 'px';
				contentElement.style.height = newHeight;
				if ($('#leftmenu').length) { document.getElementById('leftmenu').style.height = newHeight; }
				document.getElementById('cont').style.height = newHeight;
			}
			else {
				var newContentHeight = (contentHeight) + 'px';
				contentElement.style.height = newContentHeight;
				if ($('#leftmenu').length) { document.getElementById('leftmenu').style.height = newContentHeight; }
				document.getElementById('cont').style.height = newContentHeight;
			}	
		}
	}
}


// Window On Load
$(document).ready(function() {
	// Lightbox
	$("a.pic").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'overlayColor' : '#000',
		'overlayOpacity' : 0.8
	});
	$("a.iframe").fancybox({
		'width'	: 800, 
		'height' : 450,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'padding' : 20,
		'margin' : 0,
		'overlayColor' : '#000',
		'overlayOpacity' : 0.8
	});
	
	// Content height
	document.getElementById('content').initHeight = document.getElementById('content').offsetHeight;
	setContentHeight();
});


// Window On Resize
$(window).resize(function() {
	setContentHeight();
});

