function MM_preloadImages() { //v3.0
  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(quelBt) { //v3.0
	//Ajout pour ne pas que le bouton "ON" d'un section dans laquelle on se trouve, ne s'eteigne pas
	if (document.title.indexOf(quelBt) == -1) {
		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() { //v3.0
  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_openBrWindow(theURL,winName,features) { //v2.0
  //window.open(theURL,winName,features);
  var newWin = window.open(theURL,winName,features);
  newWin.focus();
}

//Utiliser pour faire des popup d'images agrandi (_popimage.html)
function popImage(theURL,largeur,hauteur) {
  if (!largeur) {
  	features = 'status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=750,height=550';
  } else {
  	features = 'status=yes,menubar=yes,resizable=yes,scrollbars=yes,width=' + largeur + ', height=' + hauteur + '';
  }
  window.open(theURL,'pop', features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  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; }
}


//Switch de langue

function switchLang(oldLang,newLang) {
	var newUrl;
	var oldUrl;

	oldLang='/' + oldLang + '/';
	newLang='/' + newLang + '/';
	oldUrl=document.location.href;
	newUrl=oldUrl.replace(oldLang,newLang);
	
	xhr = getXhr()
	xhr.open("HEAD", newUrl,true);
 	xhr.onreadystatechange=function() {
  		if (xhr.readyState==4) {
   			if (xhr.status==200) {
   				window.location.href=newUrl;
    		} else if (xhr.status==404) {
    			if (oldLang == "/fr/") {
    				alert("This page doesn't exist in french");
				} else {
					alert("Cette page n'existe pas en anglais");
				}
    		}
  		}
 	}
 xhr.send(null)
}
//Creer l'objet XMLHttpRequest
function getXhr(){
 	var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
	xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
	try {
	xhr = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	}
	else { // XMLHttpRequest non supportˇ par le navigateur 
	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	xhr = false; } 
 	return xhr
}




// Cookies - From http://www.quirksmode.org/js/cookies.html

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function alertIE6() {
	var x = readCookie('ie6alert');
	if (!x) {
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
  			createCookie("ie6alert","oui",365);
     		alert("Vous utilisez la version 6 de Internet Explorer. Vous devriez mettre \xE0 jour Internet Explorer pour utiliser toutes les nouvelles fonctionnalit\xE9s disponible sur internet.");
		}
	}
}

// Ouvrir un pop-up fullscreen
function popup(url) {
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url,'windowname4', params);
 if (window.focus) {newwin.focus()}
 return false;
}

//<a href="javascript: void(0)" onclick="popup('popup.html')">Fullscreen popup window</a>


// Pour afficher le Haut de page automatiquement - necessite jQuery
function showHautdepage() {
	hautdepageExist = $("*").index( $('div.hautdepage')[0] )
	if (hautdepageExist != -1) {
		var offset = $('div.hautdepage').offset();
		if (offset.top < "850") {
			$('div.hautdepage').css("display", "none");
		} else {
			return false;
		}
	}
}

//Au chargement
jQuery( function() { 
	showHautdepage();


	//Pour prevenir un right-click sur une image
	$('img').bind('contextmenu',function(e){
   		alert('Cette photo ne peut \xEAtre t\xE9l\xE9charg\xE9e.')
   		return false;
	});
	
	alertIE6();
} );