// MAILMASK
window.onload = function noSpam(){
	var links=document.getElementsByTagName('a');
	for(var i=0;i<links.length;i++){
		if(links[i].className=='escape'){
			var mail=links[i].firstChild;
			var domain=links[i].lastChild;
			mail.nextSibling.firstChild.innerHTML='@';
			links[i].href="mailto:"+mail.data+'@'+domain.data;
		};
	};
};

jQuery.noConflict();


jQuery(document).ready(function(){
										  
	// CUFON
    Cufon.replace
	('ul#navi li a', {hover:true, fontFamily: 'Avantage'})
	('h2', {fontFamily: 'Avantage'})
	('h3', {fontFamily: 'Avantage'})
	('h4', {fontFamily: 'Avantage'})
	('.login-shop', {fontFamily: 'Avantage'});
	('#mitglieder-shop p', {fontFamily: 'Avantage'});
	
	// COLORBOX
	jQuery("a[rel='colorbox']").colorbox();
	jQuery("a[rel='lightbox']").colorbox();	
	jQuery("a[rel='lightbox']").colorbox({maxWidth:"600px"}); 
	jQuery(".iframe").colorbox({width:"650", height:"80%", iframe:true});
	
	/* Animation für die Navi oben */
	jQuery("li.drop > ul").hide(); 
	
	
	
	jQuery("#navi li.drop a").mouseover(function(){
		
		jQuery(this).parent().children("ul").stop(true, true).slideDown(600); 
	},function(){
		jQuery(this).parent().children("ul").slideUp(400);
	});
	
	
	jQuery('#navi a')
	.css('background-position',-200)
	.mouseenter(function(){
		jQuery(this).stop(true, true).animate({
			backgroundPosition: 0
		}, 600);
		return false;
	});
	jQuery('#navi a').mouseleave(function(){
		jQuery(this).animate({
			backgroundPosition: -200
		}, 200);
	});

	
	// GOTOTOP
	jQuery('a[href=#top]').click(function(){
        jQuery('html, body').animate({scrollTop:0}, 'slow');
        return false;});
	
	// Nivo-Slider
	jQuery('#slider').nivoSlider({
        effect:'random', //Specify sets like: 'fold,fade,sliceDown'
        slices:7,
        animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
	 
});

// ACCORDION

if(!doc) var doc = document;
if(!win) var win = window;

function acc(settings){
	
	var settings = jQuery.extend({
		active: 'accActive',
		toggle: 'accToggle',
		content: 'accContent',
		accAnchor: 'accAnchor',
		multi: 'multi',
		openFirst: true
	},settings);
	var active = settings.active;
	var toggle = settings.toggle;
	var content = settings.content;
	var accAnchor = settings.accAnchor;
	var multi = settings.multi;
	var openFirst = settings.openFirst;

jQuery('.'+content).hide();
	jQuery('.'+toggle+'.'+multi).each(function(){
		if(jQuery.trim(jQuery(this).text()) == ''){
			jQuery(this).remove();
		}
	});
	$urlElem = jQuery(doc.location.hash);
	$active = $urlElem.hasClass(toggle) ? $urlElem : (openFirst ? jQuery('.'+toggle+':first') : false);
	if($active){
		$active.addClass(active).next('.'+content).show(10,function(){
			if($urlElem.hasClass(toggle)){
				var top = $active.offset().top;
				jQuery(win).scrollTop(top);
			}
		});
	}
	jQuery('.'+toggle+', .'+accAnchor).click(function(){
		$this = jQuery(this);
		$toggler = $this.hasClass(toggle) ? $this : jQuery(jQuery(this).attr('href'));
		var hidden = $toggler.next('.'+content).is(':hidden') ? true : false;
		jQuery('.'+content).slideUp(300);
		jQuery('.'+active).removeClass(active);
		if(hidden){
			if($toggler.hasClass(multi)){
				$toggler.addClass(active).nextUntil('.'+toggle).slideDown(300);
			}else{
				$toggler.addClass(active).next('.'+content).slideDown(300);
			}
		};
	});
};

jQuery(doc).ready(function(){
	acc();
});
