function scaleToViewport() {
	var viewWidth = (self.innerWidth)? self.innerWidth : 
		(document.documentElement && document.documentElement.clientWidth)? document.documentElement.clientWidth : 
		(document.body)? document.body.clientWidth : 640;
	var viewHeight = (self.innerHeight)? self.innerHeight : 
		(document.documentElement && document.documentElement.clientHeight)? document.documentElement.clientHeight : 
		(document.body)? document.body.clientHeight : 480;

	var scalableCSSURL = '/scalable.css?viewWidth='+viewWidth+'&viewHeight='+viewHeight+'&body=about/facultyAndStudents/22';

	var scalableCSS = document.createElement('link');
	scalableCSS.setAttribute('rel','stylesheet');
	scalableCSS.setAttribute('type','text/css');
	scalableCSS.setAttribute('media','screen');
	scalableCSS.setAttribute('href',scalableCSSURL);
	document.getElementsByTagName('head').item(0).appendChild(scalableCSS);

	loadCSSDoc(scalableCSSURL);
};
scaleToViewport();
window.onresize = scaleToViewport;

function cleanWhitespace(containerNode) { 
	var kids = containerNode.childNodes, node;
	if(kids) node = kids.length;
	while(node--) if(kids[node].nodeType==3 && !/\S/.test(kids[node].nodeValue) || kids[node].nodeType==8) containerNode.removeChild(kids[node]);
}

function splash() {
	document.getElementById('menu').style.visibility = 'visible';
	document.getElementById('content').style.visibility = 'visible';
	document.getElementById('splashLogo').style.cursor = 'default';
}

if(document.getElementById('menu')) {
	var submenuPreload = new Image();
	submenuPreload.src = 'images/assets/submenu0.gif';
	
	var nowOverMenu = false;
	function hideAllSubmenus(exception) {
		if(exception!='NewsMenuColumn') try { document.getElementById('NewsMenuColumn').childNodes[1].style.visibility = 'hidden'; } catch(e) {};
		if(exception!='AboutMenuColumn') try { document.getElementById('AboutMenuColumn').childNodes[1].style.visibility = 'hidden'; } catch(e) {};
		if(exception!='EventsMenuColumn') try { document.getElementById('EventsMenuColumn').childNodes[1].style.visibility = 'hidden'; } catch(e) {};
		if(exception!='EditionsMenuColumn') try { document.getElementById('EditionsMenuColumn').childNodes[1].style.visibility = 'hidden'; } catch(e) {};
		if(exception!='LiamMenuColumn') try { document.getElementById('LiamMenuColumn').childNodes[1].style.visibility = 'hidden'; } catch(e) {};
	};
	function showSubmenu(menuColumn) {
		var submenu = menuColumn.childNodes[1];
		hideAllSubmenus(menuColumn.id);
		if(submenu) submenu.style.visibility = 'visible';
	};
	function defaultSubmenu() {
		if(!nowOverMenu) {
			if (document.getElementById('selectedSubmenu')) {
				hideAllSubmenus(document.getElementById('selectedSubmenu').parentNode.id);
				document.getElementById('selectedSubmenu').style.visibility = 'visible';
			}
		};
	};

	var menuSections = ['News', 'About', 'Events', 'Editions', 'Liam'];

	var menuPreloader = new Array();
	for(menuSection in menuSections) {
		menuPreloader[menuSections[menuSection]] = new Image();
		menuPreloader[menuSections[menuSection]].src = '/img.php?q=90&w=93&h=30&t='+menuSections[menuSection]+'&f=peexL&r=255&g=255&b=255&c=10&v=50&i=images/assets/tit1.jpg';
		
		cleanWhitespace(document.getElementById(menuSections[menuSection]+'MenuColumn'));
		document.getElementById(menuSections[menuSection]+'MenuColumn').firstChild.onclick = function() {
			document.location.href = '/'+this.parentNode.id.substr(0,this.parentNode.id.indexOf('MenuColumn')).toLowerCase();
		};
		document.getElementById(menuSections[menuSection]+'MenuColumn').onmouseover = function() {
			nowOverMenu = true;
			showSubmenu(this);
		};
		document.getElementById(menuSections[menuSection]+'MenuColumn').onmouseout = function() {
			nowOverMenu = false;
			window.setTimeout('defaultSubmenu();',2000);
		};
	};
};
