// JavaScript Document

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;
}

// Suggérer une page à un(e) ami(e)

function Suggerer (){	

	 //titre='Espace «Parents et profs» de la zone Jeunesse de Radio-Canada'

	 url='http://radio-canada.ca/jeunesse/_guide'

	 jsURL='http://radio-canada.ca/util/postier/suggererJeunesse.asp?sTitre='+escape(document.title)+'&sURL='+escape(document.location);

	 jsNom='suggerer';

	 jsParam='toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,history=no,resizable=yes,width=405,height=450,left=1,top=1';

	 window.open(jsURL, jsNom, jsParam)

}
	
function openNewWindow(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400");
			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=0,screenX=1,screenY=1,width=400,height=500,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=0,width=400,height=500");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=500");
		}
}

function openNewWindowPetit(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=350");
			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=350,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=350");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=438,height=350");
		}
}


function openNewWindowConsignes(fileName){
		if (detectBrowserVersion() == 3) {
			var temp = window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=500");
			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=0,screenX=1,screenY=1,width=400,height=600,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=0,width=400,height=500");
		}
		if (detectBrowserVersion() == 6) {
			window.open(fileName,"Commentaires","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=500");
		}
}


function constructFlash(flash,width,height,version,titre,html,transparency){

	var requiredVersion = version;
	var isTransparent;
	var isTransparent2;
	if(transparency != 0){
		isTransparent = "<PARAM NAME='wmode' VALUE='transparent'>";
		isTransparent2 = "wmode='transparent'";
	}else{
		isTransparent = "";
		isTransparent2 = "";
	}
	var urlFlashPage = location.href.split("/");
	var pathFlashPage = "";
	for(i=3;i<urlFlashPage.length;i++){
		pathFlashPage += "/"+urlFlashPage[i];
	}
	/*var title = document.title.split(" ");
	var titleConcat = "";
	for(i=0;i<title.length;i++){
		titleConcat += title[i] + "+";
	}*/
	
	 var noRandom = Math.random(1000);
	 var replaceContent
	if(html != ""){
		replaceContent = html;
	}else{
		replaceContent = '<img src="'+flash+'.gif" WIDTH="'+width+'" HEIGHT="'+height+'" alt="'+titre+'" title="'+titre+'">';
	}
	var objetFlash = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'WIDTH="'+width+'" HEIGHT="'+height+'"'
		+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<PARAM NAME="MOVIE" VALUE="'+flash+'.swf?noRandom='+ noRandom+'">'
		+ '<PARAM NAME="PLAY" VALUE="true">'
		+ '<PARAM NAME="LOOP" VALUE="true">'
		+ '<PARAM NAME="QUALITY" VALUE="high">'
		+ '<PARAM NAME="MENU" VALUE="false">'
		+ isTransparent
		+ '<EMBED SRC="'+flash+'.swf?noRandom='+ noRandom+'"'
		+ 'WIDTH="'+width+'" HEIGHT="'+height+'"'
		+ isTransparent2
		+ 'PLAY="true"'
		+ 'LOOP="true"'
		+ 'QUALITY="high"'
		+ 'MENU="false"'
		+ 'TYPE="application/x-shockwave-flash"'
		+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
		+ '</EMBED>'
		+ '</OBJECT>';
//	if (actualVersion >= requiredVersion) { 		// user has a new enough version
	//if (4 >= requiredVersion) {  						// flag: it's okay to write out the object/embed tags later
		document.write(objetFlash);	
//	} else {	// user doesn't have a new enough version.
//		document.write(replaceContent);
			//document.write(noFlashPage);
//	}
}



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 "";
}