$(document).ready(function(){

	// Website zentrieren

	var WindowWidth = $(window).width();
	var WindowWidthNum = parseFloat(WindowWidth);
	var WrapperPosition = (WindowWidthNum / 2) - 335;

	if (WrapperPosition <= 50) {
		$("#MainWrapper").css({left: 50});
	} else {
		$("#MainWrapper").css({left: WrapperPosition});
	};
	
	// Window Resize

	$(window).resize(function(){
		var WindowWidth = $(window).width();
		var WindowWidthNum = parseFloat(WindowWidth);
		var WrapperPosition = (WindowWidthNum / 2) - 335;
	
		if (WrapperPosition <= 50) {
			$("#MainWrapper").css({left: 50});
		} else {
			$("#MainWrapper").css({left: WrapperPosition});
		};
	});



	// Menu

	$(".MainMenuItem").toggle(function(){

		var AjaxLoader = $(this).children(".AjaxLoader")
		$(AjaxLoader).css({display: 'inline'});

		var link = $(this)
						.find('a')
						.attr("href");

		$(this)
			.next()
			.children(".Content")
			.load(link + " div.ContentWrapper", function(){
				$(this).parent().show("slow");
				$(AjaxLoader).css({display: 'none'});	
				});

		return false;
	
	}, function(){

		$(this)
			.next()
			.hide("slow")
	
		return false;
		
	});



	$(".SubMenuItem").toggle(function(){

		var AjaxLoader = $(this).children(".AjaxLoader")
		$(AjaxLoader).css({display: 'inline'});

		var link = $(this)
						.find('a')
						.attr("href");

		$(this)
			.next()
			.children(".Content")
			.load(link + " div.ContentWrapper", function(){
				$(this).parent().show("slow");
				$(AjaxLoader).css({display: 'none'});
				});

		return false;
	
	}, function(){

		$(this)
			.next()
			.hide("slow");
	
		return false;

	});
	

	
	$(".ThirdMenuItem").toggle(function(){
	
		var AjaxLoader = $(this).children(".AjaxLoader")
		$(AjaxLoader).css({display: 'inline'});
		
		var link = $(this)
						.find('a')
						.attr("href");

		$(this)
			.next()
			.children(".Content")
			.load(link + " div.ContentWrapper", function(){
				$(this).parent().show("slow");
				$(AjaxLoader).css({display: 'none'});
				
				// LoadThickBox ();	
				
				});
					

		return false;
	
	}, function(){

		$(this)
			.next()
			.hide("solw");
	
		return false;

	});


}); // document.ready

