$(document).ready(function(){

 var aClock = $('#analog-clock');
 var clockWidthHeight = aClock.width();//width and height of the clock

 function startClock(){

 aClock.css({"height":clockWidthHeight +"px"});//sets the height if .js is enabled. If not, height = 0;
 aClock.fadeIn();//fade it in

 //call rotatehands function
 setInterval(function(){

 rotateHands();

 }, 1000);//1000 = 1 second

 rotateHands();//make sure they start in the right position

 }

 function rotateHands(){

 //get current time/date from local computer
// default_time += 1000;

 //var now = new Date(default_time * 1000);
 //default_time ++;

 clock_now.setSeconds(clock_now.getSeconds()+1);
 var h = clock_now.getHours();
 if(h > 11)
 {
 	document.getElementById('clock_meridiem').innerHTML = 'PM';
 }
 else
 {
 	document.getElementById('clock_meridiem').innerHTML = 'AM';
 }
 //set the second hand
 var secondAngle = 360/60 * clock_now.getSeconds();//turn the time into angle
 $('#secondHand').rotate(secondAngle, 'abs');//set the hand angle
 $('#secondHand').css( { "left": (clockWidthHeight - $('#secondHand').width())/2 + "px", "top":(clockWidthHeight - $('#secondHand').height())/2 + "px" });//set x and y pos

 //set the minute hand
 var minuteAngle = 360/60 * clock_now.getMinutes();//turn the time into angle
 $('#minuteHand').rotate(minuteAngle, 'abs');//set the hand angle
 $('#minuteHand').css( { "left": (clockWidthHeight - $('#minuteHand').width())/2 + "px", "top":(clockWidthHeight - $('#minuteHand').height())/2 + "px" });//set x and y pos

 //set the hour hand
 var hourAngle = 360/12 * clock_now.getHours();//turn the time into angle
 $('#hourHand').rotate((hourAngle + minuteAngle/12)%360, 'abs');//set the hand angle
 $('#hourHand').css( { "left": (clockWidthHeight - $('#hourHand').width())/2 + "px", "top":(clockWidthHeight - $('#hourHand').height())/2 + "px" });//set x and y pos

 };

 startClock();
});
