var Klockren = new KLOCKREN.domFunction(function()
{
	if(KLOCKREN.CSS3Compatible("Transform") && KLOCKREN.CSS3Compatible("TransformOrigin")) {
		// Handle the orientation and styles with compatible mobiles (TODO)
		/*
		if(KLOCKREN.isMobile()) {
			if(KLOCKREN.MOBILE_VENDOR != "Android" || KLOCKREN.MOBILE_VENDOR) {
				window.onorientationchange = function() {	
				}
			}
		};
		*/
		// Moves the pointer for seconds
		setInterval(function() {
			var seconds = new Date().getSeconds(),
			s_degree = seconds * 6,
			s_rotate = "rotate("+ s_degree +"deg)",
			s_pointer = KLOCKREN.$("visare-sekund");
			
			KLOCKREN.setCSS(s_pointer, KLOCKREN.CSS3_VENDOR + "transform", s_rotate);
		}, 1000);
		
		// Moves the pointer for hours
		setInterval(function() {
			var hours = new Date().getHours(),
			mins = new Date().getMinutes(),
			h_degree = hours * 30 + (mins/2),
			h_rotate = "rotate("+ h_degree +"deg)",
			h_pointer = KLOCKREN.$("visare-timma");
			
			KLOCKREN.setCSS(h_pointer, KLOCKREN.CSS3_VENDOR + "transform", h_rotate);
		}, 1000);
		
		// Moves the pointer for minutes
		setInterval(function() {
			var mins = new Date().getMinutes(),
			m_degree = mins * 6,
			m_rotate = "rotate("+ m_degree +"deg)",
			m_pointer = KLOCKREN.$("visare-minut");
			
			KLOCKREN.setCSS(m_pointer, KLOCKREN.CSS3_VENDOR + "transform", m_rotate);
		}, 1000);
	}
	else {
		if(KLOCKREN.hasFlash()) {
			var flash_src = "swf/klockren.swf", content = KLOCKREN.$("content");
			if(KLOCKREN.isIE()) {
				// IE7 and lower don't like the object-tag when inserted correctly in the dom tree, so we insert it ugly for the poor IE users.
				content.innerHTML = '<object type="application/x-shockwave-flash" data="' + flash_src + '" width="640" height="480"><param name="movie" value="' + flash_src + '" /></object>';
			}
			else {
				KLOCKREN.removeChildren("content");
				var flash_object = document.createElement("object"), param = document.createElement("param");
				flash_object.setAttribute("width", 640);
				flash_object.setAttribute("height", 480);
				flash_object.setAttribute("data", flash_src);
				param.setAttribute("name", "movie");
				param.setAttribute("value", flash_src);
				flash_object.appendChild(param);
				content.appendChild(flash_object);
			}
		}
		else {
			/* TODO */
		}
	}
});
