
var counter = 0;

var now = new Date();
var year = now.getYear();

if (year < 1900) 
{
	year += 1900;
}

var end = new Array();





function setEndTime(year, month, day, hour, min, countdownIndex)
{
    var stDate = month + "/" + day + "/" + year + " " + hour + ":" + min;
    
    var d = new Date();
   
    this.end[countdownIndex] = new Date();
    this.end[countdownIndex].setTime(Date.parse(stDate));
 
}


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();
  //alert(d.getDate());

  
  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('cntdwnSpanDays' + countdownIndex).innerHTML = '00';
        document.getElementById('cntdwnSpanHours' + countdownIndex).innerHTML = '00';
        document.getElementById('cntdwnSpanMins' + countdownIndex).innerHTML = '00';
        document.getElementById('cntdwnSpanSecs' + countdownIndex).innerHTML = '00';
    
  }

}





