	/*
	    Positioning issues:
	    in PositionLayer, the code varies somewhat if the position of the layer is relative
	    to the body of the page or a container. This will happen if: A parent of the layer is positioned absolute or relative. 
	    If the latter is the case the position of that container has to be substracted. 
	   
	*/
	
	function InitPage () {
		AddtoOldBrowsers()
	}	
	/*---------------------------
		Rollover layer functions
	---------------------------*/
	var LockedLayerID = "";
	var VisibleLayerID = ""
	
	function  ShowLayer (LayerID, e){
		if (!e) e = window.event; //Moz et al pass the event; explorer gets it from window.event
		if (VisibleLayerID != LayerID && VisibleLayerID != "") HideLayer (VisibleLayerID, true);
		theLayer = document.getElementById(LayerID);
		if (theLayer.style.visibility != 'visible') {
			PositionLayer (theLayer, e);
			theLayer.style.visibility = 'visible';
		}
		VisibleLayerID = theLayer.id;
		LockedLayerID = theLayer.id;
	}
	
	function PositionLayer (theLayer, e) {				
		var OffsetX = 30;
		var OffsetY = 30;
		
		theThumb = EventTarget(e);
		theContainer = document.getElementById("PageContainer")
		
		ContainerLeft = getElementPos(theContainer, "x"); 
		ContainerWidth = theContainer.offsetWidth;
		ContainerRight = ContainerLeft + ContainerWidth;
		
		ThumbLeft = getElementPos(theThumb, "x");
		ThumbTop = getElementPos(theThumb, "y");
		
		//theLayer.style.left = (GetPos (ThumbLeft, theThumb.offsetWidth, theLayer.offsetWidth,  ContainerLeft, ContainerRight, OffsetX) - ContainerLeft) + "px"
		theLayer.style.left = GetPos (ThumbLeft, theThumb.offsetWidth, theLayer.offsetWidth,  ContainerLeft, ContainerRight, OffsetX) + "px"
		theLayer.style.top = GetPos (ThumbTop, theThumb.offsetHeight, theLayer.offsetHeight, WindowTop(), WindowBottom(), OffsetY) + "px"
		
	}
	
	function GetPos (SenderMin, SenderLength, TargetLength, MinPos, MaxPos, Offset) {
		var thePos = 0;
		if (SenderMin - MinPos <= (MaxPos - MinPos) / 2) {//Object in first half of boundaries
			thePos = SenderMin + SenderLength - Offset;
			if (thePos + TargetLength > MaxPos - Offset) thePos = MaxPos - TargetLength - Offset;
		}
		else {//Object in second half of boundaries
			thePos = SenderMin - TargetLength + Offset;
			if (thePos < MinPos + Offset) thePos = MinPos + Offset;
		}
		return thePos;
	}
	
	function HideLayer (LayerID, ForceHide) {
		if (arguments.length == 0) {
			window.setTimeout("HideLayer('" + VisibleLayerID + "')", 200);
			LockedLayerID = "";
		}
		else if (LockedLayerID != LayerID || ForceHide == true) {
			document.getElementById(LayerID).style.visibility = 'hidden';
			if (VisibleLayerID == LayerID) VisibleLayerID = ""; 
			if (ForceHide == true) LockedLayerID == "";
		}
	}
	
	
	/*---------------------------
		DOM functions
	---------------------------*/
	
	//Gets the first child of the element that matches the tag name
	function FindFirstChildbyTagName (nodeCollection, theTagName) {
		for (i=0;i<nodeCollection.length;i++) {
			if (
				!isUndefined(nodeCollection[i].tagName)  && 
				nodeCollection[i].tagName.toLowerCase() == theTagName.toLowerCase()
				) 
				{return nodeCollection[i];}
		}
		return false;
	}			
	
	//Gets position of the element relative to the top left corner of the page			
	function getElementPos (e, Coord) {
		var thePos=0; 
		while(e){ 
			if (Coord == "x"){
				thePos+=e.offsetLeft
			}
			else {
				thePos+=e.offsetTop
			}
				e=e.offsetParent; ;
		} 
		return thePos;
	}
	/*---------------------------
		Cross browser functions
	---------------------------*/			
	
	//returns the origin of an event
	function EventTarget (e) {
		if (e.srcElement) return e.srcElement;
		return e.target;
	}
	
	//returns the mouse coordinates
	function GetMousePos(Coord, e) {
		if (e.pageX || e.pageY) {
			if (Coord == 'x') return e.pageX; 
			else return e.pageY; 
		}
		else if (e.clientX || e.clientY) {
			if (Coord == 'x') return e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			else return e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
	}
	
	//adds functions missing from old browsers via the prototype
	function AddtoOldBrowsers(){	
		//Array.push -> for IE5
		if (typeof Array.prototype.push == 'undefined') 
			Array.prototype.push = function() 
			{ 
				var a = arguments, b = a.length, c = this.length; 
				for(var i = 0; i < b; ++i) this[c + i] = a[i]; 
				return this.length; 
			}	
	} 
	
	function isUndefined (theObject) {
		if (typeof(theObject) === 'undefined') return true
		return false;
	}
	
	/*---------------------------
		Window area functions
	---------------------------*/		
	
	function WindowWidth () {
		if (window.innerWidth) return window.innerWidth;
		if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
		if (document.body && document.body.clientWidth) return document.body.clientWidth
	}
	
	function WindowLeft() {
		if (window.pageXOffset) return window.pageXOffset;
		if (document.documentElement && document.documentElement.scrollLeft) return document.documentElement.scrollLeft;
		if (document.body.scrollLeft) return document.body.scrollLeft;
		return 0;
	}	
	
	function WindowRight() {return WindowLeft() + WindowWidth()}
	
	function WindowHeight () {
		if (window.innerHeight) return window.innerHeight;
		if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
		if (document.body && document.body.clientHeight) return document.body.clientHeight
	}
	
	function WindowTop() {
		if (window.pageYOffset) return window.pageYOffset;
		if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop;
		if (document.body.scrollTop) return document.body.scrollTop;
		return 0;
	}
	
	function WindowBottom() {return WindowTop() + WindowHeight()}
	
	/*---------------------------
		Miscellaneous functions
	---------------------------*/			
	
	function PreloadImages (ImgArray) {
		var d = document;
		if (!d.PreloadedImages) d.PreloadedImages = new Array();
		var j = d.PreloadedImages.length;
		for (i=0;i<ImgArray.length;i++) {
			d.PreloadedImages[j] = new Image();
			d.PreloadedImages[j].src = ImgArray[i];
			j++;
		}
	}
