$(function() { 

	// Facebook-Galerie
/* 	if($('#facebook-galerie').length) { 
		$('#facebook-galerie').prepend('<div id="loader">&hellip;Inhalte werden geladen&hellip;</div>');
		$.getJSON('https://graph.facebook.com/269652816404408/photos?callback=?', function(data) {
			$.each(data.data, function(key, val) {				
				var $a 	 = $('<a />').attr({ rel: 'shadowbox[facebook]', title: val.from.name, href: val.source }).text('');
				var $img = $('<img />').attr({ src: val.picture, alt: val.from.name });
				$a.appendTo('#facebook-galerie');
				$img.appendTo($a);			
			});			
			Shadowbox.init();
			$('a[rel^="shadowbox"]').shadowbox();
			$('#loader').remove();
		});
	}; */

	// Scrollbar
	if($('.scrollbox, .scrollbox2').length) { 
		$('.scrollbox, .scrollbox2').jScrollPane({ 
			showArrows: true, 
			scrollbarWidth: 15, 
			arrowSize: 15
		});
	};
	
	// Navigation
	$('#nav li a[href$="ueber-ropelius.htm"], #nav li a[href$="about-ropelius.htm"]').parent().addClass('ueber-ropelius');
	$('#nav li a[href$="portfolio.htm"], #nav li a[href$="portfolio-en.htm"]').parent().addClass('portfolio');
	$('#nav li a').attr({ title: '' });
	var langspeed = 400;
	var navspeed = 1200;
	$('#nav li:not(.aktiv) ul').addClass('aus'); 	
	function auf() { 
		$('#nav li').removeClass('hover');
		$(this).addClass('hover');
		$('#nav li:not(.hover) ul').each(function() { 
			var width = $(this).width();
			$(this).stop().animate({ marginLeft: '-'+width+'px' }, navspeed, function() { 
				$(this).hide();
			});
		});
		$(this).find('ul').stop().show().animate({ marginLeft: '0px' }, navspeed);
		//$('a.sprachwahl').stop().animate({ opacity: 0 }, 400, function() { $(this).hide(); });
	};
	function zu() { 
	};
	$('#nav li:has(ul)').hoverIntent({
		sensitivity: 5, 
		interval: 150, 
		over: auf, 
		timeout: 350, 
		out: zu 
	});
	
	// Shadowbox
	if($('a[rel^="shadowbox"]').length) {
		Shadowbox.init();
		$('a[rel^="shadowbox"]').shadowbox();
	};

	// PNG für IE6
	if($.browser.msie && $.browser.version < 7) { 
		$('#inhalt').pngFix();
	};

	// Fenstergröße
	getWindowSize(0);
	$(window).resize(function() { 
		getWindowSize(400);	
	});

	// Schriften
	Cufon.replace('#nav li a, table.kompetenzen td a, a.sprachwahl, .precious, .precious_weiss, .precious_rot', { hover: true });
	

	$('a').attr({ title: '' });
	$('img').attr({ alt: '' }).attr({ title: '' });
});


// Fenstergröße
function getWindowSize(speed) { 
	var hoehe = $(window).height();
	var neueHoehe = -34;
	var bgPos = -2079;
	if(hoehe-790 > 0) { 
		var neueHoehe = hoehe-790;
		var bgPos = (-3000+hoehe)+162;
	}
	$('#container').stop().animate({ marginTop: neueHoehe+'px' }, speed);
	$('body').stop().animate({ backgroundPosition: '0 '+bgPos+'px' }, speed);
}


// dumb: example -> alert(dump(assoc));
function dump(a,b){var c="";if(!b)b=0;var d="";for(var j=0;j<b+1;j++)d+="    ";if(typeof(a)=='object'){for(var e in a){var f=a[e];if(typeof(f)=='object'){c+=d+"'"+e+"' ...\n";c+=dump(f,b+1)}else{c+=d+"'"+e+"' => \""+f+"\"\n"}}}else{c="===>"+a+"<===("+typeof(a)+")"}return c};

