// Live URL = http://estc.msn.com/br/intl/spec/fr-fr/CIAB/Test-Quizz/lance_test.js
// Test URL = http://go.msn.fr/10-channel/170-specials/Tests-Quizz/lance_test.js

var pageurl = window.location.toString();
var idflash = 'test_swf';
//var cheminSwf = "http://estb.msn.com/i/79/35327BF72D05FE0759E7085992D5A.swf";
var cheminSwf = "http://estc.msn.com/br/intl/spec/fr-fr/CIAB/Test-Quizz/flashtest.swf";

var varsiablesGet = window.location.search.substring(1);


function traitevar()
{
	// ----------------------------------------------------------------------------------------------------
	// si xmlUrl n'est pas dans l'url on la récupère dans un contenu : div#test_swf > H2
	// ----------------------------------------------------------------------------------------------------
	if(document.getElementById(idflash))
	{
		var h2txt = document.getElementById(idflash).getElementsByTagName("h2")[0].innerHTML;
		if(h2txt!=""){ varsiablesGet = "xmlUrl=" + h2txt; }
		//alert(varsiablesGet);
	}
	// ----------------------------------------------------------------------------------------------------
	// fin
	// ----------------------------------------------------------------------------------------------------
}

function afficheflash()
{
	if(document.getElementById(idflash))
	{
		if(varsiablesGet=="" || (varsiablesGet.indexOf("xmlUrl=")==-1 && varsiablesGet.indexOf("q=")==-1)){
			traitevar();
		}
		if(varsiablesGet.indexOf("xmlUrl=")!=-1 || varsiablesGet.indexOf("q=")!=-1)
		{
			//-- on peut renseigner xmlUrl (ou q) avec par ex : sante/quiz_aliments-anticancer
			if(varsiablesGet.indexOf("http://xml.fr.msn.com/")==-1)
			{ 
				varsiablesGet = varsiablesGet.replace("xmlUrl=","xmlUrl=http://xml.fr.msn.com/"); 
				varsiablesGet = varsiablesGet.replace("q=","xmlUrl=http://xml.fr.msn.com/"); 
			}
			if(varsiablesGet.indexOf(".aspx")==-1){ varsiablesGet = varsiablesGet + ".aspx"; }
			
			
			
			//var xml = "xmlUrl=http://xml.fr.msn.com/femmes/test_xmleditor_quizz.aspx";
			
			//alert(idflash);
				var timestamp = Math.floor((new Date()).getTime() / 1000);
				//alert(timest);
				document.getElementById(idflash).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="434" height="339" id="testQuizz" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ cheminSwf +'?'+ timestamp +'&page='+ pageurl +'&'+ varsiablesGet+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="" /><embed src="'+ cheminSwf +'?'+ timestamp +'&page='+ pageurl +'&'+ varsiablesGet+'" quality="high" bgcolor="#ffffff" width="434" height="339" name="flashtest" align="middle" allowScriptAccess="always" allowFullScreen="false" flashVars="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		}
	}
	else
	{
		setTimeout("afficheflash();", 100);
	}
}

afficheflash();