
var domain = (document.domain.indexOf("forumdeschefs.com")!=-1) ? ".com" : ".ca" ;




/**
* embedConsoleFlv
* afficher une FLV enregistrer avec Z avec la console AV
*/
function embedConsoleFlv(streamFlv){
	if ( (streamFlv.toLowerCase()).indexOf('51092/monde/2008/flash')!=-1)  {
		streamFlv = "rtmp://cp51092.edgefcs.net/ondemand/" + streamFlv.replace("51092/","")+".flv";
	}
	var _domain = (document.domain.indexOf("forumdeschefs.com")!=-1) ? ".com" : ".ca" ;
	//alert(streamFlv)
	if (streamFlv!=undefined && streamFlv!=null && streamFlv!=""){
		srcAV_write(
			{
				urlMedia : streamFlv,
				data : false, 
				autoStart : false,
				GUI : "embedSrcMini",
				showTeaserFin:false,
				cancelBtnMore:true,
				cancelExtract: true
			}
			);
	}
};

		 
/**
* getFlvZ
* afficher une FLV enregistrer avec Z
*exemple: getFlvZ('1004','FlvVestiaire','/elections/surLeWeb/lib/v1/swf/playerCamera', 'V_test.flv&amp;isPlay=0', 'swfVideoVestiare', 200, 150);
*
*/
function getFlvZ(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode){
   var sPATH_TO_FLV = "http://www.radio-canada.ca/medianet/";	
	if (_sFlashVars.indexOf('51092/monde/2008/Flash')!=-1) {
			sPATH_TO_FLV=  "rtmp://cp51092.edgefcs.net/ondemand/";
			_sFlashVars = _sFlashVars.replace("51092/","");
	}
   var _sVars = (_sFlashVars!=null) ? "flv="+sPATH_TO_FLV+_sFlashVars : null;
		
   embedSwfZ (_sDivId, _sSwfSource, _sVars , _sSwfId, _nWidth, _nHeight, _sSwfWmode);
};

/**
* embedSwfZ
* 
*/
function embedSwfZ(_sDivId, _sSwfSource, _sFlashVars, _sSwfId, _nWidth, _nHeight, _sSwfWmode){
	var _sSwf = (_sSwfSource==null) ? "/elections/surLeWeb/lib/v1/swf/playerCamera" : _sSwfSource;
	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;
				}
			}
	}
};

/**
* getSwfObj
* 
*/
function getSwfObj(movieName){ // utility function 
    if (navigator.appName.indexOf("Microsoft") != -1){
        return window[movieName];
    }else{
        return document[movieName];
    }
};

/**
* stopFlvPlayers
*
* boucle pour arreter tous les players quand on change de page (voir mèthode: afficherPageCommentaires() )
*/
function stopFlvPlayers(){
	 /// aFlv est un tableau/array créé dans le fichier lib/xsl/rendezVous_Chefs/commentaireParFiche.xsl
	 if(typeof(aFlv)!="undefined"){
		 for  (var id in aFlv){
			 if (!isNaN(id) && (aFlv[id]!=-1) ){
			getSwfObj("swfVidCitoyen"+aFlv[id]).stopPlay();
			//alert("FlvCitoyen"+aFlv[id]);
			 }
		 }
	 }
};


/**
*	
* PAGINATION : Citoyen 
*
-*/
 /////////////////////////////////////////////////////////////////////////////////////
 // Fonctions pour la gestion de la pagination des commentaires dans l'espace citoyen
 function creerLienPage(Texte,PageCourante,NbTotalPages,Id){
	 return "<a "+ Id + " onclick=\"afficherPageCommentaires("+PageCourante+","+NbTotalPages+");\" href=\"#commentaires\">"+Texte+"</a>" 										
 };


 function creerBoitePagination(PageCourante,NbTotalPages){
		 var codeHtml="";
		 /// first
		 //codeHtml+=creerLienPage("&laquo;",1,NbTotalPages,"");
		 /// previous
			codeHtml+="<a href=\"#commentaires\" onclick=\"afficherPageCommentaires("+PageCourante+((PageCourante-1>0)?"-1":"")+","+NbTotalPages+")\" class=\"precedent\" title=\"Commentaires précédents\"><span>Commentaires précédents</span></a>"
		 ///pages
		 codeHtml+="<div class=\"nbPage\">";
		 for(i=1;i<=NbTotalPages;i++){
			 if(i==PageCourante){
				codeHtml+=creerLienPage(i,i,NbTotalPages,"id='"+i+"' style='text-decoration:underline;'");
			 }else{
				 codeHtml+=creerLienPage(i,i,NbTotalPages,"id="+i);
			 }
		 	if(i<NbTotalPages){codeHtml+=" - "};
		 }
		 codeHtml+="</div>";
		 ///next
		 codeHtml+="<a href=\"#commentaires\" onclick=\"afficherPageCommentaires("+PageCourante+((PageCourante<NbTotalPages)?"+1":"")+","+NbTotalPages+");\" class=\"suivant\" title=\"Commentaires suivants\"><span>Commentaires suivants</span>"
		 
		 /// last
		 //codeHtml+=creerLienPage("&raquo;",NbTotalPages,NbTotalPages,"");
		
		 document.getElementById("pagination").innerHTML=codeHtml;
 };
 
 function afficherPageCommentaires(PageCourante,NbTotalPages){
	 
	 /// arreter les players flv
	 	//stopFlvPlayers();
	 
	 /// boucle pour afficher les pages 
	 for(i=1;i<=NbTotalPages;i++){
	 if(i!=PageCourante){
	 document.getElementById("page_"+i).style.display="none";
	 }
	 }
	 document.getElementById("page_"+PageCourante).style.display="block";
	 creerBoitePagination(PageCourante,NbTotalPages);
 };
 
 
 
/**
*	
* section "COMPAREZ" 
*
-*/
 /////////////////////////////////////////////////////////////////////////////////////
 // Fonctions pour la gestion des questions/réponses  des pages dans section  http://www.forumdeschefs.ca/comparez/
 
 var currQBtnId = "Q1-Btn"; // première question est ouverte au téléchargement de la page 
 var aTeasers = [-1,
				"480x270_JeanCharest.jpg",
				"480x270_paulineMarois.jpg",
				"480x270_marioDumont.jpg",
				"480x270_GuyRainville.jpg",
				"480x270_FrancoiseDavid.jpg"
				]; /// l'ordre index = l'ordre des asx dans aReponsesParQ[] 
 
 
 /**
 * playIntegrale()
 * 
 */
 function playIntegrale(_urlMedia/*string*/,_indexTeaser/*int*/){
	callFromObj(
		0, 
		'srcAV_jsExt_0', 
		'changeMedia', 
		{urlMedia : "http://www.forumdeschefs"+domain+_urlMedia,  urlTeaser:aTeasers[_indexTeaser],  autoStart:true}
		);
 };
 
 /**
 * toggleQ()
 * gérer les contenants de questions/réponses
 */
 function toggleQ(_oLien){
	 // toggleQ_KeepOpen(_oLien);
	  toggleQ_CloseOld(_oLien);
 };
 function toggleQ_KeepOpen(_oLien){
 //alert( _oBtn.id + ", " + _oBtn.className);
 var _suffixBtn = "-Btn";
 var _oBtn = (_oLien.id.indexOf(_suffixBtn)!=-1) ? _oLien : document.getElementById(_oLien.id+_suffixBtn);
  var _b = (_oBtn.className=="bt_action moins") ? false : true;
  ///  bouton
   _oBtn.className = (_b) ? "bt_action moins" : "bt_action plus";
  ///  contenu
 	document.getElementById(_oBtn.id.split(_suffixBtn)[0]+"-Reponses").style.display = (_b) ? "block" : "none";
 };
 function toggleQ_CloseOld(_oLien){
 //alert( _oBtn.id + ", " + _oBtn.className);
 var _suffixBtn = "-Btn";
 var _oBtn = (_oLien.id.indexOf(_suffixBtn)!=-1) ? _oLien : document.getElementById(_oLien.id+_suffixBtn);
  /// ancien bouton
  document.getElementById(currQBtnId).className = "bt_action plus";
  /// ancien contenu
 	document.getElementById(currQBtnId.split(_suffixBtn)[0]+"-Reponses").style.display = "none";
  ///  nouveau bouton
   _oBtn.className =  "bt_action moins" ;
  ///  nouveau  contenu
 	document.getElementById(_oBtn.id.split(_suffixBtn)[0]+"-Reponses").style.display = "block";
 /// sauvegarder valeur
	currQBtnId = _oBtn.id;
 };
 
 /**
 * toggleR()
 * gérer les réponses
 */
 function toggleR(_oLien){
	
	var numeroQuestion = _oLien.id.split("Q")[1];
	var numeroReponse = _oLien.id.substr(1).split("-")[0];
	//alert("numeroQuestion: "+numeroQuestion+", numeroReponse: "+ numeroReponse);
	
	/// nouvelle réponse
		_oLien.className="On";
	
	/// ancienne réponse
		if (aNumeroDernRepParQ[numeroQuestion]!=0){ /// 0 veut dire qu'il n'y a pas de réponse choisie encore
			//alert("R"+aNumeroDernRepParQ[numeroQuestion]+"-Q"+numeroQuestion);
			document.getElementById("R"+aNumeroDernRepParQ[numeroQuestion]+"-Q"+numeroQuestion).className="actif";
		}
	
	/// update array
		aNumeroDernRepParQ[numeroQuestion] = numeroReponse;
		//alert("nouvelle réponse: " + aNumeroDernRepParQ[numeroQuestion]);
		
	/// vidéo asx
	/// mèthode callFromObj() dans fichier  /audio-video/main/1.0/classInstance.js
		callFromObj(
		(numeroQuestion-1), 
		'srcAV_jsExt_0', 
		'changeMedia', 
		{urlMedia : "http://www.forumdeschefs"+domain+aReponsesParQ[numeroQuestion][numeroReponse],  urlTeaser:"/quebec2008/lib/img/"+aTeasers[numeroReponse],  autoStart:true}
		);
		
		
 };