function video(file, x, y)
{
	popup_schliessen();

	// Gesamte Seite transparent schalten
 /*
	document.getElementById('page').style.opacity = '0.15';
    document.getElementById('page').style.MozOpacity = '0.15';
    document.getElementById('page').style.KHTMLOpacity = '0.15';
    document.getElementById('page').style.filter = 'alpha(opacity:15)';
*/	

	if(!FlashDetect.installed)
	{
		alert("Adobe Flash Player is required to watch this video. ");
		return;
	}	

   	// Div dynamisch erzeugen
	popup = document.createElement("div");
   	popup.id = "popup";

    popup_width = x;
    popup_height = y;

	var scrolltop = window.pageYOffset;
	if (scrolltop == null) scrolltop = document.documentElement.scrollTop;
	if (scrolltop == null) scrolltop = document.body.scrollTop;
    if (scrolltop == null) scrolltop = 0;

	popup.style.left = (get_window_width() / 2) - (popup_width / 2) + "px";
   	popup.style.top = (get_window_height() / 2) - (popup_height / 2) + scrolltop + "px";
	popup.style.width = popup_width + "px";
	popup.style.height = popup_height + "px";

   	popup.style.display = "none";
	document.getElementsByTagName("body")[0].appendChild(popup);	
	//popup.innerHTML = document.getElementById("bild" + img_id).innerHTML + "<br /><br /><a href='javascript:popup_schliessen()'><img src='http://www.aerial.de/files/images/zurueck.gif' /></a>";

	flash_video(file, x, y, 1, popup);	
	
	toolbar = document.createElement("div");
	toolbar.id = "toolbar";
	toolbar.style.width = popup_width + "px";
	toolbar.innerHTML = "<a href='javascript:popup_schliessen()'><img src='files/images/cancel.png' alt='Schließen' title='Schließen' /></a>";
	$("popup").insertBefore(toolbar, document.getElementById("player"));	
	
	$("popup").appear();
}

function flash_video(file, x, y, autostart, target_element)
{
	if (autostart == '' || autostart == null) autostart = "false";
	if (target_element == '' || target_element == null) target_element = "video";
	url = "files/flash/mediaplayer.swf";
	// if (urls_optimieren == 1) url = root_verzeichnis + url;
	var so = new SWFObject(url,"player",x,y,"8");
	so.addParam("allowfullscreen","true");
	so.addParam("bgcolor","#557722");
	so.addVariable("contentpath", "files/flash");
	so.addVariable("file", file);
	so.addVariable("lightcolor","0x557722");
	so.addVariable("repeat","false");
	so.addVariable("shownavigation","true");
	so.addVariable("searchbar","false");
	so.addVariable("autostart",autostart);
   	so.addVariable("screencolor","0x161616");
	so.addVariable("overstretch","true");
	so.addParam("wmode", "transparent");
	so.addVariable("width",x);
	so.addVariable("height",y);
	so.write(target_element);
}

function popup_schliessen()
{
	// Div entfernen
	if (document.getElementById("popup") != null)
	{
		document.getElementsByTagName("body")[0].removeChild(popup);
    	popup = null;

    	// Transparenz aufheben
    	/*
		document.getElementById('page').style.opacity = '1';
        document.getElementById('page').style.MozOpacity = '1';
        document.getElementById('page').style.KHTMLOpacity = '1';
        document.getElementById('page').style.filter = 'alpha(opacity:100)';
		*/
	}
}

function get_window_width()
{
    if (document.documentElement.clientWidth)
		window_width = document.documentElement.clientWidth;
	else
	if (document.body.offsetWidth)
		window_width = document.body.offsetWidth;
	else
		window_width = window.innerWidth;
	return window_width;
}

function get_window_height()
{
    if (document.documentElement.clientHeight)
		window_height = document.documentElement.clientHeight;
	else
	if (document.body.offsetHeight)
		window_height = document.body.offsetHeight;
	else
		window_height = window.innerHeight;
	return window_height;
}
