// JavaScript Document

function setActiveStyleSheet(title) {
	style=title;
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title)
	  	{ a.disabled = false;
		}
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}





var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


// fonction aff_liste sert a modifier dynamiquement la boite des stats pour jour/semaine/mois
// parametre :  id = id de la boite a changer de visibilité
//				display1 : nouvelle valeur de display pour la boite (none ou block)
function afficher_1(id) 
{
	//document.all[id].style.display = 'block';
	
	document.getElementById(id).style.display  = 'block';
	return true;
}


// fonction aff_liste sert a modifier dynamiquement la boite des stats pour jour/semaine/mois
// parametre :  id = id de la boite a changer de visibilité
//				display1 : nouvelle valeur de display pour la boite (none ou block)
function aff_liste(id, display1) 
{
	document.getElementById(id).style.display = display1;
	return false;
}


// fonction change 3 couleurs de texte en meme temps
//				id1  :   c1 
//				id2  :   c2
//				id3  :   c3 
function couleur_texte(id1,id2,id3,c1,c2,c3) 
{
	 document.getElementById(id1).style.color=c1;
	 document.getElementById(id2).style.color=c2;
	 document.getElementById(id3).style.color=c3;
	return false;
}


function cacher_1() 
{
	document.getElementById('choix_1').style.display  = 'none';
	document.getElementById('choix_2').style.display  = 'none';
	document.getElementById('choix_3').style.display  = 'none';
	return true;
}


// fonction modif_video sert a modifier dynamiquement la boite des Vidéo
// parametre :  id = id de la boite a changer de visibilité
//				visibility : nouvelle valeur de display pour la boite
//              class_top = class du top pour modifier la photo du menu vidéo
function modif_video(id, visibility, id_logo, class_top) 
{
	document.getElementById(id).style.display = visibility;
	document.getElementById(id_logo).className= class_top;
	return true;
}

