// JavaScript Document

	//initial time
	var sin_h_current = -1;
	var sin_m1_current = -1;
	var sin_m2_current = -1;
	
	function flipSingapore  (SingaporeupperId, SingaporelowerId, SingaporechangeNumber, SingaporepathUpper, SingaporepathLower){
		var SingaporeupperBackId = SingaporeupperId+"Back";
		$(SingaporeupperId).src = $(SingaporeupperBackId).src;
		$(SingaporeupperId).setStyle("height", "11px");
		$(SingaporeupperId).setStyle("visibility", "visible");
		$(SingaporeupperBackId).src = SingaporepathUpper+parseInt(SingaporechangeNumber)+".png";
		
		$(SingaporelowerId).src = SingaporepathLower+parseInt(SingaporechangeNumber)+".png";
		$(SingaporelowerId).setStyle("height", "0px");
		$(SingaporelowerId).setStyle("visibility", "visible");
		
		var flipUpperSingapore = new Fx.Tween(SingaporeupperId, {duration: 200, transition: Fx.Transitions.Sine.easeInOut});
		flipUpperSingapore.addEvents({
			'complete': function(){
				var flipLowerSingapore = new Fx.Tween(SingaporelowerId, {duration: 200, transition: Fx.Transitions.Sine.easeInOut});
					flipLowerSingapore.addEvents({
						'complete': function(){	
							SingaporelowerBackId = SingaporelowerId+"Back";
							$(SingaporelowerBackId).src = $(SingaporelowerId).src;
							$(SingaporelowerId).setStyle("visibility", "hidden");
							$(SingaporeupperId).setStyle("visibility", "hidden");
						}				});					
					flipLowerSingapore.start('height', 11);
					
			}
							});
		flipUpperSingapore.start('height', 0);
		
		
	}//flip
				
	
	function retroClockSingapore(){
		
		// get new time
		 sin_now = new Date();
		 sin_h = now.getUTCHours() + 8;
		 		 		 
		 sin_m1 = sin_now.getUTCMinutes() / 10;
		 sin_m2 = sin_now.getUTCMinutes() % 10;


		 if( sin_h == 24){
				sin_h -= 24;
		}
				 
		 if( sin_h > 24){
				sin_h -= 24;
		}
	
		 if( sin_h < 0){
				sin_h += 24;
		}
			

		 
		 //change pads
		 
		 if( sin_h != sin_h_current){
			flipSingapore('SingaporehoursUp', 'SingaporehoursDown', sin_h, 'clock/Single/Up/', 'clock/Single/Down/');
			sin_h_current = sin_h;
		}
		
		if( sin_m2 != sin_m2_current){
			flipSingapore('SingaporeminutesUpRight', 'SingaporeminutesDownRight', sin_m2, 'clock/Double/Up/Right/', 'clock/Double/Down/Right/');
			sin_m2_current = sin_m2;
			
			flipSingapore('SingaporeminutesUpLeft', 'SingaporeminutesDownLeft', sin_m1, 'clock/Double/Up/Left/', 'clock/Double/Down/Left/');
			sin_m1_current = sin_m1;
		}
		
			
		
	}
	
	setInterval('retroClockSingapore()', 1000);
			
			
