var scrollPosition;
function showVideo(id) {
	if (document.documentElement && (document.documentElement.scrollTop)) {
		scrollPosition = document.documentElement.scrollTop;
	} else { 
		scrollPosition = document.body.scrollTop;
	}
	
	document.getElementById('galleries').style.display = 'none';
	document.getElementById('video').style.display = 'block';
	document.getElementById('video_control').style.display = 'block';
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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 output = '<object width="853" height="505">'
	+ '<param name="movie" value="http://www.youtube.com/v/' + id + '&hl=da_DK&fs=1&color1=0x3a3a3a&color2=0x999999&hd=1"></param>'
	+ '<param name="allowFullScreen" value="true"></param>'
	+ '<param name="allowscriptaccess" value="always"></param>'
	+ '<embed src="http://www.youtube.com/v/' + id + '&hl=da_DK&fs=1&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505">'
	+ '</embed>'
	+ '</object>';
	
	var canvas_start = document.getElementById('header').offsetHeight;
	var canvas_height = yScroll-document.getElementById('header').offsetHeight;
	var controls_gap = 20;
	var elements_height = document.getElementById('video').offsetHeight+controls_gap+document.getElementById('video_control').offsetHeight;
	
	var video_top = Math.floor((canvas_height/2)-(elements_height/2)+canvas_start);
	var controls_top = video_top+elements_height-document.getElementById('video_control').offsetHeight;

	document.getElementById('video').style.left = (xScroll/2)-(document.getElementById('video').offsetWidth/2)+'px';
	document.getElementById('video').style.top = video_top+'px';
	document.getElementById('video_control').style.left = (xScroll/2)-(document.getElementById('video_control').offsetWidth/2)+'px';
	document.getElementById('video_control').style.top = controls_top+'px';
	document.getElementById('video').innerHTML = output;
}

function closeVideo() {
	document.getElementById('video').innerHTML = '';
	document.getElementById('video').style.display = 'none';
	document.getElementById('video_control').style.display = 'none';
	document.getElementById('galleries').style.display = 'block';
	
	window.scrollTo(0, scrollPosition);
}