$(document).ready(function() {
	if( $("body").width() <= 1100 ) 
	{
		$("div.page_margins").css( 'margin-left', '10px' );
		$("#topnav").css( 'margin-left', '10px' );
		$("#header").css( 'margin-left', '10px' );
	}	
		
	$("a.mehr-button").click(
		function () 
		{
  		$("div.box-grau-bar-mehr").toggle("slide", { direction: "up" }, 1000);
		}
		);	
		
		
	$('ul.hauptnavigation > li').not('.thema').hover( function(e) {
        $(this).addClass('drop-aktiv').children('ul.hauptnavigation > li > ul').show()
    }, function() {
        $(this).stop().removeClass('drop-aktiv').children('ul.hauptnavigation > li > ul').hide();
    }); 

	
	if ($.browser.msie) {   			
		if (jQuery.browser.version.substr(0, 1) != "6") {		
			$('ul.hauptnavigation > li.thema > a.thema').removeAttr("href");	
			$('ul.hauptnavigation > li.thema > a.thema').click( 
				   function(e)
				   {	   						   		
				   		if( $('ul.hauptnavigation > li.thema').hasClass('drop-aktiv') ) {
							$('ul.hauptnavigation > li.thema').removeClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideUp(50);
							$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #a7b5c3');
							$('ul.dropdown').slideUp(50);
							$('ul.hauptnavigation > li.thema').children('a.thema').removeClass('thema_close');			
					   		//$('#brotkrumen').animate({'height': '30px' }, 50);	
							//$('#brotkrumen .brotkrumen').animate( {'padding': '0px 0 0 0' }, 50, 'linear');					
						} else {
					   		$('ul.hauptnavigation > li.thema').addClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideDown(150);	
							$('ul.hauptnavigation > li.thema').children('a.thema').addClass('thema_close');	
							$('ul.dropdown').slideDown(150);
							$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #C5D3E0');							
							//$('#brotkrumen').animate({'height': '360px' }, 150);	
							//$('#brotkrumen .brotkrumen').animate( {'padding': '330px 0 0 0' }, 150, 'linear');	
							$(document.body).click(
								function(){
							   		$('ul.hauptnavigation > li.thema').removeClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideUp(50);
									$('ul.hauptnavigation > li.thema').children('a.thema').removeClass('thema_close');		
									$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #a7b5c3');
									$('ul.dropdown').slideUp(50);	
							   		//$('#brotkrumen').animate( {'height': '30px' }, 50);	
									//$('#brotkrumen .brotkrumen').animate({'padding': '0px 0 0 0' }, 50, 'linear');				
								}					
							);														
						}
						e.preventDefault();
						e.returnValue = false;
  						return false;
				   }
			); 	
		} 
	} else {
		$('ul.hauptnavigation > li.thema > a.thema').click( 
			   function()
			   {
			   		if( $('ul.hauptnavigation > li.thema').hasClass('drop-aktiv') ) {
						$('ul.hauptnavigation > li.thema').removeClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideUp(50);
						$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #a7b5c3');
						$('ul#thema-dropdown').slideUp(50);
						$('ul.hauptnavigation > li.thema').children('a.thema').removeClass('thema_close');							
						//$('#brotkrumen .brotkrumen').animate({'padding': '0px 0 0 0' }, 50, 'linear');						   									
					} else {
				   		$('ul.hauptnavigation > li.thema').addClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideDown(150);	
						$('ul#thema-dropdown').slideDown(150);
						$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #C5D3E0');
						$('ul.hauptnavigation > li.thema').children('a.thema').addClass('thema_close');	
						//$('#brotkrumen .brotkrumen').animate({'padding': '330px 0 0 0' }, 150, 'linear');					
						$(document.body).click(
							function(e){								
						   		$('ul.hauptnavigation > li.thema').removeClass('drop-aktiv');//.children('ul.hauptnavigation > li.thema > ul').slideUp(50);
								//if(e.target.href !== undefined) { $('ul#thema-dropdown').slideUp(50).delay(500); } else { $('ul#thema-dropdown').slideUp(50); }
								$('ul#thema-dropdown').slideUp(50);
								$('ul.hauptnavigation > li.thema').css('border-bottom', '1px solid #a7b5c3');
								$('ul.hauptnavigation > li.thema').children('a.thema').removeClass('thema_close');		
								//$('#brotkrumen .brotkrumen').animate({'padding': '0px 0 0 0' }, 50, 'linear');					
							}					
						);														
					}
					return false;
			   }
			); 		
	}
						
						
	$('a#rss-links').click(
		function() {
			$('div#rss-links-box').toggle();
			return false;
		}
	);	
	
});

function checkWallpaper() { 
	if (typeof(adtype) != 'undefined') { 
		if (adtype == 'wallpaper') { 
			// Schiebe Skyscraper rechtsbündig an Leaderboard 
			$("div.bannertop").css( 'margin-left', '79px' );
			$("div.skyscraper").css( 'top', '20px' );
			
			if ($.browser.msie) {   			
				if (jQuery.browser.version.substr(0, 1) == "6") {
					$("div.bannertop").css( 'margin-left', '76px' );
				} else if (jQuery.browser.version.substr(0,1) == "7" ) {
					$("div.bannertop").css('margin-left', '80px');			
				} else {
					$("div.bannertop").css('margin-left', '80px');		
				}
			}	
		} 
		if (adtype == 'expwallpaper') { 
			// Schiebe Sky rechts unter das Leaderboard 	

			var defaultWidth = 120;		
			var skyscraperWidth = $("div.skyscraper").width();
			var addWith = skyscraperWidth - defaultWidth;
			var defaultMarginLeft = 199;
			var marginLeft = defaultMarginLeft + addWith;

			$("div.bannertop").css( 'margin-left', marginLeft+'px' );
			
			if ($.browser.msie) {   			
				if (jQuery.browser.version.substr(0, 1) == "6") {
					$("div.bannertop").css('margin-left', '196px');
					$("div.skyscraper").css('margin-top', '90px');
				} else if (jQuery.browser.version.substr(0,1) == "7" ) {
					$("div.bannertop").css('margin-left', '180px');
					$("div.skyscraper").css('margin-top', '90px');					
				} else {
					$("div.skyscraper").css( 'margin-top', '90px' );
				}
			} else {
				$("div.skyscraper").css( 'top', '110px' );
			}			
		} 
	}
	if (typeof(bgcolor) != 'undefined' && bgcolor != null) { 
		// Färbe mögliche Bereiche ein 		
		$("body").css( 'background-color', bgcolor );
		$("body").css( 'background-image', 'none' );
		$("#header").css( 'background-color', '#fff' );
		$("#modulnavigation").css( 'background-color', '#fff' );
	} 
	if (typeof(bgimage) != 'undefined' && bgimage != null) { 
		// Setze Hintergrund Bild 	
		$("body").css( 'background-image', "url('" + bgimage + "')" );
		$("#header").css( 'background-color', '#fff' );
		$("#modulnavigation").css( 'background-color', '#fff' );
	} 
	if (typeof(adclick) != 'undefined' && adclick != null) { 
		// Verlinke bei Klick auf Hintergrund auf adclick 
	} 
} 
