var ClickLien=0;
// Modifie la taille
var AdaptSize = function(){
  var CurrentSize=1+((CoeffSize*FontSize)/10);
  // DEFINI A QUOI APPLIQUER LA FONT (temps reel)
  document.getElementById("content_ic").style.fontSize=CurrentSize+"em";
  document.getElementById("ColoneLeft").style.fontSize=CurrentSize+"em";
  document.getElementById("bottom").style.fontSize=CurrentSize+"em";
  onClick("a",addParamSize);
};
// Augmente la taille de police
var FontUp = function(){
  if(FontSize<MaxSize) FontSize++;
  AdaptSize(); return false;
};
// Diminue la taille de police
var FontDown = function(){
  if(FontSize>MinSize) FontSize--;
  AdaptSize(); return false;
};
// Ajoute les parametres aux url
var addParamSize = function(){
  if(OriginalSize!=FontSize){
    var h=this.href;
    if(h.indexOf("/articles-")!=-1) this.href+="/s-"+FontSize;
    else if(h.indexOf("?")!=-1) this.href+="&s="+FontSize;
    else this.href+="?s="+FontSize;
    ClickLien=1;
  }
};
// Action au load
var TraiteLoad = function(){
  onClick("a",addParamSize);
  onClick2("a",FontUp,"FontUp");
  onClick2("a",FontDown,"FontDown");
  EraseParamSize();
};
// Action à l'unload
var TraiteUnload = function(){
  // Ajoute les paramètres de tailles si différente
  var t=document.location;
  var h=t.href;
  if(FontSize==0) FontSize="default";
  if(OriginalSize==0) OriginalSize="default";
  if(OriginalSize!=FontSize){
    if(h.indexOf("/articles-")!=-1) h+="/s-"+FontSize;
    else if(h.indexOf("?")!=-1) h+="&s="+FontSize;
    else h+="?s="+FontSize;
    // Redirection
    t.href=h;
  }
};
// Recupere un attribut dans une url
var getAttribute = function(url,key){
	var attr, searchVar;
	if(url.indexOf("&"+key+"=")!==-1) searchVar="&"+key+"=";
	else if(url.indexOf("?"+key+"=")!==-1) searchVar="?"+key+"=";
	else if(url.indexOf("/"+key+"-")!==-1) searchVar = "/"+key+"-";
	else return null;
	attr = url.substring( url.indexOf(searchVar)+searchVar.length )
	if(attr.indexOf("&")!==-1) attr = attr.substr(0, attr.indexOf("&"));
	if(attr.indexOf("/")!==-1) attr = attr.substr(0, attr.indexOf("/"));
	return attr;
};
// Ajout de onclick sur un element
var onClick = function(elm,fn){
  var d=document.getElementsByTagName(elm);
  for(var i=0;i<d.length;i++){
    var h=d[i].href;
    if(h.indexOf("javascript:")==-1 &&
        h.indexOf("/s-")==-1 &&
       h.indexOf("?s=")==-1 &&
       h.indexOf("&s=")==-1
    ){
      d[i].onclick = fn;
    }
  }
};
// Ajout de onclick sur un element avec une certaine class
var onClick2 = function(elm,fn,cls){
  var d=document.getElementsByTagName(elm),c;
  for(var i=0;i<d.length;i++){
    c=d[i].className; if(c==cls) d[i].onclick = fn;
  }
};
// Supprime les parametres de taille
var EraseParamSize = function(){
  var t=document.location;
  var h=t.href;
  var a=getAttribute(h,'s');
  if(a!=null){
    h=h.replace("&s="+a,"");
    h=h.replace("?s="+a,"");
    h=h.replace("/s-"+a,"");
    t.href=h;
  }
};
window.onload = TraiteLoad;
window.onbeforeunload = TraiteUnload;
