function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function showMovie(Id, DivId, Type, Width, Height, Preview, Image)
{
  var File = '/service/downloads.aspx?id=' + Id;

  if (Preview == true)
    File += "&action=vorschau";
 
	if ($("#"+DivId).parents(".autostart").length > 0) { autostart = true; } else { autostart = false; }

  var Height = Height; 

  if (Type == "flv")
  {
    File = encodeURIComponent(File);
    Height += 20;
	
			var flashvars = {
				file:File,
				type:Type,
				image:Image,
				autostart:autostart,
        //screencolor:'0x636363',
        //frontcolor:'0x0078bc',
        //lightcolor:'0x003959',
				width:Width,
				height:Height
			};
			var params = {
				//bgcolor : "#ffffff",
				wmode : "transparent",
				allowfullscreen : "true"
			};
			var attributes = {};
			addLoadEvent(function() {
				swfobject.embedSWF("/swf/mediaplayer.swf", DivId, Width, Height, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
			});
  }
	
  else if (Type == "swf")
  {
    File = encodeURIComponent(File);
			var flashvars = {};
			var params = {
				//bgcolor : "#ffffff",
				wmode : "transparent"
			};
			var attributes = {};
			addLoadEvent(function() { 
				swfobject.embedSWF("/swf/mediaplayer.swf", DivId, Width, Height, "9.0.0", "/swf/expressInstall.swf", flashvars, params, attributes);
			});
  }
	
  else if (Type == "wmv" || Type == "mpg" || Type == "avi")
  {
    Height += 45;
    document.write('<object id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-80c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" width="' + Width + '" height="' + Height + '" type="application/x-mplayer2"><param name="FileName" value="' + File + '"><embed src="' + File + '" width="' + Width + '" height="' + Height + '" type="application/x-mplayer2" /></object>');
  }
	
  else if (Type == "mov")
  {
    Height += 16;
    document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="' + Width + '" height="' + Height + '"><param name="src" value="' + File + '"><param name="autoplay" value="true"><param name="type" value="video/quicktime" width="' + Width + '" height="' + (Height + 16) + '"><embed src="' + File + '" width="' + Width + '" height="' + Height + '" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></object>');
  }
}


