$(function(){	
	$('a.email').nospam({
		replaceText: true
	});
	
	initializeScrollBars();
    var startfelder = "#"+$("#one .artikel")[1].id;
    goToArticle(startfelder);
	
	$.each($('.img_toload'), function(){
		if ($(this).data('ratio')){
			$(this).replaceWith('<img src="'+$(this).data('url')+'" width="'+$(this).data('ratio')+'%" />');
		} else{
			$(this).replaceWith('<img src="'+$(this).data('url')+'" width="100%" />');
		}
		
	});
	
	$('#one .artikel').click( function(){
		reSizeA();
	});
	
	$('#two .artikel').click( function(){
		reSizeB();
	});
	
	$('#three .artikel').click( function(){
		reSizeC();
	});

	$('#four .artikel').click( function(){
		reSizeD();
	});
	
	$('.artikel a').click( function(e){
		e.stopPropagation();
	});
	
	author();
	
	$('.play').click( function(event) {
		event.stopPropagation();
		var vimeoid = $(this).parent().next('.video_file_empty').attr('rel');
		$(this).parent().hide();
		if ($(this).parent().parent().width() < 500 ){
			$(this).parent().next('.video_file_empty').show().removeClass('video_file_empty').addClass('video_file').html('<iframe src="http://player.vimeo.com/video/'+vimeoid+'?autoplay=1" width="380" height="220" frameborder="0"></iframe>');
		} else {
			$(this).parent().next('.video_file_empty').show().removeClass('video_file_empty').addClass('video_file').html('<iframe src="http://player.vimeo.com/video/'+vimeoid+'?autoplay=1" width="780" height="440" frameborder="0"></iframe>');
		}
	});
	
	$('.video_file, .video_thumb').click( function(event) {
		event.stopPropagation();
	});
	
	$('.authored').click( function() {
		author();
	});
	$('.unlinked').click( function() {
		unlink();
	});
	
	$('.menupt').mouseover(function() {
		var mnuid = "#mtitel_"+$(this).attr('rel');
		$(mnuid).css({'visibility':'visible'});
	}).mouseout(function(){
		var mnuid = "#mtitel_"+$(this).attr('rel');
		$(mnuid).css({'visibility':'hidden'});
	});
	
	$('#oneContainer').scroll( function(){
		var curID = currentID('#oneContainer');
		$('#menuAlist .menupt').css({'color':'#ccc'});
		$('#mpt_'+curID).css({'color':'#000'});
	});
	
	$('#twoContainer').scroll( function(){
		var curID = currentID('#twoContainer');
		$('#menuBlist .menupt').css({'color':'#ccc'});
		$('#mpt_'+curID).css({'color':'#000'});
	});
	
	$('#threeContainer').scroll( function(){
		var curID = currentID('#threeContainer');
		$('#menuClist .menupt').css({'color':'#ccc'});
		$('#mpt_'+curID).css({'color':'#000'});
	});
	
	$('#fourContainer').scroll( function(){
		var curID = currentID('#fourContainer');
		$('#menuDlist .menupt').css({'color':'#ccc'});
		$('#mpt_'+curID).css({'color':'#000'});
	});
	
	
			
});

function author() {
	
	$('.authored').css({'text-decoration':'underline'});
	$('.unlinked').css({'text-decoration':'none'});
	
	$('.menupt').unbind('click');
	$('.menupt').bind('click', function() {
		var wohin = "#"+$(this).attr('rel');
		goToArticle(wohin);
	});
	
	
	$('#oneContainer').bind('mousewheel', function(event, delta) {
		
		if ( $(this).find('.video_file').length > 0 ){
				$(this).find('.video_thumb').show();
				$(this).find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
	
		var contoben = Math.round($(this).position().top*-1);
		
		$("#oneContainer .artikel").each(function (i) {
			var hoehe = Math.round($(this).height());
			var oben = Math.round($(this).position().top);
			var unten = hoehe + oben;
			
			if ( delta < 0 ){
				var oben = oben - 150;
				var unten = unten - 150;
			} else if ( delta > 0 ){
				var oben = oben + 150;
				var unten = unten;
			}
						
			if ( oben <= contoben && contoben < unten ) {
				var rel = $(this).attr("rel").split(",");
				scrollMit('A', rel[0], rel[1], rel[2], rel[3]);
				return false;
			}
			
		});
	});
	$('#twoContainer').bind('mousewheel', function(event, delta) {
		
		if ( $(this).find('.video_file').length > 0 ){
				$(this).find('.video_thumb').show();
				$(this).find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
	
		var contoben = Math.round($(this).position().top*-1);
		
		$("#twoContainer .artikel").each(function (i) {
			var hoehe = Math.round($(this).height());
			var oben = Math.round($(this).position().top);
			var unten = hoehe + oben;
			
			if ( delta < 0 ){
				var oben = oben - 150;
				var unten = unten - 150;
			} else if ( delta > 0 ){
				var oben = oben + 150;
				var unten = unten;
			}
						
			if ( oben <= contoben && contoben < unten ) {
				var rel = $(this).attr("rel").split(",");
				scrollMit('B', rel[0], rel[1], rel[2], rel[3]);
				return false;
			}
			
		});
	});
	$('#threeContainer').bind('mousewheel', function(event, delta) {
		
		if ( $(this).find('.video_file').length > 0 ){
				$(this).find('.video_thumb').show();
				$(this).find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
	
		var contoben = Math.round($(this).position().top*-1);
		
		$("#threeContainer .artikel").each(function (i) {
			var hoehe = Math.round($(this).height());
			var oben = Math.round($(this).position().top);
			var unten = hoehe + oben;
			
			if ( delta < 0 ){
				var oben = oben - 150;
				var unten = unten - 150;
			} else if ( delta > 0 ){
				var oben = oben + 150;
				var unten = unten;
			}
						
			if ( oben <= contoben && contoben < unten ) {
				var rel = $(this).attr("rel").split(",");
				scrollMit('C', rel[0], rel[1], rel[2], rel[3]);
				return false;
			}
			
		});
	});
	$('#fourContainer').bind('mousewheel', function(event, delta) {
		
		if ( $(this).find('.video_file').length > 0 ){
				$(this).find('.video_thumb').show();
				$(this).find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
	
		var contoben = Math.round($(this).position().top*-1);
		
		$("#fourContainer .artikel").each(function (i) {
			var hoehe = Math.round($(this).height());
			var oben = Math.round($(this).position().top);
			var unten = hoehe + oben;
			
			if ( delta < 0 ){
				var oben = oben - 150;
				var unten = unten - 150;
			} else if ( delta > 0 ){
				var oben = oben + 150;
				var unten = unten;
			}
						
			if ( oben <= contoben && contoben < unten ) {
				var rel = $(this).attr("rel").split(",");
				scrollMit('D', rel[0], rel[1], rel[2], rel[3]);
				return false;
			}
			
		});
	});
}

function unlink() {
	
	$('.authored').css({'text-decoration':'none'});
	$('.unlinked').css({'text-decoration':'underline'});
	
	$('.menupt').unbind('click');
	$('.menupt').bind('click', function() {
		var wohin = "#"+$(this).attr('rel');
		if ( $(this).parent().parent().is("#menuAlist") ) {
			$('#oneContainer')[0].scrollTo(wohin);
		} else if ( $(this).parent().parent().is("#menuBlist") ) {
			$('#twoContainer')[0].scrollTo(wohin);
		} else if ( $(this).parent().parent().is("#menuClist") ) {
			$('#threeContainer')[0].scrollTo(wohin);
		} else if ( $(this).parent().parent().is("#menuDlist") ) {
			$('#fourContainer')[0].scrollTo(wohin);
		}
	});
	
	$('#oneContainer').unbind('mousewheel');
	$('#twoContainer').unbind('mousewheel');
	$('#threeContainer').unbind('mousewheel');
	$('#fourContainer').unbind('mousewheel');
}

function initializeScrollBars() {
	$("#oneContainer").jScrollPane({animateTo:true, wheelSpeed: 10});
	$("#twoContainer").jScrollPane({animateTo:true, wheelSpeed: 10});
	$("#threeContainer").jScrollPane({animateTo:true, wheelSpeed: 10});
	$("#fourContainer").jScrollPane({animateTo:true, wheelSpeed: 10});
	$(".jScrollPaneTrack").css({'visibility' : 'hidden'});
}

function oembedcallback(){
	$('.video_file').click( function(event) {
		event.stopPropagation();
	});
}
	

function goToArticle(trgt) {
	var targ = $(trgt);	
	var reltxt = targ.attr("rel");
	var related = reltxt.split(",");
	
	if ( $(trgt).parent().is("#oneContainer") ) {
		if ( $('#oneContainer').find('.video_file').length > 0 ){
				$('#oneContainer').find('.video_thumb').show();
				$('#oneContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		$('#oneContainer')[0].scrollTo(trgt);
	} else if (related[0] != 'e') {
		if ( $('#oneContainer').find('.video_file').length > 0 ){
				$('#oneContainer').find('.video_thumb').show();
				$('#oneContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		var relA = "#"+related[0];	
		$('#oneContainer')[0].scrollTo(relA);
	}
	if ( $(trgt).parent().is('#twoContainer') ) {
		if ( $('#twoContainer').find('.video_file').length > 0 ){
				$('#twoContainer').find('.video_thumb').show();
				$('#twoContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		$('#twoContainer')[0].scrollTo(trgt);
	} else if (related[1] != 'e') {
		if ( $('#twoContainer').find('.video_file').length > 0 ){
				$('#twoContainer').find('.video_thumb').show();
				$('#twoContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		var relB = "#"+related[1];
		$('#twoContainer')[0].scrollTo(relB);
	}
	if ( $(trgt).parent().is('#threeContainer') ) {
		if ( $('#threeContainer').find('.video_file').length > 0 ){
				$('#threeContainer').find('.video_thumb').show();
				$('#threeContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		$('#threeContainer')[0].scrollTo(trgt);
	} else if (related[2] != 'e') {	
		if ( $('#threeContainer').find('.video_file').length > 0 ){
				$('#threeContainer').find('.video_thumb').show();
				$('#threeContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		var relC = "#"+related[2];
		$('#threeContainer')[0].scrollTo(relC);
	}
	if ( $(trgt).parent().is('#fourContainer') ) {
		if ( $('#fourContainer').find('.video_file').length > 0 ){
				$('#fourContainer').find('.video_thumb').show();
				$('#fourContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		$('#fourContainer')[0].scrollTo(trgt);
	} else if (related[3] != 'e') {
		if ( $('#fourContainer').find('.video_file').length > 0 ){
				$('#fourContainer').find('.video_thumb').show();
				$('#fourContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
		}
		var relD = "#"+related[3];	
		$('#fourContainer')[0].scrollTo(relD);
	}

}

function scrollMit(wer, wo1, wo2, wo3, wo4) {
	var wohin1 = "#"+wo1;
	var wohin2 = "#"+wo2;
	var wohin3 = "#"+wo3;
	var wohin4 = "#"+wo4;
	if ( wer != 'A' ){
		if ( $(wohin1).parent().is('#oneContainer') || wo1 == 'w' ) {
			if ( $('#oneContainer').find('.video_file').length > 0 ){
				$('#oneContainer').find('.video_thumb').show();
				$('#oneContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
			}
			$('#oneContainer')[0].scrollTo(wohin1);
		}
	}
	if ( wer != 'B' ){
		if ( $(wohin2).parent().is('#twoContainer') || wo2 == 'w' ) {
			if ( $('#twoContainer').find('.video_file').length > 0 ){
				$('#twoContainer').find('.video_thumb').show();
				$('#twoContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
			}
			$('#twoContainer')[0].scrollTo(wohin2);
		}
	}
	if (wer != 'C'){
		 if ( $(wohin3).parent().is('#threeContainer') || wo3 == 'w' ) {
		 	if ( $('#threeContainer').find('.video_file').length > 0 ){
				$('#threeContainer').find('.video_thumb').show();
				$('#threeContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
			}
			$('#threeContainer')[0].scrollTo(wohin3);
		 }
	}
	if (wer != 'D' ){
		if ( $(wohin4).parent().is('#fourContainer') || wo4 == 'w' ) {
			if ( $('#fourContainer').find('.video_file').length > 0 ){
				$('#fourContainer').find('.video_thumb').show();
				$('#fourContainer').find('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
			}
			$('#fourContainer')[0].scrollTo(wohin4);
		}
	}
}

function currentID(feld){
	var container = $(feld).position();
	var contoben = Math.round(container.top*-1);
	$(feld+" .artikel").each( function() {
		var oben = Math.round($(this).position().top);
		var hoehe = Math.round($(this).height());
		var unten = hoehe + oben;
		if ( oben <= contoben && contoben < unten ) {
			curID = $(this).attr('id');
			return false;
		}
	});
	return curID;
}

function reSizeA() {
	
	
	if ( $('.video_file').length > 0 ){
			$('.video_thumb').show();
			$('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
	}
    
    var trgt = "#"+currentID('#oneContainer');
    var faktor = 0;
	
	if ( $('#one').width() < 600) {
		$('#oneContainer').jScrollPaneRemove();
		$('#oneContainer').css({'top' : -$(trgt).position().top});
	    $("#one .text0hidden, #one .text1hidden").css({'visibility' : 'visible', 'display' : 'block'});
	    $('#oneContainer').css({'top' : -$(trgt).position().top});
		$('#one .artikel').css({'min-height': '610px'});
		$('#oneContainer').css({'top' : -$(trgt).position().top});
	
		$("#one").css({'z-index' : '50'});
		$("#two, #three, #four").css({'z-index' : '1'});
		
		$('#one').animate({width: "810px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#one .breite_400_810').width(Math.round(400+(810-400)*fx.pos));
						$('#one, #one .container').height(Math.round(300+(610-300)*fx.pos));
						$('#one .breite_380_780').width(Math.round(380+(780-380)*fx.pos));
						$('#one .breite_380_550').width(Math.round(380+(550-380)*fx.pos));
						$('#one .breite_110_200').width(Math.round(110+(200-110)*fx.pos));
						$('#oneContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$('#oneContainer').jScrollPane({wheelSpeed: 10});
				$('#oneContainer')[0].scrollTo(trgt);
				$('#oneContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
			}
		});
	} else {
		$('#oneContainer').jScrollPaneRemove();
		$('#oneContainer').css({'top' : -$(trgt).position().top});
		
		$('#one').animate({width: "400px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#one .breite_400_810').width(Math.round(810-(810-400)*fx.pos));
						$('#one, #one .container').height(Math.round(610-(610-300)*fx.pos));
						$('#one .breite_380_780').width(Math.round(780-(780-380)*fx.pos));
						$('#one .breite_380_550').width(Math.round(550-(550-380)*fx.pos));
						$('#one .breite_110_200').width(Math.round(200-(200-110)*fx.pos));
						$('#oneContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$("#one .text0hidden, #one .text1hidden").css({'visibility' : 'hidden', 'display' : 'none'});
	    		$('#oneContainer').css({'top' : -$(trgt).position().top});
				$('#one .artikel').css({'min-height': '300px'});
				$('#oneContainer').css({'top' : -$(trgt).position().top});
				$('#oneContainer').jScrollPane({wheelSpeed: 10});
				$('#oneContainer')[0].scrollTo(trgt);
				$('#oneContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
				$(".jScrollPaneTrack").css({'visibility' : 'hidden'});
			}
		});
	
	}
}


function reSizeB() {
	
	
	if ( $('.video_file').length > 0 ){
			$('.video_thumb').show();
			$('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
	}
    
    var trgt = "#"+currentID('#twoContainer');
    var faktor = 0;
	
	if ( $('#two').width() < 600) {
		$('#twoContainer').jScrollPaneRemove();
		$('#twoContainer').css({'top' : -$(trgt).position().top});
	    $("#two .text0hidden, #two .text1hidden").css({'visibility' : 'visible', 'display' : 'block'});
	    $('#twoContainer').css({'top' : -$(trgt).position().top});
		$('#two .artikel').css({'min-height': '610px'});
		$('#twoContainer').css({'top' : -$(trgt).position().top});
	
		$("#two").css({'z-index' : '50'});
		$("#one, #three, #four").css({'z-index' : '1'});
		
		$('#two').animate({width: "810px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#two').css({'left' : 810-Math.round(400+(810-400)*fx.pos) , 'width' : Math.round(400+(810-400)*fx.pos) , 'height' : Math.round(300+(610-300)*fx.pos) });
						$('#two .breite_400_810').width(Math.round(400+(810-400)*fx.pos));
						$('#two .container').height(Math.round(300+(610-300)*fx.pos));
						$('#two .breite_380_780').width(Math.round(380+(780-380)*fx.pos));
						$('#two .breite_380_550').width(Math.round(380+(550-380)*fx.pos));
						$('#two .breite_110_200').width(Math.round(110+(200-110)*fx.pos));
						$('#twoContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$('#twoContainer').jScrollPane({wheelSpeed: 10});
				$('#twoContainer')[0].scrollTo(trgt);
				$('#twoContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
			}
		});
	} else {
		$('#twoContainer').jScrollPaneRemove();
		$('#twoContainer').css({'top' : -$(trgt).position().top});
		
		$('#two').animate({width: "400px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#two').css({'left' : 810-Math.round(810-(810-400)*fx.pos) , 'width' : Math.round(810-(810-400)*fx.pos) , 'height' : Math.round(610-(610-300)*fx.pos) });
						$('#two .breite_400_810').width(Math.round(810-(810-400)*fx.pos));
						$('#two .container').height(Math.round(610-(610-300)*fx.pos));
						$('#two .breite_380_780').width(Math.round(780-(780-380)*fx.pos));
						$('#two .breite_380_550').width(Math.round(550-(550-380)*fx.pos));
						$('#two .breite_110_200').width(Math.round(200-(200-110)*fx.pos));
						$('#twoContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$("#two .text0hidden, #two .text1hidden").css({'visibility' : 'hidden', 'display' : 'ntwo'});
	    		$('#twoContainer').css({'top' : -$(trgt).position().top});
				$('#two .artikel').css({'min-height': '300px'});
				$('#twoContainer').css({'top' : -$(trgt).position().top});
				$('#twoContainer').jScrollPane({wheelSpeed: 10});
				$('#twoContainer')[0].scrollTo(trgt);
				$('#twoContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
				$(".jScrollPaneTrack").css({'visibility' : 'hidden'});
			}
		});
	
	}
}

function reSizeC() {
	
	
	if ( $('.video_file').length > 0 ){
			$('.video_thumb').show();
			$('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
	}
    
    var trgt = "#"+currentID('#threeContainer');
    var faktor = 0;
	
	if ( $('#three').width() < 600) {
		$('#threeContainer').jScrollPaneRemove();
		$('#threeContainer').css({'top' : -$(trgt).position().top});
	    $("#three .text0hidden, #three .text1hidden").css({'visibility' : 'visible', 'display' : 'block'});
	    $('#threeContainer').css({'top' : -$(trgt).position().top});
		$('#three .artikel').css({'min-height': '610px'});
		$('#threeContainer').css({'top' : -$(trgt).position().top});
	
		$("#three").css({'z-index' : '50'});
		$("#one, #two, #four").css({'z-index' : '1'});
		
		$('#three').animate({width: "810px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#three .breite_400_810').width(Math.round(400+(810-400)*fx.pos));
						$('#three, #three .container').height(Math.round(300+(610-300)*fx.pos));
						$('#three').css({'top' : 626-$('#three').height() });
						$('#three .breite_380_780').width(Math.round(380+(780-380)*fx.pos));
						$('#three .breite_380_550').width(Math.round(380+(550-380)*fx.pos));
						$('#three .breite_110_200').width(Math.round(110+(200-110)*fx.pos));
						$('#threeContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$('#threeContainer').jScrollPane({wheelSpeed: 10});
				$('#threeContainer')[0].scrollTo(trgt);
				$('#threeContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
			}
		});
	} else {
		$('#threeContainer').jScrollPaneRemove();
		$('#threeContainer').css({'top' : -$(trgt).position().top});
		
		$('#three').animate({width: "400px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#three .breite_400_810').width(Math.round(810-(810-400)*fx.pos));
						$('#three, #three .container').height(Math.round(610-(610-300)*fx.pos));
						$('#three').css({'top' : 626-$('#three').height() });
						$('#three .breite_380_780').width(Math.round(780-(780-380)*fx.pos));
						$('#three .breite_380_550').width(Math.round(550-(550-380)*fx.pos));
						$('#three .breite_110_200').width(Math.round(200-(200-110)*fx.pos));
						$('#threeContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$("#three .text0hidden, #three .text1hidden").css({'visibility' : 'hidden', 'display' : 'nthree'});
	   		 	$('#threeContainer').css({'top' : -$(trgt).position().top});
				$('#three .artikel').css({'min-height': '300px'});
				$('#threeContainer').css({'top' : -$(trgt).position().top});
				$('#threeContainer').jScrollPane({wheelSpeed: 10});
				$('#threeContainer')[0].scrollTo(trgt);
				$('#threeContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
				$(".jScrollPaneTrack").css({'visibility' : 'hidden'});
			}
		});
	
	}
}

function reSizeD() {
	
	
	if ( $('.video_file').length > 0 ){
			$('.video_thumb').show();
			$('.video_file').removeClass('video_file').addClass('video_file_empty').hide().empty();
	}
    
    var trgt = "#"+currentID('#fourContainer');
    var faktor = 0;
	
	if ( $('#four').width() < 600) {
		$('#fourContainer').jScrollPaneRemove();
		$('#fourContainer').css({'top' : -$(trgt).position().top});
	    $("#four .text0hidden, #four .text1hidden").css({'visibility' : 'visible', 'display' : 'block'});
	    $('#fourContainer').css({'top' : -$(trgt).position().top});
		$('#four .artikel').css({'min-height': '610px'});
		$('#fourContainer').css({'top' : -$(trgt).position().top});
	
		$("#four").css({'z-index' : '50'});
		$("#one, #two, #three").css({'z-index' : '1'});
		
		$('#four').animate({width: "810px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#four').css({'left' : 810-Math.round(400+(810-400)*fx.pos) , 'top' : 626-Math.round(300+(610-300)*fx.pos) , 'width' : Math.round(400+(810-400)*fx.pos) , 'height' : Math.round(300+(610-300)*fx.pos) });
						$('#four .breite_400_810').width(Math.round(400+(810-400)*fx.pos));
						$('#four .container').height(Math.round(300+(610-300)*fx.pos));
						$('#four .breite_380_780').width(Math.round(380+(780-380)*fx.pos));
						$('#four .breite_380_550').width(Math.round(380+(550-380)*fx.pos));
						$('#four .breite_110_200').width(Math.round(110+(200-110)*fx.pos));
						$('#fourContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$('#fourContainer').jScrollPane({wheelSpeed: 10});
				$('#fourContainer')[0].scrollTo(trgt);
				$('#fourContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
			}
		});
	} else {
		$('#fourContainer').jScrollPaneRemove();
		$('#fourContainer').css({'top' : -$(trgt).position().top});
		
		$('#four').animate({width: "400px"}, {
			duration: 500,
			step: function(now, fx) {
					if (fx.pos != faktor){
						$('#four').css({'left' : 810-Math.round(810-(810-400)*fx.pos) , 'top' : 626-Math.round(610-(610-300)*fx.pos) , 'width' : Math.round(810-(810-400)*fx.pos) , 'height' : Math.round(610-(610-300)*fx.pos) });
						$('#four .breite_400_810').width(Math.round(810-(810-400)*fx.pos));
						$('#four .container').height(Math.round(610-(610-300)*fx.pos));
						$('#four .breite_380_780').width(Math.round(780-(780-380)*fx.pos));
						$('#four .breite_380_550').width(Math.round(550-(550-380)*fx.pos));
						$('#four .breite_110_200').width(Math.round(200-(200-110)*fx.pos));
						$('#fourContainer').css({'top' : -$(trgt).position().top});
					}
					faktor = fx.pos;
			},
			complete: function() {
				$("#four .text0hidden, #four .text1hidden").css({'visibility' : 'hidden', 'display' : 'nfour'});
	    		$('#fourContainer').css({'top' : -$(trgt).position().top});
				$('#four .artikel').css({'min-height': '300px'});
				$('#fourContainer').css({'top' : -$(trgt).position().top});
				$('#fourContainer').jScrollPane({wheelSpeed: 10});
				$('#fourContainer')[0].scrollTo(trgt);
				$('#fourContainer').jScrollPane({animateTo:true, wheelSpeed: 10});
				$(".jScrollPaneTrack").css({'visibility' : 'hidden'});
			}
		});
	
	}
}
