function showLanguage(id){
	document.getElementById('language_'+id).style.display = 'block';
}
function hideLanguage(id){
	document.getElementById('language_'+id).style.display = 'none';
}

function changeLanguage(out){
	if (out){
		document.getElementById('languagemenu').style.display = "none";
	}else{
		document.getElementById('languagemenu').style.display = 'block';
	}
}

function showPopbox(){
	document.getElementById('popbox').style.display = 'block';
}
function removePopbox(){
	document.getElementById('popbox').style.display = "none";
}

function shutdownFlashbanner(){
	document.getElementById('zebra').style.display = 'none';
}

function showYoutubeMovie(width, height, url){
	var msg = '';
	msg += '<table style="background-color: #FFF;">';
	msg += '<tr><td>';
		msg = msg + '<object width="'+width+'" height="'+height+'"><param name="movie" value="'+url+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+width+'" height="'+height+'"></embed></object>';
	msg += '</td><td valign="top">';
		msg = msg +'<a href="javascript:hideMovieBox();"><img src="/images/close.gif"></a>';
	msg += '</td></tr>';
	msg += '</table>';
	showInfoBox(width + 30, height + 40, msg);
}

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 = "";
}

addLoadEvent(initInfoBox);

function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}
