document.documentElement.className = "js";




$(document).ready(function(jQuery){


	// tab-navigation: ENTWEDER per ajax oder mit vorproduzierten div.contentArea
	$('div.contentNavigator ul.pageList a[href=#]').click(function (e) {
		var link = $(this);
		var pageList = link.closest('ul.pageList');
		var include = link.parent().metadata().include;
		if (include) {
			alert(1);pageList.next('div.navigatorArea').load(include);
		} else {
			var index = pageList.find('li > a').index(this);
			pageList.siblings('div.navigatorArea').stop().css('opacity', '').addClass('hide').hide().eq(index).removeClass('hide').show();
		}
		link.parent().addClass('selected').siblings().removeClass('selected');
		return false;
	});
	
	var currentStageLink = 0;
	var stageHovering = false;
	var stageAreas = $('#stageContentNavigator .navigatorArea');
	var stageLinks = $('#stageContentNavigator').hover(function () {
		stageHovering = true;
	}, function () {
		stageHovering = false;
	}).find('ul.pageList a').bind('click.stage', function (e, autoplay) {
		if (!autoplay) {
			clearInterval(stageInterval);
			stageLinks.unbind('.stage');
		}
	});
	var stageInterval;
	if (stageLinks.length) {
		stageInterval = setInterval(function() {
			if (stageHovering) {
				return;
			}
			currentStageLink = ++currentStageLink % stageLinks.length;
			stageAreas.filter(':visible').fadeOut(2900, function() {
				$(this).addClass('hide');
			}).end().eq(currentStageLink).fadeIn(2900, function() {
				$(this).removeClass('hide');
			});
			stageLinks.parent().removeClass('selected').eq(currentStageLink).addClass('selected');
		}, 6000);
	}
	
});