function blockSatz() { 
	var blocksatz = $('#inhalt p, #inhalt ul:not(#inhaltsmenue)').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 $('#inhalt p, #inhalt ul:not(#inhaltsmenue)');
	}/*,
	onhyphenationdonecallback: function () {
		blockSatz();
	}*/

};
Hyphenator.config(hyphenatorSettings);
Hyphenator.run();


function showroom() { 		

	// FancyBox
	$('a.shadowbox').fancybox({
		'padding'					: '0',
		'overlayShow'			: false,
		'zoomSpeedIn'			: 800,
		'zoomSpeedOut'		: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack',
		'easingChange'		: 'easeInBack',
		'callbackOnStart'	:	function(){ 
				$('div#fancy_close').html('<a href="javascript:;" title="Schlie&szlig;en"></a>');
		}
		
	})
	.attr('rel', 'slide');

	$('#blaettern a').each(function(){	
																	
		var url = $(this).attr('href');	
		var zielinhalt = ' #bildinhalt';
			
		$(this).click(function(){
			$(zielinhalt).fadeOut('normal').load(url + zielinhalt, function() {
				$(this).customFadeIn('slow');
			});
			return false;
		});
	
	})
	.parent()
	.find('a:has(img.zurueck)').addClass('zurueck blaettern')
	.end()
	.find('a:has(img.weiter)').addClass('weiter blaettern');
	
};

function viewPort() { {
	
	var viewportHeight = $(window).height();
	var documentHeight = $(document).height()-4;
	var topLink = $('p.nachoben');
	var topLinkEnde = $('p:last-child.nachoben');
	var topLinkHTML = $('<p class="nachoben"><a href="#" title="zum Seitenanfang">nach oben</a></p>');
	
	topLink.find('> a').click(function(){
		$.scrollTo( '#top', 500 );
		return false;
	});
	
	/*if(viewportHeight < documentHeight){
		if($('#text:has(p:last-child.nachoben))'))
		topLinkHTML.appendTo('#text');
	}
	else {
		topLinkEnde.remove();
	}*/
	
	if(viewportHeight < documentHeight){
		topLinkEnde.show();
	}
	else {
		topLinkEnde.hide();
	}
	
};

};


$(document).ready(function() {  
													 
	viewPort();
	$(window).wresize(viewPort);
	
	/* JS-generiertes Element zur Vermeidung eines Anzeige-Bugs bei Resize-Event 
	-> Untermenü wird abgeschnitten, als hätte #kopf overflow: hidden! (Opera sucks) */
	if($.browser.opera){
		$('#kopf').wrapInner('<div id="opera-fix"></div>');
	};
			
	// Lesefreundliche E-Mail-Adressausgabe
	$('span.at').replaceWith('&#64;');
	$('span.dot').replaceWith('&#46;');
	//$.cssRule('#rahmen a.mail-adresse', 'cursor:pointer; text-decoration:underline; color: #c4002c');
	
	if($('#bildinhalt').length) {
		$('#bildansicht').append('<span class="laden"></span>');
	};
	
	
	if($.browser.msie && $.browser.version <= 8){
		$('input[type=text], textarea, select').focus(
			function() {
				$(this).css({'border-color':'#004a99'});
				//$(this).parents('span').find('> input[type=checkbox').css({'display':'none'});
		});
		$('input[type=text], textarea, select').blur(
			function() {
				$(this).css({'border-color':'#b7b7b7'});
		});
	};
	if($.browser.msie && $.browser.version <= 7){
		$('input[type=checkbox]').addClass('checkbox');
		$('input[type=radio]').addClass('radio');
	};
	
	//$('body').prepend('<a id="top"></a>');

	/*if($(window).height() < $(document).height()){
		$topLink.show().find('> a').click(function(){
			$.scrollTo( '#top', 500 );
			return false;
		});
	}
	else {
		$topLink.hide();
	};
	$(window).resize(function(){
		if($(window).height() < $(document).height()){
			$topLink.show().find('> a').click(function(){
				$.scrollTo( '#top', 500 );
				return false;
			});
		}
		else {
			$topLink.hide();
		};
	});*/
	
	// Leeres TITLE-Attribut an IMG anhängen -> keine ALT-Text-Tooltips in IE bis v7
	if($.browser.msie && $.browser.version <= 7){

		$('img:not([title])').each(function() {
		 
		var bildtitel = $(this).parents('a');
		
		if($(bildtitel).attr('title')){
			$(this).attr('title', $(bildtitel).attr('title'));
		 }
		else{
			$(this).attr('title', '');
		 }
		});
		
	};
	
	if($.browser.msie && $.browser.version <= 8){
		$('#inhalt #text')
			.find('p:last-child, ul:last-child, ul:last-child li:last-child')
			.addClass('last-child');
	};
	
	// Neues Fenster für Links via Klasse
	$('a.neues-fenster').attr('target', '_blank');
	
	showroom();
			
/*	$('a#fadeOut').click(function() {
		$('ul').customFadeOut('slow');
		return false;
	});
	$('a#fadeIn').click(function() {
		$('ul').customFadeIn('slow');
		return false;
	});*/


// Ende $(document).ready(function()
});


$(document).ajaxStop(function(){	
															
	showroom();	
	
});