$(document).ready(function() {

	// navi-ebene 2 ausrichten
	if ($('#second ul').length > 0) {
		var naviText = $('#first .active').text();
		var posXWrapper = $('#wrapper').offset().left;
		var posX = $('#first .active').offset().left;
		var newPos = posX-posXWrapper-440;
		
		// bei navipunkt presse und galerie müssen wir etwas weiter nach links rücken
		if (naviText == 'presse') {
			newPos = newPos-30;
		}
		if (naviText == 'galerie') {
			newPos = newPos-80;
		}
		
		$('#second').css({
			'margin-left': newPos
		});
	}
	
	if ($('a[@rel*=lightbox1]').length > 0) {
		$(function() {
		   $('a[@rel*=lightbox1]').lightBox({});
		});
	}
	
	if ($('a[@rel*=lightbox2]').length > 0) {
		$(function() {
		   $('a[@rel*=lightbox2]').lightBox({});
		});
	}
	
	if ($('a[@rel*=lightbox3]').length > 0) {
		$(function() {
		   $('a[@rel*=lightbox3]').lightBox({});
		});
	}
	
	if ($('a[@rel*=lightbox4]').length > 0) {
		$(function() {
		   $('a[@rel*=lightbox4]').lightBox({});
		});
	}
	
	if ($('a[@rel*=lightbox5]').length > 0) {
		$(function() {
		   $('a[@rel*=lightbox5]').lightBox({});
		});
	}
	
	// presse-artikel - div des bildes ausblenden, wenn nicht vorhanden und content breiter machen
	$('.artikelinhalt').each(function(index) {
			if ($(this).find('.bild img').length == 0) {
			   $(this).find('.bild').css({'display':'none'});
			   $(this).find('.artikelcontent').css({'display':'block', 'float':'none', 'width':'auto'});
			   //$(this).find('.artikelcontent p').css({'padding-bottom':'0px'});
			}
	});
	
	// check browser - constants
	var OS_VERSION = navigator.appVersion;
	var IS_ANDROID = (/android/gi).test(OS_VERSION);
	var IS_IPAD = (/ipad/gi).test(OS_VERSION);
	var IS_IPHONE = (/iphone/gi).test(OS_VERSION);
	var CSS_3D = ('WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix());
	var SUPPORTS_TOUCH_SCROLL = (IS_ANDROID || IS_IPAD || IS_IPHONE) && CSS_3D;

	
	// scroller for iphone/ipad -> http://cubiq.org/iscroll
	if (SUPPORTS_TOUCH_SCROLL && typeof iScroll !== 'undefined') {
		//$(document).bind('touchmove', function() {
		//	return false;
		//});

		myScroll = new iScroll('contentright_inner', { desktopCompatibility:true, hScrollbar: false, vScrollbar:true });
		//myScroll = new iScroll('contentright_inner');
	}

	
});

