$(function(){
	var curHeight = 340;
	var newHeight = 0;	
	var newSubHeight = 0;

	
	/* Dropdowns die per click geöffnet werden z.B. Erweiterte Suche */
     $("ul.dropdown li.clickopen .dropdownEntry").click(function(){   
		if($(this).parents('li.clickopen').find('ul:first').css('visibility')=='visible'){
			$(this).parents('li.clickopen').find('div.dropdownEntry').removeClass("hover");	
			$(this).parents('li.clickopen').find('ul:first').css('visibility', 'hidden');		
			$("#fancy_outer",top.document).css('height',curHeight+'px');	
			$(this).parents('li.clickopen').find('.headerSearchAdvancedSubdropdown ul').css('display', 'none'); 	
			newSubHeight = 0;	
			
		}else{
			newHeight = $(this).parents('li.clickopen').find('ul:first').height();
			curHeight = $("#fancy_outer",top.document).css('height').substr(0,3);			
			$("#fancy_outer",top.document).css('height',(parseInt(curHeight)+parseInt(newHeight)-50)+'px');
			$(this).parents('li.clickopen').find('div.dropdownEntry').addClass("hover");
			$(this).parents('li.clickopen').find('ul:first').css('visibility', 'visible');						
		}	
    });
		
	 $("ul.dropdown li.clickopen").hover(function(){ 		
				/* $('div.dropdownEntry',this).addClass("hover");
				$('ul:first',this).css('visibility', 'visible');   */ 
    }, function(){   		
	    	$('div.dropdownEntry',this).removeClass("hover");
        $('.headerSearchAdvancedSubdropdown ul',this).css('display', 'none'); 
				$('ul:first',this).css('visibility', 'hidden'); 
				$("#fancy_outer",top.document).css('height',curHeight+'px');				
				newSubHeight = 0;	
    });
	
	
	/* Erweitere Suche SubDropdown (z.B. Länder > Deutschland) */	
	$(".dropdownSubEntry").click(function(){ 
		if($(this).parents('.headerSearchAdvancedSubdropdown').find('ul').css('display')=='block'){
			newSubHeight = newSubHeight-$(this).parents('.headerSearchAdvancedSubdropdown').find('ul:first').height();			
			if($(this).parents('#overlayDropdown5').height()){
				newSubHeight = newSubHeight -150;
			}
		}else{
			newSubHeight = newSubHeight+$(this).parents('.headerSearchAdvancedSubdropdown').find('ul:first').height();
			if($(this).parents('#overlayDropdown5').height()){
				newSubHeight = newSubHeight +150;
			}
		}			
			
			
			$("#fancy_outer",top.document).css('height',(parseInt(curHeight)+parseInt(newHeight)+parseInt(newSubHeight)-50)+'px');
			$(this).parents('.headerSearchAdvancedSubdropdown').find('ul').css('visibility', 'visible');	
			$(this).parents('.headerSearchAdvancedSubdropdown').find('ul').slideToggle("fast");
			
		
    });
	
	
});

