// Fonction JavaScript simulant l'objet ASP Request
function request(leChamp) {
	var leQueryString = (location.search ? location.search.toLowerCase().substring(1) : '');
	var lesPairesNomVal = leQueryString.split("&"); // %26 est le code pour le symbole &
	for(var i = 0; i < lesPairesNomVal.length; i++){
		unePaireNomVal = lesPairesNomVal[i].split("=");
		if (unePaireNomVal[0]==leChamp)
		return unePaireNomVal[1];
		}
	return ""; // retourner une chaine vide pour que les comparaisons ne plantent pas même si le champ n'a pas été trouvé
}


function Decode(msg){
var DECRYPT = false;
var ClearMessage="";
ClearMessage += codeIt(msg);
document.write(ClearMessage);
} var key = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1029384756><#].";
function codeIt (_message) {
var wTG;var mcH = key.length / 2;
var _newString = "";
var dv;
for (var x = 0; x < _message.length; x++) {
wTG = key.indexOf(_message.charAt(x));
if (wTG > mcH) {
dv = wTG - mcH;_newString += key.charAt(33 - dv);
} else {
if (key.indexOf(_message.charAt(x)) < 0) {
_newString += _message.charAt(x);
} else {
dv = mcH - wTG;
_newString += key.charAt(33 + dv);
}
}
}
return (_newString);
}


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];}
}

//Onglets du Top joueurs - Jeux
function swapOnglets(mode,numDiv){
	
	if (mode != "general"){ // mode = 7jours
		document.getElementById("ongletSeptDerniersJours"+numDiv).style.display = "block";
		document.getElementById("ongletClassementGeneral"+numDiv).style.display = "none";
	}else{// mode = general
		document.getElementById("ongletSeptDerniersJours"+numDiv).style.display = "none";
		document.getElementById("ongletClassementGeneral"+numDiv).style.display = "block";
	}
}

//Onglets du Top joueurs - Jeux
function swapDiv(numDIv, maxDiv){
	for (x=1; x < maxDiv+1; x++) {
		if ( x == numDIv){ // mode = 7jours
			document.getElementById("episode"+x).style.display = "block";
		}else{// mode = general
			document.getElementById("episode"+x).style.display = "none";
		}
	}
	swapOnglets('general',numDIv);
}

function openQuiz(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Quiz","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=480,height=300");
			temp.focus();			
		}
		if (detectBrowserVersion() == 1 ||
			detectBrowserVersion() == 4 ||
			detectBrowserVersion() == 0) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,screenX=1,screenY=1,width=480,height=300,left=1,top=1");
			temp.focus();
		}
		if (detectBrowserVersion() == 2) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=480,height=300");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=480,height=300");
		}
}




function openQuizNoel(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Quiz","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
			temp.focus();			
		}
		if (detectBrowserVersion() == 1 ||
			detectBrowserVersion() == 4 ||
			detectBrowserVersion() == 0) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,screenX=1,screenY=1,width=438,height=276,left=1,top=1");
			temp.focus();
		}
		if (detectBrowserVersion() == 2) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
		}
}

function openQuizThematique(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Quiz","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
			temp.focus();			
		}
		if (detectBrowserVersion() == 1 ||
			detectBrowserVersion() == 4 ||
			detectBrowserVersion() == 0) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,screenX=1,screenY=1,width=438,height=276,left=1,top=1");
			temp.focus();
		}
		if (detectBrowserVersion() == 2) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=276");
		}
}




function detectBrowserVersion(){
	var version = 0;
	if (navigator.userAgent.indexOf("Mozilla/5.0") != -1) version = 6;
	else if (navigator.userAgent.indexOf("Mozilla/4") != -1) version = 4;
	else if (navigator.userAgent.indexOf("Mozilla/3") != -1) version = 3;
	else if (navigator.userAgent.indexOf("Mozilla/2") != -1) version = 2;
	else if (navigator.userAgent.indexOf("MSIE") != -1) version = 1;
	else version = 0;
		
	return version;
}

sas_tmstp=Math.round(Math.random()*10000000000);
sas_masterflag=1;

function SmartAdServer_iframe(sas_pageid,sas_formatid,sas_target) {
	if (sas_masterflag==1) {
		sas_masterflag=0;
		sas_master='M';
	} else {
		sas_master='S';
	};
	
	switch (sas_formatid) {
		case 1841:
			sas_w = 728;
			sas_h = 90;
			break;
		case 1839:
			sas_w = 300;
			sas_h = 250;
			break;
		case 1846:
			sas_w = 424;
			sas_h = 60;
			break;
		case 1840:
			sas_w = 160;
			sas_h = 600;
			break;
		default :
			return;
		break;
	}
	strDartSize = sas_w + "x" + sas_h;
	
	if (strDartSize == "728x90") {
	document.write('<table cellspacing="0" id="prom'+strDartSize+'Bg" class="resizeTable">');
		document.write('<tr>');
			document.write('<td class="resizeTd">');
	} else {
			document.write('<div id="prom'+strDartSize+'Bg">');
	}
				document.write('<div id="prom'+strDartSize+'">');
					document.write('<div class="top"></div>');
					document.write('<div class="content">');
						//document.write('<SCR'+'IPT SRC="http://www2.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
						document.write('<iframe src="http://www2.smartadserver.com/call/pubif/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?" width=' + sas_w + ' height=' + sas_h + ' marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
						//document.write('<scr'+'ipt language=Javascr'+'ipt>\ndocument.write\(\'<SCR\'+\'IPT SRC="http://www2.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR\'+\'IPT>\'\)\;\n</scr'+'ipt>');
						document.write('</iframe>');
						
					document.write('</div>');
					document.write('<div class="bottom"></div>');
				document.write('</div>');
	if (strDartSize == "728x90") {
			document.write('</td>');
			document.write('<td>&nbsp;</td>');
		document.write('</tr>');
	document.write('</table>');
	} else {
			document.write('</div>');
	}
}






///	DART qui ne sera plu utiisé après le 1 mai 2008

//	2006-01-24 Sirivanh Soutannouvong
//		DARTord est maintenant var global
//		ajout du 5e parametre optionnel DARTTile
//	2006-03-06 Martin Rancourt
//		Ajout de la gestion des zone rss

var DARTord=Math.random()*10000000000000000;
var isFromRss = document.location.toString().toLowerCase().indexOf("ref=rss") != -1;

function getPub(DARTSite, DARTZone, DARTWidth, DARTHeight, DARTTile) {
	if (pubRequest("prov") != "") return;
	var strDartSite = DARTSite;
	var strDartZone = DARTZone;
	if (isFromRss) strDartZone += "_rss";
	var strDartSize = DARTWidth + "x" + DARTHeight;
	var strTile
	if (typeof(DARTTile) === 'undefined' || DARTTile == "") {
		strTile = '';
	} else {
		strTile = ';tile='+ DARTTile;
	}
	if (strDartSize == "728x90") {
	document.write('<table cellspacing="0" id="prom'+strDartSize+'Bg" class="resizeTable">');
		document.write('<tr>');
			document.write('<td class="resizeTd">');
	} else {
			document.write('<div id="prom'+strDartSize+'Bg">');
	}
				document.write('<div id="prom'+strDartSize+'">');
					document.write('<div class="top"></div>');
					document.write('<div class="content">');
					
						document.write('<iframe src="http://ad.ca.doubleclick.net/adi/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+strTile+';ptile=1;mtfIFPath=/pub/dart/;ord=' + DARTord + '?" width="'+DARTWidth+'" height="'+DARTHeight+'" frameborder="no" border="0" marginwidth="0" marginheight="0" SCROLLING="no">');
						document.write('<a href="http://ad.ca.doubleclick.net/jump/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+';abr=!ie4;abr=!ie5;abr=!ie6'+strTile+';ord=' + DARTord + '?" target="_blank">');
						document.write('<img src="http://ad.ca.doubleclick.net/ad/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+';abr=!ie4;abr=!ie5;abr=!ie6'+strTile+';ord=' + DARTord + '?" width="'+DARTWidth+'" height="'+DARTHeight+'" border=0 alt=""></a>');
						document.write('</iframe>');
					
					document.write('</div>');
					document.write('<div class="bottom"></div>');
				document.write('</div>');
	if (strDartSize == "728x90") {
			document.write('</td>');
			document.write('<td>&nbsp;</td>');
		document.write('</tr>');
	document.write('</table>');
	} else {
			document.write('</div>');
	}
};



function getPubInnerHTML(DARTSite, DARTZone, DARTWidth, DARTHeight, DARTTile) {
	if (pubRequest("prov") != "") return;
	var strDartSite = DARTSite;
	var strDartZone = DARTZone;
	if (isFromRss) strDartZone += "_rss";
	var strDartSize = DARTWidth + "x" + DARTHeight;
	var strTile
	if (typeof(DARTTile) === 'undefined' || DARTTile == "") {
		strTile = '';
	} else {
		strTile = ';tile='+ DARTTile;
	}
	
	var _s ;
	_s = '<div id="prom'+strDartSize+'Bg">' 
			+ 
				'<div id="prom'+strDartSize+'">'
			+
					'<div class="top"></div>'
			+
						'<div class="content">'
			+
			
				 		'<iframe src="http://ad.ca.doubleclick.net/adi/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+strTile+';ptile=1;mtfIFPath=/pub/dart/;ord=' + DARTord + '?" width="' 
			+ 
						DARTWidth+'" height="'+DARTHeight+'" frameborder="no" border="0" marginwidth="0" marginheight="0" SCROLLING="no">' +
				 		'<a href="http://ad.ca.doubleclick.net/jump/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+';abr=!ie4;abr=!ie5;abr=!ie6'+strTile+';ord=' + DARTord + '?" target="_blank">' 
			+ 
				        '<img src="http://ad.ca.doubleclick.net/ad/'+strDartSite+'/'+strDartZone+';sz='+strDartSize+';abr=!ie4;abr=!ie5;abr=!ie6'+strTile+';ord=' + DARTord + '?" width="'
			+
						DARTWidth+'" height="'+DARTHeight+'" border=0 alt=""></a>' +
				'</iframe>' 
			+ 
			
						'</div>'
			+ 
					'<div class="bottom"></div>' 
		+ 
				'</div>' 
		+ 
			'</div>';
	
	return ( _s);
};

function getPubTxt(arrObjPub) {
	var strDartSize = "Txt"
	
	document.write('<div id="prom'+strDartSize+'Bg">');
		document.write('<div id="prom'+strDartSize+'">');
			document.write('<div class="top"></div>');
			document.write('<div class="content">');
			
				for (var i = 0; i < arrObjPub.length; i++) {
					document.write('<p>');
						document.write('<a href="http://ad.ca.doubleclick.net/jump/'+ arrObjPub[i].strDartSite +'/'+ arrObjPub[i].strDartZone +';sz=86x40;ord='+DARTord+'?" target="_blank">');
							document.write('<img src="http://ad.ca.doubleclick.net/ad/'+ arrObjPub[i].strDartSite +'/'+ arrObjPub[i].strDartZone +';sz=86x40;ord='+DARTord+'?" width="86" height="40" border="0" alt="">');
							document.write(arrObjPub[i].txt);
						document.write('</a>');
					document.write('</p>');
				}
			
			document.write('</div>');
			document.write('<div class="bottom"></div>');
			//	Enlever par MR 2006-03-07
			//document.write('<br style="clear:both;" />');
		document.write('</div>');
	document.write('</div>');
}

function classPub(DARTSite, DARTZone, txt) {
	this.strDartSite = DARTSite;
	if (isFromRss) {
		this.strDartZone = DARTZone + "_rss";
	} else {
		this.strDartZone = DARTZone;
	}
	this.txt = txt;
}
function pubRequest(param) {
	/*	CC Martin Rancourt */
	/*	v 1.0	*/
	var strParam = param.toString().toLowerCase();
	var strQS = window.document.location.search.toString().toLowerCase().slice(1);//enlève le ?
	if (strQS.indexOf(strParam) != -1) {
		var arrQS = strQS.split("&");
		for(var i = 0; i < arrQS.length; i++) {
			if (arrQS[i].slice(0, arrQS[i].indexOf("=")) == strParam) return arrQS[i].slice(arrQS[i].indexOf("=")+1);
		}
	}
	return "";
}
