	
	function countdown(_elapsed, _timenow) {
		if ($$('countdown')) {
			var seclefts = new Array();
			$$('.countdown').each(function(el){
				timestamp_end = el.title;
				var type = "";
				if (el.hasClass('long')) {
					type = 'long'
				}
				sec_left = timestamp_end - _timenow -  _elapsed;
				seclefts.push(sec_left);
				el.setHTML(format_seconds(sec_left, type));
			});
			_elapsed++;
	
			seclefts_min = Math.min.apply( Math, seclefts);
			if (seclefts_min <= 60*60) {next_update = 1;}
			else {next_update = 10;}
			
			setTimeout("countdown("+_elapsed+", "+ _timenow + ")", next_update*1000);
		}
	}
	
	function format_seconds(_in, _type) {
		var tt = '';
		var t_rest = 0;
		var out = '';
		var days = Math.floor(_in/(60*60*24));
		var hours = Math.floor(_in/(60*60));
		var minutes = Math.floor(_in/(60));
		var seconds = _in;
		
		if (_in < 0) {
			return "Auktionen er udløbet";
		}
		
		if (_in >= 60*60*24) {
			tt = 'days';
			t_rest = _in - days*60*60*24;
		}
		if (_in >= 60*60 && _in < 60*60*24) {
			tt = 'hours';
			t_rest = _in - hours*60*60;
		}
		if (_in >= 60 && _in < 60*60) {
			tt = 'minutes';
			t_rest = _in - minutes*60;
		}
		if ( _in < 60) {
			tt = 'seconds';
		}

		if (days > 1) {days = days + " dage ";}
			else {days = days + " dag ";}
		if (hours > 1) {hours = hours + " timer ";}
			else {hours = hours + " time ";}
		if (minutes > 1) {minutes = minutes + " minutter ";}
			else {minutes = minutes + " minut ";}
		seconds = seconds + " sekunder ";
		
		if (tt == 'days') {
			out = days;
		}
		if (tt == 'hours') {
			out = hours;
		}
		if (tt == 'minutes') {
			out = minutes;
		}
		if (tt == 'seconds') {
			out = seconds;
		}
		
		if (_type == 'long' && _in >= 60) {
			out = out + format_seconds(t_rest);
		}
		/* else {
			if (_in%4 == 0) {out += ' /';}
			if (_in%4 == 1)  {out += ' -';}
			if (_in%4 == 2)  {out += ' \\';}
			if (_in%4 == 3)  {out += ' |';}
		}*/
		
		return out;
	}	

	
function imgtiny_mouseover_listen() {
	
	// FIND EACH TINY THUMBNAIL ON THE PAGE (CONTAINS THE CLASS "imgtiny")
	$$('.imgtiny').each(function(img) {
		
		// GET THE SOURCE FILENAME AND REPLACE WITH A LARGER THUMBNAIL
		var src = img.getProperty('src');
		src = src.replace('tiny', 'thumbnail');
		
		// GET THE POSITION OF THE TINY IMAGE
		var pos = img.getPosition();
		
		// ON MOUSEOVER
		img.addEvent('mouseover', function(e) {
			new Event(e).stop();
			
			// IF THUMBNAIL CONTAINER DOESN'T EXIST, CREATE IT AND INJECT IN THE HTML
			if (!$('imgzoom')) {
				new Element('div').setProperty('id', 'imgzoom').injectInside(document.body);
			}
			// GET APPROPIATE POSITION COORDINATES. 
			if (img.hasClass('popunder')) {
				var left = pos.x - 5;
				var top = pos.y + 34;
			} else {
				var left = pos.x + 35;
				var top = pos.y - 20;
			}
			// SET THE THUMBNAIL CONTAINER AT THE POSITION, AND SET THE THUMBNAIL HTML
			$('imgzoom').setStyles({'left': left, 'top': top});
			$('imgzoom').setHTML('<div class="imgholder"><img src="' + src + '"></div>');
			
			// FADE IN THE THUMBNAIL CONTAINER, IF IT IS NOT VISIBLE ALL READY
			if ($('imgzoom').getStyle('visibility') == 'hidden') {
				new Fx.Style('imgzoom', 'opacity').start(0,1);
			}
			//setTimeout("if ($('imgzoom').getStyle('visibility') == 'visible') {new Fx.Style('imgzoom', 'opacity').start(1,0);}",10000);
		});
	
		// ON MOUSE OVER OUTSIDE THE IMG, HIDE THE THUMBNAIL CONTAINER
		$('bodyobject').addEvent('mouseover', function(e) {
			new Event(e).stop();
			if ($('imgzoom')) {
				$('imgzoom').setOpacity(0);
				//new Fx.Style('imgzoom', 'opacity').start(0,1);
			}
		});
	});
}
