$(function() { 

	// 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);
}