
// Author:		Elmar Bransch
// Email:		elmar@minkenberg-medien.de


function setState( sNewState ) {
	var sSelf = window.location.href;
	sSelf += window.location.search;
	// get rid of anchors
	if( sSelf.indexOf('#') )
		sSelf = sSelf.substr( 0, sSelf.indexOf('#') );
	// get rid of our own parameters
	sSelf = sSelf.replace( /state\=.+&/g, '' );
	sSelf = sSelf.replace( /state\=.+$/g, '' );
	sSelf += (sSelf.indexOf('?')>=0?'&':'?');
	// get rid of duplicates cgi separators
	sSelf = sSelf.replace( '??', '?' );
	sSelf = sSelf.replace( '?&', '?' );
	location.replace( window.location.href = sSelf+'state='+sNewState );
}


function hideVideo( bDontSetState ) {
	document.getElementById( 'eaplay_video' ).style.display = 'none';
	if( bDontSetState==true) return;
	setState( 'videooff' );
}

function showVideo() {
	setState( 'videoon' );
}

function openLink ( sMsg, sURL) {
	if( confirm( sMsg ) ) {
		oWin = window.open(sURL, "extlink", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes,location=yes,menu=yes");
		oWin.focus();
	}
	return false;
}


function fadeOutVideo() {
	if( document.getElementById( 'eaplay_video' ) )
	{
		oAnimVideo = new eaplay_anim();
		oAnimVideo.instName( 'oAnimVideo' );
		oAnimVideo.setAnimObj( document.getElementById( 'eaplay_video' ) );
		oAnimVideo.onComplete( hideVideo );
		oAnimVideo.shrinkTo( 260, 10 );
	}
}


var eaplay_anim = function() {
	this.is_ie = (document.all && document.getElementById);
	this.is_moz = (!document.all && document.getElementById);
	this.is_opera = (navigator.userAgent.indexOf("Opera") > -1);
	this.is_animating = false;
	this.oAnimObj = null;
	this.iFadeInOp = 100;
	this.sMyInstName = '';
	this.oOnComplete = null;
	
	this.instName = function( sInstName ) {
		this.sMyInstName = sInstName;
	}

	this.onComplete = function( oFunc ) {
		this.oOnComplete = oFunc;
	}

	this.setAnimObj = function(oObj) {
		this.oAnimObj = oObj;
	}

	this.getAnimObj = function() {
		return this.oAnimObj;
	}

	this.shrinkTo = function( iFrom, iTo  ) {
		if( iFrom>0 && iTo>0 ) {
			this.iShrinkFrom = iFrom;
			this.iShrinkTo = iTo;
			this.iHeight = this.iShrinkFrom;
			this.is_animating = true;
		}
		if( this.iHeight > this.iShrinkTo ) {
			this.ClipY( this.iHeight );
			this.getAnimObj().style.height = this.iHeight + 'px';
			this.iHeight -= 40;
			setTimeout( this.sMyInstName+".shrinkTo()", 100);
		} else {
			this.is_animating = false;
			this.ClipY( this.iShrinkTo );
			this.iHeight = this.iShrinkTo;
			this.getAnimObj().style.height = this.iHeight + 'px';
			if( this.oOnComplete )	this.oOnComplete();
		}
	}
	
	this.ClipY = function( iY ) {
		// rect(oben rechts unten links)
		this.getAnimObj().style.clip = "rect( 0 750 "+iY+" 0)";
		document.getElementById( 'eaplay_flash' ).height = iY + 'px';
		document.getElementById( 'eaplay_flash' ).setAttribute( 'height', iY );
	}

	this.fadein = function() {
		if(this.iFadeInOp < 100) {
			this.is_animating = true;
			this.iFadeInOp += 10;
			if(is_opera)  {
				this.iFadeInOp = 100;
			} else	 if(is_ie) {
				this.getAnimObj().filters.alpha.opacity = this.iFadeInOp;
			} else	 if(is_moz) {
				this.getAnimObj().style.MozOpacity = (this.iFadeInOp/100);
			}
			setTimeout( this.sMyInstName+".fadein()", 100); 
		} else {
			this.iFadeInOp = 100;
			this.is_animating = false;
		}
	}

	this.fadeout = function() {
		if(this.iFadeInOp > 0) {
			this.is_animating = true;
			this.iFadeInOp -= 10;
			if(is_opera)  {
				this.iFadeInOp = 0;
			} else	 if(is_ie) {
				this.getAnimObj().filters.alpha.opacity = this.iFadeInOp;
			} else	 if(is_moz) {
				this.getAnimObj().style.MozOpacity = (this.iFadeInOp/100);
			}
			setTimeout( this.sMyInstName+".fadeout()", 100); 
		} else {
			this.iFadeInOp = 0;
			this.is_animating = false;
		}
	}

}



/***********************************************************************************************************************
      _       _     _ _____     _____                 _   _
     / \   __| | __| |_   _|__ |  ___|   _ _ __   ___| |_(_) ___  _ __  ___
    / _ \ / _` |/ _` | | |/ _ \| |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
   / ___ \ (_| | (_| | | | (_) |  _|| |_| | | | | (__| |_| | (_) | | | \__ \
  /_/   \_\__,_|\__,_| |_|\___/|_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/

***********************************************************************************************************************/

function bookmarksite(title, url){
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}


/***********************************************************************************************************************
 _____ _           _       ____  _             _         _   _                 _ _ _             
|  ___| | __ _ ___| |__   |  _ \| |_   _  __ _(_)_ __   | | | | __ _ _ __   __| | (_)_ __   __ _ 
| |_  | |/ _` / __| '_ \  | |_) | | | | |/ _` | | '_ \  | |_| |/ _` | '_ \ / _` | | | '_ \ / _` |
|  _| | | (_| \__ \ | | | |  __/| | |_| | (_| | | | | | |  _  | (_| | | | | (_| | | | | | | (_| |
|_|   |_|\__,_|___/_| |_| |_|   |_|\__,_|\__, |_|_| |_| |_| |_|\__,_|_| |_|\__,_|_|_|_| |_|\__, |
                                         |___/                                             |___/ 
***********************************************************************************************************************/
                                                                                                                      

// 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 (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)) >= 5)
		return true;
	else
		return false;
}

function	writeFlashDiv(sMovieName,sAltHTML,sParams,iWidth,iHeight,sBgColor)
{
	document.write( '<div id="hasbroFlash">' );
	// document.write( '<div id="hasbroFlash" style="position:absolute;top:64px;left:' + ((document.body.offsetWidth*1)/2-196) + 'px;">' );
	writeFlash(sMovieName,sAltHTML,sParams,iWidth,iHeight,sBgColor);
	document.write( '</div>' );
}

function	writeFlash(sMovieName,sAltHTML,sParams,iWidth,iHeight,sBgColor)
{
	//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 : '' );

		document.writeln('<object id="eaplay_flash" 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 + '>');
		document.writeln('<param name="movie" value="'+sMovieName+'">');
		document.writeln('<param name="quality" value="high">');
		document.writeln('<param name="scale" value="exactfit">');
		document.writeln('<param name="menu" value="false">');

		if( sParams )
			document.writeln('<param name="flashvars" VALUE="'+sParams+'">');

		if( sBgColor )
			document.writeln('<param name="bgcolor" value='+sBgColor+'">');

		document.writeln('<embed id="eaplay_flash" src="' + sMovieName + sSWFParams + '" scale="exactfit" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' + sColorTag + sWidthTag + sHeightTag + '></embed>');
		document.writeln('</object>');
	}
	else
	{
		document.writeln( sAltHTML );
	}
	// document.close();
}

