// *****************************************ABCD
// FUCNTIONS FUER VOLKSWAGEN.DE
// *****************************************
// POSITIONIERUNG DES LAYERS und globale Variablen
		var posTop  = 200;
		var posLeft = 100;
		var psymaPopupURL = 'http://www.psyma-surveys.com/uc/abfr_volkswagen/';
		var filter_url = false;
    
		var imgEckeLinks  = "http://www.volkswagen.de/vwcms_publish/etc/medialib/vwcms/virtualmaster/de/common/psyma.Par.0001.Image.gif";
		var imgEckeRechts = "http://www.volkswagen.de/vwcms_publish/etc/medialib/vwcms/virtualmaster/de/common/psyma.Par.0002.Image.gif";
		var imgLogoVW     = "http://www.volkswagen.de/vwcms_publish/etc/medialib/vwcms/virtualmaster/de/common/psyma.Par.0006.Image.gif";

		var psyma_cookie = true;                                      //  PSYMA COOKIE - ZUR LIVE-SCHALTUNG BITTE AKTIVIEREN!!!
		var fadeLayerIn  = false;                                     // langsames einblenden --> true or false
		var layerTimer   =  800;                                      // Verz?gerung in Milisekunden, bis Layer erscheint
		var samplingRate =  0;                                       // Wahrscheinlichkeit in Prozent, mit der ein PopUp aufgehen soll
		var rndNumber    =  parseFloat(1 + 100 * (Math.random()));   // Zufallzahl zwischen 0 und 100
		
		var psyma_test 	 = false;
		
		

		
// ERSETZEN DER URSPRUENGLICHEN FUNCTION "showPopup()"
		function showPopup() {
				if ( rndNumber <= samplingRate && psyma_participation != 1 && psyma_url_ok() ) {
            psyma_init_layer();
				}
		}
		
		function psyma_init_layer(){} // dummy function

// NEU BESCHREIBEN DER BUEHNE MIT WMODE=TRANSPARENT
		function chgFlash() {
		    flashDiv = document.getElementsByTagName("object")[0].parentNode;
		    flashDivHTML = flashDiv.innerHTML;
		    // REPLACEN DER VERSCHIEDEN JAVASCRIPT-INTERPRETATIONEN DIV. BROWSER
		    flashDivHTMLRewritten = flashDivHTML.replace(/<PARAM NAME="LOOP" VALUE="false">/gi,'<PARAM NAME="LOOP" VALUE="false"><PARAM NAME="WMODE" VALUE="transparent">'); //IE
		    flashDivHTMLRewritten = flashDivHTMLRewritten.replace(/NAME="WMode" VALUE="Window"/gi,'NAME="WMode" VALUE="transparent"'); //IE
        
// XML PATH AUSLESEN   
        xmlPath = flashDivHTMLRewritten.split('xmldata=');
        xmlPathTemp = xmlPath[1].split('.xml');
        xmlPathComplete = xmlPathTemp[0] + ".xml"
        flashDivHTMLRewritten = flashDivHTMLRewritten.replace(/.swf"/gi,'.swf?xmldata='+xmlPathComplete+'"');
        
		    flashDivHTMLRewritten = flashDivHTMLRewritten.replace(/loop="false"/gi,'loop="false" WMODE="transparent" '); // MOZ
			  flashDivHTMLRewritten = flashDivHTMLRewritten.replace(/LOOP="0"/gi,'loop="0" WMODE="transparent" '); // OPERA

//        showContent(flashDivHTMLRewritten);
			  flashDiv.innerHTML = flashDivHTMLRewritten;
		}

// HILFSFUNCTION!!!  
    function showContent(cont) {
       var fenster = window.open("", "neu")
       if (fenster != null){
          with (fenster.document){
             open()
             write("<"+"HTML"+">")
             write("<"+"HEAD"+">")
             write("<"+"TITLE"+">Popup Maker"+"<"+"/TITLE"+">")
             write("<"+"/HEAD"+">")
             write("<"+"BODY BGCOLOR=#ffffff"+">")
             write("<"+"font style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-weight: normal; color: #000000;'"+">")
             write("<"+"textarea"+" cols=80 rows=30>"+cont+"<"+"/textarea"+">")
             write("<"+"br"+">")
             write("<"+"br"+">"+"<"+"br"+">")
             write("<"+"/BODY"+">"+"<"+"/HTML"+">")
             close()
          }
       }
    }


// *****************************************
// BEGIN PSYMA FUNCTIONS
// *****************************************
		// Cookie benutzen (0: nein, 1: Cookie mit Ablaufdatum, 2: Cookie läuft x nach Tagen ab )
		var psyma_cookie_type = 2;
		var psyma_use_cookies = "false";
		var psyma_cookie_exp_date = "2007-12-31";
		var psyma_cookie_exp_days = 60;
		var psyma_participation = 0;
		var psyma_participation_cookie = "psyma_participation";
		var psyma_participation_exp = null;
		var psyma_fade = true;
		

		
		var image1 = new Image();
		var image2 = new Image();
//		image1.src = "http://www.psyma-statistics.com/img/AudioVideo/ecken/ecke-links-336699.gif";
//		image2.src = "http://www.psyma-statistics.com/img/AudioVideo/ecken/ecke-rechts-336699.gif";
		image1.src = imgEckeLinks;
		image2.src = imgEckeRechts;
		
		// Layer URLs
		var layer_count_url = "http://www.psyma-surveys.com/uc/admin/0dec/";	
		var client_logo_src = "http://www.psyma-surveys.com/uc/abfr_volkswagen/images/vw_logo_das_auto.gif";
		var website_name = "volkswagen.fr";
		var client_name = "Volkswagen";
		var psyma_logo_src = "http://www.psyma-statistics.com/documents/por.gif";
		var por_cookie_url = "http://www.psyma-statistics.com/documents/cookies.php?lang=fr";
		var por_privacy_url = "http://www.psyma-statistics.com/documents/privacy.php?lang=fr";
		var por_info_url = "http://www.psyma-statistics.com/documents/por.php?lang=fr";
		var por_prize_draw_url = "http://www.psyma-statistics.com/documents/gewinnspiel.php?lang=fr";
		var por_wtp_url = "http://www.psyma-statistics.com/documents/wtp.php?lang=fr";
		
		function get_psyma_cookie(a)
		{
			if ( psyma_cookie )
			{
				var c=document.cookie.split(a+"=");
				return (c.length>1)?unescape(c[1].split(";")[0]):"";
			}
			else
			return null;
		}

		// set cookie
		function set_psyma_cookie(name, value, path, domain, secure, expires)
		{
			if ( psyma_cookie ) 
			{
				document.cookie =
				  name + "="
				  + escape(value)
				  + ((path) ? "; path=" + path : "")
				  + ((expires) ? "; expires=" + expires.toGMTString() : "")
				  + ((domain) ? "; domain=" + domain : "")
				  + ((secure) ? "; secure" : "");
			}
		}
		
		function psyma_url_ok()
		{
			var my_location = new Array();
			var return_value = false;
			
			var psyma_domain = location.href.split("?");
			
			//my_location.push('');
         
			for (i=0; i<my_location.length; i++)
			{
				if ( psyma_domain[0] == my_location[i] )
				{
					return_value = true;
					break;
				}
			}

			if ( !filter_url )
				return_value = true;
			
			return return_value;
		}


		psyma_participation = get_psyma_cookie(psyma_participation_cookie);
      
		if ( psyma_participation != 1 && psyma_url_ok() )
		{
            // Cookie vorbereiten
			if ( psyma_use_cookies && psyma_cookie_type == 1 )
			{
				var psyma_temp_string = psyma_cookie_exp_date;
				var psyma_this_date = psyma_temp_string.split("-");
				psyma_participation_exp = new Date(psyma_this_date[0], psyma_this_date[1]-1, psyma_this_date[2]);
			}
			else if ( psyma_use_cookies && psyma_cookie_type == 2 )
			{
				var psyma_day_offset = psyma_cookie_exp_days;		// wieviel Tage soll Cookie aktiv sein?
				var psyma_milli_offset = psyma_day_offset * 1000 * 60 * 60 * 24;
				var psyma_now = new Date();
				psyma_participation_exp = new Date(psyma_now.valueOf() + psyma_milli_offset);
			}
			
			function psyma_findLayer(name, doc) 
			{
				var i, layer;
				var length = doc.layers.length;
				for (i = 0; i < length; i++){
					layer = doc.layers[i];
					if (layer.name == name)	{
						return layer;
					}
					if (layer.document.layers.length > 0) {
						if ((layer = psyma_findLayer(name, layer.document)) != null) {
							return layer;
						}
					}
				}
				return null;
			}

			function psyma_showLayer(id) {
				// if (document.layers) document.layers[''+id+''].visibility = "show"
				if (document.layers) {
					id = psyma_findLayer(id, document);
					id.visibility = "show";
				} else if (document.all) {
					document.all[''+id+''].style.visibility = "visible";
				} else if (document.getElementById)	{
					document.getElementById(''+id+'').style.visibility = "visible";
				}				
			}

			function psyma_hideLayer(id) {
				// if (document.layers) document.layers[''+id+''].visibility = "hide"
				if (document.layers) {
					id = psyma_findLayer(id, document);
					id.visibility = "hide";
				} else if (document.all) {
					document.all[''+id+''].style.visibility = "hidden";
				} else if (document.getElementById)	{
					document.getElementById(''+id+'').style.visibility = "hidden";
				}				
			}

			function psyma_posLayer(id,lax,lay) {
				if (lax) {
					if (document.layers) { document.layers[''+id+''].left = lax }
					else if (document.all) { document.all[''+id+''].style.left = lax }
					else if (document.getElementById) { document.getElementById(''+id+'').style.left = lax + "px" }
				}
				if (lay) {
					if (document.layers) { document.layers[''+id+''].top = lay }
					else if (document.all) { document.all[''+id+''].style.top = lay }
					else if (document.getElementById) { document.getElementById(''+id+'').style.top = lay + "px"}
				}
			}

			function psyma_button1() {
				psyma_hideLayer('psyma_layer');
				var psyma_width = window.screen.width;
				var psyma_height = window.screen.width;
				if (psyma_width >= 1024)
					psyma_width = 1024;
				if (psyma_height >= 700)
					psyma_height = 700;
				var survey_window = window.open(psymaPopupURL, 'psyma_survey', 'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width='+psyma_width+',height='+psyma_height+',top=0,left=0');
				if (survey_window)
				{
					survey_window.opener.focus();
				}
				return false;
			}

			function psyma_button2()
			{
				set_psyma_cookie(psyma_participation_cookie, 1, "/", "", "", psyma_participation_exp);
				psyma_hideLayer('psyma_layer');
				return false;
			}

			function psyma_write_layer()
			{
				document.write('<style type="text/css">');
document.write('#psyma_layer { display: block; visibility: hidden; z-index: 100000; position: absolute; top: 60px; left: 0px; width: 550px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; background-color: #fff; color: #000000; border: 3px solid #E6E6EB; padding: 0; }');
document.write('');
document.write('#psyma_layer p { font-family: Arial, Helvetica, sans-serif; font-size: 13px; padding: 0; margin: 0 0 10px 0; line-height: 105%; }');
document.write('');
document.write('#psyma_layer #header-background { width: 100%; height: 50px; z-index: 0; background-color: #9999A3; }');
document.write('');
document.write('#psyma_layer #header-background2, #header-background3 { width: 100%; height: 20px; z-index: 0; background-color: #E6E6EB; }');
document.write('');
document.write('#psyma_layer #titel { font-family: Arial, Helvetica, sans-serif; position: absolute; top: 28px; right: 20px; color: #fff; background-color: none; font-size: 18px; font-weight: bold; z-index: 1; }');
document.write('');
document.write('#psyma_layer #client-logo-li { position: absolute; top: 11px; left: 20px; padding: 0; margin: 0; text-align: center; width: auto; background: #fff url(\'http://www.psyma-statistics.com/img/AudioVideo/ecken/ecke-links-9999A3.gif\') no-repeat top left; }');
document.write('');
document.write('#psyma_layer #client-logo-re { padding: 5px; background: url(\'http://www.psyma-statistics.com/img/AudioVideo/ecken/ecke-rechts-9999A3.gif\') no-repeat top right; }');
document.write('');
document.write('#psyma_layer a:link, #psyma_layer a:active, #psyma_layer a:visited, #psyma_layer a:hover { font-size: 13px; font-family: Arial, Helvetica, sans-serif; color: #3E5F88; text-decoration: underline; }');
document.write('');
document.write('#psyma_layer a:hover { text-decoration: none; }');
document.write('');
document.write('#psyma_layer a:link, #psyma_layer a:active, #psyma_layer a:visited, #psyma_layer a:hover { font-size: 13px; font-family: Arial, Helvetica, sans-serif; color: #3E5F88; text-decoration: underline; }	#psyma_text { font-family: Arial, Helvetica, sans-serif; font-size: 13px; margin: 30px 20px 0px 20px; padding: 0; }');
document.write('');
document.write('#psyma_text { text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 13px; margin: 50px 20px 0px 20px; padding: 0; }');
document.write('');
document.write('#psyma_layer #psyma_liste { font-family: Arial, Helvetica, sans-serif; margin: 10px 20px 10px 20px; padding: 0 0 0 15px; list-style: square; font-size: 11px; }');
document.write('');
document.write('#psyma_liste .link_small:link, #psyma_liste .link_small:active, #psyma_liste .link_small:visited, #psyma_liste .link_small:hover, #psyma_layer .link_small:link, #psyma_layer .link_small:active, #psyma_layer .link_small:visited, #psyma_layer .link_small:hover { font-size: 11px; font-family: Arial, Helvetica, sans-serif; color: #3E5F88; text-decoration: underline; }');
document.write('');
document.write('#psyma_liste li { text-align: left; font-size: 11px; }');
document.write('');
document.write('#psyma_layer #psyma_logo { margin: -10px 0 10px 0; padding: 0 20px 0 10px; float: right; }');
document.write('');
document.write('#psyma_button { list-style: none; margin: 0 auto; }');
document.write('');
document.write('#psyma_button li { display: block; float: left; border: 1px solid #000; margin: 0 5px 7px 0; }');
document.write('');
document.write('#psyma_button li a, #psyma_button li a:link, #psyma_button li a:visited, #psyma_button li a:hover, #psyma_button li a:active { font-size: 13px; display: block; text-align: center; text-decoration: none; color: #fff; background-color: #E1862B; width: 190px; padding: 5px; }');
document.write('');
document.write('#psyma_button li a:hover { color: #000; background-color: #E6E6EB; }');
document.write('');
document.write('</style>');
document.write('');
document.write('<div id="psyma_layer">');
document.write('');
document.write('<div id="header-background"></div>');
document.write('');
document.write('<div id="header-background2"></div>');
document.write('');
document.write('<div id="titel">Votre opinion nous int&eacute;resse!</div>');
document.write('');
document.write('<div id="client-logo-li"><div id="client-logo-re"><img src="'+imgLogoVW+'" alt="client logo"/></div></div>');
document.write('');
document.write('<div style="position: absolute; top: 75px; right: 20px;"><a href="#" onclick="psyma_hideLayer(\'psyma_layer\'); return false;">fermer</a></div>');
document.write('');
document.write('<div id="psyma_text">');
document.write('');
document.write('<p>Cher Visiteur, Ch&egrave;re Visiteuse,</p>');
document.write('');
document.write('<p>Nous cherchons &agrave; am&eacute;liorer volkswagen.fr avec <strong>votre aide et opinion</strong>. Souhaitez vous participer &agrave; notre enqu&ecirc;te en ligne (8 &agrave; 10 minutes seulement)?</p>');
document.write('');
document.write('<ul id="psyma_button">');
document.write('<li><a id="psyma_button1" href="#" onclick="psyma_button1();">Oui, je souhaite y participer apr&egrave;s ma visite du site.</a></li>');
document.write('<li><a id="psyma_button2" href="#" onclick="psyma_button2();">Non merci, je ne souhaite pas y participer.</a></li>');
document.write('</ul>');
document.write('');
document.write('<p style="clear: both;"></p>');
document.write('');
document.write('<a href="#" onclick="window.open(\''+por_wtp_url+'\', \'por_wtp\', \'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=400,top=0,left=0\'); return false;">Pourquoi participer?</a>');
document.write('');
document.write('</div>');
document.write('');
document.write('<div id="psyma_logo"><img src="'+psyma_logo_src+'" alt="Psyma Online Research"/></div>');
document.write('');
document.write('<ul id="psyma_liste">');
document.write('<li>Enqu&ecirc;te effectu&eacute;e pour '+client_name+' par <a class="link_small" href="#" onclick="window.open(\''+por_info_url+'\', \'por_info\', \'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=400,top=0,left=0\'); return false;">Psyma Research+Consulting</a></li>');
document.write('<li>Nos <a href="#" onclick="window.open(\''+por_privacy_url+'\', \'psyma_privacy\', \'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=610,top=0,left=0\'); return false;">r&egrave;gles de confidentialit&eacute;</a></li>');
document.write('</ul>');
document.write('');
document.write('<img src="'+layer_count_url+'" width="1" height="1" style="visibility: hidden;"/>');
document.write('');
document.write('</div>');
			}

			// fade script thanks to Richard Rutter
			function psyma_initObject(id) {
				
			  objectId = id;
			  object = document.getElementById(objectId);
        if (fadeLayerIn) {
			    psyma_setOpacity(object, 0);
        }
			  object.style.visibility = 'visible';
        if ((document.getElementsByTagName("object")[0] != undefined) || (document.getElementsByTagName("object")[0] != null)) {
          chgFlash();
        }
        setTimeout("psyma_fadeIn(objectId,0)",layerTimer);
//			  psyma_fadeIn(objectId,0);
			}

			function psyma_setOpacity(obj, opacity) {
			  opacity = (opacity == 100)?99.999:opacity;
			  
			  // IE/Win
			  obj.style.filter = "alpha(opacity:"+opacity+")";
			  
			  // Safari<1.2, Konqueror
			  obj.style.KHTMLOpacity = opacity/100;
			  
			  // Older Mozilla and Firefox
			  obj.style.MozOpacity = opacity/100;
			  
			  // Safari 1.2, newer Firefox and Mozilla, CSS3
			  obj.style.opacity = opacity/100;
			}

			function psyma_fadeIn(objId,opacity) {
			  if (document.getElementById) {
				obj = document.getElementById(objId);
				if (fadeLayerIn && (opacity <= 100)) {
				  psyma_setOpacity(obj, opacity);
				  opacity += 5;
				  window.setTimeout("psyma_fadeIn('"+objId+"',"+opacity+")", 3);
				}
				else {
				  obj.style.visibility = "visible";
				}
			  }
			}

			function psyma_init_layer()
			{
				var myWidth = 0, myHeight = 0;

				if( typeof( window.innerWidth ) == 'number' )
				{
					//Non-IE
					myWidth = window.innerWidth;
					myHeight = window.innerHeight;
				} 
				else if ( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) )
				{
					//IE 6+ in 'standards compliant mode'
					myWidth = document.documentElement.clientWidth;
					myHeight = document.documentElement.clientHeight;
				}
				else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
				{
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
				}

//				poswidth = (780 - 550) / 2;
//				psyma_posLayer("psyma_layer", poswidth, 400);
				psyma_posLayer("psyma_layer", posLeft, posTop);
				if ( psyma_fade && navigator.userAgent.indexOf("Netscape") < 0 )
				{
					psyma_initObject("psyma_layer");
				}
				else
					psyma_showLayer("psyma_layer");
				// *********************************************************************************
				// SETZT COOKIE, ZUR LIVE-SCHALTUNG BITTE AKTIVIEREN
				// *********************************************************************************
        if (psyma_cookie) {
				  set_psyma_cookie(psyma_participation_cookie, 1, "/", "", "", "");
        }
			}
			if ( rndNumber <= samplingRate && psyma_participation != 1 && psyma_url_ok() ) {
                psyma_write_layer();
            }
			
			// function to be called on script execution -- cache existing function

/*
// AUSKOMMENTIERT, WEIL DURCH showPopup() ABGEFANGEN
			if (window.onload)
			{
				cached_onload = window.onload;
				window.onload = new Function(				
					"new_onload",
					"psyma_init_layer();" +			
					"cached_onload();" +
					""
				);
			}
			else
			{
				window.onload = psyma_init_layer;
			}
*/


		} // end of if psyma_participation


