// JavaScript Document


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

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////
 var convCountDown = {
        month:'8',     //  '*' for next month, '0' for this month or 1 through 12 for the month
        day: '24',       //  Offset for day of month day or + day **exact day - 25th = 25**
        hour: 8,        //  0 through 23 for the hours of the day **subtract 1 hour from actual time - 9am = 8**
        tz: -7,         //  Offset for your timezone in hours from UTC
        lab: 'tzcd',    //  The id of the page entry where the timezone countdown is to show



            // **    The start function can be changed if required   **


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

        setTZCountDown :function (month,day,hour,tz)
        {
            var toDate = new Date();
            if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
            else if (month > 0)
            {
            if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
            toDate.setMonth(month-1);
            }
            if (day.substr(0,1) == '+')
            {var day1 = parseInt(day.substr(1));
            toDate.setDate(toDate.getDate()+day1);
            }
            else{toDate.setDate(day);
            }
            toDate.setHours(hour);
            toDate.setMinutes(0-(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);
        },
        displayTZCountDown :function (countdown,tzcd)
        {

            if (countdown < 0) document.getElementById(tzcd).innerHTML = "August 24, 2011";
            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;
            var countdown2 = (countdown1 - mins) / 60;
            var hours = countdown2 % 24;
            var days = (countdown2 - hours) / 24;
            document.getElementById(tzcd).innerHTML = "<strong>"+days + "</strong>d" + (days == 1 ? '' : ' ') + ': <strong>' +hours+ '</strong>h : <strong>' +mins+ '</strong>m : <strong>'+secs+'</strong>s';
            setTimeout('convCountDown.displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
            }
        },
      start: function() {
            convCountDown.displayTZCountDown(convCountDown.setTZCountDown(convCountDown.month,convCountDown.day,convCountDown.hour,convCountDown.tz),convCountDown.lab);
        }

}
        window.onload = convCountDown.start;


