// JavaScript Document
var xhr=false;
function showPopup(region)
{
	getPopup(region);
	return false;
}

function hidePopup() {
	//make popups invisible
	document.getElementById("darkenWin").style.visibility="hidden";
	document.getElementById("popupWin").style.visibility="hidden";
	document.getElementById("popupTitle").style.visibility="hidden";
}

function getPopup(region) {
	//request content for popup
	url="/Projects/"+region+".htm";
	if(window.XMLHttpRequest) {
		xhr=new XMLHttpRequest();
	} else {
		if(window.ActiveXObject) {
			try {
				xhr=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {}
		}
	}
	if(xhr) {
		xhr.onreadystatechange=showContents;
		xhr.open("GET",url,true);
		xhr.send(null);
	} else {
		alert("Error on XMLHttpRequest");
	}
}

function showContents() {
	//if ready, get content
	if(xhr.readyState==4) {
		var darkenWin=document.getElementById("darkenWin");
		var popupWin=document.getElementById("popupWin");
		var popupTitle=document.getElementById("popupTitle");
		//adjust popup sizes/positions to browser window/screen size
		darkenWin.style.height=parseInt(screen.availHeight)+"px";
		darkenWin.style.width=parseInt(screen.availWidth)+"px";
		popupWin.style.left=(parseInt(screen.availWidth)/2-300)+"px";
		popupTitle.innerHTML="<div 	style='text-align: right;'>Close <img style='vertical-align:text-bottom;' src='/images/closebox-off.png' onclick='hidePopup()'/></div>";
		popupTitle.style.width=popupWin.style.width;
		popupTitle.style.top=(parseInt(screen.availHeight)/2-250)+"px";
		popupWin.style.top=(parseInt(popupTitle.style.top)+18)+"px";
		popupTitle.style.left=popupWin.style.left;
		//insert content into popup
		popupWin.innerHTML=(xhr.status==200)?xhr.responseText:"Error on request: "+xhr.status;
		//make popups visible
		darkenWin.style.visibility="visible";
		popupWin.style.visibility="visible";
		popupTitle.style.visibility="visible";
	}
}

