$(document).ready(function(){
	/* * * * * START: SHOW MAIN NAV * * * * */
	$('ul li#logo a').click(function() {
		if ($('ul#mainNav').hasClass('open')) {
			document.location.href="/";	
		} else {
			// show main nav
			$('ul#mainNav').show().addClass('open');
		}
		return false;
	});
	
	/* * * * * START: HAUPTNAV * * * * */
	// for all
	$('ul.step1 li a').click(function () {
		$('#cover article').removeClass('active').addClass('inactive');
		$('ul.step1 li.active').removeClass('active');
		$(this).parent().addClass('active');
		$('.results').hide();
	});
	// specific buttons
	$('li#mnBuecher a').click(function () {
		loadNav("/includes/nav.westfluegel.buecher.inc.php")
		return false;
	});
	$('li#mnBuecherAutoren a').click(function () {
		loadNav("/includes/nav.westfluegel.autoren.inc.php")
		return false;
	});
	$('li#mnBuecherKritiker a').click(function () {
		loadNav("/includes/nav.westfluegel.kritiker.inc.php")
		return false;
	});
	$('li#mnVeranstaltungen a').click(function () {
		loadNav("/includes/nav.westfluegel.veranstaltungen.inc.php");
		return false;
	});
	$('li#mnInchFurniture a').click(function () {
		loadNav("/includes/nav.westfluegel.inchFurniture.inc.php");
		return false;
	});
	$('li#mnInformation a').click(function () {
		loadNav("/includes/nav.westfluegel.information.inc.php");
		return false;
	});	
	
	
	function loadNav(newPage) {
		$('#resultsContainer').load(newPage, function() {
			attachPaginNav();
		});
		return false;
	}
	/* * * * * END: HAUPTNAV * * * * */
	
	
	/* * * * * START: PAGING NAV * * * * */
	function attachPaginNav() {
		$('a.pagingNext').bind('click', function() {
			var newPage = $('a.pagingNext').attr("href");
			loadNav(newPage);
			return false;
		});
		$('a.pagingBack').bind('click', function() {
			var newPage = $('a.pagingBack').attr("href");
			loadNav(newPage);
			return false;
		});
	}
	/* * * * * END: PAGING NAV * * * * */


	/* * * * * START: FOCUS ON SELECTED ARTICLE * * * * */
	$('article:not(".active")').addClass('inactive');
	$('article').click(function () {
		$('article').removeClass('active').addClass('inactive');
		$(this).removeClass('inactive').addClass('active');
		//$('nav#westfluegelNav ul#mainNav li.active').removeClass('active');
		//hideNav();
	});
	/* * * * * START: FOCUS ON SELECTED ARTICLE * * * * */
	
	
});
