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

function mehrfachAuswahl() {
	var hauptauswahl = document.getElementById('hauptauswahl');
	var multiselect = document.getElementById('multiselect');
	if (multiselect.checked == true) {
  		hauptauswahl.setAttribute("multiple", "multiple", 0);
	}
	else {
		hauptauswahl.removeAttribute("multiple", 0);
	}  
}
//window.onload = mehrfachAuswahl;


$(document).ready(function() {  
										 
	nachOben();	
	$(window).resize(nachOben); 
	
	$('#slide').cycle({  
		fx:      	'fade',
		//fx:      	'curtainX',
		//fx:      	'shuffle',
		//fx:      	'uncover',
		sync:			true,
		speed:    3000,
		timeout:  6000,
		//random:  	1,
		pause:  	1
	});
	
	/*$('noscript.mehrfachauswahl')
		.before('<label for="multiselect" onclick="mehrfachAuswahl()" class="hinweis">\
				<input type="checkbox" name="multiselect" id="multiselect" value="Mehrfachauswahl" /> \
				Mehrfachauswahl mit Strg-(Befehls-)Taste erlauben </label>');*/
		
	$('form.buchanfrage').each(function() {
		mehrfachAuswahl();
	});
			
	$('.epost').yasp();
	
	$('#rahmen').prepend('<a id="top"></a>');
	
	// 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($('form.buchanfrage').length){
		mehrfachAuswahl()
	};
	
	
	// Neues Fenster für Links via Klasse
	$('a.neues-fenster').attr('target', '_blank');
	
	/*$('p.zurueck a').click(function() {
		history.back();
		return false;
	});
*/

});

