var dgd_thisLayeredSrc = 'ML_Nonstop-Streaming_400x400.swf';         // relative path to Flash-file
var dgd_Ads_ClickUrl = "http%3A%2F%2Fwww.musicload.de%2Fconnect%3Ftid%3DB23FDD9C6FF1546B7C402910E9493DB2";         // the default and fallback target-URL
var dgd_viewOnceLifetime = 7;						// how long should the banner not be displaed again (in days), set to 0 do dispaly it every time
var dgd_showOnlyOnce = false;                       //use Cookiebased Feature to show it only once in a certain time
var dgd_Ads_ClickTarget = "_blank";					//Where should it open?
var dgd_loops = 1;								    //LoopBanner
var dgd_ZIndex = 100;
var dgd_thisLayeredWidth = 400;                     // width of Flash Overlay
var dgd_thisLayeredHeight = 400;                    // height of Flash Overlay
var dgd_HPosition = 250;							// position
var dgd_VPosition = 350;							// position
var dgd_FSID= "dgdml09"; 							//replace this everywhere!!
// END OF USER CONFIG

var isNav = false;
var isIE = false;

function dgdml09_DoFSCommand(strCommand, strArgs){ 
 switch(strCommand){
        case 'linkcall1':
            window.open( dgd_Ads_ClickTracking + '?l=' + escape(dgd_Ads_ClickUrl), dgd_Ads_ClickTarget);
            break;
       case 'adlayerhider':
            dgd_AdscloseLayer ();
            break;
    }
}

function dgd_printLayerAd(flSrc,flw,flh,Ads_ClickUrl,xPos,yPos)
{
    document.write('<div id="dgdbanner" STYLE="position:absolute; visibility:visible; left: ' + xPos + 'px ; top: ' + yPos + 'px ; width: '+flw+'px; height: '+flh+'px; z-index:9999;"><div id="dgdbannerflash"></div></div>');
    setTimeout('display()', 200);
    var flashvars = {
    	loops: dgd_loops,
    	clickTag: dgd_Ads_ClickUrl,
    	clickTarget: dgd_Ads_ClickTarget
    };
	var params = {
  		menu: "false",
  		quality: "autohigh", 
  		scale: "none",
  		play: true,
  		swliveconnect: true,
  		allowscriptaccess: "always"
	};
	var attributes = {
  		id: dgd_FSID,
  		name: dgd_FSID
	};
    swfobject.embedSWF(dgd_thisLayeredSrc, "dgdbannerflash", dgd_thisLayeredWidth, dgd_thisLayeredHeight, "8.0.0", false, flashvars, params, attributes);
}

function dgd_AdscloseLayer()
{
 	if(document.all) { document.all['dgdbanner'].style.display = "none"; }
    if(document.layers) { document.layers['dgdbanner'].style.display = "none" ;}
    if(!document.all && document.getElementById) { document.getElementById('dgdbanner').style.display = "none"; }
    dgd_Ende_Werbemittel();
}

function dgd_Start_Werbemittel() 
{
    for(i=0; i < document.getElementsByTagName("select").length; i++) {
        document.getElementsByTagName("select")[i].style.visibility="hidden";
    }
}
function dgd_Ende_Werbemittel()
{
    for(i=0; i < document.getElementsByTagName("select").length; i++) {
        document.getElementsByTagName("select")[i].style.visibility="visible";
    }
}
function display()
{
    //***********************************************************************
    // Abfrage nach dem aktuellen MSIE-Status, beendet die if-Schleife erst,*
    // wenn der IE Status=complete zurueckgibt                                *
    //***********************************************************************

    if (navigator.appVersion.indexOf("MSIE") != -1)
    {
        if (document.readyState) {
            if (document.readyState != 'complete') {            
                setTimeout('display()', 50);
                return;
            }
        }
        dgd_Start_Werbemittel();
    }
}
if (parseInt(navigator.appVersion)>=4) {
    if(navigator.appName.indexOf("Netscape")!= -1)isNav=true;
    if(navigator.appName.indexOf("Microsoft")!= -1)isIE=true;
}
/**
* Get a cookie value
* @param string cookie name
*/
function dgd_getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/**
* Set a cookie
* @param string cookie name
* @param string cookie value
* @param string cookie expiration counter in days
* @param string cookie path
* @param string cookie domain
* @param bool secure?
*/
function dgd_setCookie ( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 24 * 60 * 60;
	}
	
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+"="+escape( value ) +
		( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

//####
//## Ausgabe
//## This could also be called by some js
//## There is no FlashCheck here, we assume this is handled by cms
//####

	if (dgd_thisLayeredSrc && dgd_thisLayeredWidth && dgd_thisLayeredHeight && dgd_Ads_ClickUrl) {
		if (dgd_getCookie( "dgd_viewedBannerOnce" ) != 1 || dgd_showOnlyOnce != true){
		dgd_printLayerAd(dgd_thisLayeredSrc,dgd_thisLayeredWidth,dgd_thisLayeredHeight,dgd_Ads_ClickUrl,dgd_HPosition,dgd_VPosition);
		dgd_setCookie ( "dgd_viewedBannerOnce", "1", dgd_viewOnceLifetime );
		}
	}