$(document).ready(function(){
	
	var aClock3 = $('#clock3');
	var clockWidthHeight3 = aClock3.width();//width and height of the clock
	
	function startClock3(){
		
		aClock3.css({"height":clockWidthHeight3 +"px"});//sets the height if .js is enabled. If not, height = 0;
		aClock3.show();//fade it in
		
		//call rotatehands function
		setInterval(function(){
		
			rotateHands3();
			
		}, 200);//1000 = 1 second
			
		rotateHands3();//make sure they start in the right position
		
	}
		
	function rotateHands3(){
		
		//get current time/date from local computer
		var now3 = new Date();
		var newyork = now3.toGMTString();
		var curdate = new Date();
		var offset = curdate.getTimezoneOffset()/60;
		var newyork = now3.getHours() +offset -4;
		//alert (newyork);
		
		// helle Uhr oder dunkle Uhr
		var stunde3 = newyork;
		 if (stunde3 > 6 && stunde3 < 18) {
			 $("#bg3").attr("src","img/clockBg_tag.png"); 
			 $("#hourHand3").attr("src","img/hourHand_tag.png"); 
			 $("#minuteHand3").attr("src","img/minuteHand_tag.png"); 
		 }
		 else {
		     $("#bg3").attr("src","img/clockBg_nacht.png"); 
			 $("#hourHand3").attr("src","img/hourHand_nacht.png"); 
			 $("#minuteHand3").attr("src","img/minuteHand_nacht.png"); 
		 }


		/*//set the second hand
		var secondAngle3 = 360/60 * now3.getSeconds();//turn the time into angle
		$('#secondHand3').rotate(secondAngle3, 'abs');//set the hand angle
		$('#secondHand3').css( { "left": (clockWidthHeight3 - $('#secondHand3').width())/2 + "px", "top":(clockWidthHeight3 - $('#secondHand3').height())/2 + "px" });//set x and y pos*/

		//set the minute hand
		var minuteAngle3 = 360/60 * now3.getMinutes();//turn the time into angle
		$('#minuteHand3').rotate(minuteAngle3, 'abs');//set the hand angle
		$('#minuteHand3').css( { "left": (clockWidthHeight3 - $('#minuteHand3').width())/2 + "px", "top":(clockWidthHeight3 - $('#minuteHand3').height())/2 + "px" });//set x and y pos
		
		//set the hour hand
		var hourAngle3 = 360/12 * newyork;//turn the time into angle
		$('#hourHand3').rotate((hourAngle3 + minuteAngle3/12)%360, 'abs');//set the hand angle
		$('#hourHand3').css( { "left": (clockWidthHeight3 - $('#hourHand3').width())/2 + "px", "top":(clockWidthHeight3 - $('#hourHand3').height())/2 + "px" });//set x and y pos

	};
	
	startClock3();
	
	
});
