/*
Author: Robert Hashemian
http://www.hashemian.com/

You can use this code in any manner so long as the author's
name, Web address and this disclaimer is kept intact.
********************************************************
Achtung:
Die Daten der naechsten Rennen sowie die Texte, Rennstreckenbilder und Links sind alle schon vorbereitet und mussen bei Bedarf nur auskommentiert werden - und das jeweilig abgelaufene natuerlich kommentieren
*/
/* Datum 8h Le Castellet */
/* TargetDate = "04/11/2010 11:00 AM"; */
/* Datum 1000 km Spa */
/* TargetDate = "05/09/2010 12:50 PM"; */
/* Datum 24h Le Mans */
/* TargetDate = "06/13/2010 3:00 PM"; */
/* Datum 1000 km Algarve */
TargetDate = "07/17/2010 3:00 PM"; 
/* Datum 1000 km Hungaroring */
/* TargetDate = "08/22/2010 3:00 PM"; */
/* Datum 1000 km Silverstone */
/* TargetDate = "09/12/2010 1:00 PM"; */
BackColor = "white";
ForeColor = "grey";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Tage, %%H%%h:%%M%%m:%%S%%s";
FinishMessage = "Es geht los!";


function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountBack(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
  }
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
 document.write("<h2>N&auml;chstes Rennen:</h2>");
 document.write("<span id='cntdwn' style='background-color:" + backcolor +
                "; color:" + forecolor + "'></span>");
 document.write ("<br />");
 
 /* 8h Le Castellet 
 document.write ("<br />8h du Castellet");
 document.write ("<br />11. April 2010");
 document.write ("<br /><img src=images/circuit-paulricard_92x28.gif width=92 height=28 alt=Paul Ricard />");
 document.write ("<br /><a href=http://www.circuitpaulricard.com target=_blank>Paul Ricard</a><br />");
 */
 
 /* 1000 km Barcelona
 document.write ("<br />1000 km Barcelona");
 document.write ("<br />5. April 2009");
 document.write ("<br /><img src=images/circuit-catalunya.jpg width=92 height=36 alt=Circuit de Catalunya />");
 document.write ("<br /><a href=http://www.circuitcat.com/ingles/index.asp target=_blank>Circuit de Catalunya</a><br />"); */


/* 1000 km Monza
 document.write ("<br />1000 km Monza");
 document.write ("<br />27. April 2008");
 document.write ("<br /><img src=images/circuit-monza_92x49.gif width=92 height=49 alt=Autodromo Nazionali Monza />");
 document.write ("<br /><a href=http://www.monzanet.it target=_blank>Autodromo Nazionali Monza</a><br />");
*/

/* 1000 km Spa 
 document.write ("<br />1000 km Spa");
 document.write ("<br />9. Mai 2010");
 document.write ("<br /><img src=images/circuit-spa_92x51.gif width=92 height=51 alt=Spa Franchorchamps />");
 document.write ("<br /><a href=http://www.spa-francorchamps.be target=_blank>Spa Franchorchamps</a><br />");
*/

/* Testtag Le Mans
 document.write ("<br />Testtag Le Mans");
 document.write ("<br />1. Juni 2008");
 document.write ("<br /><img src=images/circuit-lemans_92x48.gif width=92 height=48 alt=Le Mans />");
 document.write ("<br /><a href=http://www.lemans.org target=_blank>Circuit 24 Heures</a><br />");
*/
/* 24 Std. von Le Mans 
 document.write ("<br />24 Std. von Le Mans");
 document.write ("<br />12. Juni 2010");
 document.write ("<br /><img src=images/circuit-lemans_92x48.gif width=92 height=48 alt=Le Mans />");
 document.write ("<br /><a href=http://www.lemans.org target=_blank>Circuit 24 Heures</a><br />");
*/

/* 1000 km Algarve */
 document.write ("<br />1000 km Algarve");
 document.write ("<br />17. Juli 2010");
 document.write ("<br /><img src=images/circuit-algarve.gif width=92 height=42 alt=Alagarve />");
 document.write ("<br /><a href=http://autodromodoalgarve.com target=_blank>Algarve</a><br />");


/* 1000 km Silverstone
 document.write ("<br />1000 km Silverstone");
 document.write ("<br />14. Sept. 2008");
 document.write ("<br /><img src=images/circuit-silverstone_92x52.gif width=92 height=52 alt=Silverstone />");
 document.write ("<br /><a href=http://www.silverstone.co.uk target=_blank>Silverstone</a><br />");
*/

/* 1000 km Shanghai
 document.write ("<br />1000km Shanghai");
 document.write ("<br />3. Nov. 2008");
 document.write ("<br /><img src=images/circuit-shanghai_92x65.gif width=92 height=65 alt=Shanghai />");
 document.write ("<br /><a href=http://http://www.icsh.sh.cn target=_blank>Shanghai Circuit</a><br />");
*/


 document.write ("<p><br /><img src=\"images/grey_dot.gif\"  width=\"140\" height=\"1\" alt=\"\" /></p>");
                }

if (typeof(BackColor)=="undefined")
  BackColor = "white";
if (typeof(ForeColor)=="undefined")
  ForeColor= "black";
if (typeof(TargetDate)=="undefined")
  TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
  CountActive = true;
if (typeof(FinishMessage)=="undefined")
  FinishMessage = "";
if (typeof(CountStepper)!="number")
  CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
  LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
  CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);