
var selectGenres = "";
var lolTimeout;

var tabImages = new Array();

function makeyourtime(urlComplet)
{

	var xmlHttp;
	var url = urlComplet;
	
	if(document.all) {
		  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		  xmlHttp = new XMLHttpRequest();	  
	}
	xmlHttp.onreadystatechange = function() {stateChange(xmlHttp); };

	xmlHttp.open("GET",url);
	xmlHttp.send(null);
}


var IE = false, FIREFOX = false,NETSCAPE = false,OPERA = false,AUTRE = false,ZOOMOK = false;
var strChUserAgent = navigator.userAgent;
var intSplitStart = strChUserAgent.indexOf("(",0);
var intSplitEnd = strChUserAgent.indexOf(")",0);
var strChStart = strChUserAgent.substring(0,intSplitStart);
var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
var strChEnd = strChUserAgent.substring(strChEnd);
if(strChMid.indexOf("MSIE") != -1)IE = true;
else if(strChEnd.indexOf("Firefox") != -1)FIREFOX = true;
else if(strChEnd.indexOf("Netscape") != -1)NETSCAPE = true;
else if(strChStart.indexOf("Opera") != -1)OPERA = true;
else AUTRE = true;


function stateChange(xmlHttp){

	if(xmlHttp.readyState == 4) {

		var  reponse = xmlHttp.responseText;
		
		if (reponse.substr(0,18)=='CHARGEMENT GALERIE') {
			
			// Vérifier s'il s'agit d'un chargement de galerie avec un ID bien précis
			if(reponse.substr(0,19)=='CHARGEMENT GALERIEX') {
				// Récupérer l'ID de la galerie
				var tab = reponse.split(new RegExp("[|]"));
				var idGalerie = tab[1];
								
				
								
				document.getElementById(idGalerie).innerHTML=tab[2];
				
				jQuery('#'+idGalerie).jcarousel({vertical: false});
				hs.graphicsDir='/academie/OWS/Images/highslide/';
				hs.align='center';			hs.transitions=['expand', 'crossfade'];
				hs.fadeInOut=true;
				if(hs.addSlideshow){hs.addSlideshow({slideshowGroup:idGalerie,interval: 5000,repeat: false,useControls: false,fixedControls: 'fit',autoplay: false,overlayOptions:{opacity: .60,position: 'above left',hideOnMouseOut: true}});}

				jQuery("#waiting_"+idGalerie).fadeTo(2000,0,function(){jQuery("#waiting_"+idGalerie).hide();});//$("#getgalerie").fadeTo('slow',1,function(){});});
				
			} else {			
				document.getElementById("idgalerie").innerHTML=reponse.substr(19);
												
				jQuery('#idgalerie').jcarousel();
				hs.graphicsDir='/academie/OWS/Images/highslide/';
				hs.align='center';			hs.transitions=['expand', 'crossfade'];
				hs.fadeInOut=true;
				if(hs.addSlideshow){hs.addSlideshow({slideshowGroup:'idgalerie',interval: 5000,repeat: false,useControls: false,fixedControls: 'fit',autoplay: false,overlayOptions:{opacity: .60,position: 'above left',hideOnMouseOut: true}});}
				
				jQuery("#waiting").fadeTo(2000,0,function(){jQuery("#waiting").hide();});//$("#getgalerie").fadeTo('slow',1,function(){});});
			}
			
			
		}
		else if (reponse.substr(0,16)=='COMMANDE ENVOYEE') {
			
			document.getElementById("erreur"+reponse.substr(16)).innerHTML = "Votre commande a bien \351t\351 enregistr\351e. Un email a \351t\351 envoy\351 afin d'y r\351pondre dans les plus brefs d\351lais. Merci!";
			jQuery("#erreur"+reponse.substr(16)).fadeIn(1000, function(){setTimeout(function(){jQuery("#erreur"+reponse.substr(16)).fadeOut(1000,function(){document.getElementById("erreur"+reponse.substr(16)).innerHTML ="";jQuery(".formulaire"+reponse.substr(16)).fadeOut(500);});},3000);});
		}
		else if (reponse.substr(0,10)=='TEXTE CREE') {
			window.location=reponse.substr(10);
		}
		else if (reponse.substr(0,15)=='ARCHIVE CHARGEE') {
			var tab = reponse.split('|');
			var iddoc=tab[1];
			var load=tab[2];
			if (load==1) document.getElementById('contenu'+iddoc).innerHTML=tab[3];
			scrollTo(0, 0);
			setTimeout(function(){lolTimeout=MagicMagnify.start(false);},1000);
			var offsetleft=calculeOffsetLeft(document.getElementById('balise'+iddoc));
			var ll=largeur_fenetre();var hh=hauteur_fenetre()-40;
			jQuery('#iframe'+iddoc+', .grd'+iddoc).css({'margin-top':(-calculeOffsetTop(document.getElementById('balise'+iddoc))+10)+'px'});
			jQuery('#divinterne'+iddoc).css({'height':Math.max(700,Math.min(hh,843))+'px'});
			jQuery('#mini'+iddoc).css({'height':Math.max(700,Math.min(hh,843))-119-59-2*(13+10)-10+'px'});
			jQuery('.hauteuroverflow'+iddoc).css({'height':Math.max(700,Math.min(hh,843))-119-82-285-75-10+'px'});
			jQuery('.hauteurfiche'+iddoc).css({'height':Math.max(700,Math.min(hh,843))-119-82-285-10+'px'});
			//jQuery('.alldiv').hide();jQuery('.alldiv:first').show();
			jQuery('.alldiv').hide();jQuery('.alldiv:first').show();
			jQuery('.formulaire'+iddoc).css({'margin-top':(-calculeOffsetTop(document.getElementById('balise'+iddoc))+10+140)+'px'});
			jQuery('#hoverbody').css({'height':'100%','min-height':(document.body.clientHeight||document.height)+'px'});
			jQuery('.imagefiligrane'+iddoc).each(function(){$(this).css({'max-width':(ll-50)+'px','max-height':(hh-30)+'px'});});
			jQuery('.grd'+iddoc).each(function(){$(this).css({'margin-left':(-offsetleft+(ll-parseInt($(this).width()))/2)+'px'});});
			jQuery('.formulaire'+iddoc).each(function(){$(this).css({'margin-left':(-offsetleft+(ll-parseInt($(this).width()))/2)+'px'});});
			if (true) { jQuery('.MagicZoom img').each(function(){var w=this.width*((Math.max(700,Math.min(hh,843))-119-82-10)/2-10)/this.height;jQuery(this).parent('.MagicZoom').attr('rel','zoom-position:right;zoom-height:273px;zoom-width:'+(763-18-Math.min(w,574)-1)+'px;');}); }
			setTimeout(function(){jQuery('.alldiv:first .imapercu').each(function(){var w=this.width;jQuery(this).parent('a').attr('rel','zoom-height:273px;zoom-width:'+(763-16-Math.min(w,574)-1)+'px;');MagicZoom.refresh();});},200);
			jQuery('#iframe'+iddoc).fadeIn();jQuery('#hoverbody').fadeIn();jQuery('#hoverbody').click(function(){if (FIREFOX) {clearTimeout(lolTimeout);MagicMagnify.stop();}jQuery('#iframe'+iddoc+',#hoverbody,.grd'+iddoc+',.formulaire'+iddoc).fadeOut();});
			jQuery('.note').hover(function(){montre(document.getElementById('long'+this.id).innerHTML);},function(){cache();});
			jQuery('.infobull').css({'background-color':'#AAAAAA'});
			MagicZoom.refresh();
		}
		else {
			switch (reponse) {
			
				case "ERREUR URL":
					alert("URL Error");
				break;

				case "MOT DE PASSE ENVOYE":
					document.getElementById("passlostContenu").innerHTML = "Votre mot de passe vous a \351t\351 envoy\351 par e-mail.";
				break;

				case "LOGIN DOUBLON":
					document.getElementById("erreur").innerHTML = "Cet utilisateur a \351t\351 trouv\351 plusieurs fois dans la base de donn\351es. Veuillez contacter l'administrateur du site internet.";
					document.getElementById("erreur").style.display = "";
				break;

				case "LOGIN INCORRECT":
					document.getElementById("erreur").innerHTML = "Ce nom d'utilisateur n'a pas \351t\351 trouv\351e dans la base de donn\351es.";
					document.getElementById("erreur").style.display = "";
				break;
				
				case "PAS DE MAIL TROUVE" : 
					document.getElementById("erreur").innerHTML = "Aucune adresse e-mail trouv\351e pour cet utilisateur. Veuillez contacter l'administrateur du site internet.";
					document.getElementById("erreur").style.display = "";
				break;
				
				default:
				break;
			}
		}
	}
}

function getmygalerie(id)
{	
	var idGalerie = 'idgalerie';
	idType = 'typegalerie';
	idNoEnreg = 'idactivite';	
	if(id) {
		idGalerie = id;
		idType = 'typegalerie_' + id;
		idNoEnreg = 'idactivite_' + id;
	}
	
	var url = "";
	var d = new Date();
	
	if(id)
		url='/makeyourtime/ws/chargementgalerie/' + document.getElementById(idNoEnreg).value + '/' + document.getElementById(idType).value + '/' + idGalerie + '/' + d.getTime();
	else
		url='/makeyourtime/ws/chargementgalerie/' + document.getElementById(idNoEnreg).value + '/' + document.getElementById(idType).value + '/' + d.getTime();
		
	makeyourtime(url);
}

function creerTexteArchive(id)
{
	var url = "";
	var d = new Date();
	url='/makeyourtime/academie/creertextearchive/' + id + '/' + d.getTime();
	makeyourtime(url);
}

function commanderImage(id,titre,nom,prenom,email,tel,image,note)
{
	var url = "";
	var d = new Date();
	url='/makeyourtime/academie/commanderimage/' + id + '/' + titre + '/' + nom + '/' + prenom + '/' + email + '/' + tel + '/' + image + '/' + note + '/' + d.getTime();
	makeyourtime(url);
}
function loadarchive(id)
{
	var url = "";
	var d = new Date();
	if (document.getElementById('contenu'+id).innerHTML=='') var load=1;
	else var load=0;
	url='/makeyourtime/academie/loadarchive/' + id + '/' + load + '/' + d.getTime();
	makeyourtime(url);
}

/* Fonctions pour le slideshow */
var glob_high=false;

function highslideStart () {
	
	if(glob_high) {hs.next();setTimeout("highslideStart()",5000);}
	return true;
}

function show_slideshow() {

	jQuery(".highsliding_image_on").each(function (){jQuery(this).css('display','inline');});
	//$(".highsliding_image_off").each(function (){$(this).css('display','none');});
}
function hide_slideshow() {

	jQuery(".highsliding_image_on").each(function (){jQuery(this).css('display','none');});
	//$(".highsliding_image_off").each(function (){$(this).css('display','inline');});
}

function highslide_play (imageID,caption) {
var inPageOptions = {
   slideshowGroup: imageID,
   allowSizeReduction: true, // was originally FALSE
   wrapperClassName: 'in-page controls-in-heading',
   captionText: caption,
   autoplay: true
}
	glob_high=true;
	return hs.expand(document.getElementById('first'+imageID),inPageOptions);
}

/* Fin des fonctions pour le slideshow */

function popUp(URL,vWidth,vHeight) 

{

day = new Date();

id = day.getTime();

var scr_w = screen.availWidth;

var scr_h = screen.availHeight;

var haut = (scr_w-vWidth)/2;

var gauche = (scr_h-vHeight)/2;

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+vWidth+",height="+vHeight+",left = "+haut+",top = "+gauche+"');");}




function submitus()
{
var arg = submitus.arguments;
var vbSubmit = true;

if(vbSubmit==true)
{
if (arg[1] != null)
  {arg[0].owHrefP1.value = arg[1];}
if (arg[2] != null)
  {arg[0].owHrefP2.value = arg[2];}
if (arg[3] != null)
  {arg[0].owHrefP3.value = arg[3];}
if (arg[4] != null)
  {arg[0].owHrefP4.value = arg[4];}
if (arg[5] != null)
  {arg[0].owHrefP5.value = arg[5];}
if (arg[6] != null)
  {arg[0].owHrefP6.value = arg[6];}
if (arg[7] != null)
  {arg[0].owHrefP7.value = arg[7];}
if (arg[0].owHrefP1.value == "")
  {
  return false;}
else
  {
  arg[0].submit();}
  }
}


function ClicBouton ()
{
var arg = ClicBouton.arguments;
document.orgform.owHrefP1.value = arg[0] ;
document.orgform.owHrefP2.value = arg[1] ;
document.orgform.owHrefP3.value = arg[2] ;
document.orgform.owHrefP4.value = arg[3] ;
document.orgform.owHrefP5.value = arg[4] ;
document.orgform.owHrefP6.value = arg[5] ;
document.orgform.owHrefP7.value = arg[6]
document.orgform.submit() ;
}

function SubmitBouton ()
{
var arg = SubmitBouton.arguments;
document.arg[0].owHrefP1.value = arg[1] ;
owHrefP2.value = arg[2] ;
owHrefP3.value = arg[3] ;
owHrefP4.value = arg[4] ;
owHrefP5.value = arg[5] ;
owHrefP6.value = arg[6] ;
owHrefP7.value = arg[7] ;
submit() ;
}


function checkform2 (valeur)
{
if (valeur == "")
{
  alert("Faux");
 return false;

}
else
  alert("Vai");
 return true;
}


function checkform ()
{
if (document.orgform.owHrefP1.value == "")
{
  alert("Faux");
 return false;

}
else
  alert("Vai");
 return true;
}

function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function fenedit( desturl , fennom){
varRefWin=window.open(desturl , fennom ,'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=750,height=600');
}

function commtot (n, p, f) {
{
var nn = Number(n);
x=(nn*p)+f
x=x+' Eur'
return x
}
}

function dateValide(jour,mois,annee){
var vDate;
//set up a Date object based on the day, month and year arguments
//javascript months start at 0 (0-11 instead of 1-12)
vDate=new Date(annee,mois-1,jour);

/*
Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
*/
return ((jour==vDate.getDate()) && ((mois-1)==vDate.getMonth()) && (annee==vDate.getFullYear()));
}

function LoadMap(address,htmlInfo) {
	 if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("googlemap"));
		var geocoder = new GClientGeocoder();
		geocoder.getLatLng(address,function (point) {
									if (!point) {
										document.getElementById("googlemap").innerHTML="";
									} else {	
										map.setCenter(new GLatLng(point.lat()+0.007,point.lng()), 13);
										var marker = new GMarker(point);
										map.addOverlay(marker);
										marker.openInfoWindowHtml(htmlInfo);
										map.addControl(new GSmallMapControl());	
										map.addControl(new GMapTypeControl());
										map.enableScrollWheelZoom();
									}
								}
								);
	 }
}


function Remplacer(chaine)
 {
 var a, tmp;
 tmp = "";
 a = chaine;

 for(var i = 0; i < a.length; i++)
	{
 	tmp = tmp + a.charAt(i);
	if (a.charAt(i) == " ")
 		{
		 tmp = tmp.replace(" ","");
 		}
 	if (a.charAt(i) == ",")
 		{
		 tmp = tmp.replace(",",".");
 		}
	if (a.charAt(i) == "W")
 		{
		 tmp = tmp.replace("W","");
 		}
	if (a.charAt(i) == "I")
 		{
		 tmp = tmp.replace("I","");
 		}
	if (a.charAt(i) == "N")
 		{
		 tmp = tmp.replace("N","");
 		}
 	}

 a = tmp;
 return a
 } 

function RecupIndice(chaine)
 {
 var a, tmp;
 tmp = "";
 a = chaine;

 for(var i = 0; i < a.length; i++)
	{
	if (a.charAt(i) == ".")
 		{
		i=a.length;
 		} 
	else
		{
 		tmp = tmp + a.charAt(i);
		}
		
 	}

 a = tmp;
 return a
 } 
 
function InsertFlashByNav(LienFlv)
{
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(strChEnd); 
			
    var hasReqestedVersionAvant = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);		
		
	if (hasReqestedVersionAvant) 
	{             
		var version = GetSwfVer();
		version = Remplacer(version);
		version = RecupIndice(version);		
		version = parseInt(version); 
		document.write("<p id='Lien_Adobe' class='contact' style='font-size:12px;'>Le lecteur vid&eacute;o est indisponible car le <i><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'>Flash Player</a></i> est inf&eacute;rieur &agrave; la version 9 requise.<br><br><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'><IMG SRC='www2.academieroyale.be/academie/ows/images/get_flash_player.gif' BORDER='0'></A></p>");
		document.getElementById("Lien_Adobe").style.display="none";	
		if (version > 8)
		{
              if((strChEnd.indexOf("Firefox/3") != -1)|(strChEnd.indexOf("Firefox/2") != -1)|(strChEnd.indexOf("Firefox") != -1) |( (strChEnd.indexOf("Safari") != -1) & (strChEnd.indexOf("Version/5") != -1) & (strChEnd.indexOf("Version/5.0") == -1))|(strChEnd.indexOf("Chrome") != -1))
           		{
					//FIREFOX, CHROME, SAFARI 5.1 +
					document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");
					document.write("<object id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
					document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
					document.write("<param name='allowFullScreen' value='true'/>");	 	
					document.write("<param name='FlashVars' value='flv="+LienFlv+"&showopen=0&showprevious=0&shownext=0&showstop=1&showvolume=1&showtime=1&showfullscreen=1&autoplay=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
					document.write("<EMBED movie='flv_player_multi.swf' type='application/x-shockwave-flash' SRC='/academie/ows/flash/flv_player_multi.swf' PLUGINSPAGE='http:www.macromedia.com/go/getflash' WIDTH='589' HEIGHT='472' NAME='movie'>");
					document.write("</EMBED>");
					document.write("</object>");
					document.write("</div>");
           	}                               
           	else 
			{
				document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");       
				document.write("<object id='myFlash' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
				document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
				document.write("<param name='allowFullScreen' value='true'/>");	 	
				document.write("<param name='FlashVars' value='flv="+LienFlv+"&showopen=0&showprevious=0&shownext=0&autoplay=1&showstop=1&showvolume=1&showtime=1&showfullscreen=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
				document.write("</object>");
				document.write("</div>");	   
			} 
			document.getElementById("Lien_Adobe").style.display="none";              	
		}
		else
		{	
			document.write("<div id='MasqueObjet' style='margin-left:-5px;'><div>"); 
			document.getElementById("Lien_Adobe").style.display="";	
		}                                
	}
	else
	{
		document.write("<p id='Lien_Adobe' class='contact' style='font-size:12px;'>Le lecteur vid&eacute;o est indisponible car le <i><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'>Flash Player</a></i> n'est pas install&eacute; sur ce navigateur.<br><br><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'><IMG SRC='www2.academieroyale.be/academie/ows/images/get_flash_player.gif' BORDER='0'></A></p>");		       	   


        if((strChMid.indexOf("MSIE 7") != -1)|(strChMid.indexOf("MSIE 6") != -1))
		{
			   //IE
			document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");       
			document.write("<object id='myFlash' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' 	type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
			document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
			document.write("<param name='allowFullScreen' value='true'/>");	 	
			document.write("<param name='FlashVars' value='flv="+LienFlv+		"&showopen=0&showprevious=0&shownext=0&showstop=1&showvolume=1&showtime=1&showfullscreen=1&autoplay=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
			document.write("</object>");
			document.write("</div>");
		}            
		else if((strChEnd.indexOf("Firefox/3") != -1)|(strChEnd.indexOf("Firefox/2") != -1)|(strChEnd.indexOf("Firefox") != -1))
		{
                //FIREFOX
			document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");
			document.write("<object id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
			document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
			document.write("<param name='allowFullScreen' value='true'/>");	 	
			document.write("<param name='FlashVars' value='flv="+LienFlv+"&showopen=0&showprevious=0&shownext=0&showstop=1&showvolume=1&showtime=1&showfullscreen=1&autoplay=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
			document.write("<EMBED movie='flv_player_multi.swf' type='application/x-shockwave-flash' SRC='/academie/ows/flash/flv_player_multi.swf' PLUGINSPAGE='http:www.macromedia.com/go/getflash' WIDTH='589' HEIGHT='472' NAME='movie'>");
			document.write("</EMBED>");
			document.write("</object>");
			document.write("</div>");
       	}                               
       	else if((strChStart.indexOf("Opera/9") != -1)|(strChStart.indexOf("Opera/9") != -1))
		{
           		//OPERA
			document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");
			document.write("<object id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
			document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
			document.write("<param name='allowFullScreen' value='true'/>");	 	
			document.write("<param name='FlashVars' value='flv="+LienFlv+"&showopen=0&showprevious=0&shownext=0&showstop=1&showvolume=1&showtime=1&showfullscreen=1&autoplay=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
			document.write("<EMBED movie='flv_player_multi.swf' type='application/x-shockwave-flash' SRC='/academie/ows/flash/flv_player_multi.swf' PLUGINSPAGE='http:www.macromedia.com/go/getflash' WIDTH='589' HEIGHT='472' NAME='movie'>");
			document.write("</EMBED>");
			document.write("</object>");
			document.write("</div>");
		}           	     
        else
		{	
			//SAFARI
           	document.write("<div id='MasqueObjet' style='margin-left:-5px;'>");
			document.write("<object id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='589' height='472'>");
			document.write("<param name='movie' value='/academie/ows/flash/flv_player_multi.swf'/>");
			document.write("<param name='allowFullScreen' value='true'/>");	 	
			document.write("<param name='FlashVars' value='flv="+LienFlv+"&showopen=0&showprevious=0&shownext=0&showstop=1&showvolume=1&showtime=1&showfullscreen=1&autoplay=1&bgcolor1=0xE2E2E2&bgcolor2=0xE2E2E2&buffermessage=Chargement en cours ..._n_&autoload=1&listener=myListener'/>");
			document.write("<EMBED movie='flv_player_multi.swf' type='application/x-shockwave-flash' SRC='/academie/ows/flash/flv_player_multi.swf' PLUGINSPAGE='http:www.macromedia.com/go/getflash' WIDTH='589' HEIGHT='472' NAME='movie'>");
			document.write("</EMBED>");
			document.write("</object>");
			document.write("</div>");
		} 
		document.getElementById('Lien_Adobe').style.display="";	
	}       	      
		   		   		
}

 

function VerifVersionLecteurInstal(IndexVideo)
{
	var hasReqestedVersionApres = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
        if (hasReqestedVersionApres)
		{ 			     		
	    var version = GetSwfVer();
		version = Remplacer(version);
		version = RecupIndice(version);		
		version = parseInt(version); 		

		if (version > 8)
		{
		document.getElementById("Lien_Adobe").style.display="none";
                document.getElementById("myFlash").SetVariable("player:jsPlay", IndexVideo);		
		}
		else
		{
		document.getElementById("Lien_Adobe").style.display="";	
		}
			   if(document.getElementById("Lien_Adobe").style.display=="")
				{
					document.getElementById("ListeVideo").style.display="none";					
				}
				else
				{
					document.getElementById("ListeVideo").style.display="";
				}
				
				
				document.getElementById("MasqueObjet").style.display="";
		}
		else 
		{ 		
		document.getElementById("MasqueObjet").style.display="none";
		document.getElementById("Lien_Adobe").style.display=""; 
		document.getElementById("ListeVideo").style.display="none";                																					 		  		        
		}
ResizeRightDiv();

}


function ResizeRightDiv()
{

document.getElementById("sponsor_aca").style.display="";
var hauteur1=document.getElementById("leftContent").offsetHeight;
var hauteur2=document.getElementById("rightContent").offsetHeight;
var hauteur3=document.getElementById("menu_table").offsetHeight;
if (hauteur1>hauteur2)
{
	document.getElementById("rightContent").style.height=hauteur1+"px";
}
else
{
	document.getElementById("leftContent").style.height=(hauteur2-23)+"px";
	document.getElementById("myTable").style.height=(hauteur2-23)+"px";
	document.getElementById("sponsor_table").style.height=(hauteur2-23-hauteur3)+"px";
}	
}

function ResizeRightDivRCTS()
{

	document.getElementById("sponsors").style.display="";
	document.getElementById("fonctionsInferieures").style.display="";
		
	empecherChevauchement('menuSection','sponsors',20);
	empecherChevauchement('colonneDroiteSuperieure','fonctionsInferieures',0);
		
	var hauteurGauche=document.getElementById("leftContent").offsetHeight;
	var hauteurCentre=document.getElementById("rightContent").offsetHeight;
	var hauteurDroite=document.getElementById("colonneDroite").offsetHeight;

	//alert(hauteurGauche + " - " + hauteurCentre + " - " + hauteurDroite);

		
	var paddingTopGauche = parseInt(jQuery("#leftContent").css('paddingTop'));
	var paddingTopCentre = parseInt(jQuery("#rightContent").css('paddingTop'));
	var paddingTopDroite = parseInt(jQuery("#colonneDroite").css('paddingTop'));
	
	
	var hauteurMax = 0;

	if((hauteurGauche+paddingTopGauche)>hauteurMax) hauteurMax=hauteurGauche;
	if((hauteurCentre+paddingTopCentre)>hauteurMax) hauteurMax=hauteurCentre;
	if((hauteurDroite+paddingTopDroite)>hauteurMax) hauteurMax=hauteurDroite;
	
		
	document.getElementById("leftContent").style.height=(hauteurMax-paddingTopGauche)+"px";
	document.getElementById("rightContent").style.height=(hauteurMax-paddingTopCentre)+"px";
	document.getElementById("colonneDroite").style.height=(hauteurMax-paddingTopDroite)+"px";
	
	var hauteurGauche=document.getElementById("leftContent").offsetHeight;
	var hauteurCentre=document.getElementById("rightContent").offsetHeight;
	var hauteurDroite=document.getElementById("colonneDroite").offsetHeight;
	
	//alert(hauteurMax + " ----- " + hauteurGauche + " - " + hauteurCentre + " - " + hauteurDroite);
}

function ResizeRightDivArticle()
{

	document.getElementById("sponsors").style.display="";
	//document.getElementById("fonctionsInferieures").style.display="";
		
	empecherChevauchement('menuSection','sponsors',20);
	//empecherChevauchement('colonneDroiteSuperieure','fonctionsInferieures',0);
		
	var hauteurGauche=document.getElementById("leftContent").offsetHeight;
	var hauteurCentre=document.getElementById("rightContent").offsetHeight;
	//var hauteurDroite=document.getElementById("colonneDroite").offsetHeight;

	//alert(hauteurGauche + " - " + hauteurCentre + " - " + hauteurDroite);

		
	var paddingTopGauche = parseInt(jQuery("#leftContent").css('paddingTop'));
	var paddingTopCentre = parseInt(jQuery("#rightContent").css('paddingTop'));
	//var paddingTopDroite = parseInt(jQuery("#colonneDroite").css('paddingTop'));
	
	
	var hauteurMax = 0;

	if((hauteurGauche+paddingTopGauche)>hauteurMax) hauteurMax=hauteurGauche;
	if((hauteurCentre+paddingTopCentre)>hauteurMax) hauteurMax=hauteurCentre;
	//if((hauteurDroite+paddingTopDroite)>hauteurMax) hauteurMax=hauteurDroite;
	
		
	document.getElementById("leftContent").style.height=(hauteurMax-paddingTopGauche)+"px";
	document.getElementById("rightContent").style.height=(hauteurMax-paddingTopCentre)+"px";
	//document.getElementById("colonneDroite").style.height=(hauteurMax-paddingTopDroite)+"px";
	
	var hauteurGauche=document.getElementById("leftContent").offsetHeight;
	var hauteurCentre=document.getElementById("rightContent").offsetHeight;
	//var hauteurDroite=document.getElementById("colonneDroite").offsetHeight;
	
	//alert(hauteurMax + " ----- " + hauteurGauche + " - " + hauteurCentre + " - " + hauteurDroite);
}

function empecherChevauchement(elem1,elem2,ecartSupplementaire) {

	if(!ecartSupplementaire) ecartSupplementaire=0;
	var posElem1 = getPos(document.getElementById(elem1));
	var posElem2 = getPos(document.getElementById(elem2));
	
		
	if(posElem1.b > posElem2.t) {
		var elem1_paddingV = parseInt(jQuery('#'+elem1).css('paddingTop')) + parseInt(jQuery('#'+elem1).css('paddingBottom'));
		var elem2_paddingV = parseInt(jQuery('#'+elem2).css('paddingTop')) + parseInt(jQuery('#'+elem2).css('paddingBottom'));
		var newMargin = (parseInt(jQuery('#'+elem1).css('marginBottom'))+ (posElem1.b-posElem2.t)+elem1_paddingV+elem2_paddingV+ecartSupplementaire)  + "px";
		jQuery('#'+elem1).css('marginBottom',newMargin);
	}
		
}

function ResizeRightDivAudio()
{

document.getElementById("sponsor_aca").style.display="";
var hauteur1=document.getElementById("leftContent").offsetHeight;
var hauteur2=document.getElementById("rightContent").offsetHeight;
var hauteur3=document.getElementById("menu_table").offsetHeight;

document.getElementById("leftContent").style.height=(hauteur2+400-23)+"px";
document.getElementById("myTable").style.height=(hauteur2+400-23)+"px";
document.getElementById("sponsor_table").style.height=(hauteur2+400-23-hauteur3)+"px";
}

function InsertFlashForAudioFile()
{
	var strChUserAgent = navigator.userAgent;
    var intSplitStart = strChUserAgent.indexOf("(",0);
    var intSplitEnd = strChUserAgent.indexOf(")",0);
    var strChStart = strChUserAgent.substring(0,intSplitStart);
    var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
    var strChEnd = strChUserAgent.substring(strChEnd); 
	
	var hasReqestedVersionAvant = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);		
	
	if (hasReqestedVersionAvant) 
	{             
		var version = GetSwfVer();
		version = Remplacer(version);
		version = RecupIndice(version);		
		version = parseInt(version); 
		
		if (version < 9){  		               																					 		  		        
		document.write("<p id='Lien_Adobe' class='contact' style='font-size:12px;'>Le lecteur mp3 est indisponible car le <i><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'>Flash Player</a></i> est inf&eacute;rieur &agrave; la version 9 requise.<br><br><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'><IMG SRC='www2.academieroyale.be/academie/ows/images/get_flash_player.gif' BORDER='0'></A></p>");               																					 		  		        
		}  
		else
		{
		if((strChMid.indexOf("MSIE 7") != -1)|(strChMid.indexOf("MSIE 6") != -1))
			{
			//IE   
			document.write("<object class='playerpreview' id='myFlash' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' type='application/x-shockwave-flash' data='/academie/ows/flash/flv_player_multi.swf' width='1' height='1'>");
			document.write("<param name='movie' value='/academie/ows/flash/player_mp3.swf' />");
			document.write("<param name='AllowScriptAccess' value='always' />");
			document.write("<param name='FlashVars' value='listener=myListener&amp;interval=500' />");
			document.write("</object>")	
           }            
           else if((strChEnd.indexOf("Firefox/3") != -1)|(strChEnd.indexOf("Firefox/2") != -1)|(strChEnd.indexOf("Firefox") != -1))
				{
				//FIREFOX
				document.write("<object class='playerpreview' id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/player_mp3.swf' width='1' height='1'>");
				document.write("<param name='movie' value='/academie/ows/flash/player_mp3.swf' />");
				document.write("<param name='AllowScriptAccess' value='always' />");
				document.write("<param name='FlashVars' value='listener=myListener&amp;interval=500' />");
				document.write("</object>")	
				}                               
				else if((strChStart.indexOf("Opera/9") != -1)|(strChStart.indexOf("Opera/9") != -1))
					{
					//OPERA
					document.write("<object class='playerpreview' id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/player_mp3.swf' width='1' height='1'>");
					document.write("<param name='movie' value='/academie/ows/flash/player_mp3.swf' />");
					document.write("<param name='AllowScriptAccess' value='always' />");
					document.write("<param name='FlashVars' value='listener=myListener&amp;interval=500' />");
					document.write("</object>")	
					}           	     
					else
						{	
						//SAFARI
						document.write("<object class='playerpreview' id='myFlash' type='application/x-shockwave-flash' data='/academie/ows/flash/player_mp3.swf' width='1' height='1'>");
						document.write("<param name='movie' value='/academie/ows/flash/player_mp3.swf' />");
						document.write("<param name='AllowScriptAccess' value='always' />");
						document.write("<param name='FlashVars' value='listener=myListener&amp;interval=500' />");
						document.write("</object>")	
					} 	
		}
	}
	else
	{
	document.write("<p id='Lien_Adobe' class='contact' style='font-size:12px;'>Le lecteur mp3 est indisponible car le <i><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'>Flash Player</a></i> n'est pas install&eacute; sur ce navigateur.<br><br><A onclick='window.open(this.href);return false' HREF='http://www.macromedia.com/go/getflashplayer'><IMG SRC='www2.academieroyale.be/academie/ows/images/get_flash_player.gif' BORDER='0'></A></p>");		       	   
	}	
}

function InitFlashForAudioFile(_index)
{
	myListener.index = _index;
	myListener.position = 0;

	if(autoPlay == true){
		read(_index);
	}
	
	setVolume();
}

function CheckFlashForAudioFile()
{
	var hasReqestedVersionApres = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
			
    if (hasReqestedVersionApres)
		{ 			     		
	    var version = GetSwfVer();
		version = Remplacer(version);
		version = RecupIndice(version);		
		version = parseInt(version); 		
		
		if (version > 8)
			{

			if(document.getElementById("Lien_Adobe") != null){
					document.getElementById("Lien_Adobe").style.display="none"; 																					 		  		        
				}
			document.getElementById("ListeAudio").style.display=""; 
			document.getElementById("lecteurMP3").style.display="";                																					 		  		        			
			}
		else
			{
			if(document.getElementById("Lien_Adobe") != null){
				document.getElementById("Lien_Adobe").style.display="";
				}			
			document.getElementById("lecteurMP3").style.display="none";                																					 		  		        
			document.getElementById("ListeAudio").style.display="none";                																					 		  		        
			}
		}
	else 
	{ 	
		if( document.getElementById("Lien_Adobe") != null){
			document.getElementById("Lien_Adobe").style.display="";
		};
		document.getElementById("lecteurMP3").style.display="none";  	
		document.getElementById("ListeAudio").style.display="none"; 		
	}
ResizeRightDivAudio();
}

function AllerSurChamp(champ)
{
	document.getElementById(champ).focus();
}

function RendreObjetEditable(typeObj,condition,option,valeur,resultat,idObj,actionSP)
{	
	switch(typeObj)
		{
		case 'select':		
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':		
			
			break;						
			case '!=':		
			if(option!=valeur){document.getElementById(idObj).disabled=false;}				
			break;		
			}														
		break;		
		}		
}

function RendreObjetNonEditable(typeObj,condition,option,valeur,resultat,idObj,actionSP)
{	
	switch(typeObj)
		{
		case 'select':		
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':		
			if(option==valeur){document.getElementById(idObj).disabled=true;}				
			break;						
			case '!=':		
			break;		
			}														
		break;		
		}	
		
}

function RendreObjetEgale(typeObj,condition,option,valeur,resultat,idObj,actionSP)
{	
	switch(typeObj)
		{
		case 'select':		
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':		
			if(option==valeur){					
			for(var i = 0; i < document.getElementById(idObj).length; i++) 
				{     
				if(document.getElementById(idObj).options[i].text==resultat)
					{
					document.getElementById(idObj).selectedIndex=i;  
					i=document.getElementById(idObj).length									
					}										       								                                      
				} 		 
			}				
			break;						
			case '!=':		
			break;		
			}														
		break;		
		}	
		
}

function RendreObjetVisible(typeObj,condition,option,valeur,resultat,idObj,actionSP)
{		
		switch(typeObj)
		{
		case 'select':		
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':		
			if(option==valeur){
			document.getElementById(idObj).style.display='';				
			}
			break;						
			case '!=':		
			break;		
			}
		case 'radio':	
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':	
			option=option.substring(option.lastIndexOf("-", option.length)+1, option.length);				
			if(option==valeur){
			document.getElementById(idObj).style.display='';
			}	
			break;						
			case '!=':
		
			break;		
			}
		break;		
		}
		
}

function RendreObjetInvisible(typeObj,condition,option,valeur,resultat,idObj,actionSP)
{	
	var idInput=idObj.substring(4, idObj.length);
	switch(typeObj)
		{
		case 'select':		
		switch(condition)
			{
			case 'remplie':		
			
			break;		
			
			case 'vide':		
			
			break;						
			case '==':	
			if(option==valeur){	
			document.getElementById(idInput).value='';
			document.getElementById(idObj).style.display='none';			
			}						
			break;						
			case '!=':
			if(option!=valeur){
			document.getElementById(idInput).value='';
			document.getElementById(idObj).style.display='none';			
			}			
			break;		
			}	
		break;
		case 'radio':	
		switch(condition)
			{
			case 'remplie':		
			
			break;					
			case 'vide':		
			
			break;						
			case '==':
			if(actionSP==''){option=option.substring(option.lastIndexOf("-", option.length)+1, option.length);}
			if(option==valeur){	
			document.getElementById(idObj).style.display='none';
	            if(document.getElementById(idInput).type=='select-one')
				{ document.getElementById(idInput).selectedIndex=0;}
				else{
				document.getElementById(idInput).value='';}
				}		
			else{}	
			break;						
			case '!=':
		
			break;		
			}	
		break;		
		}
}

/*
'0' : Etat initial - Ne pas créer de fiches [FD_ValeurReponse]
'1' : Etat d'ajout - Créer les fiches [FD_ValeurReponse]
'2' : Etat de modification - Modifier les fiches [FD_ValeurReponse]
'3' : Etat de suppression - Supprimer les fiches [FD_ValeurReponse]
*/

function CreationLigne(ItemObj,Message)
{

var Obj = ItemObj.split("$$$");
var ObjBool = false;

	for(i=0;i<Obj.length-1;i++)
		{	
			
			if(document.getElementById(Obj[i]).style.display=='none')
			{				
				switch (document.getElementById('SL'+Obj[i]).value)
				{
				case '0': //Ne pas tenir en compte l'élément de la sous-liste 
				document.getElementById('SL'+Obj[i]).value='1'
				break;
				case '3': //Supprimer l'élément de la sous-liste 
				document.getElementById('SL'+Obj[i]).value='2'
				break;
				}
				document.getElementById(Obj[i]).style.display='';
				i=Obj.length-1;	
				ObjBool=true;	
			}			
		}	
	
	if(ObjBool==false)
	{
		alert(Message);
	}
	
}

function SuppressionLigne(ItemObj)
{
	document.getElementById(ItemObj).style.display='none';	
	
	switch (document.getElementById('SL'+ItemObj).value)
			{
				case '1': //Ne pas tenir en compte l'élément de la sous-liste 
				document.getElementById('SL'+ItemObj).value='0'
				break;
				case '2': //Supprimer l'élément de la sous-liste 
				document.getElementById('SL'+ItemObj).value='3'
				break;
			}
}

function ValiderForm()
{
	var arg = ValiderForm.arguments;
	document.form_inscription.owHrefP1.value = arg[0] ;
	document.form_inscription.owHrefP2.value = arg[1] ;
	document.form_inscription.owHrefP3.value = arg[2] ;
	document.form_inscription.owHrefP4.value = arg[3] ;
	document.form_inscription.owHrefP5.value = arg[4] ;
	document.form_inscription.owHrefP6.value = arg[5] ;
	document.form_inscription.owHrefP7.value = arg[6] ;
	document.form_inscription.submit();
	document.clear() ;	
	document.close() ;	
}

function CanChoixModal(value){
	switch (value)
			{
				case 'radio-ci': 
				document.getElementById("btn_inscription_ci").style.display="";	
				document.getElementById("btn_inscription_cc").style.display="none";	
				document.getElementById("radio-cc").checked=false;
				break;
				case 'radio-cc':
				document.getElementById("btn_inscription_cc").style.display="";	
				document.getElementById("btn_inscription_ci").style.display="none";	
				document.getElementById("radio-ci").checked=false;
				break;
			}

}

function SubmitNewsletter(tableNo){

	ValiderForm('Bvalclic',tableNo,'','','','','');
	alert('Votre demande sera trait\351e dans les plus brefs d\351lais.');

}


function manageOverflow() {

	var nav=navigator.appName;

	jQuery(".overflowNewContainer").each( function () {
		var child = jQuery(this).children(".overflowElement");
		var h = jQuery(this).css('height');
		this.style.height='auto';
		/*if (nav=='Microsoft Internet Explorer') var height=this.offsetHeight;
		else */
		var height=this.offsetHeight-parseInt(jQuery(this).css('paddingTop')) - parseInt(jQuery(this).css('paddingBottom'));
		this.style.height=h;
		var heightmax=parseInt(h);
		if (height>heightmax) {
			var tmin=""; // texte min
			var tmax=child.html(); // texte max
			var tmean=tmax.substr(0,Math.floor((tmax.length+tmin.length)/2)); // texte milieu
			while (tmin!=tmean) {
				var t=child.html();
				child.text(tmean+'...'); // on tente de mettre le texte milieu
				this.style.height='auto';
				/*if (nav=='Microsoft Internet Explorer') var height=this.offsetHeight;
				else*/
				var height=this.offsetHeight-parseInt(jQuery(this).css('paddingTop')) - parseInt(jQuery(this).css('paddingBottom'));
				
				//alert('height: '+height + ' - heightmax: ' + heightmax);
				
				this.style.height=h;
				if (height>heightmax) tmax=tmean; // c'est encore trop grand, le texte max devient le texte milieu
				else tmin=tmean; // c'est trop petit, le texte min devient le texte milieu
				tmean=tmax.substr(0,Math.floor((tmax.length+tmin.length)/2)); // on recalcule le texte milieu
			}
			// on a atteint un point fixe, on a trouv? la bonne taille du texte
			if (tmean!='') child.text(tmean+'...');
			else child.text(tmean);
		}
	});
}


jQuery(document).ready(function() {
	
	Custom.init();
	manageOverflow();	
	//article_positionnerImages();
});

/* Positionne les images dans le texte des articles en les centrant verticalement */
function article_positionnerImages() {
	jQuery(".imgageDansTexte").each( function () {
		var elem = jQuery(this)
		var height = elem.attr("height");
		
		elem.css('margin-top', height + "px");
	});
	
}

/* Fonction d'ajout de champ dans la recherche globale */
var cptLigneRechercheGlobale = 0;

function RechercheGlobaleAjoutLigne(lienSubmit) { 
	cptLigneRechercheGlobale++;
	var inputText = "";
	
	var valeurChamp = "";
	if(langueInterface == 'fr')
		valeurBouton = "Entrez un mot";
	else
		valeurBouton = "Enter a word";
		
	var parent = document.getElementById('lignesRechercheGlobale');
	var elem = document.createElement('div');
	elem.id = 'ligneRecherche'+cptLigneRechercheGlobale;
	elem.className = 'ligneRecherche';
	
	inputText +="<input type='text' name='recherche_glob"+cptLigneRechercheGlobale+"' value='"+valeurBouton+"' class='searchInput' onFocus=\"if(this.value=='"+valeurBouton+"')this.value='';\" onkeypress=\"if(event.keyCode==13){"+lienSubmit+";return false;}\"/>"
	//inputText += "<input type='text' class='rechercheGlobale' value='Entrez un mot' name='ligneRechercheGlobale"+cptLigneRechercheGlobale+"' />";
	
	elem.innerHTML = inputText;
	parent.appendChild(elem);
	document.getElementById('lignesRechercheGlobaleCompteur').value=cptLigneRechercheGlobale;
	
} 

function RechercheGlobaleSupprLigne(num) {
	var parent = document.getElementById('lignesRechercheGlobale');
	var child = document.getElementById('ligneRecherche'+num);
	
	parent.removeChild(child);

}
function ArticlesRech(RechOption)
{

		document.getElementById('colonneDroite').style.height = 'auto';
		switch(RechOption)
			{
			case 'S':
			document.getElementById('rechercheSimpleArticleLien').style.display='';	
			document.getElementById('rechercheAvanceeArticleLien').style.display='none';		
			document.getElementById('recherche_simple').style.display='';
			document.getElementById('recherche_avancee').style.display='none';			
			document.getElementById('modeRecherche_id').value='simple';
			break;		
			case 'A':		
			document.getElementById('rechercheSimpleArticleLien').style.display='none';	
			document.getElementById('rechercheAvanceeArticleLien').style.display='';	
			document.getElementById('recherche_simple').style.display='none';
			document.getElementById('recherche_avancee').style.display='';
			document.getElementById('modeRecherche_id').value='avance';
			break;							
			}
}

var getPos = function (elem) {
    var pos={'r':0,'l':0,'t':0,'b':0};
    var tmp=elem;
 
    do {
        pos.l += tmp.offsetLeft;
        tmp = tmp.offsetParent;
    } while( tmp !== null );
    pos.r = pos.l + elem.offsetWidth;
 
    tmp=elem;
    do {
        pos.t += tmp.offsetTop;
        tmp = tmp.offsetParent;
    } while( tmp !== null );
    pos.b = pos.t + elem.offsetHeight;
 
    return pos;
};

function afficherMasquer(objet,afficher,creerCookie) {
	
	switch(objet) {
		case 'auteur' :
			jQuery('.auteurs').each(function() {
				if(afficher)
					jQuery(this).css('display','');
				else
					jQuery(this).css('display','none');
			});
			break;
			
		case 'reference' :
			jQuery('.numero').each(function() {
				if(afficher)
					jQuery(this).css('display','');
				else
					jQuery(this).css('display','none');
			});
			break;
			
		case 'date' :
			jQuery('.date').each(function() {
				if(afficher)
					jQuery(this).css('display','');
				else
					jQuery(this).css('display','none');
			});
			break;
			
		case 'discipline' :
			jQuery('.categories').each(function() {
				if(afficher)
					jQuery(this).css('display','');
				else
					jQuery(this).css('display','none');
			});
			break;
			
		
	}
	
	// Enregistrer le cookie
	if(creerCookie)
		document.cookie = "listeArticle_" + objet + "=" + afficher + ";expires=01/01/2020 00:00:00";
	
}

function changeType(obj,type)
{
	if(type == "normal")
		document.getElementById("passwordBox").innerHTML = "<input type=\"text\" name=\"fake\" onKeyPress=\"javascript:return EnterSubmit(event);\" value=\"Mot de passe\" onFocus=\"javascript:changeType(this,'password');\"/>";
	else {
		document.getElementById("passwordBox").innerHTML = "<input id=\"passwordInput\" type=\"password\" name=\"motdepasse\" onKeyPress=\"javascript:return EnterSubmit(event);\" value=\"\" onBlur=\"if(this.value==''){changeType(this,'normal');}\"/>";
		setTimeout("document.getElementById('passwordInput').focus();", 10);
	}
}

function largeur_fenetre()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.documentElement.clientWidth) return document.documentElement.clientWidth;
 else return 0;
}

function hauteur_fenetre()
{
 if (window.innerHeight) return window.innerHeight  ;
 else if (document.documentElement.clientHeight) return document.documentElement.clientHeight;
 else return 0;
}

var xcoord="";
var ycoord="";
function GetId(id)
{
return document.getElementById(id);
}
var ibulle=false; // La variable i nous dit si la bulle est visible ou non

function move(e) {
	   // Si la bulle est visible, on calcul en temps reel sa position ideale
	var posx=0;var posy=0;
   if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
		xcoord=e.pageX + 20+"px";
		ycoord=e.pageY + 10+"px";
	}
	else { // Modif proposear TeDeum, merci ?ui
		if(document.documentElement.clientWidth>0 && false) {
			xcoord=20+event.x+document.documentElement.scrollLeft+"px";
			ycoord=10+event.y+document.documentElement.scrollTop+"px";
			
		}
		else {
			xcoord=20+event.x+document.body.scrollLeft+"px";
			ycoord=10+event.y+document.body.scrollTop+"px";
		}
	}
	
}

function calculeOffsetLeft(r){
	var n=calculeOffset(r,"offsetLeft");
	return n;
}
function calculeOffsetTop(r){
	var n=calculeOffset(r,"offsetTop");
	return n;
}
function calculeOffset(element,attr){
  var offset=0;
  while(element){
    offset+=element[attr];
    element=element.offsetParent
  }
  return offset
}

function montre(text) {
	  if(ibulle==false) {
	  
	  GetId("curseur").innerHTML = text; // Cette fonction est a am?orer, il parait qu'elle n'est pas valide (mais elle marche)
	  ibulle=true;
	  
	  GetId("curseur").style.left=xcoord;
	  GetId("curseur").style.top=ycoord;
	  
	  
	  jQuery("#curseur").fadeTo('fast',1,function(){});
	}
}
function cache() {
	if(ibulle==true) {
	jQuery("#curseur").fadeTo('fast',0,function(){GetId("curseur").innerHTML = "";GetId("curseur").style.left=0;GetId("curseur").style.top=0;});
	ibulle=false;
	}
}
document.onmousemove=move; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.

// ************************
//  Formulaire Contributeur
// ************************
var cptLigneDiplome = 0;

function Contributeur_DiplomeAjoutLigne() { 

	var valeurBouton = "";
	if(langueInterface == 'fr') {
		valeurBouton = "Supprimer ce dipl\364me";
		libelleInstitution = "Institution";
		libelleTitre = "Titre";
		libelleAnnee = "Ann\351e";
	}
	else {
		valeurBouton = "Delete this diploma";
		libelleInstitution = "Institution";
		libelleTitre = "Title";
		libelleAnnee = "Year";
	}
	
	cptLigneDiplome++;
	var inputText = "";
	
	var parent = document.getElementById('lignesDiplomes');
	var elem = document.createElement('div');
	elem.id = 'ligneDiplome'+cptLigneDiplome;
	elem.className = 'ligneDiplome';
	
	inputText +="<label class='centre'>"+libelleInstitution+"</label><textarea class='required' name='contributeur_diplome_institution"+cptLigneDiplome+"'></textarea><br/>";
	inputText +="<label class='centre'>"+libelleTitre+"</label><textarea class='required' name='contributeur_diplome_titre"+cptLigneDiplome+"'></textarea><br/>";
	inputText +="<label>"+libelleAnnee+"</label><input type='text' class='required' name='contributeur_diplome_annee"+cptLigneDiplome+"' value='' />";
	inputText +="<div class='clear'></div>";
	inputText +="<input type='button' onclick='Contributeur_DiplomeSupprLigne("+cptLigneDiplome+")' value='"+valeurBouton+"' class='boutonSupprimer' />";
	inputText +="<div class='clear'></div>";
	//inputText +="<div style='height: 5px;'></div>";
	
	elem.innerHTML = inputText;
	parent.appendChild(elem);
	document.getElementById('lignesDiplomesCompteur').value=cptLigneDiplome;
	
	document.getElementById('rightContent').style.height = 'auto';
	ResizeRightDivRCTS();
}

function Contributeur_DiplomeSupprLigne(num) {
	var parent = document.getElementById('lignesDiplomes');
	var child = document.getElementById('ligneDiplome'+num);
	
	parent.removeChild(child);

	ResizeRightDivRCTS();
}


var cptLigneTelecom = 0;

function Contributeur_TelecomAjoutLigne() { 
	cptLigneTelecom++;
	var inputText = "";
	
	var valeurBouton = "";
	if(langueInterface == 'fr') {
		valeurBouton = "Supprimer ce t\351l\351com";
		libelleGenre = "Genre";
		libelleNumero = "Num\351ro / Adresse";
		libelleNote = "Note";
		libellePublication = "Publication autoris\351e";
		libelleOui = "Oui";
		libelleNon = "Non";
	}
	else {
		valeurBouton = "Delete this telecom";
		libelleGenre = "Type";
		libelleNumero = "Number / Address";
		libelleNote = "Note";
		libellePublication = "Authorised publication";
		libelleOui = "Yes";
		libelleNon = "No";
	}
		
	var parent = document.getElementById('lignesTelecoms');
	var elem = document.createElement('div');
	elem.id = 'ligneTelecom'+cptLigneTelecom;
	elem.className = 'ligneTelecom';
	
	inputText +="<label>"+libelleGenre+"</label><select class='styled validate-selection' id='selectGenre_"+cptLigneTelecom+"' name='contributeur_telecom_genre"+cptLigneTelecom+"'/>"+selectGenres+"</select><br/>";
	inputText +="<span class='selectMarginBottom'></span>";
	inputText +="<label>"+libelleNumero+"</label><input type='text' class='required' name='contributeur_telecom_numero"+cptLigneTelecom+"' value='' /><br/>";
	inputText +="<label>"+libelleNote+"</label><input type='text' name='contributeur_telecom_note"+cptLigneTelecom+"' value='' /><br/>";
	inputText +="<label>"+libellePublication+"</label><div class='groupeRadio'><input type='radio' name='Tel_Publication_"+cptLigneTelecom+"' value='oui' checked='checked' id='Tel_PublicationOui_"+cptLigneTelecom+"' /><label for='Tel_PublicationOui_"+cptLigneTelecom+"' class='radioLabel'>"+libelleOui+"</label>";
	inputText +="<input type='radio' name='Tel_Publication_"+cptLigneTelecom+"' value='non' id='Tel_PublicationNon_"+cptLigneTelecom+"' /><label for='Tel_PublicationNon_"+cptLigneTelecom+"' class='radioLabel'>"+libelleNon+"</label></div>";
	inputText +="<div class='clear'></div>";
	inputText +="<div style='height: 5px;'></div>";

	inputText +="<input type='button' onclick='Contributeur_TelecomSupprLigne("+cptLigneTelecom+")' value='"+valeurBouton+"' class='boutonSupprimer' />";
	inputText +="<div class='clear'></div>";
	//inputText +="<div style='height: 5px;'></div>";
	
	elem.innerHTML = inputText;
	parent.appendChild(elem);
	document.getElementById('lignesTelecomsCompteur').value=cptLigneTelecom;
	
	document.getElementById('rightContent').style.height = 'auto';
	ResizeRightDivRCTS();
	Custom.init("selectGenre_"+cptLigneTelecom);
} 

function Contributeur_TelecomSupprLigne(num) {
	var parent = document.getElementById('lignesTelecoms');
	var child = document.getElementById('ligneTelecom'+num);
	
	parent.removeChild(child);

	ResizeRightDivRCTS();
}

function RechGlobale(RechOption)
{

		document.getElementById('colonneDroite').style.height = 'auto';
		switch(RechOption)
			{
			case 'S':
			document.getElementById('rechercheSimpleGlobaleLien').style.display='';	
			document.getElementById('rechercheAvanceeGlobaleLien').style.display='none';		
			document.getElementById('recherche_simple_glob').style.display='';
			document.getElementById('recherche_avancee_glob').style.display='none';			
			document.getElementById('modeRechercheGlob_id').value='simple';
			break;		
			case 'A':		
			document.getElementById('rechercheSimpleGlobaleLien').style.display='none';	
			document.getElementById('rechercheAvanceeGlobaleLien').style.display='';	
			document.getElementById('recherche_simple_glob').style.display='none';
			document.getElementById('recherche_avancee_glob').style.display='';
			document.getElementById('modeRechercheGlob_id').value='avance';
			break;							
			}
}

function sendPassword()
{
	var url = "";
	var d = new Date();
		
	document.getElementById("erreur").innerHTML = "&nbsp;";
	if(document.getElementById("pwdlost_email").value != "")
	{
		url='/makeyourtime/academie/motdepasseperdu/' + document.getElementById('pwdlost_email').value + '/' +d.getTime();
		makeyourtime(url);
	}
	else
	{
		document.getElementById("erreur").innerHTML = "Veuillez entrer votre nom d'utilisateur";
		document.getElementById("erreur").style.display = "";
		document.getElementById("pwdlost_email").focus();
	}
}

//  Place les images des paragraphes à la hauteur de ces paragraphes si possible
function PlacerImagesParagraphes() {


return ;

	var i = 0;
	
	// Pour chaque image dans le tableau, vérifier si elle se trouve au dessus du paragraphe. Si elle s'y trouve, la descendre
	for(i = 0; i < tabImages.length; i++) {
		var idBloc = tabImages[i];
		
		// Récupérer le paragraphe à côté duquel il devrait se trouver
		var tab = idBloc.split(new RegExp("[_]"));
		var idParagraphe = tab[3];
		
		// Chercher la position du paragraphe et du bloc image
		var positionParagraphe = getPos(document.getElementById('paragraphe_'+idParagraphe));
		var positionImage = getPos(document.getElementById(idBloc));

		// Si le bloc image est au dessus du paragraphe, calculer la différence le placer à côté du paragraphe
		var difference = positionParagraphe.t - positionImage.t;
		if(difference > 0) {
			var newMargin = parseInt(jQuery('#'+idBloc).css('marginTop')) + difference + "px";
			jQuery('#'+idBloc).css('marginTop',newMargin);
		}
	}

}

function ajusterFondBanniere() {
	// récupérer la largeur du div affichant le fond
	var elem = document.getElementById("background_header_left")
	var positionDiv = getPos(elem);
	var largeurAGauche = positionDiv.r - 298;
	
	var mod = largeurAGauche % 3;
	
	switch (mod) {
	
		case 0 : jQuery(elem).css("background-position","1px 0");
		break;
		
		case 1 : jQuery(elem).css("background-position","2px 0");
		break;
		
		case 2 : jQuery(elem).css("background-position","3px 0");
		break;
		
	}
}

function getSelectValue(selectId)
{
	/**On récupère l'élement html <select>*/
	var selectElmt = document.getElementById(selectId);
	/**
	selectElmt.options correspond au tableau des balises <option> du select
	selectElmt.selectedIndex correspond à l'index du tableau options qui est actuellement sélectionné
	*/
	return selectElmt.options[selectElmt.selectedIndex].value;
}

function getSelectText(selectId)
{
	/**On récupère l'élement html <select>*/
	var selectElmt = document.getElementById(selectId);
	/**
	selectElmt.options correspond au tableau des balises <option> du select
	selectElmt.selectedIndex correspond à l'index du tableau options qui est actuellement sélectionné
	*/
	return selectElmt.options[selectElmt.selectedIndex].text;
}


function contributeurMajChamps() {

	var nomTitre = getSelectText("nomTitre");
	var nomPrenom = GetId("nomPrenom").value;
	var nomNom = GetId("nomNom").value;
	
	/*
	alert(nomTitre);
	alert(nomPrenom);
	alert(nomNom);
	*/
	
	if(nomTitre != "" && nomPrenom != "" && nomNom != "" && GetId("adresseProf_Nom").value=="") {
		GetId("adresseProf_Nom").value = nomTitre + " " + nomPrenom + " " + nomNom;
	}
	
	if(nomTitre != "" && nomPrenom != "" && nomNom != "" && GetId("adressePriv_Nom").value=="") {
		GetId("adressePriv_Nom").value = nomTitre + " " + nomPrenom + " " + nomNom;
	}
	
	var profession_organisation = GetId("professionOrganisation").value;
	var profession_fonction = GetId("professionFonction").value;
	
	if(profession_organisation != "" && GetId("adresseProf_Organisation").value == "") {
		GetId("adresseProf_Organisation").value = profession_organisation;
	}

	if(profession_fonction != "" && GetId("adresseProf_Fonction").value == "") {
		GetId("adresseProf_Fonction").value = profession_fonction;
	}

}

function customForm_Select_Choose(select) {
	document.getElementById("select" + select.name).childNodes[0].nodeValue = select.options[select.selectedIndex].childNodes[0].nodeValue;
}

function addFeedCount(flux_no,urlCible) {
	
	// Incrémente le compteur du flux
	var url = "";
	var d = new Date();
	
	url='/makeyourtime/ws/compteurFlux/' + flux_no + '/' + d.getTime();
		
	makeyourtime(url);
	
	// ouvre une nouvelle fenêtre avec le flux à télécharger
	external=window.open(urlCible,'external');
	//external.focus();
}
