var allOverlays = new Array('art', 'tech', 'evolution');

function showOverlay(menuId) {
	hideAll();
	if(document.getElementById) {
		document.getElementById(menuId).style.visibility = "visible";
	} else if(document.all) {
		document.all[menuId].style.visibility = "visible";
	} else if(document.layers) {
		document.layers[menuId].visibility = "visible";
	}
}

function hideAll() {
	for(i = 0; i < allOverlays.length; i++) {
		if(document.getElementById) {
			document.getElementById(allOverlays[i]).style.visibility = "hidden";
		} else if(document.all) {
			document.all[allOverlays[i]].style.visibility = "hidden";
		} else if(document.layers) {
			document.layers[allOverlays[i]].visibility = "hidden";
		}
	}
}

if(document.images) {
	normal			= new Image();	normal.src			= "/images/main.jpg";
	overArt			= new Image();	overArt.src			= "/images/main_art.jpg";
	overTech		= new Image();	overTech.src		= "/images/main_tech.jpg"
	overEvolution	= new Image();	overEvolution.src	= "/images/main_evolution.jpg";
}

function changeImg(imgName, imgSrc) {
		document.images[imgName].src = imgSrc;
}

function init() {
	window.setInterval("compensate()", 40);
}

function getWidth() {
	if(window.innerWidth)
		return window.innerWidth;
	else if(document.body.clientWidth)
		return document.body.clientWidth;
	else
		return false;
}

function getHeight() {
	if(window.innerHeight)
		return window.innerHeight;
	else if(document.body.clientHeight)
		return document.body.clientHeight;
	else
		return false;
}

var overlayWidth = 250;
var artHeight = 230;
var evolutionHeight = 202;

function compensate() {
	windowWidth = getWidth();
	windowHeight = getHeight();
	newArtLeft = 10;
	newArtTop = windowHeight - (artHeight + 10);
	newTechLeft = windowWidth - (overlayWidth + 10);
	newTechTop = 10;
	newEvolutionLeft = windowWidth - (overlayWidth + 10);
	newEvolutionTop = windowHeight - (evolutionHeight + 10);
	if(document.getElementById) {
		document.getElementById('art').style.left = newArtLeft + "px";
		document.getElementById('art').style.top = newArtTop + "px";
		document.getElementById('tech').style.left = newTechLeft + "px";
		document.getElementById('tech').style.top = newTechTop + "px";
		document.getElementById('evolution').style.left = newEvolutionLeft + "px";
		document.getElementById('evolution').style.top = newEvolutionTop + "px";
	} else if(document.all) {
		document.all.art.style.left = newArtLeft;
		document.all.art.style.top = newArtTop;
		document.all.tech.style.left = newTechLeft;
		document.all.tech.style.top = newTechTop;
		document.all.evolution.style.left = newEvolutionLeft;
		document.all.evolution.style.top = newEvolutionTop;
	} else if(document.layers) {
		document.art.moveTo(newArtLeft, newArtTop);
		document.tech.moveTo(newTechLeft, newTechTop);
		document.evolution.moveTo(newEvolutionLeft, newEvolutionTop);
	}
}