var scrollOptions = {
        duration: 500
    };
	
var scrollOptionsFirst = {
        duration: 0
    };
    
var active;
var first;
function showLast(){
    sel=$("#pageselector").text();
    if (active==sel) return;
    $("#"+sel).trigger("mouseover");
    return;
}
var zapto;
var nozap;
function showThis(component){
  zapto=$(component).attr("id");;
  //console.log("active="+active+" Zapto="+zapto);
  if (0==1 && active=='kwick_7' && zapto!="kwick_7"){
    //console.log("Efface");
    $(".kwicks.horizontal li#kwick_7 a").fadeOut(500);
  }
  
  setTimeout("showThis_delayed()",500);
}

function showThis_delayed(){
  sel=zapto;
  //console.log("delayed"+sel+"="+active);
  if (active==sel) return;
  //console.log("Active delayed"+sel);
  
   if (active!='kwick_7')
    $("li#"+active+" a").css("display","none");
    
    if (sel!='kwick_7' && !first)
    $("li#"+sel+" a").css("display","block");
   
   // $(".kwicks.horizontal li#"+sel+" a").css("display","block");
   
   active=sel;
  if (nozap) {nozap=false;return;}
   //console.log(sel);
  if (sel){
    licontainer=$("#"+sel).html();
    
    licontainer=licontainer.replace(/^[^#]+#([^'"]+)['"].*$/,"$1");
    //alert(licontainer);
    if (first)
        $('#scroller').scrollTo("#"+licontainer,scrollOptionsFirst);
      else
        $('#scroller').scrollTo("#"+licontainer,scrollOptions);
    first=false;  
  } 
}

$(function () {
active=false;
zapto=false;
first=true;
nozap=false;
init=true;
  //initCoda();
  //initScroller();
  
  //Juste d&eacute;plac&eacute; l'initialisation de Kwick
   nb=$("#kwicknum").text();
   g=nb;
   g++;
   //active="kwick_"+g;
  //console.log("select :"+nb);
   $('.kwicks').kwicks({
    	           max : 230,
	           spacing : -7,
	           defaultKwick:nb,
	           sticky:true
                  });
  
  //Montre le texte au survol des bars
  $(".kwicks.horizontal li").mouseover(function(){showThis(this);});
  
  //Affiche la bar par defaut quand la souris quitte le UL
  $('.kwicks').bind("mouseleave", function() {
    showLast();
  });
  $('#leftcol').bind("onmouseover",function() {
    showLast();
  });
  $('.panel').bind("onmouseover",function() {
    showLast();
  });
  $('#scroller').bind("onmouseover",function() {
    showLast();
  });
  
  //INITIALISATION
   
  
  
  
  showLast();
});




