<!--
// Start Schedule/Standings Function
function displaySchedule(display) { 
    var schedule = document.getElementById("lk_schedule");
    var standings = document.getElementById("lk_standings");
    
    if (display == "Schedule") {
        schedule.style.visibility = "visible";
        schedule.style.display = "block";
        standings.style.visibility = "hidden";
        standings.style.display = "none";
    }
    if (display == "Standings") {
        schedule.style.visibility = "hidden";
        schedule.style.display = "none";
        standings.style.visibility = "visible";
        standings.style.display = "block";
    }
}
// End Schedule/Standings Function

// Start Navigation
var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}
// End Navigation

// Countdown Clock Start
function countdown(year, month, day, hour, minute, format) {
     Today = new Date();
     Todays_Year = Today.getFullYear() - 2000;
     Todays_Month = Today.getMonth();                  
     
     //Convert both today's date and the target date into miliseconds.                           
     Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                             Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
     Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();                  
     
     //Find their difference, and convert that into seconds.                  
     Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
     
     if(Time_Left < 0)
        Time_Left = 0;
     
     switch(format)
           {
           case 0:
                //The simplest way to display the time left.
                document.getElementById("lk_countdown").innerHTML = Time_Left + ' seconds';
                break;
           case 1:
                //More datailed.
                days = Math.floor(Time_Left / (60 * 60 * 24));
                Time_Left %= (60 * 60 * 24);
                hours = Math.floor(Time_Left / (60 * 60));
                Time_Left %= (60 * 60);
                minutes = Math.floor(Time_Left / 60);
                Time_Left %= 60;
                seconds = Time_Left;
                
                // document.getElementById("lk_countdown").innerHTML = '<h2>24 Heures Du Mans</h2>';
                document.getElementById("lk_countdown_timer").innerHTML = days + 'd ';
                document.getElementById("lk_countdown_timer").innerHTML += hours + 'h ';
                document.getElementById("lk_countdown_timer").innerHTML += minutes + 'm ';
                document.getElementById("lk_countdown_timer").innerHTML += seconds + 's ';
                break;
           default: 
                document.getElementById("lk_countdown").innerHTML = Time_Left + ' seconds';
           }
           
     //Recursive call, keeps the clock ticking.
     setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}
// Countdown Clock End
//-->
