// JavaScript Document
// A function to get viewport height to calculate different heights.
function newPage(){
var viewportwidth;
var viewportheight;
 
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined'){
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
}
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
    viewportwidth = document.documentElement.clientWidth,
    viewportheight = document.documentElement.clientHeight
}
 
// older versions of IE
else{
    viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
    viewportheight = document.getElementsByTagName('body')[0].clientHeight
}

/* Set height on various css tags depending on viewport size */
var contentHeight = viewportheight - 238;
var bigText = viewportheight - 422;
var subHeight = viewportheight - 218;

// Real webbrowsers...
if(document.styleSheets[0].cssRules){
	var oLength = document.styleSheets[0].cssRules.length;
	document.styleSheets[0].insertRule('html, body {font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #666; margin: 0; height: '+viewportheight+'px;}', oLength);
	document.styleSheets[0].insertRule('#content {overflow: auto; background-color: #FFFFFF; padding: 0 20px 20px 22px; width: 600px; height: '+contentHeight+'px;}', oLength);
	document.styleSheets[0].insertRule('.ed {width: 590px; height: '+bigText+'px;}', oLength);
	document.styleSheets[0].insertRule('#sub_menu {width: 137px; float: left; background-image: url(images/sub_menu.png); margin-top: -20px; border-right: 1px solid #c8c8c8; padding: 10px; height: '+subHeight+'px;}', oLength);
	
// ... and IE.
}else if(document.styleSheets[0].rules){
	var newstyle = document.createStyleSheet();
	newstyle.addRule('html, body' , 'font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #666; margin: 0; height: '+viewportheight+'px;');
	newstyle.addRule('#content' , 'overflow: auto; background-color: #FFFFFF; padding: 0 20px 20px 22px; width: 600px; height: '+contentHeight+'px;');
	newstyle.addRule('.ed' , 'width: 590px; height: '+bigText+'px;');
	newstyle.addRule('#sub_menu' , 'width: 137px; float: left; background-image: url(images/sub_menu.png); margin-top: -20px; border-right: 1px solid #c8c8c8; padding: 10px; height: '+subHeight+'px;');
}
/* <---- endofHeight ----> */
}

window.onload = newPage;
