<!--
// JavaScript Document
	function myHeight() {
	// Find window height
	// based on "www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16"
		var h=0;
		if (window.innerHeight) {
			h = window.innerHeight;
		} else {
			if (document.documentElement && document.documentElement.clientHeight) {
				h = document.documentElement.clientHeight;
			} else {
				h = document.body.clientHeight;
			}
		}
		return h;
	}
	function myWidth() {
	// Find window width
	// based on "www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16"
		var w=0;
		if (window.innerWidth) {
			w = window.innerWidth;
		} else {
			if (document.documentElement && document.documentElement.clientWidth) {
				w = document.documentElement.clientWidth;
			} else {
				w = document.body.clientWidth;
			}
		}
		return w;
	}
	function setCookie(name,value,days,path) {
		var expiryDate = new Date();
		expiryDate.setTime(expiryDate.getTime() + days*24*60*60*1000);
		document.cookie=(name + "=" + value + "; expires=" + expiryDate.toGMTString() + "; path=" + path);
	}
function slideYTo(e,y,uTime) {
// based on xSlideTo in x.js, but only moving Y coordinate
  if (!(e=xGetElementById(e))) return;
  if (!e.timeout) e.timeout = 25;
  e.yTarget = y; e.slideTime = uTime; e.stop = false;
  e.yA = e.yTarget - xTop(e); // A = distance
  e.B = Math.PI / (2 * e.slideTime); // B = period
  e.yD = xTop(e); // D = initial position
  var d = new Date(); e.C = d.getTime();
  if (!e.moving) slideY(e);
}
function slideY(e) {
  if (!(e=xGetElementById(e))) return;
  var now, s, t, newY;
  now = new Date();
  t = now.getTime() - e.C;
  if (e.stop) { e.moving = false; }
  else if (t < e.slideTime) {
    setTimeout("slideY('"+e.id+"')", e.timeout);
    s = Math.sin(e.B * t);
    newY = Math.round(e.yA * s + e.yD);
    xTop(e, newY);
    e.moving = true;
  }  
  else {
    xTop(e, e.yTarget);
    e.moving = false;
  }  
}
function adjustBackgroundPositionY(e)
// to adjust vertical position of background image if document has been scrolled
// Only needed for IE on Windows
{
  if(!(e=xGetElementById(e))) return "";
  //Test for MSIE on Windows
  var uA=navigator.userAgent.toLowerCase();
  if (uA.indexOf('msie')!=-1 && uA.indexOf('windows')!=-1)
  {
	// find amount of scroll
    var yPos = document.body.scrollTop;
	// set background image position to match scrolled position
    e.style.backgroundPosition = "right "+yPos;
  }
}
	function adjustGlobalContainer() {
		// get height of usable area of browser's window
		windowHeight=myHeight();
		
		// set height of global container to equal window height, if currently less
		if (xHeight("globalcontainer") < windowHeight ) {
			xHeight("globalcontainer",windowHeight);
		}
	}
	function adjustGlobalContainerBackground() {
		adjustBackgroundPositionY("globalcontainer");
	}
	function adjustMenubarPosition() {
		// If window is large enough to accommodate the whole menu bar,
		// then slide it to the same position after the page is scrolled;
		// otherwise we just let it scroll with the page.
		//
		// height of menubar calculated as 59 plus 24 padding for each button, less 12 bottom padding for last icon, plus 6 top padding
		e = xGetElementById ("menustrip");
		// change from position=fixed, which doesn't work in MSIE
		e.style.position = "absolute";
		if (myHeight() >= (5*83-12)+6) {
			slideYTo("menustrip",xScrollTop(),100);
//			xTop("menustrip",xScrollTop());
		}
	}
function adjustLayout() {
	//Test for MSIE
	var uA=navigator.userAgent.toLowerCase();
	msIE = (uA.indexOf('msie')!=-1)

	xAddEventListener(window, "resize", adjustGlobalContainer, false);
//	xAddEventListener(window, "resize", adjustMenubarPosition, false);
	xAddEventListener(window, "scroll", adjustGlobalContainerBackground, false);
	if (msIE) {
		xAddEventListener(window, "scroll", adjustMenubarPosition, false);
	}
	adjustGlobalContainer();
	adjustGlobalContainerBackground();
	if (msIE) {
		adjustMenubarPosition();
	}
}
//-->
