
// ****  Time Zone Count Down Javascript  **** //
/*
Visit http://rainbow.arch.scriptmania.com/scripts/
 for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var year = 2007;
var month = 1;     //  '*' for next month, '0' for this month or 1 through 12 for the month 
var day = 6;        //  Offset for day of month day or + day  
var hour = 15;        //  0 through 23 for the hours of the day
var minute = 30       //  0 through 59 for the minute
var tz = -5;          //  Offset for your timezone in hours from UTC
var lab = 'tzcd';      //  The id of the page entry where the timezone countdown is to show

function startTZCount() {displayTZCountDown(setTZCountDown(year,month,day,hour,minute,tz),lab);}

////////// DO NOT EDIT PAST THIS LINE //////////////////

function setTZCountDown(year,month,day,hour,minute,tz) 
{
  var toDate = new Date();

  toDate.setYear(year);
  toDate.setMonth(month-1);
  toDate.setDate(day);
  toDate.setHours(hour);
  toDate.setMinutes(minute -(tz*60));
  toDate.setSeconds(0);

  var fromDate = new Date();
  fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());

  var diffDate = new Date(0);
  diffDate.setMilliseconds(toDate - fromDate);

  return Math.floor(diffDate.valueOf()/1000);
}

function displayTZCountDown(countdown,tzcd) 
{
  if (countdown < 0) //past the time...
  {
    countup = -countdown;
    
    var secs = countup % 60; 
    if (secs < 10) secs = '0'+secs;
  
    var countup1 = (countup - secs) / 60;
    var mins = countup1 % 60; 

    if (mins < 10) mins = '0'+mins;

    countup1 = (countup1 - mins) / 60;

    var hours = countup1 % 24;
    var days = (countup1 - hours) / 24;

    document.getElementById(tzcd).innerHTML = 'It\'s been ' + days + ' day' + (days == 1 ? '' : 's') + ', ' +hours+ ' hour' + (hours == 1 ? '' : 's') + ', ' +mins+ ' minute' + (mins == 1 ? '' : 's') + ' and '+secs+ ' second' + (secs == 1 ? '' : 's') + ' since our wedding!';
    setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
  }
  else 
  {
    var secs = countdown % 60; 
    if (secs < 10) secs = '0'+secs;
  
    var countdown1 = (countdown - secs) / 60;
    var mins = countdown1 % 60; 

    if (mins < 10) mins = '0'+mins;

    countdown1 = (countdown1 - mins) / 60;

    var hours = countdown1 % 24;
    var days = (countdown1 - hours) / 24;

    document.getElementById(tzcd).innerHTML = days + ' day' + (days == 1 ? '' : 's') + ', ' +hours+ ' hour' + (hours == 1 ? '' : 's') + ', ' +mins+ ' minute' + (mins == 1 ? '' : 's') + ' and '+secs+ ' second' + (secs == 1 ? '' : 's') + ' until our wedding!';
    setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
  }
}
