$(document).ready(function () {

	/* _________________________________ Klasse für aktives JavaScript*/
	$('body').addClass('jsactive');

	/* _________________________________ fügt eine Klasse an den letzten Eintrag der rechten Spalte */
	$('.sidebar:last').addClass('last');

	/* _________________________________ Metanavi Sprachumschalter nur aufklappen */
	$('li.lang > a').click(function(){return false});

	/* _________________________________ "+" ersetzen */

	$('body :contains("+")').each(function(){
		if($(this).children().length < 1)
			$(this).html(
				$(this).text().replace(
					/\+/g,
					'<span class="plus">+<\/span>'
				)
			)
	});

	/* _________________________________ Externe Links für Google Analytics v. 2 */

	$('#content a').filter(function() {
		if (this.hostname && this.hostname !== location.hostname) {
			$(this).attr({target:'_blank'}).addClass('external');
			//	pathToTrack = '/gatracker-external/' + $(this).attr('href');
			//	if (pageTracker) $(this).bind('click', function(event) { pageTracker._trackPageview(pathToTrack); });
		} else if ((this.href).match(/(\.pdf|\.txt|\.rtf|\.doc|\.xls|\.ppt|\.sxw|\.odt|\.sxi|\.odp|\.zip|\.rar|\.tar|\.gz|\.tgz|\.exe|\.jpg|\.jpeg|\.png|\.gif|\.wma|\.mov|\.avi|\.mp4|\.mpg|\.flv|\.wmv|\.mp3)$/i)) {
			$(this).attr({target:'_blank'}).addClass('download');
			//pathToTrack = '/gatracker-download/' + $(this).attr('href');
			//if (pageTracker) $(this).bind('click', function(event) { pageTracker._trackPageview(pathToTrack); });
		}
	});

	/* _________________________________ Slideshow initialisieren */
	$('#slider').jshowoff({
		autoPlay: true,
		animatePause: false,
		effect: 'slideLeft',
		hoverPause: true,
		speed: 7000, // delay between each animation
		changeSpeed: 600, // animation speed
		controlText: { play:'abspielen', pause:'pausieren', previous:'vorheriges', next:'nächstes' },
		links: true
	});

	
	if($('#subhead .col-left .image-container img').size() > 1){
		$('#subhead .col-left .image-container').jshowoff({
			autoPlay: true,
			animatePause: false,
			effect: 'slideLeft',
			hoverPause: true,
			speed: 14000, // delay between each animation
			changeSpeed: 600, // animation speed
			links: false
		});
	}

	
	if($('#left #teaser-image img').size() > 1){
		$('body').addClass("teaser-content");
		$('#left #teaser-image').jshowoff({
			autoPlay: true,
			animatePause: false,
			effect: 'slideLeft',
			hoverPause: true,
			speed: 14000, // delay between each animation
			changeSpeed: 600, // animation speed
			links: false
		});
	}
});
