function getWinSize() {

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	
	return new Array(winWidth,winHeight);

}

function windowResize() {
	
	var main_wrapper = document.getElementById('main_wrapper');
	var black = document.getElementById('black');
	
	var sizes = getWinSize();
	
	var winWidth = sizes[0];
	var winHeight = sizes[1];
	
	black.style.width = String(winWidth) + "px";
	black.style.height = String(winHeight) + "px";
		
	main_wrapper.style.left = String(winWidth/2-526) + "px";
	main_wrapper.style.top = String(winHeight/2-400) + "px";
	
}

function changePage(page) {
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
		  document.getElementById("content_pane").innerHTML=xmlHttp.responseText;
		  }
		else {
			document.getElementById("content_pane").innerHTML="<center><br /><br /><br /><br /><br /><br /><img src='images/loading.gif'><br /><br /><br /><br /><br /><br /></center>";
		}
		}
	  xmlHttp.open("GET","pages/" + page + ".php",true);
	  xmlHttp.send(null);
 }
 
function getDefaultPage() {
	if(location.hash) {
		page=location.hash.substr(1);
	} else {
		page="about";
	}
	
	changePage(page);
}

/*************************

	Gallery Functions

*************************/

function getPage(path,target) {

	var xmlHttp;
	try {
	  // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
	  // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	  
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			target.innerHTML=xmlHttp.responseText;
		} else {
			target.innerHTML="<img src='images/loading.gif'>";	
		}
	}
	
	xmlHttp.open("GET","pages/" + path,true);
	xmlHttp.send(null);
		

}

function resizePopUp(width) {

	var popup = document.getElementById("popup");
	
	popup.style.left = String(winWidth/2 - width/2) + "px";

}

function openPopUp(page,width,height) {
	
	var popup = document.getElementById("popup");
	
	getPage(page,document.getElementById('popupcontent'));
				
	if(width) {
		popup.style.width = String(width) + "px";
		popup.style.left = String(winWidth/2 - width/2) + "px";
	}
	
	if(height) {
		popup.style.height = String(height) + "px";
		popup.style.top = String(winHeight/2 - height/2) + "px";
	}
	
	document.getElementById('black').style.display='table-cell';
	popup.style.display="table-cell";
	
	
}

function closePopUp() {
	
	document.getElementById('black').style.display='none';
	document.getElementById("popup").style.display="none";
	
}

function showClose() {

	document.getElementById('closepopup').style.display="block";

}

function hideClose() {
	
	document.getElementById('closepopup').style.display="none";

}

function switchInfo(which) {

	var elements = document.getElementsByName("playbackinfo");
	var element = document.getElementById(which);
	
	for(i=0;i<elements.length;i++) {
		elements[i].style.display="none";
	}
		
	element.style.display="block";

}

function pageLoaded() {
	
	getDefaultPage();
	windowResize();
	
	if(window.addEventListener) {
		window.addEventListener('resize',windowResize,false);
	} else {
		window.attachEvent("onresize",windowResize);
	}
	
}