// © Distinctive Web Services


// Get the browser Type
var IE = document.all?true:false;
var browsertype = new String( navigator.appName );
var IE6 = false;

// Detect Netscape
if ( browsertype == "netscape" || browsertype == "Netscape" ) {
	var ns = true; var IE = false;
// IE and compatable browsers
} else {
	var ns = false; var IE = true;
}

// What version of IE?
if ( IE ) {
	if ( 
		navigator.appVersion.indexOf( "MSIE 1" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 2" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 3" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 4" ) > -1
		||
		navigator.appVersion.indexOf( "MSIE 5" ) > -1
	) {
		var IE6 = false;
	} else {
		var IE6 = true;
	}
}


// Make Netscape / Mozilla monitor the mouse events
if ( !IE ) { document.captureEvents( Event.MOUSEMOVE ); document.captureEvents( Event.RESIZE ); }


// RETURNS THE HEIGHT OF THE DOCUMENT
function docHeight () {
	if ( IE ) {
		if ( IE6 ) {
			return document.documentElement.clientHeight;
		} else {
			return document.body.clientHeight;
		}
	} else {
		return window.innerHeight;
	}
}


// RETURNS THE POSITION OF THE BOTTOM OF THE CONTENT
function contentHeight () {
	if ( IE ) {
		if ( IE6 ) {
			return document.documentElement.clientHeight;
		} else {
			return document.body.clientHeight;
		}
	} else {
		return window.innerHeight;
	}
}


// RETURNS THE HEIGHT OF A SPECIFIED DIV ELEMENT
function divHeight ( id ) {
	if ( IE ) 
		return parseInt( document.getElementById( "content" ).clientHeight );
	else 
		return parseInt( document.getElementById( "content" ).offsetHeight );
}


// ON LOAD AND ON RESIZE THE SIZE OF THE CONTENT ELEMENT SHOUDL BE CHECKED
window.onload = function () {
	resizeContainer(); 
} 
window.onresize = function () {
	resizeContainer(); 
} 


// RESIZE THE CONTAINER 
function resizeContainer () { 

	// Work out the min height of the content area
	var minHeight = divHeight( "content" ) + 165 + 61;
	if ( minHeight < 500 ) minHeight = 500;

	// If the Y viewable space of the window is greater then the height of the content then place the footer at window bottom
	// Otherwise place the footer at the bottom of the content
	if ( docHeight() > ( minHeight + 50 ) ) {
		document.getElementById( "layout-footer" ).style.top = ( docHeight() - 50 ) + "px"; 
		document.getElementById( "content-container" ).style.height = ( docHeight() - 165 - 50 ) + "px"; 
	} else {
		document.getElementById( "layout-footer" ).style.top = minHeight + "px"; 
		document.getElementById( "content-container" ).style.height = ( minHeight - 165 ) + "px"; 
	}
	document.getElementById( "layout-left-menu" ).style.height = document.getElementById( "content-container" ).style.height; 

} 


// Open a new window and display the page in it.
function openWindow ( url, title, w, h, fullscreen ) {
	if ( fullscreen == "fullscreen" ) {
		// Get the browser type from the ASP variable
		// IE only supports "fullscreen" mode, if the browser is IE then execute this
		if ( !IE ) {
			var w = screen.availWidth - 10
			var h = screen.availHeight - 30
		}
		window.open( url, title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + w + ",height=" + h + ",fullscreen=yes,left=0,top=0" )
	} else {
		window.open( url, title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + w + ",height=" + h )
	}
}

