$(document).ajaxError(function(e, xhr, opts, err){
	var status = (xhr || {}).status;
	xhr = null;
	setTimeout(function(){
		throw(e.type +' | '+ status +' | '+ opts.url);
	}, 0);
});
// JavaScript Document
$(document).ready(function(){
	
	
		init = function () {
			activateSifr();

			/*	--------------------------------------
			Bildergalerie
			--------------------------------------	*/
	
			$(".pics a .desc").hide();
			$(".pics a").mouseenter(function() {$('.desc',this).fadeTo(300,.9)});
			$(".pics a").mouseleave(function() {$('.desc',this).fadeTo(300,0)});
	
			// custom easing called "custom"
			$.easing.custom = function (x, t, b, c, d) {
					if (t==0) return b;
					if (t==d) return b+c;
					if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
					return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
			}
	
			// enable circular scrollables with a click handler
				$(".scroll").scrollable({ mousewheel: true,easing: 'custom', speed: 1100,circular: true }).autoscroll({ autoplay: true,interval: 5000 });
	
			$('a.browse').mouseenter(function() {$(".browseBg",this).fadeTo(300,.01);});
			$('a.browse').mouseleave(function() {$(".browseBg",this).fadeTo(300,1);});
		}



	/*	--------------------------------------
		Hauptnavigation
		--------------------------------------	*/

		onNaviOver = function(){
			jQuery('#mNav > ul > li > ul').not(jQuery('ul',this)).hide();
			jQuery('ul', this).show();
			return false;
		}
		onNaviLeave = function(){
			jQuery('#mNav > ul > li > ul').not(jQuery('ul.active',this)).hide();
			jQuery('#mNav > ul > li > ul.active').show();
			return false;
		}
		jQuery('#mNav > ul > li').live("mouseover", onNaviOver);
		jQuery('#kontaktleiste').mouseover(onNaviLeave);
		jQuery('#header').mouseleave(onNaviLeave);

	
	//	Hintergrund in Navigation
		$('#mNav ul li:first-child, #meta li:first-child').addClass("first");
	
	
	/*	--------------------------------------
		Mitarbeiterliste
		--------------------------------------	*/
		$('.mitarbeiterliste .col:odd').addClass("odd");




		var dotCounter = 0;
		var intId = setInterval(addDot,1000);
		function addDot(){
			if (dotCounter < 10) {
				dotCounter++;
				$('#dots').append('.');
			} else {
				clearInterval(intId);  
			}
		}
		

	/*	--------------------------------------
		Nachladen von Inhalten - Referenzen
		
		
		http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/
		
		--------------------------------------	*/
		function hideContent(toLoad) {  
			$('#main').fadeTo('slow',.1,loadContent(toLoad));  
		 }  
		function loadContent(toLoad) {
			 $('#wrap').load(toLoad+' #wrap','',showContent())  
		}
		function showContent() {
			$('#main').fadeTo('slow',1,init);  
		}

	 $('.colnavi li a,.browsenavi a').live('click',function(){  
			var toLoad = $(this).attr('href');  
		hideContent(toLoad);
		 return false;  
		 });
	 
	init();
	
});

