var hyphenatorSettings = {
	//hyphenchar : '|',
	displaytogglebox : true,
	minwordlength : 4,
	intermediatestate : 'visible',
	selectorfunction: function () {
		return $('#menue, #text p, #text li, #text dl, #newsbox p, #text table, .innenrahmen h2, .innenrahmen h3, fieldset, form, label');
	}/*,
	onhyphenationdonecallback : function () {
		return $('#text p, #text li, #text dl, #newsbox p').css({
				 'text-align' : 'justify'
		});
	}*/,
	onerrorhandler : function (e) {
        //do nothing
    }
};
Hyphenator.config(hyphenatorSettings);
Hyphenator.run();

Shadowbox.loadSkin('doerr', 'http://www.doerr-haus.de/_js/shadowbox/skin');
Shadowbox.loadLanguage('de-DE', 'http://www.doerr-haus.de/_js/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'http://www.doerr-haus.de/_js/shadowbox/player');

$(document).ready(function() {  
			
	$('.epost').yasp();
	
	$('span[id^=bild]').preload();
	
	/*if($.browser.msie && $.browser.version <= 8){
		$('span[id^=bild] img').show('fast');
	}
	else {
		$('span[id^=bild]').preload().find('>img').fadeIn(1000);
	};*/

	$('#bild1').cycle({
		fx:    'fade',
		pause:  0,
		random: 1,
		speed:    2000,
		timeout:  12000,
		sync:  true,
		delay: -8000
	});
	$('#bild2').cycle({
		fx:    'fade',
		pause:  0,
		random: 1,
		speed:    2000,
		timeout:  12000,
		sync:  true,
		delay: -6000
	});
	$('#bild3').cycle({
		fx:    'fade',
		pause:  0,
		random: 1,
		speed:    2000,
		timeout:  12000,
		sync:  true,
		delay: -4000
	});
	$('#bild4').cycle({
		fx:    'fade',
		pause:  0,
		random: 1,
		speed:    2000,
		timeout:  12000,
		sync:  true,
		delay: -2000
	});
	
	$('#text p, #text li, #text dl, #newsbox p')
			.css({'text-align' : 'justify'});
			
	$('#inhalt .innenrahmen p:last-child, #inhalt .innenrahmen ul:last-child, #inhalt .innenrahmen ol:last-child, #inhalt .innenrahmen dl:last-child, #inhalt .innenrahmen li:last-child')
			.css({'margin-bottom' : '0'});	
	
	//Shadowbox Initialisierung und Konfiguration  
	var options = {
			//gallery:      	'Slideshow',
			counterType:		'default',
			counterLimit:		20,
			continuous:			true,
			animSequence:		'sync',
			slideshowDelay:	6,
			//fadeDuration: 	2,
			overlayOpacity:	0.8
	};
	Shadowbox.init(options);
	
	/*Shadowbox.init({
		skipSetup:true
	});
	Shadowbox.setup($('a.shadowbox'),{
		overlayOpacity:	0.6
	});
	Shadowbox.setup($('a.shadowbox-slideshow'),{
		gallery:        'Slideshow',
		counterType:	'default',
		counterLimit:	10,
		continuous:		true,
		animSequence:	'sync',
		slideshowDelay:	6,
		overlayOpacity:	0.8
	});
	$('#text').append('<a class="shadowbox-slideshow"><!-- Fake, um Script-Fehler zu vermeiden --></a>');*/
	
	if($.browser.msie && $.browser.version <= 8){
		$('input[type=text], textarea').focus(
			function() {
				$(this).css({'border-color':'#004a99'});
				//$(this).parents('span').find('> input[type=checkbox').css({'display':'none'});
		});
		$('input[type=text], textarea').blur(
			function() {
				$(this).css({'border-color':'#b7b7b7'});
		});
	};
	if($.browser.msie && $.browser.version <= 7){
		$('input[type=checkbox]').addClass('checkbox');
		$('input[type=radio]').addClass('radio');
	};
	
	$('#rahmen').prepend('<a id="top"></a>');
	var $topLink = $('p.nachoben');

	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', '');
		 }
		});
	};
	
	
	// Neues Fenster für Links via Klasse
	$('a.neues-fenster').attr('target', '_blank');
	
	
	// Erweiterte Formularfunktionen (primär doerr-immo.de)
	$('#anfrageart').find('select').change(function() {
			$('#anfrageart')
				.submit()
				.find('select')
				.addClass('laden')
				.after(' <img src="http://www.doerr-haus.de/_img/loadingAnimation.gif" alt="" class="select-ersatz" /> Laden&hellip;');
			$('#kontaktformular')
				.addClass('wechsel')
				.find('input, textarea, select, button')
				.attr('disabled','disabled')
				.addClass('disabled');
	})
	.end()
	.find('button')
	.remove()
	.end()
	.find('select')
	.addClass('autochange');
	
											 
	$('.zusatzoptionen')
	.find('input, textarea, select, button, label')
	.attr('disabled','disabled')
	.addClass('disabled');
				
	$('span.noscript').remove()


});

