/***
 *      JavaScript per homepage
 ***/
 
/* Dichiarazione di oggetti globali */  
var objLightWindow;

/* Gestione eventi della pagina */
$E.add(window, "load", loading, false );

/* Funzioni e oggetti locali */
function loading()
{ 
  // Istanzio l'oggetto   
  objLightWindow = new LightWindowT ( $("discipline"), { "bgColor": "#202020" } );
  
  // Controllo l'effetto sul click esterno
  $E.add( objLightWindow, "exit", objLightWindow.hideWithFade, false );
  
  // Aggiungo l'evento al link per la chiusura
  var fn = function()
  {
    objLightWindow.hideWithFade();
  }
  
  $E.add( $("winClose"), "click", fn, false );

  // Aggiungo gli eventi ai link delle discipline
  var elDisc = $$(".links");
  
  for (i=0; i < elDisc.length; i++)
  {
    $E.add( elDisc[i], "click", openScreen, false );
  }

}

function openScreen(e)
{
  $E.preventDefault(e);
  
  // Recupero il nome del file
  var html = loadSyncFile(this.href.replace("/discipline","/discipline/xml"));
  
  $("contentDiscipline").innerHTML = html;
 
  objLightWindow.reposition();
  objLightWindow.showWithFade();              
} 

/* Funzione di utilità : sleep */
function pausecomp(millis)
{
  var date = new Date();
  var curDate = null;
  
  do { curDate = new Date(); }
  while(curDate-date < millis);
} 
