// JavaScript Document

var hidevar = true;
var hidevar_ = true;

$(document).ready(function(){
	
	//diese men�s sollen rechts angeordnet sein
	$("#menu_6, #menu_7").parent().addClass("menu-right");

//breite anpassen
	//UNTERNEHMEN
	$("#menu_3").parent().find("ul.ebene1:not(ul.ebene2)").css("width","130px");
	$("#menu_3").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","99px");
	$("#menu_3").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","99px");
	$("#menu_3").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-108.png') no-repeat",

		"width":"200px"
	});
	$("#menu_3").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-108.png') no-repeat",
		"width":"200px"
	})
	$("#menu_3").parent().find("ul.ebene2:not(.ebene3)").css("left","108px");
	
	$("#menu_3").parent().find("ul.ebene1 ul>li:not(.ebene3 li)").css("width","166px");
	$("#menu_3").parent().find("ul.ebene1 ul>li:not(.ebene3 li) a").css("width","166px");	
	$("#menu_3").parent().find("ul.ebene1 ul>li.navi-sub-top:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-sub-top-short.png') no-repeat",

		"width":"200px"
	});
	$("#menu_3").parent().find("ul.ebene1 ul>li.navi-sub-bottom:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-short.png') no-repeat",
		"width":"200px"
	})
	$("#menu_3").parent().find("ul.ebene3").css("left","175px");	

	
	//HARDWARE
	$("#menu_4").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","191px");
	$("#menu_4").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","191px");	
	$("#menu_4").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-200.png') no-repeat",

		"width":"200px"
	});
	$("#menu_4").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-200.png') no-repeat",
		"width":"200px"
	})
	$("#menu_4").parent().find("ul.ebene2:not(.ebene3)").css("left","200px");	
	
	$("#menu_4").parent().find("ul.ebene1 ul>li:not(.ebene3 li)").css("width","171px");
	$("#menu_4").parent().find("ul.ebene1 ul>li:not(.ebene3 li) a").css("width","171px");	
	$("#menu_4").parent().find("ul.ebene1 ul>li.navi-sub-top:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-sub-top-180.png') no-repeat",

		"width":"200px"
	});
	$("#menu_4").parent().find("ul.ebene1 ul>li.navi-sub-bottom:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-180.png') no-repeat",
		"width":"200px"
	})
	$("#menu_4").parent().find("ul.ebene3").css("left","180px");

	$("#menu_4").parent().find("ul.ebene3 li").css("width","171px");
	$("#menu_4").parent().find("ul.ebene3 li a").css("width","171px");	
	$("#menu_4").parent().find("ul.ebene3 li.navi-sub-top").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-sub-top-180.png') no-repeat",

		"width":"200px"
	});
	$("#menu_4").parent().find("ul.ebene3 li.navi-sub-bottom").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-180.png') no-repeat",
		"width":"200px"
	})			

	$("#menu_5").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","181px");
	$("#menu_5").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","181px");	
	$("#menu_5").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-190.png') no-repeat",

		"width":"200px"
	});
	$("#menu_5").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-190.png') no-repeat",
		"width":"200px"
	})
	$("#menu_5").parent().find("ul.ebene2:not(.ebene3)").css("left","190px");
	
	$("#menu_5").parent().find("ul.ebene1 ul>li:not(.ebene3 li)").css("width","166px");
	$("#menu_5").parent().find("ul.ebene1 ul>li:not(.ebene3 li) a").css("width","166px");	
	$("#menu_5").parent().find("ul.ebene1 ul>li.navi-sub-top:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-sub-top-short.png') no-repeat",

		"width":"200px"
	});
	$("#menu_5").parent().find("ul.ebene1 ul>li.navi-sub-bottom:not(.ebene3 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-short.png') no-repeat",
		"width":"200px"
	})
	
	
	$("#menu_6").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","141px");
	$("#menu_6").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","141px");	
	$("#menu_6").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-b-150.png') no-repeat",

		"width":"200px"
	});
	$("#menu_6").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-150.png') no-repeat",
		"width":"200px"
	})	
	$("#menu_6").parent().find("ul.ebene2 >li:not(.ebene3 li) a").css("width","190px");	
	
	$("#menu_7").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","141px");
	$("#menu_7").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","141px");	
	$("#menu_7").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-b-150.png') no-repeat",

		"width":"200px"
	});
	$("#menu_7").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-150.png') no-repeat",
		"width":"200px"
	})		
	
	$("#menu_8").parent().find("ul.ebene1 >li:not(.ebene2 li)").css("width","141px");
	$("#menu_8").parent().find("ul.ebene1 >li:not(.ebene2 li) a").css("width","141px");	
	$("#menu_8").parent().find("ul.ebene1 >li.navi-sub-top:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-top-b-150.png') no-repeat",

		"width":"200px"
	});
	$("#menu_8").parent().find("ul.ebene1 >li.navi-sub-bottom:not(.ebene2 li)").css({
		"background":"url('fileadmin/templates/_images/navi/navi-sub-bottom-150.png') no-repeat",
		"width":"200px"
	})

	

	
	//breite muss h�ndisch angepasst werden
	$("#menu_6").parent().children("ul:first").css("left","-92px");
	$("#menu_7").parent().children("ul:first").css("left","-30px");
	$("#menu_8").parent().children("ul:first").css("left","-79px");	
	
	//alle men�s werden versteckt
	$("#menu ul ul ul ul").hide();
	$("#menu ul ul ul").hide();	
	$("#menu ul ul").hide();
	$("#menu ul div").hide();
	
	$(".navi-sub-bottom").prev().css("border","none");
	
	$("#menu ul.root li:not(.left) a.active").parent().find(".root-active-left").css({
		"background":"url('fileadmin/templates/_images/navi/navi-active2-left.png') no-repeat",
		"display":"block",
		"height":"57px",
		"width":"23px",
		"left":"-23px"
	});
	
	$("#menu ul.root li.left a.active").parent().find(".root-active-left").css({
		"background":"url('fileadmin/templates/_images/navi/navi-active2-left-a.png') no-repeat",
		"display":"block",
		"height":"57px",
		"width":"9px",
		"left":"-9px"
	});
	
	$("#menu ul.root li a.active:first").css({
		"color":"#fff",
		"background":"url('fileadmin/templates/_images/navi/navi-active2-mid.png') repeat-x",
		"font-weight":"normal",
		"height":"57px",
		"position":"relative",
		"padding-top":"22px",												
		"top":"-10px",
		"margin-bottom":"-30px"
	});									
	
	$("#menu ul.root li:not(.right) a.active").parent().find(".root-active-right").css({
		"background":"url('fileadmin/templates/_images/navi/navi-active2-right.png') no-repeat",
		"display":"block",
		"height":"57px",
		"right":"-3px",
		"width":"23px"
	});
	
	$("#menu ul.root li.right a.active").parent().find(".root-active-right").css({
			"background":"url('fileadmin/templates/_images/navi/navi-active2-right-a.png') no-repeat",
			"display":"block",
			"height":"57px",
			"right":"-9px",
			"width":"9px"
	});
	
	$('#menu ul.root>li').hover(
				
				function(){
					
				/*$('#menu ul.root>li').each(function(){
					hideit(this);
				});*/
				
					$(this).children('a').css("zIndex","1000000");
					$('#menu ul.root li a.active:first').parent('li').css("zIndex","1");	
					
					hidevar = false;
					
					if (!$(this).hasClass(".left")){
						$(this).find("a:first").css({
							"color":"#fff",
							"background":"url('fileadmin/templates/_images/navi/navi-active-mid.png') repeat-x",
							"font-weight":"normal",
							"height":"36px",
							"position":"relative",
							"padding-top":"22px",												
							"margin-bottom":"-20px",												
							"top":"-10px"												
						});
						
						
						if ($(this).hasClass("menu-right")){
						
							$(this).find("a:first").parent().find(".root-active-left").css({
								"left":"-17px",
								"width":"17px",
								"background":"url('fileadmin/templates/_images/navi/navi-active-left-b.png') no-repeat"
							});						
							
						} else {
							
							$(this).find("a:first").parent().find(".root-active-left").css({
								"left":"-9px",
								"width":"9px",
								"background":"url('fileadmin/templates/_images/navi/navi-active-left.png') no-repeat"
							});
							
						}
						
						// WENN ES DER LETZTE IST
						if ($(this).hasClass("right")){
							$(this).find("a:first").parent().find(".root-active-right").css({
								"right":"-17px"
							});	
						//
						
						// WENN NICHT DER LETZTE
						} else {
							$(this).find("a:first").parent().find(".root-active-right").css({
								"right":"3px"
							});	
						}
						//

						if ($(this).hasClass("menu-right")){
						
							$(this).find("a:first").parent().find(".root-active-right").css({
									"width":"17px",
									"background":"url('fileadmin/templates/_images/navi/navi-active-right-b.png') no-repeat"
							});	
						
						} else {

							$(this).find("a:first").parent().find(".root-active-right").css({
									"width":"17px",
									"background":"url('fileadmin/templates/_images/navi/navi-active-right.png') no-repeat"
							});	
						
						}
											
						$(this).find("div").show();
					
					} else {
							$(this).find("a:first").parent().find(".root-active-left").css({
								"background":"url('fileadmin/templates/_images/navi/navi-active2-left-a.png') no-repeat",
								"display":"block",
								"height":"57px",
								"width":"9px",
								"left":"-9px"
							});	 

							$(this).find("a:first").css({
								"color":"#fff",
								"background":"url('fileadmin/templates/_images/navi/navi-active2-mid.png') repeat-x",
								"font-weight":"normal",
								"height":"57px",
								"position":"relative",
								"padding-top":"22px",												
								"top":"-10px",
								"z-index":"1000"
							});									
							
							$(this).find("a:first").parent().find(".root-active-right").css({
								"background":"url('fileadmin/templates/_images/navi/navi-active2-right-a.png') no-repeat",
								"display":"block",
								"height":"57px",
								"right":"-3px",
								"width":"23px",
								"z-index":"1000"
							});
						
					}
					$(this).children("ul:first").show();
				},
	
				function(){
					hidevar = true;
					obj = this;
					hideit(obj);
					//&window.setTimeout("hideit(obj)",200);
				});

	
	// EBENE 2
	$('#menu ul.root li ul.ebene1 li').hover(
				 
				function(){
					
					obj_ = this;
					
					hidevar_ = false;
					/*$(this).parent('ul').children('li').children('ul').each(function(){
						if (!$(this).parent('li').hasClass("active")){
							$(this).hide();
						}
					});*/

					$(this).children("a:first").css("font-weight","bold");					
					$(this).children("ul:first").show();
				},
				function(){
					if ((!$(this).children("a:first").hasClass("active"))) $(this).children("a:first").css("font-weight","normal");
					hidevar_ = true;
					obj_ = this;
					hideit_(obj_);
					//window.setTimeout("hideit_(obj_)",200);
				}
 	);
});

function hideit_(obj_){

	if(hidevar_){
		$(obj_).children("ul:first").hide();							
	}
}

function hideit(obj){
	
	if (hidevar){
						$(obj).children('a').css("zIndex","1000");
						$('#menu ul.root li a.active:first').parent('li').css("zIndex","10000000");						

						if (!$(obj).find("a:first").hasClass("active")){
							$(obj).children("a:first").css({
									"color":"#4C4C4C",
									"background":"none",
									"height":"26px",
									"padding-top":"12px",												
									"margin-bottom":"0px",												
									"top":"0px"												
								});
							$(obj).find("ul:first").hide();
							$(obj).find("div").hide();
						} else {
							
								if ($(obj).hasClass(".left")){
									$(obj).find("a.active:first").parent().find(".root-active-left").css({
										"background":"url('fileadmin/templates/_images/navi/navi-active2-left-a.png') no-repeat",
										"display":"block",
										"height":"57px",
										"width":"9px",
										"left":"-9px"
									});
								} else {
									$(obj).find("a.active:first").parent().find(".root-active-left").css({
										"background":"url('fileadmin/templates/_images/navi/navi-active2-left.png')",
										"display":"block",
										"height":"57px",
										"width":"23px",
										"left":"-23px"
									});
								}
								$(obj).find("a.active:first").css({
									"color":"#fff",
									"background":"url('fileadmin/templates/_images/navi/navi-active2-mid.png') repeat-x",
									"font-weight":"normal",
									"height":"57px",
									"position":"relative",
									"padding-top":"22px",												
									"top":"-10px"												
								});									
	
						
							if ($(obj).hasClass(".right")){
								$(obj).find("a.active:first").parent().find(".root-active-right").css({
										"background":"url('fileadmin/templates/_images/navi/navi-active2-right-a.png') no-repeat",
										"display":"block",
										"height":"57px",
										"right":"-9px",
										"width":"9px"
								});
							
							} else {
			
								$(obj).find("a.active:first").parent().find(".root-active-right").css({
									"background":"url('fileadmin/templates/_images/navi/navi-active2-right-a.png') no-repeat",
									"display":"block",
									"height":"57px",
									"right":"-3px",
									"width":"23px"
								});	
								
							}
					}
					
					$(obj).children("ul:first").hide();
					
					$('#menu ul.root li ul.ebene1 li').each(function(){
						hideit_(this);											 
					 });
	}
}