function ShowHideLayer(id) {
	var v = document.getElementById(id).style.visibility;
	if(v == "visible") {
		document.getElementById(id).style.visibility = "hidden";
	} else {
		document.getElementById(id).style.visibility = "visible";
	}
}

function WriteFlashObject() {
	var file 	= document.getElementById('marginal_videofile').value;
	var fo 		= document.getElementById('marginal_flashobject');
	fo.innerHTML = '<a href="javascript:StopVideo()"><img style="margin: 0px; padding: 0px;"  src="/fileadmin/templates/matrix42_mainTemplate_2009_FILES/videobox_close.gif" alt="Close"></a><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="640" height="500" id="videoplayer" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="FlashVars" value="filename='+file+'" /><param name="movie" value="/fileadmin/flash/videoplayer.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/fileadmin/flash/videoplayer.swf" quality="high" FlashVars="filename='+file+'" bgcolor="#ffffff" width="640" height="500" name="player" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
}

function VideoOverlay(state) {
	if(state=="on") {
		var overlayDIV	= document.createElement("div");
		document.body.insertBefore(overlayDIV, document.body.firstChild);
		var neuBText 	= document.body.firstChild.setAttribute("id", "marginal_video_overlay");
		document.getElementById('marginal_video_overlay').style.height = document.body.offsetHeight; 
		
} else { // delete Div 
		document.body.firstChild.innerHTML = '';	
	  	var Knoten = document.body.firstChild;
		document.body.removeChild(Knoten);
	}
}

function EraseFlashObject() {
	var fo 		= document.getElementById('marginal_flashobject');
	fo.innerHTML = '';
	VideoOverlay('off');
}

function StartVideo() {
	ShowHideLayer('marginal_video');
	VideoOverlay('on');
	WriteFlashObject();
}

function StopVideo() {
	ShowHideLayer('marginal_video');
	EraseFlashObject();
}
