/*function sfHover()
{
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {this.className+=" sfhover";}
		sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp("sfhover\\b"), "");}
	}
}
window.addEvent('domready', function(){ sfHover();});*/

function swicthImgLoupe(loupeurl,urlsmall,urlbig){
	layerLoupe = $('loupeFlash');
	if(layerLoupe){
		layerLoupe.setHTML(' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="264" height="362" id="loupe" align="middle"><param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="'+loupeurl+'?imgBig='+urlbig+'&imgSmall='+urlsmall+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque" /><embed src="'+loupeurl+'?imgBig='+urlbig+'&imgSmall='+urlsmall+'" quality="high" bgcolor="#ffffff" width="264" height="362" name="loupe" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" /></object>');
	}
}

function swicthImgLoupeBig(loupeurl,urlsmall,urlbig,width,height){
	if (!width) width=350;
	if (!height) height=480;
	layerLoupe = $('loupeFlash');
	if(layerLoupe){
		layerLoupe.setHTML(' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="loupe" align="middle"><param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="'+loupeurl+'?imgBig='+urlbig+'&imgSmall='+urlsmall+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque" /><embed src="'+loupeurl+'?imgBig='+urlbig+'&imgSmall='+urlsmall+'" quality="high" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="loupe" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" /></object>');
	}
}

function resetOnglet(){
		var E=1;
		while ($('bout'+E)) {
			$('bout'+E).addClass('deselected');
			$('main'+E).setStyle('display','none');
			$('star40_'+E).setStyle('display','none');
			E++;
	}
}
function showOnglet(E){
	resetOnglet();
	mainE='main'+E;
	ongletE='bout'+E;
	starE='star40_'+E;
	$(ongletE).removeClass('deselected');
	$(ongletE).addClass('selected');
	$(mainE).setStyle('display','block');
	$(starE).setStyle('display','block');
}

/* Fonction de gestion de la mise en favoris */
function fav( siteURL, siteNOM ) {
  /*-- MESSAGE --*/
  function myMessage (raccourciClavier) {
    alert ("Utilisez '" + raccourciClavier + "'\npour ajouter " + siteNOM + " dans vos favoris !");
  }


  /*-- TRAITEMENT DES NAVIGATEURS --*/

  //Konqueror
  if (navigator.userAgent.indexOf('Konqueror') >= 0) {
    /*Test a effectuer avant tout les autres car repond TRUE aux differents tests sans pouvoir les exploiter*/
    myMessage("CTRL + B");
  } else if (window.external && !window.sidebar) {
    /* Internet Explorer 4+, et ses dérivés (Crazy Browser, Avent Browser ...) */
    window.external.AddFavorite(siteURL,siteNOM);
  } else if (document.all && (navigator.userAgent.indexOf('Win') < 0)) {
    /* Internet Explorer Mac */
    myMessage("POMME + D");
  } else if (document.layers || window.sidebar || (navigator.userAgent.indexOf('Opera/9') >= 0)) {
    /* Netscape 4 ; Netscape 6+ ; Mozilla, FireFox et compagnie (K-Meleon ...) */
    myMessage("CTRL + D");
  } else if (window.opera && window.print) {
    /* Opera 6 */
    myMessage("CTRL + T");
  } else if (document.layers || window.sidebar || (navigator.userAgent.indexOf('Opera/9') >= 0)) {
    /* Netscape 4 ; Netscape 6+ ; Mozilla, FireFox et compagnie (K-Meleon ...) */
    myMessage("CTRL + D");
  } else {
    alert ("Cette fonction n'est pas disponible pour votre navigateur.");
  }
}

/* Fonction de récupération des variables d'url */
function getVar (nomVariable) {
  variable = false;
  infos = location.href.substring( location.href.indexOf( "?" )+1, location.href.length )+"&";
  if ( infos.indexOf( "#" ) != -1 )
    infos = infos.substring( 0, infos.indexOf( "#" ) )+"&";

  nomVariable = nomVariable + "=";
  taille = nomVariable.length;
  if ( infos.indexOf( nomVariable ) != -1 )
    variable = infos.substring( infos.indexOf( nomVariable )+taille, infos.length ).substring( 0, infos.substring( infos.indexOf( nomVariable )+taille, infos.length ).indexOf( "&" ) );

  return variable;
}

/* Mode plein écrand du SWF */
function swf_fullscreen(mode,file,autostart){
  if (navigator.appName == "Microsoft Internet Explorer"){
    window.open(wwwroot + "/fullscreen.php?file=" + file + "&autostart=" + autostart, "VSD", "menubar=no,resizable=no,scrollbars=no,width=" + (screen.width-10) + ",height=" + (screen.height-30) + ",top=0,left=0");
  }
  else{
    window.open(wwwroot + "/fullscreen.php?file=" + file + "&autostart=" + autostart, "VSD", "menubar=no,resizable=no,top=0,left=0,width=" + screen.availWidth + ",height=" + screen.availHeight);
  }
}

/* Animation Unes homepage */
function moveFocus(id){
	var une_img=document.getElementById('une_img');
	var topLeftLinks=document.getElementById('topLeftLinks');
	var i=0;
	var j=0;
	var k=0;
	var indice=0;
	for ( var child in topLeftLinks.childNodes ){
		if (topLeftLinks.childNodes[child].id=='linkOn' || topLeftLinks.childNodes[child].id=='linkOff'){
			indice=indice+1;
			if (topLeftLinks.childNodes[child].id=='linkOn'){
				topLeftLinks.childNodes[child].id='linkOff';
				var next=indice;
			}
		}
	}
	if (id!=undefined){
		next=id;
	}
	if (next>4){
		next=0;
	}
	for ( var child in topLeftLinks.childNodes ){
		if (topLeftLinks.childNodes[child].id=='linkOn' || topLeftLinks.childNodes[child].id=='linkOff'){
			if (k==next){
				topLeftLinks.childNodes[child].id='linkOn';
			}
			k=k+1;
		}
	}
	for ( var imgChild in une_img.childNodes){
		if (une_img.childNodes[imgChild].id=='imageOn'){
			une_img.childNodes[imgChild].setStyle('display','none');
			une_img.childNodes[imgChild].id='imageOff';
		}
		if (une_img.childNodes[imgChild].id=='content_label_uneOn'){
			une_img.childNodes[imgChild].id='content_label_uneOff';
		}
		if (une_img.childNodes[imgChild].id=='imageOn' || une_img.childNodes[imgChild].id=='imageOff'){
			if (i==next){
				une_img.childNodes[imgChild].setStyle('display','block');
				une_img.childNodes[imgChild].id='imageOn';
			}
			i=i+1;
		}
		if (une_img.childNodes[imgChild].id=='content_label_uneOn' || une_img.childNodes[imgChild].id=='content_label_uneOff'){
			if (j==next){
				une_img.childNodes[imgChild].id='content_label_uneOn';
			}
			j=j+1;
		}
	}
}
var timeflow = 0;
function startAnimation() {
	timeflow = setTimeout('callSwapMenu()',4000);
}
function stopAnimation(){
	clearTimeout(timeflow);
}
function callSwapMenu(){
	moveFocus();
	timeflow = setTimeout('callSwapMenu()',4000);
}

/* Fil d'infos */
var defile;
var psinit = 665;
var pscrnt = psinit;
var pix;
function texteDefile() {
	if (!defile) defile = document.getElementById('defile');
	if (defile) {
		if(pscrnt < (- defile.offsetWidth) ){
			pscrnt = psinit;
		} else {
			pscrnt+= -pix;
		}
		if (pscrnt>psinit){
			pscrnt = -defile.offsetWidth;
		}
		defile.style.left = pscrnt+"px";
		timeDefile = setTimeout("texteDefile()",20);
	}
}
function normalDefile(){ pix=2; }
function startDefile(){ normalDefile(); timeDefile = setTimeout("texteDefile()",20); }
function stopDefile(){ clearTimeout(timeDefile); }
function backwardDefile(){ pix=10; }
function forwardDefile(){ pix=-10; }

function fixHeight(){
	var divLeft = document.getElementById('leftContent');
	var divRight = document.getElementById('rightContent');
	if (divLeft.offsetHeight > divRight.offsetHeight){
		if (navigator.appName == "Microsoft Internet Explorer"){
			divRight.style.height = (divLeft.offsetHeight-8);
		}
		else{
			divRight.setStyle('height',(divLeft.offsetHeight-8));
		}
	}
}
