
var counter = 0;

var now = new Date();
var year = now.getYear();

if (year < 1900) 
{
	year += 1900;
}

var end = new Array();


//document.write('<div style="text-align: center">');
//document.write('	<span id="lc1" style="FONT: bold 30px arial; COLOR: green"></span><br />');
//document.write('	<span id="c2" se="font: bold 25px arial; color: blue">;</span><br />');
//document.write('	...bis zum 31. Dezember ' + year);
//document.write('</div>');

//var parentDiv = document.getElementById("cntdwnDiv");
//var cntdwnSpan = document.createElement("span");

//parentDiv.appendChild(cntdwnSpan);


function setEndTime(year, month, day, hour, min, countdownIndex)
{
    this.end[countdownIndex] = new Date()
    this.end[countdownIndex].setFullYear(parseInt(year, 10));
    this.end[countdownIndex].setMonth(parseInt(month, 10) - 1);
    this.end[countdownIndex].setDate(parseInt(day, 10));
    this.end[countdownIndex].setHours(parseInt(hour, 10));
    this.end[countdownIndex].setMinutes(parseInt(min, 10)); 
}


function toSt2(n) 
{
  s = "";
  if (n < 10) s += "0";
  return (s + n).toString();
}

function toSt3(n) 
{
  s = "";
  if (n < 10) s += "00";
  else if (n < 100) s += "0";
  return (s + n).toString();
}

function countdown(countdownIndex)
{
  d = new Date();
  
  count = Math.floor(end[countdownIndex].getTime() - d.getTime());

  if(count > 0) 
  {
    
    count = Math.floor(count/1000);
    
    seconds = toSt2(count%60); count = Math.floor(count/60);
    minutes = toSt2(count%60); count = Math.floor(count/60);
    hours = toSt2(count%24); count = Math.floor(count/24);
    days = toSt2(count);
    

    document.getElementById('cntdwnSpanDays' + countdownIndex).innerHTML = days;
    document.getElementById('cntdwnSpanHours' + countdownIndex).innerHTML = hours;
    document.getElementById('cntdwnSpanMins' + countdownIndex).innerHTML = minutes;
    document.getElementById('cntdwnSpanSecs' + countdownIndex).innerHTML = seconds;
    
    //document.getElementById('cntdwnSpan2').innerHTML = hours + ':' + minutes + ':' + seconds;
    
    //alert("yes");
    
    /*
    var myTags = document.getElementsByTagName("span");
    
    
    for(var i = 0; i < myTags.length; i++)
    {
        if(myTags[i].id == "cntdwnSpan1")
        {
            if(myTags[i].innerHTML =" ")
            {
                myTags[i].innerHTML = days + ':' + hours + ':' + minutes + ':' + seconds;
            }
        }    
    }
    */
    
    setTimeout("countdown(" + countdownIndex + ")", 300);
  }
  else
  {
        document.getElementById('cntdwnNull').innerHTML = "Das warten hat ein Ende";
        document.getElementById('cntdwnCounter').style.display = 'none';
        document.getElementById('cntdwnLabel').style.display = 'none';
  }

}




