function showSubmenu(id, nummer){
	document.getElementById(id).style.display = 'block';
	document.getElementById(nummer).src = '/images/tussenmenu_act.gif';
}

function hideSubmenu(id, nummer){
	document.getElementById(id).style.display = 'none';
	document.getElementById(nummer).src = '/images/tussenmenu.gif';
}

function showImage(id, foto, omschrijving, border){
	document.getElementById(id).src = foto;
	document.getElementById('omschrijving').innerHTML = omschrijving;
	if(border){
		document.getElementById(id).style.border = 'solid 1px #c6c7c8';
	} else {
		document.getElementById(id).style.border = 'none';
	}
}

function changeImage(id, foto){
	document.getElementById(id).src = foto;	
}

var xmlHttp;

function showMovieBox(id, action){
	xmlHttp = GetXmlHttpObject();
	var url = '/ajax/'+id+'/'+action+'.htm';
	xmlHttp.onreadystatechange=showInfoState;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showInfoState(){
	if (xmlHttp.readyState==4){
		var xmldoc = xmlHttp.responseXML;
		var msg = xmldoc.getElementsByTagName('msg')[0].childNodes[0].nodeValue;
		showInfoBox(767,420,msg);

		if (document.getElementById('vraagteken')){
			var objVraagteken = document.getElementById('vraagteken');
			objVraagteken.stopInterval();
		}

	}
}

function showInfoBox(width, height, msg){
	buildDiv(width, height);
	var infoDiv = document.getElementById('infoDiv');
	infoDiv.innerHTML = msg;
}

function buildDiv(width, height){
	var objOverlay = document.getElementById('infoOverlay');
	var objDivbox = document.getElementById('infoBox');

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

	// center divbox and make sure that the top and left values are not negative
	// and the image placed outside the viewport
	var divboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - height) / 2);
	var divboxLeft = ((arrayPageSize[0] - 20 - width) / 2);

	objDivbox.style.top = (divboxTop < 0) ? "0px" : divboxTop + "px";
	objDivbox.style.left = (divboxLeft < 0) ? "0px" : divboxLeft + "px";

	objDivbox.style.display = 'block';

	// After image is loaded, update the overlay height as the new image might have
	// increased the overall page height.
	arrayPageSize = getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	
	objDivbox.style.width = width + 'px';
	objDivbox.style.height = height + 'px';
	objDivbox.style.overflow = 'auto';
}

function initInfoBox(){
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','infoOverlay');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	// create Divbox div, same note about styles as above
	var objDivbox = document.createElement("div");
	objDivbox.setAttribute('id','infoBox');
	objDivbox.style.display = 'none';
	objDivbox.style.position = 'absolute';
	objDivbox.style.zIndex = '100';	

	var infoDiv = document.createElement("div");
	infoDiv.setAttribute('id','infoDiv');

	objDivbox.appendChild(infoDiv);

	objBody.insertBefore(objDivbox, objOverlay.nextSibling);
}

function hideMovieBox(){
	var objOverlay = document.getElementById('infoOverlay');
	var objDivbox = document.getElementById('infoBox');

	objOverlay.style.display = 'none';
	objDivbox.style.display = 'none';

	var infoDiv = document.getElementById('infoDiv');
	infoDiv.innerHTML = "";

	if (document.getElementById('vraagteken')){
		var objVraagteken = document.getElementById('vraagteken');
		objVraagteken.startInterval();
	}
}

addLoadEvent(initInfoBox);

//## ajax get XML ## 
function GetXmlHttpObject(){
	var xmlHttp=null;
	try	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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 loadExtended(){
	var element = document.getElementById('hotstuf_expand_flash');
	element.style.width = '1000px';
	element.style.zIndex = 10;
	element.init();
}

function closeHotstufGame(){
	var element = document.getElementById('hotstuf_expand_flash');
	element.style.width = '1px';
	element.style.zIndex = 1;
}