var bw = 0;
var bh = 0;
var sw = 0;
var sh = 0;

function showDiv(id){
	div = document.getElementById(id);
	
	div.style.display = 'block';
}
function hideDiv(id){
	document.getElementById(id).style.display = 'none';
}

function closeDisplay(){
	
	box = document.getElementById('display');
	boxover = document.getElementById('over');
	
	box.innerHTML = '';
	box.style.width = '0px';
	boxover.style.width = '0px';
	boxover.style.height = '0px';
}
function openMovie(clip,size){ 
	loadID('/movie/' + clip +'/'+ size +'/','display');
} 
function openImage(clip){ 
	loadID('/image/' + clip +'/','display');
} 
function loadID(url,id){

	if (window.XMLHttpRequest){
		
		req = new XMLHttpRequest();
		
		req.onreadystatechange = function(){
			displayID();
		};
		
		req.open("GET", url, true);
		req.send(null);
	
	}else if (window.ActiveXObject){
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req){
			req.onreadystatechange = function(){
				displayID();
			};
			
			req.open("GET", url, true);
			req.send();
		}
	}
	return;
}    
function displayID(){
	
	box = document.getElementById('display');
	boxover = document.getElementById('over');

	box.style.display = 'none';
	box.style.width = '100%';
	
	if (req.readyState == 4){
		if (req.status == 200){
			box.innerHTML = req.responseText;
			
			getSizes();
			getScrollSizes();
			
			h = 360;
			box.style.top = ((bh + sh) - ((h + bh) / 2)) + 'px';
			
			box.style.display = '';
			boxover.style.width = '100%';
			boxover.style.height = (bh + sh) + 'px';			
			
		}else{
			box.innerHTML = "error: " + req.statusText;
		}
	}
	return;
}
function getSizes(){

	if( typeof( window.innerWidth ) == 'number' ) {
		bw = window.innerWidth;
		bh = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		bw = document.documentElement.clientWidth;
		bh = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		bw = document.body.clientWidth;
		bh = document.body.clientHeight;
	}

	return;

}
function getScrollSizes() {
	
	if( typeof( window.pageYOffset ) == 'number' ) {
		sw = window.pageXOffset;
		sh = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		sw = document.body.scrollLeft;
		sh = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		sw = document.documentElement.scrollLeft;
		sh = document.documentElement.scrollTop;
	}
  	return;

}
