	var actualNavPoint = "";

$(document).ready(function(){



	$("ul.level_1").children("li").each(function(){

		$(this).hover(function(){

			$submenu = $(this).children("ul.level_2");


			if($(this).children("div").children("a").html() != actualNavPoint)
			{
//				alert(actualNavPoint+"---"+$(this).children("div").children("a").html())
				handleHide();
				actualNavPoint = $(this).children("div").children("a").html();
			}

			if($submenu.length > 0)
			{
				$(this).css("zIndex", 1000);

				$submenu.hover(function(){

					stopHideSubs();

				})



				$(this).children("div").children("a").addClass("hovered");

				//$submenu.css("left", $(this).offset().left - $("#wrapper").offset().left);
			   	$(this).children("ul.level_2").show();
			}



		})

	})



	$("ul.level_2 li").hover(function(){

		stopHideSubs();

	})

	$("#container").hover(function(){

		handleHide();

	})

	$(".mod_changelanguage").hover(function(){

		handleHide();

	});


//	$(".mod_navigation").hover(function(){
//
//		handleHide()
//	});
//
//
	$(".subtext").each(function(){

		$(this).hide();

	})

	$("h3.subhead").each(function(){

		$(this).hide();

	})

	$("#beraterteam").click(function(){

		initHomeAni()


	})

	$("h2.subhead").click(function(){

		p = $(this).next().next("p").html();

		h1 = $("<h1>");
		h2 = $("<h2>");

		h1.html($(this).html());
		h2.html($(this).next("h3").html());

		body = $("<div>");
		body.append(h1);
		body.append(h2);
		body.append(p);

		if($("#LayerContent").html() == null)
		{
			$("#Layer").append('<div id="LayerContent"></div>');
		}


		//alert($("#Layer").html());

		$("#LayerContent").html(body.html());
		showLayer();


	})

	$("h2.conhead a").click(function(e){

		e.preventDefault();
	})


	$("h2.conhead").click(function(){


//240x333

		h1 = $("<h1>");
		h2 = $("<h2>");
		p = $("<p>");
		img = $("<img>");

		span = $("<span>");

		h1.html($(this).children(".name").html());
		h2.html($(this).children(".profession").html());
		p.html($(this).next("p").children(".text").html());
		p.css("width", 275);
		p.css("line-height","21px");
		p.css("margin-top","15px");

		img.attr("src", $(this).next("p").children("img").attr("src"));

		img.css({
			position: "absolute",
			right: "85px",
			top: "75px"
		});

		span.css({
			"position": "absolute",
			"left": "85px",
			"bottom": "25px",
			"width": 200
		});
		span.html("Telefon: "+$(this).next("p").children(".phone").html()+"<br>Telefax: "+$(this).next("p").children(".fax").html()+"<br>"+$(this).children(".email").html())
		span.children("a").css("color", "red");
		span.children("a").css("fontWeight", "bold");

		body = $("<div>");
		body.append(h1);
		body.append(h2);
		body.append(p);
		body.append(img);
		body.append(span);

		$("#LayerContent").html(body.html());
		showLayer();

	})

	$("body").append('<div id="LayerBg"></div><div id="Layer"><a id="Close" href="javascript:;" onclick="hideLayer();"><img src="/tl_files/images/close.png"> schließen</a><div id="LayerContent></div></div>');

	hideLayer();

})

var hideTimer;

function hideLayer()
{
	$("#LayerBg").hide();
	$("#Layer").hide();
}

function showLayer()
{
	$("#LayerBg").show();
	$("#Layer").show();
}

function hideSubs()
{
	return;
	hideTimer = setTimeout("handleHide()", 300);
}

function stopHideSubs()
{
	clearTimeout(hideTimer);
}

function handleHide()
{
	$("ul.level_1 li .square").each(function(){
		$(this).css("backgroundColor", "#fff");
	})
	$("*").removeClass("hovered");
	$("ul.level_2").each(function(){

		$(this).hide();

	})

}

function initHomeAni(){

	$("#beraterteam").animate({
		    opacity: 0.25,
		  }, 500, function() {
		    $("#starttext").fadeIn(500);
		  });


}

$(window).load(function(){

	setTimeout("initHomeAni()", 5000);

})
