jQuery(document).ready(function(){
	
	var myClock = jQuery('#icewatch');
	
	function makeWatch(){
		
			
		//call rotatehands function
		setInterval(function(){
		
			rotateHands1();
			
		}, 200);//1000 = 1 second
			
		//rotateHands();//make sure they start in the right position
		
	}
		
	function rotateHands1(){
		
		
		
		
		//get current time/date from local computer
		var now = new Date();
		
		var clockWidthHeight = 200;
		
		//set the second hand
		var secondAngle = 360/60 * now.getSeconds();//turn the time into angle
		jQuery('#icewatch_second').rotate(secondAngle, 'abs');//set the hand angle
		var secondMarginLeft = (clockWidthHeight - jQuery('#icewatch_second').width())/2;
		secondMarginLeft = secondMarginLeft - 31;
		var secondMarginTop = (clockWidthHeight - jQuery('#icewatch_second').height())/2;
		secondMarginTop = secondMarginTop + 10;
		if (navigator.appName == "Microsoft Internet Explorer") {
				secondMarginLeft = secondMarginLeft - 22;//IEBUG
		}
		
		jQuery('#icewatch_second').css( { "left": secondMarginLeft + "px", "top": secondMarginTop + "px" });//set x and y pos


		//set the minute hand
		var minuteAngle = 360/60 * now.getMinutes();//turn the time into angle
		jQuery('#icewatch_minute').rotate(minuteAngle, 'abs');//set the hand angle
		var minuteMarginLeft = (clockWidthHeight - jQuery('#icewatch_minute').width())/2;
		minuteMarginLeft = minuteMarginLeft - 30;
		var minuteMarginTop = (clockWidthHeight - jQuery('#icewatch_minute').height())/2;
		minuteMarginTop = minuteMarginTop + 11;
		if (navigator.appName == "Microsoft Internet Explorer") {
				minuteMarginLeft = minuteMarginLeft - 12; //IEBUG
		}
		
		jQuery('#icewatch_minute').css( { "left": minuteMarginLeft + "px", "top": minuteMarginTop + "px" });//set x and y pos
		
		
		
		//set the hour hand
		var hourAngle = 360/12 * now.getHours();//turn the time into angle
		jQuery('#icewatch_hour').rotate((hourAngle + minuteAngle/12)%360, 'abs');//set the hand angle
		var hourMarginLeft = (clockWidthHeight - jQuery('#icewatch_hour').width())/2;
		hourMarginLeft = hourMarginLeft - 31;
		var hourMarginTop = (clockWidthHeight - jQuery('#icewatch_hour').height())/2;
		hourMarginTop = hourMarginTop + 9;
		jQuery('#icewatch_hour').css( { "left": hourMarginLeft + "px", "top": hourMarginTop + "px" });//set x and y pos


	};
	
	makeWatch();
	
	
});
