$(document).ready(function(){
	
	var aClock1 = $('#clock1');
	var clockWidthHeight1 = aClock1.width();//width and height of the clock

	function startClock1(){
		
		aClock1.css({"height":clockWidthHeight1 +"px"});//sets the height if .js is enabled. If not, height = 0;
		aClock1.show();//fade it in
		
		//call rotatehands function
		setInterval(function(){
		
			rotateHands1();
			
		}, 200);//1000 = 1 second
			
		rotateHands1();//make sure they start in the right position
		
	}
		
	function rotateHands1(){
		
		//get current time/date from local computer
		var hamburg = new Date();

		// helle Uhr oder dunkle Uhr
		var stunde1 = hamburg.getHours();
		 if (stunde1 > 6 && stunde1 < 18) {
			 $("#bg1").attr("src","img/clockBg_tag.png"); 
			 $("#hourHand1").attr("src","img/hourHand_tag.png"); 
			 $("#minuteHand1").attr("src","img/minuteHand_tag.png"); 
		 }
		 else {
		     $("#bg1").attr("src","img/clockBg_nacht.png"); 
			 $("#hourHand1").attr("src","img/hourHand_nacht.png"); 
			 $("#minuteHand1").attr("src","img/minuteHand_nacht.png"); 
		 }
		
		//set the second hand
		/*var secondAngle1 = 360/60 * hamburg.getSeconds();//turn the time into angle
		$('#secondHand1').rotate(secondAngle1, 'abs');//set the hand angle
		$('#secondHand1').css( { "left": (clockWidthHeight1 - $('#secondHand1').width())/2 + "px", "top":(clockWidthHeight1 - $('#secondHand1').height())/2 + "px" });//set x and y pos*/

		//set the minute hand
		var minuteAngle1 = 360/60 * hamburg.getMinutes();//turn the time into angle
		$('#minuteHand1').rotate(minuteAngle1, 'abs');//set the hand angle
		$('#minuteHand1').css( { "left": (clockWidthHeight1 - $('#minuteHand1').width())/2 + "px", "top":(clockWidthHeight1 - $('#minuteHand1').height())/2 + "px" });//set x and y pos
		
		//set the hour hand
		var hourAngle1 = 360/12 * hamburg.getHours();//turn the time into angle
		$('#hourHand1').rotate((hourAngle1 + minuteAngle1/12)%360, 'abs');//set the hand angle
		$('#hourHand1').css( { "left": (clockWidthHeight1 - $('#hourHand1').width())/2 + "px", "top":(clockWidthHeight1 - $('#hourHand1').height())/2 + "px" });//set x and y pos

	};
	
	startClock1();
	
	/*var dt = new Date();
	window.alert(dt.getTimezoneOffset()/60);*/

 	
	
});
