// JavaScript Document
function setActiveStyleSheet(title) {
	var i, a, main;

	apetit = document.getElementById("stylesheetpetit")
	agrand = document.getElementById("stylesheetgrand")
	anormal = document.getElementById("stylesheetnormal")
	
	apetit.disabled = true;
	agrand.disabled = true;
	anormal.disabled = true;
	
	if (title == "stylesheetpetit"){
		apetit.disabled = false;
	}
	
	if (title == "stylesheetgrand"){
		agrand.disabled = false;
	}	
	
	if (title == "stylesheetnormal"){
		anormal.disabled = false;
	}	
	
	if (navigator.appName == "Microsoft Internet Explorer") {
//		window.resizeBy(0,-10);
//		window.resizeBy(0,+10);
	}

}

function getActiveStyleSheet() {

  var i, a;
	
	a = document.getElementById("stylesheetpetit")
	if (a.disabled == false){ return a.getAttribute("id");}  
	
	a = document.getElementById("stylesheetgrand")
	if (a.disabled == false){ return a.getAttribute("id");}

	a = document.getElementById("stylesheetnormal")
	if (a.disabled == false){ return a.getAttribute("id");}	

  return null;
}



function getPreferredStyleSheet(e) {
	
  if (e = "stylesheetpetit"){ return "stylesheetpetit";}  
  if (e = "stylesheetgrand"){ return "stylesheetgrand";}
  if (e = "stylesheetnormal"){ return "stylesheetnormal";}

  return "stylesheetnormal";

}



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(cookie);
 setActiveStyleSheet(title);
 
}


window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
