jQuery(function($) {
	$('#scout .date').datepicker({ dateFormat: 'dd.mm.yy' });
	
	$('#findersubmit span').click(function(){
		$('#scout').submit();
	});
});

function changeStartImage () {
	if (current == images.length) current = 0;
	var nocache = Math.round(Math.random()*10);
	var image  = new Image();
	jQuery(image).attr('class', 'headerimage');
	jQuery(image).attr('src', 'imageresize/954w__300h__' + images[current] + '?nocache=' + nocache).hide();
	jQuery(image).load(function(){
		jQuery('#headerImage .headerimage').fadeOut('slow', function(){ jQuery(this).remove(); });
		jQuery('#headerImage').append(image);
		jQuery(image).fadeIn('slow');
	});
	
	current++;
	setTimeout('changeStartImage()', interval);
}

$(document).ready(function() {
	$(".tourlink").hover(function(){		
		$('.tourmap').css("display","none");
		$("#image_"+$(this).attr("rev")).css("display","block");
	}, function() {
		$('.tourmap').css("display","none");
		$("#image_"+$("#tourmenu .active").attr("rev")).css("display","block");		
	});
	
	$('a.extLink').click(function() {
		window.open($(this).attr('href'),'','');
		return false;
	});
	
	$('.lottery input[type="text"].error').focus(function() {
		if ($(this).val() == 'füll mich') {
			$(this).val('');
			$(this).removeClass('error');
				
			$(this).blur(function() {
				if ($(this).val() == '') {
					$(this).val('füll mich');
					$(this).addClass('error');
				}		
			});
		}
	});		
});
