$.fn.noSpam = function() {
	var at = '@';
	return this.each(function(){
		var e = null;
		$(this).find('span').replaceWith(at);
		e = $(this).text();
		$(this).attr('href', 'mailto:' + e);
	});
};

$.fn.topLink=function(settings){
	settings=$.extend({min:1,fadeSpeed:200,scrollSpeed:1000,topPos:0,ieOffset:50},settings);
	return this.each(function(){
		var el=$(this);
		$(window).scroll(function(){
			if(!jQuery.support.hrefNormalized)el.css({'position':'absolute','top':$(window).scrollTop()+$(window).height()-settings.ieOffset}); //ie 6 fix
			if($(window).scrollTop()>=settings.min)el.fadeIn(settings.fadeSpeed);
			else el.fadeOut(settings.fadeSpeed);
		});
		el.click(function(){
			$('html,body').animate({scrollTop:settings.topPos},settings.scrollSpeed);
			return false;
		});
	});
};


function slideSwitch() {
	var ct = $('#slideshow > *').length;
    var $active = $('#slideshow li.active');
    if ( $active.length == 0 ) $active = $('#slideshow li:last');
    var $next =  $active.next().length ? $active.next() : $('#slideshow li:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


/*--- fancybox ------------------------------------*/
		jQuery(document).ready(function() {
			jQuery("a[class=zoom]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'overlayOpacity'	:	0.5,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			
			jQuery("a.iframe").fancybox({
				'easingIn, easingOut': true,
				'frameWidth':610,
				'frameHeight':700,
				'overlayOpacity'	:	0.3,
				'overlayColor'		:	'#cccccc'
			});
		
		
accordion();
});
		


/*--- accordion ------------------------------------*/

function accordion(){
	jQuery('.inhalt').slideUp();
//	jQuery('.inhalt:first').slideDown();
	jQuery('.click').click(function(){
			jQuery('.inhalt').slideUp('slow');
			jQuery('.activeClick').removeClass('activeClick');
		if(jQuery(this).next('.inhalt').css('display') == 'none'){
			jQuery(this).next('.inhalt').slideDown('slow');
			jQuery(this).addClass('activeClick');
		}
	});
};

$(document).ready(function() {
	$("a[rel='lightbox']").fancybox();
	$('a.email').noSpam();
	$('a.scrollToTop').topLink();
	$("a[href^='http:']:not([href*='" + window.location.host + "'][target='_blank'])").live('click', function(){
		$(this).attr('target','_blank');
	});
});

