(function(jQuery) {
	jQuery.fn.clock = function(options){
		// default configuration properties
		var defaults = {	
			timeZone: 0
		};
		
		var o = jQuery.extend(defaults, options);
		
		this.each(function() {
			var obj = jQuery(this);
			var objMinute = obj.find(".Minutes");
			var objHour = obj.find(".Hours");
			var objClockBase = obj.find(".ClockBase");
			
			function init() {
				hours();
				minutes(); 
			}
			function minutes() {				
				var nMinutes = new Date().getUTCMinutes();
				//var nRound = 5;
//				var nDiff = nMinutes % nRound;
//				if(nDiff != 0)
//				{
//					if (nDiff < 3) { nMinutes -= nDiff; } // round down
//					else { nMinutes += nRound - nDiff; } // round up
//				}
				if(nMinutes > 59)
				{
					// handle increase the hour instead
					nHour++;
					nMinutes = 0;
				}
//				// Update the on page elements//				
				objMinute.addClass('min' + nMinutes);	
				setTimeout(function() { minutes(); }, 60000); // update the css clock every minute (or so)
			}
			function hours(){
				var nHour =  new Date().getUTCHours() + o.timeZone;
				if(nHour < 6 || nHour  >= 18) {
					objClockBase.addClass("ClockChange");
				  }
				else {
					objClockBase.removeClass("ClockChange");
				}
				if (nHour > 12) { 
					nHour -= 12;
				}  // switch from 24-hour to 12-hour system
				objHour.addClass('hr' + nHour);
				setTimeout(function() { hours(); }, 60000);
			}			
			// int
			init();			
			// other active
		});
	}
})(jQuery);

        
