function crossFade($container, classElement, classActive, fadeTime, delay) {
	var $cur = $container.find("." + classActive);
	var $next = $container.find("." + classActive).next("." + classElement);
	if ($next.length !== 1) {
		$next = $container.find("." + classElement + ":first");
	}
	$cur.css('z-index', 1).removeClass(classActive);
	$next.stop().css('z-index', 2).animate({'opacity': 1}, fadeTime, null, function(){
		$next.addClass(classActive);
		$cur.css('opacity', 0);
		if (typeof(delay) != 'undefined') {
			setTimeout(function(){
				crossFade($container, classElement, classActive, fadeTime, delay);
			}, delay);
		}
	});
}


$(document).ready(function(){
	
	if($('#eyecatchers .eyecatcher').length > 1) {
	
		$('#eyecatchers .eyecatcher').css('opacity', '0');
		$("#eyecatchers .eyecatcher:first").css({'opacity': 1, 'z-index': 2}).addClass('active');
		setTimeout(function(){
			crossFade($("#eyecatchers"), 'eyecatcher', 'active', 1000, 5000);
		}, 5000);
	}
	
	var initText = 'emailadres...';
	var clear = function() {
		$(this).val('').css('color', 'black');
		$(this).unbind('mousedown').unbind('focus');
	};
	
	if($('#newsletterSubscribeInput').val() == '') { // prevent removal of content when back button is used
		$('#newsletterSubscribeInput').val(initText).css('color', 'gray');
		$('#newsletterSubscribeInput').mousedown(clear).focus(clear);
	}

});


