/*** ABBR-Tag-Workaround für IE ***/
document.createElement('abbr');

/*** Blocksatz bei Silbentrennung (optional) ***/
function blockSatz() { 
	var blocksatz = $('#inhalt').css({'text-align' : 'justify'});
	return blocksatz;
};

/*** Einstellungen für Silbentrennung ***/
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 : 6,
	intermediatestate : 'hidden',
	remoteloading: false,
	selectorfunction: function () {
		return $('#inhalt');
	},
	onhyphenationdonecallback : function () {
		blockSatz();
	}
};
Hyphenator.config(hyphenatorSettings);
Hyphenator.run();

/*** dynamisches Ein-/Ausblenden des Links zum Seitenanfang mit sanftem Scrollen ***/
function nachOben() {
	var viewportHeight = $(window).height();
	var documentHeight = $(document).height()-50;
	var topLink = $('p.nachoben');
	
	if(viewportHeight < documentHeight){
		topLink.show().find('> a').click(function(){
		$('html, body').animate({
				scrollTop: 0
			}, {
				duration: 500,
				specialEasing: { 
					scrollTop: 'easeInQuad' // ohne jQuery-Easing-Plugin: 'linear' oder 'swing'!
				}
			});
		return false;
		});
	}
	else {
		topLink.hide();
	}
};

/*** Initiierung wenn DOM geladen ***/
$(function(){
	
	/*** E-Mail-Spam-Schutz ***/
	$('.epost').yasp();

	/*** dynamisch generierter Google-Map-iFrame für Strict-Validität ***/
	var href = $('#googlemap a').attr('href');
	$('#googlemap a')
		.clone()
		.appendTo('#googlemap')
		.attr('target', '_blank')
		.text('Größere Kartenansicht')
		.wrap('<small></small>');
	$('#googlemap span a')
		.wrap('<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowtransparency="true" src="' + href + '&amp;output=embed' + '"></iframe>');
	
	/*$('body.studio-start #hilfsmenue ul').each(function() {
														
		var hmHeight = $('#hilfsmenue ul').height();
		var hmWidth = $('#hilfsmenue ul').width();
		var hmSubParent = $('#hilfsmenue ul').each(function() { $(this).parents('li'); });
		var hmSubParentWidth = $('#hilfsmenue ul').each(function() { $(this).parents('li').outerWidth(); });
		var offsetRight = hmSubParent.position();
		
		$(this)
			.css({
					'opacity': '0',
					'top': '0',
					'right': offsetRight.left,
					'width': '0px'
			}).animate({ 
					opacity: 1,
					top: '1.75em',
					right: '0', 
					width: hmWidth
				}, 3000, 'easeInOutQuart', function(){
						if ($.browser.msie)  
						this.style.removeAttribute('filter');
					}
			);
	});*/
			
	/*** Sanftes Einblenden von Bild-Elementen (und Map-Frame) bei Seitenaufruf ***/	   
	$('#inhalt')
	.find('p#googlemap iframe')
	.hide()
	.fadeIn(3000)
	.end()
	.find('p.bilder img, div.bildspalte img')
	.hide()
	.fadeIn(2000);
	
	/*** neue Fenster via JS für Strict-Validität ***/
	$('a.neues-fenster, a.externer-link').click(function(){
		window.open(this.href);
		return false;
	});

	/*** Funktionsuafruf für Link zum Seitenanfang ***/
	$(window).resize(nachOben); 
	nachOben(); 

});	
