window.onload = function() {
	if (document.getElementById) {
		if (document.getElementById("textContainer")) {
			initTicker();
		}
		if (typeof(initScrolls) != 'undefined') {
			initScrolls();
		}
		if (typeof(initTickerIf) != 'undefined') {
			initTickerIf();
		}
	}
	setText();
}

//=============================================================
//	----------	Racourci code		----------
//=============================================================

var d = document;
function $id() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
var $url = document.location.toString().toLowerCase();

function setClass(obj, strClass) {
	if (obj) {
		if (obj.className != "") obj.className += " ";
		obj.className += strClass;
	}
}

//=============================================================
//	----------	Function webtrends		----------
//=============================================================

function callWebtrends(strA, strB) {
	ClicTrack('dcsuri',strB,'clic_action',strB,'clic_contenu',strB,'WT.ti',strB,'WT.clic',strA);
}

function CT(strClicEmplacement) {
	//alert("CT('" + strClicEmplacement + "')");
	var strProfil
	var strUrl = $url;

	if ((strUrl.indexOf("/nouvelles/index.shtml") != -1) || (strUrl.indexOf("/nouvelles/") == strUrl.length - 11) || (strUrl.indexOf("/lib/v1/inc/ticker/nouvelles.html") != -1)) {
		strProfil = "PA_nouvelles";
	} else if((strUrl.indexOf("/sports/index.shtml") != -1) || (strUrl.indexOf("/sports/") == strUrl.length - 8) || (strUrl.indexOf("/lib/v1/inc/ticker/sports.html") != -1)) {
		strProfil = "PA_sport";
	} else if((strUrl.indexOf("/arts-spectacles/index.shtml") != -1) || (strUrl.indexOf("/arts-spectacles/") == strUrl.length - 17) || (strUrl.indexOf("/lib/v1/inc/ticker/arts-spectacles.html") != -1)) {
		strProfil = "PA_arts";
	} else {
		return;
	}
	ClicTrack('dcsuri',strUrl ,'clic_action',strClicEmplacement, 'WT.ti',strClicEmplacement, 'WT.clic',strProfil);
	//alert("'dcsuri',"+strUrl+" ,'clic_action',"+strClicEmplacement+", 'WT.ti',"+strClicEmplacement+", 'WT.clic',"+strProfil+"");
}
//=============================================================
//	----------	Function Zap			----------
//=============================================================

function callMediaPlayer(urlMedia, numMenu) {
	if (numMenu == null || numMenu == "") numMenu = 1;
	window.open('/audio-video/pop.shtml#urlMedia=' + urlMedia + '&epr=true', 'audioVideo','toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,history=no,resizable=yes,width=1,height=1');
}
//=============================================================
//	----------	Gestion des CSS		----------
//=============================================================

function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("alternate stylesheet") != -1 && !(a.getAttribute("id"))) {
				a.disabled = true;
			if(a.getAttribute("title") == title	) {
					a.disabled = false;
				}
			}
		}
	}
}

function setSizeStyleSheet(size) {
	//alert("setSizeStyleSheet("+size+")");
	if (document.getElementById) {
		if (document.getElementById("tailleTextS") && document.getElementById("tailleTextM") && document.getElementById("tailleTextL")) {

			document.getElementById("tailleTextS").setAttribute("className", "");
			document.getElementById("tailleTextS").setAttribute("class", "");
			document.getElementById("tailleTextM").setAttribute("className", "");
			document.getElementById("tailleTextM").setAttribute("class", "");
			document.getElementById("tailleTextL").setAttribute("className", "");
			document.getElementById("tailleTextL").setAttribute("class", "");
	
			if (size == "0") {
					document.getElementById("T1").disabled = true;
					document.getElementById("T2").disabled = true;
					document.getElementById("tailleTextS").setAttribute("className", "TailleTypoOn");
					document.getElementById("tailleTextS").setAttribute("class", "TailleTypoOn");
			} else if(size == "T1") {
					document.getElementById("T1").disabled = false;
					document.getElementById("T2").disabled = true;
					document.getElementById("tailleTextM").setAttribute("className", "TailleTypoOn");
					document.getElementById("tailleTextM").setAttribute("class", "TailleTypoOn");
			} else if(size == "T2") {
					document.getElementById("T1").disabled = true;
					document.getElementById("T2").disabled = false;
					document.getElementById("tailleTextL").setAttribute("className", "TailleTypoOn");
					document.getElementById("tailleTextL").setAttribute("class", "TailleTypoOn");
			}
			setCookie("srcTailleTexte", size, 365) ;
		}
	}
}

function setText() {
	var size = getCookie("srcTailleTexte") ;
	if (size == null) {
		setSizeStyleSheet("0");
	} else {
		setSizeStyleSheet(size);
	}
}


//=============================================================
//	----------	Cookie		----------
//=============================================================
function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function deleteCookie(name) {
	setCookie(name,"",-1);
}
//=============================================================
//	----------	Encode email		----------
//=============================================================

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);
}

//=============================================================
//	----------	Autres fonctions		----------
//=============================================================


function pop(dest,largeur,hauteur,scroll) {
    jsURL=dest;
    jsNom='fenetre';
	jsParam='toolbar=no,directories=no,status=no,menubar=no,scrollbars=' + scroll + ',history=no,resizable=yes,width=' + largeur + ',height='+hauteur+',left=1,top=1';
	window.open(jsURL, jsNom, jsParam);
}

function popup(URL, Nom, Param) {
	window.open(URL, Nom, Param);
}

function pageAccueil(doc,url){
if(navigator.appVersion.charAt(navigator.appVersion.indexOf("MSIE") + 5) >= 5 && navigator.platform.indexOf("Win16") == -1 && navigator.platform.indexOf("Mac") == -1){
	doc.style.behavior='url(#default#homepage)';
	doc.setHomePage(document.location.hostname + url);
	doc.href="#";
	return true;
	}else{
	return false
	}
}	
function request(param) {
	/*	CC Martin Rancourt */
	/*	v 1.0	*/
	var strParam = param.toString().toLowerCase();
	var strQS = d.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 "";
}



//=============================================================
//	-------	START nouveau - fonctions "libGlobalv1_"  --------
//  ---------- BRovito - 19-03-2008 --------------------------
//=============================================================

var isSwfInstall=false;

/**
* libGlobalv1_getFlv
*
* afficher une FLV 
* exemple: libGlobalv1_getFlv('FlvVestiaire','/nouvelles/surLeWeb/lib/v1/swf/playerCamera', 'V_test.flv&amp;isPlay=0', 'swfVideoVestiare', 200, 150);
*
* Note: passer la valeur null au params non utilisés
*/
 function libGlobalv1_getFlv( _sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aFlashVersion /* [major,minor,revision]*/ ){

	// base path to FLVs
  		//var sPATH_TO_FLV="http://www.radio-canada.ca/medianet/";
   
   // flash player version required
  	 var _aVersion = ( (_aFlashVersion!=undefined) && (_aFlashVersion!=null)) ? _aFlashVersion : null;
   
   // embed swf WITH player detection
  	 if (_sDivId!=null){
  		   libGlobalv1_embedSwf (_sDivId, _sSwfSource, "flv="+_sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aVersion);
	 }else{	  	
		 return libGlobalv1_embedSwf (_sDivId, _sSwfSource, "flv="+_sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aVersion);
		 
	 }
};


/**
* libGlobalv1_getFlvZ
*
* afficher une FLV enregistrer avec Z
* exemple: libGlobalv1_getFlvZ('FlvVestiaire','/nouvelles/surLeWeb/lib/v1/swf/playerCamera', 'V_test.flv&amp;isPlay=0', 'swfVideoVestiare', 200, 150);
*
* Note: passer la valeur null au params non utilisés
*/
 function libGlobalv1_getFlvZ( _sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aFlashVersion /* [major,minor,revision]*/ ){

	// base path to FLVs
  		
		//var sPATH_TO_FLV="http://www.radio-canada.ca/medianet/";
  		
		//2010-03-05 : RThouin, ajouter pour régler un bug du video de budget fed 2010, le path est complet dans la BD, pas besoin d'ajouter le path complet. 
		//var sPATH_TO_FLV= _sDivId == "FLV128183" ? "" : "http://www.radio-canada.ca/medianet/";
  		
		///2010-04-01 : BRovito : les vidéos créés en 2010+ contient le path complet dans la BD, et donc pas besoin d'ajouter le path.
		///En plus, tous les documents créés les années précédentes, qui se trouvait dans  http://www.radio-canada.ca/medianet/ se trouvent maintenant dans http://medias.radio-canada.ca/diffusion/
         var sPATH_TO_FLV = (_sFlashVars.indexOf("http://medias.radio-canada.ca") >= 0) ? "" /* document 2010+*/ : "http://medias.radio-canada.ca/diffusion/";
   
   
   
   // flash player version required
  	 var _aVersion = ( (_aFlashVersion!=undefined) && (_aFlashVersion!=null)) ? _aFlashVersion : null;
   
   // embed swf WITH player detection
  	 if (_sDivId!=null){
  		   libGlobalv1_embedSwf (_sDivId, _sSwfSource, "flv="+sPATH_TO_FLV+_sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aVersion);
	 }else{	  	
		 return libGlobalv1_embedSwf (_sDivId, _sSwfSource, "flv="+sPATH_TO_FLV+_sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aVersion);
		 
	 }
};

/**
* libGlobalv1_embedSwf
*
* DÉTECTER la version du flash player avant de faire un embed swf
*
* Note: passer la valeur null au params non utilisés 
*/
 function libGlobalv1_embedSwf( _sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode, _aFlashVersion/* [major,minor,revision]*/ ){

	var _sSwf = (_sSwfSource==null) ? "" : _sSwfSource; // sans extension .swf
	var _sVars = (_sFlashVars==null) ? "" : _sFlashVars;
	var _sId = (_sSwfId==null)? "PlayerCamera" : _sSwfId;
	var _nW = (_nWidth==null)? 200 : _nWidth;
	var _nH = (_nHeight==null)? 150 : _nHeight;
	var _sWmode = (_sSwfWmode==null) ? "opaque" : _sSwfWmode;
		
	// Major version 
		var requiredMajorVersion = 	(_aFlashVersion!=null && _aFlashVersion!=undefined) ? _aFlashVersion[0] : 6; // 9
	// Minor version 
		var requiredMinorVersion = 	(_aFlashVersion!=null && _aFlashVersion!=undefined) ? _aFlashVersion[1] : 0; // 0
	// Minor version
		var requiredRevision = 		(_aFlashVersion!=null && _aFlashVersion!=undefined) ? _aFlashVersion[2] : 65; // 115
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
		var hasProductInstall = DetectFlashVer(6, 0, 65);	
	// Version check based upon the values defined in globals
		var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	// alt content if flash not detected
		var alternateContent = "<div  style=\"background-color:#fff;border:1px grey solid;padding:3px;\"><p>Le plugiciel <b>« Flash "+requiredMajorVersion+"."+requiredMinorVersion+"."+requiredRevision+" »</b> n'est pas installé sur votre ordinateur.<br/><a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Cliquez ici pour le télécharger</a>.</p><p><b>Note pour les utilisateurs Macintosh:</b> Il se peut que vous deviez redémarrer votre ordinateur une fois l'installation terminée.</p></div>";
	
	// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
		if ( !hasRequestedVersion  && hasProductInstall) {
			
			/*// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
				 This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
				 DO NOT MODIFY THE FOLLOWING FOUR LINES
				 Location visited after installation is complete if installation is required 
			*/
				var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
				var MMredirectURL = window.location;
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				var MMdoctitle = document.title;
			
			
			if(!isSwfInstall){// only prompt install 1 time
				isSwfInstall=true;
				if (isIE){
					libGlobalv1_doEmbedSwf(_sDivId, "/lib/v1/swf/playerProductInstall", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", "installFlashPlayer", _nWidth, _nHeight, _sSwfWmode);
				}else{
					if (_sDivId!=null){
						document.getElementById(_sDivId).innerHTML = alternateContent;
					}else{
						return alternateContent;
					}
				}
			}
		}else if (hasRequestedVersion) { // if we've detected an acceptable version
			if (_sDivId!=null){
				libGlobalv1_doEmbedSwf(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode);
			}else{
				return libGlobalv1_doEmbedSwf(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode);
			}
			// embed the Flash Content SWF when all tests are passed
			
		} else {  // flash is too old or we can't detect the plugin
			if (_sDivId!=null){
				document.getElementById(_sDivId).innerHTML = alternateContent;
			}else{
				return alternateContent;
			}
		}
	};


/**
* libGlobalv1_doEmbedSwf
*
* faire un embed swf SANS détection de version du flash player 
*
* Note: passer la valeur null au params non utilisés 
*/
 function libGlobalv1_doEmbedSwf( _sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode ){
						
		var _sSwf = (_sSwfSource==null) ? "" : _sSwfSource; // sans extension .swf
		var _sVars = (_sFlashVars==null) ? "" : _sFlashVars;
		var _sId = (_sSwfId==null)? "PlayerCamera" : _sSwfId;
		var _nW = (_nWidth==null)? 200 : _nWidth;
		var _nH = (_nHeight==null)? 150 : _nHeight;
		var _sWmode = (_sSwfWmode==null) ? "opaque" : _sSwfWmode;
		var _sEmbedHtml = "";
		
		if (_sSwfSource != ""){
			if (AC_FL_GetContent == 0) {
				alert('This page requires AC_RunActiveContent.js. In Flash, run Apply Active Content Update in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.');
				} else {
					/* Safari bug fix: must write someting to innerHTML and then "+=" the other content ;See following innerHTML assignment*/
					_sEmbedHtml +=  "<span style='display:none'>Radio-Canada.ca</span>"; 
					_sEmbedHtml +=  AC_FL_GetContent(
						'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
						'width', _nW,
						'height', _nH,
						'src', _sSwf,
						'movie', _sSwf,
						'quality', 'high',
						'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
						'align', 'middle',
						'play', 'true',
						'loop', 'true',
						'scale', 'showall',
						'wmode', _sWmode,
						'devicefont', 'false',
						'id', _sId,
						'bgcolor', '#000000',
						'name', _sId,
						'menu', 'true',
						'allowScriptAccess','always',
						'salign', '',
						'FlashVars',  _sVars
						); //end AC code
					
					if (_sDivId!=null){
						document.getElementById(_sDivId).innerHTML = _sEmbedHtml;
					}else{
						return  _sEmbedHtml;
					}
				}
		}
	};
	
	
/**
* libGlobalv1_writeFlashEmbed
*
* à utiliser quand on veux écrire l'embed flash dans le document (donc la première var dans la fonction libGlobalv1_embedSwf() est mise à null)
*
* Exemple:   libGlobalv1_writeFlashEmbed(
										 libGlobalv1_embedSwf(null,"/nouvelles/enProfondeur/Societe/conversions-religieuses/lib/swf/webcam", _sFVars, "swfWebcam", 228, 430, "transparent", [9,0,0])
										 );
*/
	function libGlobalv1_writeFlashEmbed(_sEmbedhtml){
		document.write ( _sEmbedhtml  );
	};
//=============================================================
//	----------	END nouveau - fonctions "libGlobalv1_"  -------
//=============================================================


