/* Javascript commun à tout le site
*/


/***Anti-frame****************************************************************************/
if (top.location != location) top.location.href = location.href; //se libère des frames


/***Netscape 4****************************************************************************/
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);


/***Rollover Internet Exploiter***********************************************************/
// Rollover IE 
// http://msdn.microsoft.com/library/en-us/dndude/html/dude010598.asp
// modifié par Walter Wlodarski (Orbite fauve)
//
// syntaxe : <img src="Img1.gif" rollsrc="Img1over.gif" alt="">
//
function RollOver() {
  var e, temp;

  e = window.event.srcElement; 
  
  if (e.rollsrc == null)
     return;

  temp = e.src; 
  e.src = e.rollsrc;  
  e.rollsrc = temp;
  
}

document.onmouseover = RollOver; //remplace la fonction onmouseover

document.onmouseout = RollOver; //remplace la fonction onmouseout

/***Redirection avec chronomètre**********************************************************/
// Redirection automatique
//
//	Exemple
//  		<script language="JavaScript" type="text/javascript">
//  		<!--
//			var delai=78
//  			var Url_redirection="destination.html"
//			var destination = "ici même"
//  		-->
//  		</script>

var delai
var Url_redirection
var destination
var mes
var heure_de_depart
var Secondes_approx
var Secondes=0
var decompte_en_seconde=0


function redirection_init()
{
	heure_de_depart=new Date().getTime()
	if (delai) { Redirection_auto() }
}

function Redirection_auto()
{

	Secondes_approx= new Date().getTime()

	decompte_en_seconde=(Secondes_approx - heure_de_depart)/1000

	Secondes=Math.round(delai-decompte_en_seconde)

	if (decompte_en_seconde <= delai)
	{
		var timer=setTimeout("Redirection_auto()",1000)
		if (destination > "" ) {mes=destination} else {mes = "« "+Url_redirection+" »"}
		window.status="Redirection automatique vers " + mes + " dans " + Secondes + " s"
	}
	else
	{
		window.location.href=Url_redirection
	}
}

window.onload=redirection_init

// Selection de l'apparence
//
// Copyright (c) 2001, 2002 Darren Brierton
// www.dzr-web.com/copyright.php
// This is loosely based on A List Apart's excellent styleswitcher.js
// see http://www.alistapart.com/stories/alternate/

var SS = document.styleSheets;

function setActiveStyleSheet(style_name) {
  for ( var i = 0; i < SS.length; i++ ) {
    if ( SS[i].title ) {
      SS[i].disabled = true;
      if ( SS[i].title == style_name ) {
        SS[i].disabled = false;
        createCookie("style", style_name, 365);
      }
    }
  }
}

function changeStyleSheet() {
  var style_names = document.styleswitcher.stylename;
  for ( var i = 0; i < style_names.length; i++ ) {
    if ( style_names[i].checked == true ) {
      style_name = style_names[i].value;
      setActiveStyleSheet(style_name);
    }
  }
}

function writeStyleSwitcher() {
  document.writeln('<table width=\"100%\" class=\"menu\" cellspacing=0 cellpadding=3>');
  if (navigator.userAgent.indexOf('MSIE')!=-1) {
  	document.writeln('<tr><td class=\"ttmenu\" style=\"filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=\'#00000000\', EndColorStr=\'#30000000\');\">Apparence<\/td><\/tr>');
  	}
  else {
  	document.writeln('<tr><td class=\"ttmenu\">Apparence<\/td><\/tr>');
  }  document.writeln('<tr><td><p class=\"mini\">Si la palette de couleurs du site ne vous convient pas, vous pouvez en choisir une autre:<br>');
  document.writeln('<form action=\"null\" name=\"styleswitcher\">');
  for ( var i = 0; i < SS.length; i++ ) {
    if ( SS[i].title ) {
      var style_title = SS[i].title;
      document.write('<input type=\"radio\" name=\"stylename\" value=\"' +style_title + '\" id=\"' + style_title + '\"');
      if ( SS[i].disabled == false ) {
        document.write('checked>');
      } else {
        document.write('>');
      }
      document.writeln('<label for=\"' + style_title + '\">' + style_title + '<\/label>');
      if ( i != SS.length - 1 ) {
        document.writeln('<br>');
      }
    }
  }
  
  document.writeln('<br><input type=\"button\"  value=\"Choisir\" onclick=\"changeStyleSheet(); return false;\">');
  document.writeln('<\/p>');
  document.writeln('<\/form>');
  document.writeln('<\/td><\/tr><\/table>');
}

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 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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  if ( document.styleSheets && cookie && ( cookie != "null" ) ) {
    setActiveStyleSheet(cookie);
  }
}

var cookie = readCookie("style");
if ( document.styleSheets && cookie && ( cookie != "null" ) ) {
  setActiveStyleSheet(cookie);
}

