// Browser Window Size and Position 110723
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
// http://javascript.about.com/library/blscreen2.htm

// Notes: 
// 1. If the page already has an window.onload then we must include SetPos in that function on the page itself	
// 2. If the body of the page is too wide then you will see bottom scroll bars. In that case (e.g. ccm.htm) just 
//    set body width <div id="body" style="visibility: hidden;  width:620">
// SetPos is now called via onload of first image in Right border
// but the include of getScreen.js is in body page
// 110802 Occasional blank screens. Include window.onload as belt and braces
// 110821 No, problem with multiple onload's - remove again
//window.onload=SetPos

function SetPos() {
//alert("Here")
//alert(document.getElementById("right") != undefined)

//alert("pageWidth: " + pageWidth())  
scnwidth=pageWidth()
// The 20 deduction is to allow for RH scrollbars
// IE includes them in width, Firefox seems to account for them i.e. has net screen width
// Result is that FF right border is further 20 to left
Pad = ((scnwidth - 20 - 920) / 2)
//alert(scnwidth + " " + Pad)
// Wider than 940
if (Pad >= 0) {
	//document.getElementById("right").style.paddingRight = Pad + 22;				
	
	if (document.getElementById("right") != undefined) {document.getElementById("right").style.paddingRight = Pad + 20;}
}
else {
	if (scnwidth > 920) {
		// Between 920 and 940. Still some padding of right border
		Pad=0
		//document.getElementById("right").style.paddingRight = (scnwidth - 940) + 22;		
		if (document.getElementById("right") != undefined) {document.getElementById("right").style.paddingRight = (scnwidth - 940) + 20;}	
	}
	else {
		// Less than width of web page	
		Pad = 0
		if (document.getElementById("right") != undefined) {document.getElementById("right").style.paddingRight = 0;}
	}
}
document.getElementById("top").style.paddingLeft = Pad;
document.getElementById("left").style.paddingLeft = Pad;
document.getElementById("bottom").style.paddingLeft = Pad;
// Unhide everything after moving
document.getElementById("top").style.visibility = "visible"
document.getElementById("left").style.visibility = "visible"
if (document.getElementById("right") != undefined) {document.getElementById("right").style.visibility = "visible";}
document.getElementById("body").style.visibility = "visible"
document.getElementById("bottom").style.visibility = "visible"

// Show main menu. This is so it doesn't immediately display in original position when page loads
showFloatMenuAt('MainMenu',Pad + 17, 170);


}

function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 

function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 

function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 

function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
