/***********************************************************************************************************************
 _____ _           _       ____  _             _         _   _                 _ _ _
|  ___| | __ _ ___| |__   |  _ \| |_   _  __ _(_)_ __   | | | | __ _ _ __   __| | (_)_ __   __ _
| |_  | |/ _` / __| '_ \  | |_) | | | | |/ _` | | '_ \  | |_| |/ _` | '_ \ / _` | | | '_ \ / _` |
|  _| | | (_| \__ \ | | | |  __/| | |_| | (_| | | | | | |  _  | (_| | | | | (_| | | | | | | (_| |
|_|   |_|\__,_|___/_| |_| |_|   |_|\__,_|\__, |_|_| |_| |_| |_|\__,_|_| |_|\__,_|_|_|_| |_|\__, |
                                         |___/                                             |___/
Author:		Elmar Bransch
Email:		elmar@minkenberg-medien.de
***********************************************************************************************************************/


// VB Script for IE extra handling is embedded in page separately

var MM_contentVersion = 6;
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_flash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');

function MM_checkPlugin(plgIn) {
	var ok=false;
	document.MM_returnValue = false;

	with (navigator) {
		if( plugins[plgIn] && plugins[plgIn].description )
		{
			var aVersionInfo = plugins[plgIn].description.split( ' ' );
			var aMajVersion = aVersionInfo[2].split( '.' );
			if( aMajVersion[0]<8.0 )
			{
				// for outdated versions show an extra page
				window.location.href = "noflash.html";
				ok = false;
				return ok;
			}
		}

		if (appName.indexOf('Microsoft')==-1) {
			ok=(plugins && plugins[plgIn]);
		}
		else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
				if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null)
					ok=window.MM_flash;
				else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null)
					ok=window.MM_dir;
				else
					ok=false
		}
	}
	return ok;
}


function	popupMediaFile(sSrcPath,sText,iOptWidth,iOptHeight)
{
	var iWidth 	= ( (iOptWidth) ? iOptWidth : 780 );
	var iHeight = ( (iOptHeight) ? iOptWidth : 640 );
	// var	oMyWindow = window.open(  '' , 'WCMSPOPUP','width=780, height=640, toolbar=no, directories=no, hotkeys=no,  location=no, menubar=no, status=no, scrollbars=yes,resizable=yes' );
	var	oMyWindow = window.open(  '' , 'WCMSPOPUP','width='+(iWidth.toString())+', height='+(iHeight.toString())+', toolbar=no, directories=no, hotkeys=no,  location=no, menubar=no, status=no, scrollbars=yes,resizable=yes' );
	oMyWindow.document.open();
	oMyWindow.Title = 'MM Media Viewer';
	oMyWindow.document.writeln( '<html><head>' );
	oMyWindow.document.writeln( '<title>MM Media Viewer</title>' );
	oMyWindow.document.write( '<link rel="stylesheet" href="/css/corporate.css">' );
	oMyWindow.document.writeln( '</head>' );
	oMyWindow.document.write( '<body style="margin-top:-9px;" topmargin"0" leftmargin="0" marginwidth="0" marginheight="0">' );
	oMyWindow.document.writeln( '<table width="100%" border=0 cellspacing=0 cellpadding=0><tr height="39" valign="top">' );
	oMyWindow.document.writeln( '<td align="left" bgcolor="#ffffff">' );
	oMyWindow.document.writeln( '<img src="/publish/img/popup_mm.gif"></td>' );
	oMyWindow.document.writeln( '<td align="right" bgcolor="#ffffff">' );
	oMyWindow.document.writeln( '<img src="/publish/img/popup_gradient.gif"></td>' );
	oMyWindow.document.writeln( '</tr><tr valign="center">' );
	oMyWindow.document.writeln( '<td colspan=2 align="center">' );
	oMyWindow.document.writeln( '<br> <div id="shadow" Style="_height:33%;filter: progid:DXImageTransform.Microsoft.dropShadow( Color=cccccc,offX=3,offY=3,positive=1,Enabled=1);">' );
	oMyWindow.document.writeln( '<a style="border:1px solid #333333;" href="javascript:window.close()" title="Klicken zum Schliessen"><img src="' + sSrcPath + '" border="0"></a>' );
	oMyWindow.document.writeln( '</div>' );
	if( sText )
		oMyWindow.document.writeln( '<br>' + sText );
	oMyWindow.document.writeln( '</td></tr></table>' );
	oMyWindow.document.writeln( '</body></html>' );
	oMyWindow.document.close();
}


function MacCheckFlashMime()
{
	var plugin = (navigator.mimeTypes &&
	navigator.mimeTypes["application/x-shockwave-flash"] ?
	navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
	if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 8)
		return true;
	else
		return false;
}

function	writeFlash(sMovieName,mAltHTML,sParams,iWidth,iHeight,sBgColor,bNoTransparent)
{
	//document.open();			

	if( (MM_checkPlugin("Shockwave Flash") || MacCheckFlashMime()) )
	{
		var sOut = "";
		var sHeightTag 	= ( (iHeight>0) ? ' height="' + iHeight + '" ' : '' );
		var sWidthTag 	= ( (iWidth>0) ? ' width="' + iWidth + '" ' : '' );
		var sColorTag	= ( (sBgColor) ? ' bgcolor="' + sBgColor + '" ' : '' );
		var sSWFParams	= ( (sParams) ? '?1=1' + (sParams.indexOf('&') == 0 ? sParams : '&' + sParams) : '' );
		
		var aQueryParams = sSWFParams.substring(1).split( '&' );
		var sNSSWFParams = '';
		for( var i = 0; i < aQueryParams.length; i++) {
			var aPairs = aQueryParams[i].split( '=' );
			sNSSWFParams += '&' + aPairs[0] + '=' + encode( aPairs[1] );
		}

		// add missing referer info to Flash Movie
		sParams += "&referer=" + escape( window.location.href );
		sNSSWFParams += "&referer=" + encode( window.location.href );

		sNSSWFParams = '?' + sNSSWFParams.substring(1);

		sOut = '<object swLiveConnect="true" id="oFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"' + sWidthTag + sHeightTag + '>';
		sOut += '<param name="movie" value="'+sMovieName+'">';
		sOut += '<param name="quality" value="high">';
		sOut += '<param name="scale" value="exactfit">';
		sOut += '<param name="menu" value="false">';
		
		// Only for Firefox and Internet Explorer transparent possible:
		if (navigator.userAgent.indexOf('Firefox') == -1 && navigator.userAgent.indexOf('Opera') == -1 && navigator.appName.indexOf("Microsoft Internet Explorer") == -1)
		{
			bNoTransparent = true;
		}
		
		if (!bNoTransparent)
		{			
			sOut += '<param name="wmode" value="transparent" />';
		}

		if( sParams )
			sOut += '<param name="flashvars" VALUE="'+sParams+'">';

		if( sBgColor )
			sOut += '<param name="bgcolor" value='+sBgColor+'">';

		
		sOut += '<embed  id="oFlashE" SW2LIVECONNECT=true ' + (bNoTransparent ? '' : 'wmode="transparent"') + ' name="oFlash" src="' + sMovieName + sNSSWFParams + '" scale="exactfit" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' + sColorTag + sWidthTag + sHeightTag + '></embed>';
		sOut += '</object>';				
		
		document.writeln(sOut);
		
		window.onload = function() {
			if (document.getElementById("oFlashE"))	
			{		
				document.getElementById('oFlashE').focus();
			}
			else
			{
				document.getElementById('oFlash').focus();		
			}
		}
	}
	else
	{
		if( typeof( mAltHTML ) == 'string' )
			document.writeln( mAltHTML );
		if( typeof( mAltHTML ) == 'function' )
			mAltHTML();
	}
	// document.close();
}


function	writeFlashHTML(sMovieName,sAltHTML,sParams,iWidth,iHeight,sBgColor,bNoTransparent)
{
	var sHTML = '';		
			
	//document.open();
	if( MM_checkPlugin("Shockwave Flash") || MacCheckFlashMime() )
	{
		var sHeightTag 	= ( (iHeight>0) ? ' height="' + iHeight + '" ' : '' );
		var sWidthTag 	= ( (iWidth>0) ? ' width="' + iWidth + '" ' : '' );
		var sColorTag	= ( (sBgColor) ? ' bgcolor="' + sBgColor + '" ' : '' );
		var sSWFParams	= ( (sParams) ? '?1=1' + sParams : '' );

		var aQueryParams = sSWFParams.substring(1).split( '&' );
		var sNSSWFParams = '';
		for( var i = 0; i < aQueryParams.length; i++) {
			var aPairs = aQueryParams[i].split( '=' );
			sNSSWFParams += '&' + aPairs[0] + '=' + encode( aPairs[1] );
		}
		sNSSWFParams = '?' + sNSSWFParams.substring(1);

		sHTML += '<object swLiveConnect="true" id="oFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"' + sWidthTag + sHeightTag + '>';
		sHTML += '<param name="movie" value="'+sMovieName+'">';
		sHTML += '<param name="quality" value="high">';
		sHTML += '<param name="scale" value="exactfit">';
		sHTML += '<param name="menu" value="false">';
		
		if (!bNoTransparent)
		{
			sHTML += '<param name="wmode" value="transparent" />';
		}

		if( sParams )
			sHTML += '<param name="flashvars" VALUE="'+sParams+'">';

		if( sBgColor )
			sHTML += '<param name="bgcolor" value='+sBgColor+'">';

		sHTML += '<embed SW2LIVECONNECT=true name="oFlash" src="' + sMovieName + sNSSWFParams + '" scale="exactfit" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' + sColorTag + sWidthTag + sHeightTag + '></embed>';
		sHTML += '</object>';
	}
	else
	{
		sHTML += ( sAltHTML );
	}	
	return sHTML;
	// document.close();
}


var digits ="0123456789abcdef";
var hex = new Array( 256 );
for( var idx = 0; idx < 256; idx++ )
    hex[ idx ] = "%" + digits.charAt( idx >> 4 ) + digits.charAt( idx & 0xf );



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function encode( s )
{
    var sbuf = "";
    if( !s )
    	return '';
    var len = s.length;
    for( var i = 0; i < len; i++ ) {
      var ch = s.charAt(i);

      if( /[A-Za-z0-9-_.!~*'()]/.test( ch ) ) {
        sbuf += ch;
      } else{
         var cc = s.charCodeAt(i);
         if (cc <= 0x007f) {          // other ASCII
            sbuf += hex[cc];
         } else if (cc <= 0x07FF) {          // non-ASCII <= 0x7FF
            sbuf += hex[0xc0 | (cc >> 6)]
                 + hex[0x80 | (cc & 0x3F)];
         } else {                         // 0x7FF < ch <= 0xFFFF
            sbuf += hex[0xe0 | (cc >> 12)]
                 + hex[0x80 | ((cc >> 6) & 0x3F)]
                 + hex[0x80 | (cc & 0x3F)];
         }
      }
    }
    return sbuf;
}


