// JavaScript Document
//Get and format the last change date for the page
function documentUpdateDate(){
	datelastmod = new Date(document.lastModified)
	document.write(datelastmod.getDate() + "/" + (datelastmod.getMonth()+1) + "/" + datelastmod.getFullYear() +".") 
}

//These scripts combine to put the footer in the right place. The first measures the height of the window.
//The second measures the height of the relatively position divs and either positions the footer relatively, 
//if they're higher than the window height, or absolutely stuck to the bottom of the window id the page is short.
		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;
		}
		function getWindowWidth() {
			var windowWidth = 0;
			if (typeof(window.innerWidth) == 'number') {
				windowWidth = window.innerWidth;
			}
			else {
				if (document.documentElement && document.documentElement.clientWidth) {
					windowWidth = document.documentElement.clientWidth;
				}
				else {
					if (document.body && document.body.clientWidth) {
						windowWidth = document.body.clientWidth;
					}
				}
			}
			return windowWidth;
		}
		
		function setPosition() {
	
			if (document.getElementById) 
			{
				var windowHeight = getWindowHeight();
				var windowWidth = getWindowWidth();
				//alert(windowWidth);
				if (windowHeight > 0)
				{

//					var container = document.getElementById('container');
					var mainContent = document.getElementById('mainContent');
					var header = document.getElementById('header');
					var bodyContent = document.getElementById('bodyContent');
					var footer = document.getElementById('footer');
//					var rightMargin = document.getElementById('rightMargin');
					var leftMargin = document.getElementById('leftMargin');					
//					var contentHeight = header.offsetHeight + bodyContent.offsetHeight;
					var headerHeight = header.offsetHeight;
					var footerHeight = footer.offsetHeight;
					var contentHeight = headerHeight + bodyContent.offsetHeight + footerHeight;


					if (!(typeof window.expand == "function"))
					{
						
						//Get the footer to stick to the bottom of the window
						if (contentHeight < windowHeight)
						{	
							bodyContent.style.height = (windowHeight - headerHeight - footerHeight - 20) + 'px';
							if ( bodyContent.offsetHeight < 500)
								bodyContent.style.height = 500;
	//						rightMargin.style.height = windowHeight + 'px';
	//						leftMargin.style.height = windowHeight + 'px';						
						// else if content is longer than the page						
						}
						
						
						//alert("else");
						if (windowWidth > 920) 
							document.getElementById('container').style.left = (windowWidth - 920) / 2 + 'px';
						//If not, at least make sure the navigation bar is visible
						else 
						{
							//find current y offset for all browsers (needed for maintaining hyperlinks to page references in expertise section)
							var y;
							if (self.pageYOffset) // all except Explorer
							{
								y = self.pageYOffset;
							}
							else if (document.documentElement && document.documentElement.scrollTop)
								// Explorer 6 Strict
							{
								y = document.documentElement.scrollTop;
							}
							else if (document.body) // all other Explorers
							{
								y = document.body.scrollTop;
							}
							window.scrollTo(920 - windowWidth -30, y);
						}
					}
					
					/*if (windowHeight > contentHeight){
						rightMargin.style.height = windowHeight + 'px';
						leftMargin.style.height = windowHeight + 'px';
						mainContent.style.height = windowHeight + 'px';
					} else {
						rightMargin.style.height = contentHeight + 'px';
						leftMargin.style.height = contentHeight + 'px';
					}*/
					


				}
			}
		}
		
/*		function getScrollDistance(){
				var scrollDistance;
				// all except Explorer
				if (self.pageYOffset){
					scrollDistance = self.pageYOffset;
				// Explorer 6 Strict
				} else if (document.documentElement && document.documentElement.scrollTop){
					scrollDistance = document.documentElement.scrollTop;
				// all other Explorers	
				} else if (document.body){
					scrollDistance = document.body.scrollTop;
				}
				return scrollDistance;
		}*/
		
//Window.onload function is in stylesheetSwitcher which also uses that event - can't have 2 definitions of the same function in different files

		
		window.onresize = function(e) {
		
			setPosition();
		}
		