function rundlauf(){
   	$('#slide').cycle({ 
        timeout: 3000, 
        speed:   333
    });
   }
   

$(document).ready(function() {
				   
	var resuming = 'true'; 
	
	EventPictureHeight = new Array();
	AspectRatio = new Array();
	
	function numComparisonAsc(a, b){
		return a-b;
	}
	

   $("#slide").mouseenter(function(){
      $(this).cycle('pause');
    }).mouseleave(function(){
		if (resuming != 'false'){
      		$(this).cycle('resume');
		}
    });
	
	$("#picture_slide").mouseenter(function(){
      $(this).cycle('pause');
    }).mouseleave(function(){
		if(resuming != 'false'){
      		$(this).cycle('resume');
		}
    });
						   
						   
						   
	
	// Pfeile für Subnavigation einblenden bei Klick
	$('.submenue > a').click(function() { 
        $('.submenue > a > img').remove(); 
		$(this).append('<img src="/images/base/nav_pfeil.gif" />');
        return false; 
    });	
	
	//Positionierung der 3 Hauptspalten - links:#submenue, mitte:#right, rechts:.overlay
	var container_width = $('#start_container').css("width");
	var PosP_container_width = container_width.indexOf("p");
	container_width = container_width.slice(0,PosP_container_width);
	container_width = parseInt(container_width);
	
	function resize_wide(){
		
		$('#slide > div').css({'width' : '932px'});
		$('.event_image > a > img').load(function() {
			var hoehen = $(this).attr("height");
			var breiten = $(this).attr("width");
			var verhaeltnis = hoehen/breiten;
			AspectRatio.push(verhaeltnis);
			EventPictureHeight.push(hoehen);
			EventPictureHeight.sort(numComparisonAsc);
			EventPictureHeight.reverse();
			var MaxPictureHeight = EventPictureHeight[0];
		})
		if (WindowWidth() >= 1130 && WindowWidth() < 1351){
			
			var space = WindowWidth() - 1120;
			$('#start_right').css({'marginLeft' : space/2});
			$('#start_container').css({'width' : WindowWidth() + 'px'});
			$('.bottom_line').css({'width' : '934px'});
			$('.event_image > a > img').attr("width","470");
			
		}else{
			if (WindowWidth() <= 1130){
					$('#start_right').css({'marginLeft' : '5px'});	
					$('#start_container').css({'width' : '1120px'});
					imageWidth = 1130 - WindowWidth();
					rightWidth = WindowWidth() - 165;
					imageWidth = 465 - imageWidth;
					 if (imageWidth > 310){
						$('.event_image > a > img').attr("width",imageWidth);
						$('.bottom_line').css({'width' : 462 + imageWidth +'px'});
					 }else{
					 	$('.event_image > a > img').attr("width","310");
					 }
			}else{
				$('#start_right').css({'marginLeft' : '115px'});
				$('#start_container').css({'width' : WindowWidth() + 'px'});
				$('.event_image > a > img').attr("width","470");
				$('.bottom_line').css({'width' : '934px'});
			}	
		}	
	}
	
	resize_wide();
	window.setTimeout("rundlauf()", 100);		
	
	
	$(window).resize(function(){
		resize_wide();
		EventPictureHeight.splice(0,EventPictureHeight.length);
		$('.event_image > a > img').each(function (i) {
			breiten = $(this).attr("width");
			EventPictureHeight.push(Math.ceil(AspectRatio[i]*breiten));
			EventPictureHeight.sort(numComparisonAsc);
			EventPictureHeight.reverse();
			MaxPictureHeight = EventPictureHeight[0];
		})
		$('#slide').css({'height' : MaxPictureHeight + 'px'});	
	});
	
});