// JavaScript Document
function closeElement(ID)
{
	var targetElement = document.getElementById(ID);
	targetElement.style.display = 'none';
}

function positionElement(ID, hor, vert)
{
	Init();
	var targetElement = document.getElementById(ID);
	var targetWidth = targetElement.offsetWidth;
	var targetHeight = targetElement.offsetHeight;
	var newX;
	var newY;
	
	
	if(hor == 'left'){newX = 0;}
	else if(hor == 'center'){newX = PageWidth/2 - targetWidth/2;}
	else if(hor == 'right'){newX = PageWidth - targetWidth;}
	
	if(vert == 'top'){newY = 0;}
	else if(vert == 'middle'){newY = PageHeight/2 - targetHeight/2;}
	else if(vert == 'bottom'){newY = PageHeight - targetHeight;}
	
	//alert("positionElement:"+ID+", "+hor+", "+vert+"\ntaget width:"+targetWidth+" target height:"+targetHeight+"\nnewX:"+newX+" newY:"+newY);
	targetElement.style.left = newX+"px";
	targetElement.style.top = newY+"px";
}

// -----------------------------------------------------------------------------------
//	The piece of code below are taken from :
//	Lightbox v2.03
//	by Lokesh Dhakar - http://www.huddletogether.com
//	4/9/06
// -----------------------------------------------------------------------------------
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function Init()
{
	var arrayPageSize = getPageSize();
	PageWidth = arrayPageSize[0];
	PageHeight = arrayPageSize[1];
}

if(document.loaded) {Init(); } 
else {
	if (window.addEventListener) {
		window.addEventListener('load', Init, false);
	} else if (window.attachEvent){
		window.attachEvent('onload', Init);
	} else {Init();}
} 
