function popupJT(jt, seq)
{
steljtURL = "http://www.la1.be/video/jt/index.htm?jt=" + jt + "&seq=" + seq;
settings = "width=330,height=400,scrollbars=no,location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";
win = window.open(steljtURL, 'RTBFJT', settings);
win.focus();
}

function popupJTS()
{
//steljtURL = "mms://video1.rtbf.be/JT_20071001_193000_200.wmv"
steljtURL = "http://mediaserver.rtbf.be/sites/rtbf-media/themes/rtbfmedia/iPlayer/MediaPlayer.php"settings = "width=840,height=550,scrollbars=yes,location=no,directories=no,status=RTBF,menubar=no,toolbar=no,resizable=no";
win = window.open(steljtURL, 'RTBF', settings);
win.focus();
}

function popup(url,larg,haut){
settings="width=" + larg + ",height=" + haut + ",scrollbars=no,location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";
win=window.open(url,'RTBF',settings);
win.focus();
}

function popupRTBF(url,larg,haut){
settings="width=" + larg + ",height=" + haut + ",scrollbars=no,location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";
win=window.open(url,'RTBF',settings);
win.focus();
}function popupRTBFWR(url,larg,haut,scroll){settings="width=" + larg + ",height=" + haut + ",scrollbars=" + scroll + ",location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";win=window.open(url,'RTBF',settings);win.focus();}

function popupVID(fiche,target)
{
steljtURL = "http://www.rtbf.be/video/elec/"+fiche+"?target="+target;
settings = "width=330,height=450,scrollbars=no,location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";
win = window.open(steljtURL, 'RTBF', settings);
win.focus();
}

//tdf
function popupTDF(){
flashURL="http://www.rtbf.be/info/sports/dossiers/tdf/2006/flash/";
var haut = 595;
var larg = 921;
settings = "width="+larg+",height="+haut+",scrollbars=no,location=no,directories=no,status=,menubar=yes,toolbar=no,resizable=no,top="+(screen.height-haut)/2+",left="+(screen.width-larg)/2;
popu= window.open(flashURL, 'RTBFTDF', settings);
popu.focus();
}

function oldpopupJT(myname,pj,pr)
{
var win = null;
w = 620;
h = 550;
pos = 'left';
infocus = 'front';
if(pr=="*") {pr='';}
if(pj=="*") {pj='noj';}
mypage = "http:\/\/skynet.rtbf.be/index.html?pj=" + pj + "&pr=" + pr;
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=40;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();
}

function popupSelf(haut,larg){
if(window.name!='popupself'){
        xWin = window.open(window.top.location.href,'popupself',
			'width='+larg+',height='+haut+
			',top='+Math.round((screen.availHeight-haut)/2)+',left='+Math.round((screen.availWidth-larg)/2)+',menubar=no,scrollbars=yes,location=no,directories=no,resizable=no,toolbar=no') ;
      if ( (xWin==null) || (typeof(xWin)=="undefined") || (typeof(xWin.location.hash)!="string")) {
	  alert("Pour que cette page fonctionne bien, il faut autoriser les popups pour ce site!!!\nMerci");
	  }
	 else {
	  	window.opener = self;
        if(self.document.referrer != null && self.document.referrer != "")  
	  	   self.location.href=self.document.referrer;
	    else
	  	   self.close();
	  }
    }    
}

//image_article
var visible = 0;
function popupImg(url){
if(visible == 1) fenetre.close();
var larg = 400;
var haut = 300;
settings = "width="+larg+",height="+haut+",scrollbars=no,location=no,directories=no,status='RTBF',menubar=no,toolbar=no,resizable=no,top="+(screen.height-haut)/2+",left="+(screen.width-larg)/2;
fenetre = window.open('','',settings);
fenetre.document.open("text/html","replace");
fenetre.document.write("<html><head><title>RTBF</title></head><body status = 'RTBF' leftmargin=0 marginwidth=0 topmargin=0 marginheigth=0 oncontextmenu='return false'><a href='RTBF'><img src="+url+" border='0' alt='cliquer pour fermer' width='"+larg+"' height='"+haut+"' onClick='window.close()'/></a></body></html>");
fenetre.document.close();
visible = 1;
}
//article
var nbimg = 0;
var nbbimg = 0;
var bigimg = new Array(2);
var imgArt;
var i=0;
function initImage(tot){
imgArt = new Array(tot);
}

function addImage(src,leg){
var tmp = new Image;
tmp.src = src;
tmp.alt = leg;
imgArt[nbimg++] = tmp;
}   

function BigImage(src){
var tmp = new Image;
tmp.src = src;
bigimg[nbbimg++] = tmp;
}  

function popupBig(num){
 if(bigimg[num] != null)
 popupImg(bigimg[num].src);
} 

function showImage(){
if (i == nbimg){
  i = 0;
}
document.imasec.src = imgArt[i].src;
var legen = document.getElementById("legendesec");
if(legen != null){
   legen.innerHTML = imgArt[i].alt;
}
setTimeout("showImage()",3000);
i++;
}

//sport
var id;
var elemcat;
var x = 0;
function show(cat){
 id = document.getElementById("categorie"+cat);
 elemcat = document.getElementById("categorie");
 if(id != null && elemcat != null && x == 0)
	gauche(); 
 window.status = "RTBF";	
}

function gauche(){
 x -=  30;
 if(x > -365){
  elemcat.style.left = x ;
  left=setTimeout("gauche()",5); 
 }
 else{
 clearTimeout(left);
 elemcat.innerHTML=id.innerHTML;
 droite(); 
 }
}

function droite(){
 x +=  30;
 if(x < 30){
 elemcat.style.left = x ;
 right=setTimeout("droite()",5); 
 }
 else{
 x=0;
 clearTimeout(right);
 }
}

function changeNoeud(index) {
 /*switch(index){
	case 1 :  if(document.sportform.noeud2 != null)
			  document.sportform.noeud2.options[document.sportform.noeud2.selectedIndex].value = "1";
	case 2 :  if(document.sportform.noeud3 != null)
 			  document.sportform.noeud3.options[document.sportform.noeud3.selectedIndex].value = "1";
	case 3 :  document.sportform.poule.options[document.sportform.poule.selectedIndex].value = "";  			  
 }*/
 document.sportform.submit();
}

//Loterie
function showGain(cat){
 id = document.getElementById("gain_"+cat);
 if(id != null)
	id.style.display = (id.style.display == "none"?"block":"none");
 window.status = "RTBF";	
}

//blink
function flash(src,color){
var elem = document.getElementById(src);
if(elem != null){
	if (elem.style.color==color)
	elem.style.color="red";
	else
	elem.style.color=color;
	setTimeout("flash('"+src+"','"+color+"')",1000);
}
}

//bourse
var bourse = new Array(4);
var ticker = 0;
var inter = 15 * 60 * 1000;
function PreLoadBourse(src,linkb){
var tmp = new Image;
tmp.src = src;
tmp.alt = linkb;
setTimeout("LoadBourse('"+src+"','"+ticker+"','"+linkb+"')",inter);
bourse[ticker++] = tmp;
if(ticker == 4)
  diapoBourse();
}  

var diap = 0;
function diapoBourse(){
 if(diap == ticker)
   diap = 0;
 showBourse(diap);
 setTimeout("diapoBourse()",5000);
 diap++;
}

function LoadBourse(src,num,linkb){
var tmp = new Image;
tmp.src = src;
tmp.alt = linkb;
bourse[num] = tmp;
setTimeout("LoadBourse('"+src+"','"+num+"','"+linkb+"')",inter);
}  

function showBourse(num){
 id = document.getElementById("bourselink");
 if(bourse[num] != null){
 document.symexchart.src = bourse[num].src;
 if(id != null)
 id.href = bourse[num].alt;
 }
}  

var countImgRefr=0;function refreshImage(id,duree){ elem = document.getElementById(id);  if(elem != null){ 	countImgRefr++;	var index = elem.src.lastIndexOf('?');	var srcIm = "";	if(index > -1)	srcIm = elem.src.substring(0,index);	else	srcIm = elem.src;	var tmp = new Image; 	if(srcIm.lastIndexOf('?') > -1)	tmp.src = srcIm+"&count="+countImgRefr+"&id="+Math.random(); 	else	tmp.src = srcIm+"?count="+countImgRefr+"&id="+Math.random(); 	elem.src = tmp.src; 	window.status = " Studio VivaCité - Webcam";	setTimeout("refreshImage('"+id+"','"+duree+"')",duree);  }}  

//statusbar
function rtbf(){
window.status = "RTBF";
}

//menu rtbf
function showitem(nommenu,color)
{
 var menu = ["rtbfbe","info","radio","television","entreprise","teletexte"];
 for (i = 0; i < menu.length; i++)
{
  id = document.getElementById(menu[i]);
  ida = document.getElementById("_"+menu[i]);
  if(nommenu == menu[i]){
   if(ida != null)
   ida.style.color = color;
   if(id != null)
   id.style.display='inline';
  }
  else{
  if(id != null)
  id.style.display='none';
  if(ida != null)
  ida.style.color = '';
  }
 
}
}

function toggleVisible(oId)
{
	id = document.getElementById(oId);
 	if(id != null) id.style.display = (id.style.display == "none"?"block":"none");
}


function nextecouter(index,y,haut)
{
    moveH(y,index,haut);
}
var ccontecouter;

function moveH(x,index,haut)
{
    ccontecouter = document.getElementById("ecoutez-item-"+index);
    var hau = parseInt(ccontecouter.style.height + 0);
    var i = 0;
    var savx = x;
    var stepecouter =5;
    if(hau==0) ccontecouter.style.height = haut+'px';
	moved = 0;
	if((hau==0 || hau==haut) && x > 0)
    {
		while(savx > 0)
        {
            setTimeout("ccontecouter.style.height = parseInt(ccontecouter.style.height + 0) + " +parseInt(stepecouter)+ " + 'px';", i*50);
            i++;
			savx-=stepecouter;
        }
   }
   else {
   		 ccontecouter.style.height = haut+'px';
   }
}

var ccont;
var step=0;
var maxStep;
var count = 3;
function next()
{
    if(step < maxStep){
    step++;
    moveL(count * 97);
    }
}

function previous()
{
    if(step > 0 && step <= maxStep){
    step--;
    moveL(-count * 97);
    }
}

function moveL(pixels)
{
    if(!ccont) ccont = document.getElementById('galerie-photos');
    var i = 1;
    if(pixels > 0)
    {
        while(32*i <= pixels)
        {
            setTimeout("ccont.style.left = parseInt(ccont.style.left + 0) - 32 + 'px';", i*70);
            i++;
        }
        setTimeout("ccont.style.left = parseInt(ccont.style.left + 0) - 3 + 'px';", i*70);
   }
    else
    {
         while(-32*i >= pixels)
        {
            setTimeout("ccont.style.left = parseInt(ccont.style.left + 0) + 32 + 'px';", i*70);
            i++;
        }
        setTimeout("ccont.style.left = parseInt(ccont.style.left + 0) + 3 + 'px';", i*70);
    }
}

function limite24heures(s)
{
	var heures = s.split(":");
	if (heures[0] > 23) return ((heures[0] - 24) + ":" + heures[1]);
	else return s;
}
function adapteDate(d,h)
{
	if(h == null) return d;
	var heures = h.split(":");
	if(heures[0] < 24)
	 d= new Date(d.substring(6,10), d.substring(3,5)-1, d.substring(0,2),heures[0],heures[1],0,0);
	else
	 d= new Date(new Date(d.substring(6,10), d.substring(3,5)-1, d.substring(0,2),heures[0]-24,heures[1],0,0).getTime()+86400000);
	return d;
}
function formatOO(Value) {
  return (Value > 9) ? "" + Value : "0" + Value;
}
function getDuration(d)
{
	if(d == null) return null;
	var details = d.split(":");
	var duree = parseInt(details[0]) * 60 + parseInt(details[1]);
	return duree + "'";
}
function displayEmission(em, imgBase, cssMainClass, detailLink)
{
	var i;
	semaine = ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"];
	mois = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
	var d = adapteDate(em.date,em.heure);
	document.write("<div class=\"" + cssMainClass + "\">");
	document.write("<div class=\"titre\">");
	if (detailLink) document.write("<a href=\"" + detailLink + em.id_won + "\">");
	document.write(semaine[d.getDay()] + " " + d.getDate() + " " + mois[d.getMonth()] + " à " + formatOO(d.getHours()) + ":" + formatOO(d.getMinutes()) + " " + ((em.genre && em.genre != "null")?" - "+em.genre:"") + "<br/>" + em.titre);
	document.write((em.sous_titre?" - " + em.sous_titre: ""));
	document.write(((em.inedit != 0)?"<strong> - Inedit</strong>":""));
	if (detailLink) document.write("</a>");
	document.write("</div>");
	document.write("<div class=\"clearer\"></div>");
	document.write((em.num_episode > 0?"<div class=\"infos\"><strong>Episode: </strong>" + em.num_episode + " / " + em.max_episode+"</div><br/>":""));
	document.write("<div class=\"resume\">");
	if (em.images && em.images.length > 0)
	{
		for(var i=0; i < em.images.length ; i++)
		{
		document.write("<div class=\"imgwrap\">");
		if (detailLink) document.write("<a href=\"" + detailLink + em.id_won + "\">");
		if (em.images[i].type == "P")		document.write("<img src=\"" + imgBase + em.images[i].url + "\"/>");
		if (detailLink) document.write("</a>");
		document.write("</div>");
		}
	}
	if (em.resumeInternet) 
	{
		document.write(em.resumeInternet);
	}
	document.write("</div>");
	document.write("<div class=\"infos\">");
	if (em.personnes && em.personnes.length > 0)
	{
		i = 0;
		while (i < em.personnes.length)
		{
			var fct = em.personnes[i].fonction;
			var cast = "";
			while (i < em.personnes.length && fct == em.personnes[i].fonction)
			{
				cast = cast + em.personnes[i].prenom + " " + em.personnes[i].nom;
				if(em.personnes[i].role != null)
					cast = cast + " (" + em.personnes[i].role + ")";
				i++;
				if(i < em.personnes.length && fct == em.personnes[i].fonction)
					cast = cast + ", ";
			}
			document.write("<br/><strong>" + fct + ":</strong> " + cast);
		}
	}
	var duree = getDuration(em.duree);
	if(duree != null)
	document.write("<div class=\"duree\"><strong>Durée: </strong>" + duree + "</div>");
	document.write("<div class=\"signaletique\">" + (em.signaletique?"<strong>Signalétique: </strong>" + em.signaletique:"") + "</div>");
	document.write("<div class=\"rapport_image\">" + (em.rapport_image?"<strong>Rapport image: </strong>" + em.rapport_image:"") + "</div><br/>");
	document.write("<div>" + (em.annee_production?"<strong>Année de production: </strong>" + em.annee_production:"") + "</div><br/>");
	if (em.precedentes_diffision && em.precedentes_diffision.length > 0)
	{
		document.write("<div><strong>Précédente diffusion: </strong></div>");
		for(var i=0; i < em.precedentes_diffision.length ; i++)
		{
			document.write("<div style=\"padding-left:10px;\">");
			document.write(em.precedentes_diffision[i].date + " à " + em.precedentes_diffision[i].heure + " sur " + em.precedentes_diffision[i].chaine);
			document.write("</div>");
		}
	}
	if (em.prochaines_diffision && em.prochaines_diffision.length > 0)
	{
		document.write("<div><strong>Prochaine diffusion: </strong></div>");
		for(var i=0; i < em.prochaines_diffision.length ; i++)
		{
			document.write("<div style=\"padding-left:10px;\">");
			document.write(em.prochaines_diffision[i].date + " à " + em.prochaines_diffision[i].heure + " sur " + em.prochaines_diffision[i].chaine);
			document.write("</div>");
		}
	}
	document.write("</div>");
	document.write("</div>");
	
}

function DateHeureActuel(){
  d = new Date();
  return formatOO(d.getHours())+':'+formatOO(d.getMinutes())+' '+formatOO(d.getDate())+'/'+formatOO(d.getMonth())+'/'+d.getFullYear();
}

function afficheDateheureActuel(elem){
 document.getElementById(elem).innerHTML = DateHeureActuel();
 setTimeout("afficheDateheureActuel('"+elem+"')",1000);
}
