function blockSatz() { 
	//var blocksatz = $('#text, div[class^=textspalte-] p, div[class^=textspalte-] li, div[class^=textspalte-] dl').css({'text-align' : 'justify'});
	var blocksatz = $('#text').css({'text-align' : 'justify'});
	return blocksatz;
};

var hyphenatorSettings = {
	//hyphenchar : '|',
	displaytogglebox : true,
	togglebox : function (s) {
		var textAktiv = 'Sil-ben-tren-nung ak-ti-viert';
		var myBox;
		if (!!(myBox = document.getElementById('HyphenatorToggleBox'))) {
			if (s) {
				myBox.firstChild.data = textAktiv;
			} else {
				myBox.firstChild.data = 'Silbentrennung deaktiviert';
			}
		} else {
			var bdy, myIdAttribute, myTextNode, myClassAttribute; 
			bdy = document.getElementsByTagName('body')[0];
			myBox = document.createElement('div');
			myIdAttribute = document.createAttribute('id');
			myIdAttribute.nodeValue = 'HyphenatorToggleBox';
			myClassAttribute = document.createAttribute('class');
			myClassAttribute.nodeValue = 'donthyphenate';
			myTextNode = document.createTextNode(textAktiv);
			myBox.appendChild(myTextNode);
			myBox.setAttributeNode(myIdAttribute);
			myBox.setAttributeNode(myClassAttribute);
			myBox.onclick =  Hyphenator.toggleHyphenation;
			bdy.appendChild(myBox);
		}
	},
	minwordlength : 4,
	intermediatestate : 'visible',
	selectorfunction: function () {
		return $('#text, div[class^=textspalte-], ul#hauptmenue > li > a');
	},
	onhyphenationdonecallback : function () {
		/*blockSatz();*/
		$('div#menuebox').css({
				 'table-layout' : 'fixed'
		});
	}
};
Hyphenator.config(hyphenatorSettings);
Hyphenator.run();

function nachOben() { 	

	var viewportHeight = $(window).height();
	var documentHeight = $(document).height()-75;
	var topLink = $('p.nachoben');

	if(viewportHeight < documentHeight){
		$(topLink).show().find('> a').click(function(){
			$.scrollTo(0, 800, {easing:'easeOutExpo'});
			return false;
		});
	}
	else {
		$(topLink).hide();
	};
};


$(document).ready(function() {
													 
	nachOben();	
	$(window).resize(nachOben); 
	
	$('.noscript').removeClass('noscript');
	

	/*** Superfish-Menü konfigurieren ***/
	$('ul#hauptmenue').superfish({
		hoverClass:     'hover',
		//pathClass:    'aktiv',
		//pathLevels:	1,                             // the number of levels of submenus that remain open or are restored using pathClass
		delay:			600,                           // delay in ms on mouseout
		animation:		{height:'toggle'},             // fade-in animation
		/*animation:			{opacity:'toggle',height:'toggle'},// fade-in and slide-down animation
		onShow:					function(){
											var dropDownFix = $(this).find('.dropdown');
											if ($.browser.msie)  
            						document.dropDownFix.style.removeAttribute('filter');
										},*/
		speed:			400,                           // faster animation speed
		autoArrows:		false,                         // disable generation of arrow mark-up
		dropShadows:	true                           // disable drop shadows
	})
	.find('> li > a:not(:only-child)')
	.addClass('dropdown-hinweis');
	
	
	$('div#block-links:only-child').after('<div class="menue" id="submenue"></div>');
	
	$('ul.submenue').each(function(event){
																 
		var menuepunkt = $(this).parents('li');
		var menuelink = menuepunkt.find('> a');
		var menuebreite = menuepunkt.outerWidth() + 10;
		var menueblock = $(this).parents('body:eq(0)').find('#submenue');			 
		var position = menuelink.position();

		$(this)
			.parents('li.aktiv').find('ul.submenue')
			.clone()
			.appendTo(menueblock)
			.css({'display' : 'block', 'visibility' : 'visible'});
			
		$(this)
			.remove()
			.insertAfter(menuelink)
			.removeClass('submenue')
			.addClass('dropdown')
			.css({'display' : 'none', 'visibility' : 'hidden', 'min-width' : menuebreite, 'left' : position.left});
	});


	if($.browser.msie && $.browser.version <= 7){
		
		$('ul#hauptmenue').supersubs({ 
					minWidth:    15,   	// minimum width of sub-menus in em units 
					maxWidth:    30,   	//maximum width of sub-menus in em units 
					extraWidth:  1     	// extra width can ensure lines don't sometimes turn over 
										// due to slight rounding differences and font-family 
		});
		
		
		/*** Submenü-Überschrift für IE <= 7 ***/
		//var textStr = $('li[id^=m-]').find('> a strong').text();
		var subHead = $('ul#hauptmenue > li.aktiv > a').text();
		$('.menue').find('ul.submenue').prepend('<h3>' + subHead + '</h3>');
	};
	
	if($.browser.msie && $.browser.version <= 6){
		$('div.newstext a').each(function() {
			var newsHref = $('div.newstext a').attr('href');
			$('div.newstext').css({'cursor' : 'hand'}).click(function() {
				window.location.href=newsHref;
			});
		});
	};

	$('.epost').yasp();
	
	$('a.marker').click(function(){
		$.scrollTo( '#twGmap', 800 );
		return false;
	});
	
	$('li#m-shop > a').click(function(){
		window.open(this.href);
		return false;
	});
	
});
