$(document).ready(function(){
	$("li.layer0").click(function(){
											 
									if ($(this).next("ul."+$(this).attr("owner")).length){
										$("ul.l4").hide();
										$("ul.l3").hide();
										$("ul.l2").hide();
										$("ul.l1").hide();
										$(this).next("ul."+$(this).attr("owner")).toggle();
										
								  		return false;
									}
								 			  
								  });
	$("li.layer1").click(function(){
										 
									if ($(this).next("ul."+$(this).attr("owner")).length){
										$("ul.l4").hide();
										$("ul.l3").hide();
										$("ul.l2").hide();
										$(this).next("ul."+$(this).attr("owner")).toggle();
										
								  		return false;
									}
								 			  
								  });
	$("li.layer2").click(function(){
										 
									if ($(this).next("ul."+$(this).attr("owner")).length){
										$("ul.l4").hide();
										$("ul.l3").hide();
										$(this).next("ul."+$(this).attr("owner")).toggle();
										
								  		return false;
									}
								 			  
								  });
	$("li.layer3").click(function(){
										 
									if ($(this).next("ul."+$(this).attr("owner")).length){
										$("ul.l4").hide();
										$(this).next("ul."+$(this).attr("owner")).toggle();
										
								  		return false;
									}
								 			  
								  });
	
						$("li.layer0[id='activ']").next("ul.l1").show();
					
	
	d1 = $("ul.l1").length;
				
				for (i=0; i<d1; i++){
					if ($("ul.l1").eq(i).find("li[id='activ']").length !== 0){
						$("ul.l1").eq(i).show();
					}
				}
	d2 = $("ul.l2").length;
				
				for (i=0; i<d2; i++){
					if ($("ul.l2").eq(i).find("li[id='activ']").length !== 0){
						$("ul.l2").eq(i).show();
					}
				}
	d3 = $("ul.l3").length;
				
				for (i=0; i<d3; i++){
					if ($("ul.l3").eq(i).find("li[id='activ']").length !== 0){
						$("ul.l3").eq(i).show();
					}
				}
	d4 = $("ul.l4").length;
				
				for (i=0; i<d4; i++){
					if ($("ul.l4").eq(i).find("li[id='activ']").length !== 0){
						$("ul.l4").eq(i).show();
					}
				}
	
});


