var currentMenu = null;
function expandMenu(obj){
	if(currentMenu){
		currentMenu.className=''
	}
	currentMenu = obj.parentNode;
	currentMenu.className = "over"
}
function setMenu(url){
	var nav = document.getElementById("nav")
	for(var i = 0; i < nav.childNodes.length; i++){
		if(nav.childNodes[i].nodeName == "LI"){
			var linkList = nav.childNodes[i].getElementsByTagName("a")
			for(var j = 0; j < linkList.length; j++){
				if(url == linkList[j].href){
					nav.childNodes[i].className = "over"
					currentMenu = nav.childNodes[i];
					return;
				}
			}
		}
	}
}
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 showOverlay(){
		var overlay = $("overlay");
		var sizes = getPageSize()
		if(sizes[0] < 960){
			sizes[0] = 960
		}
		overlay.style.width = sizes[0] + "px"
		overlay.style.height = sizes[1] + "px"
		overlay.style.display = "block";
	}

	function showPopup(){
		showOverlay()
		window.onresize = showOverlay
		
		new Effect.Appear("popup", {duration: 0.2})
	}
	function closePopup(){
		window.onresize = null;
		$("overlay").style.display = "none"
		new Effect.Fade("popup", {duration: 0.2})
	}
	
	
function showMore(e){
	var element = Event.element(e);
	element.up("div.lessmorebox").select(".lessmoreshort")[0].hide();
	element.up("div.lessmorebox").select(".lessmorefull")[0].show();
	return false;
}
function showLess(e){
	var element = Event.element(e);
	element.up("div.lessmorebox").select(".lessmoreshort")[0].show();
	element.up("div.lessmorebox").select(".lessmorefull")[0].hide();
	return false;
}

