window.addEvent('domready',function(){
	window.console = window.console || {log:function(){}};
	(function(){
		var theWebinar = new Date();
		theWebinar = new Date(theWebinar.toDateString()+' 20:00:00');
		var theWebinarMS = theWebinar.getTime();
		var theTimer = function(){
			var theTime = new Date();
			var theTimeMS = theTime.getTime() + ( theTime.getTimezoneOffset() * 60000 );
			var theCountdown = Math.floor(( theWebinarMS - theTimeMS ) / 60000);
			if ( theCountdown < 0 ) {
				theCountdown = theCountdown + 1440;
			}
			var theCountdownHours = '' + Math.floor(theCountdown/60);
			var theCountdownMinutes = '' + theCountdown % 60;
			if ( theCountdownHours.length === 1 ) {
				theCountdownHours = '0' + (theCountdownHours);
			}
			if ( theCountdownMinutes.length === 1 ) {
				theCountdownMinutes = '0' + (theCountdownMinutes);
			}
			var theMessage = "";
			switch ( theCountdownHours ) {
				case '00' :
					theMessage = "in " + theCountdownMinutes + " minutes";
					if ( theCountdownMinutes == '00' ) {
						theMessage = "RIGHT NOW!";
					} 
					break;
				case '23' :
					theMessage = "RIGHT NOW!";
					break;
				default:
					theMessage = "in " + theCountdownHours + ":" + theCountdownMinutes + " hours";
			}
			$$('.ho_webinarcount span').each(function(theSpan){
				var msg = theMessage;
				if ( theSpan.getParent().getProperty('id') == 'element_90771' && msg == "RIGHT NOW!" ) {
					msg = msg + "<br />CLICK HERE TO JOIN";
				}
				theSpan.setHTML(msg);
			});
		};
		theTimer();
		theTimer.periodical(60000);
	})();
});

