jQuery.noConflict();
jQuery(document).ready(function(){
	var containerHeight = jQuery("#CONTAINER").height();
	var naviHeight = jQuery("#MAIN-NAVI").height();
	var marginalHeight = jQuery("#CONT-MARGINAL").height();
	
	jQuery(window).scroll(function (ev) {
		//Hauptnavigation
		var myHeight = jQuery("#IMAGE").height();
		//alert(jQuery("#SLIDESHOW").height());
		if (jQuery("#SLIDESHOW").height()>=10){
			  myHeight = jQuery("#SLIDESHOW").height();
		  };
		var newNaviPos = jQuery(window).scrollTop() - myHeight;
		
		if (naviHeight + newNaviPos > containerHeight) {
			newNaviPos = containerHeight - naviHeight;
		}
		
		if (newNaviPos < 0) {
			newNaviPos = 0;	
		}
		
		jQuery("#MAIN-NAVI")
			.stop()
			.animate({"marginTop": + newNaviPos + "px"}, "slow");
			
		//Marginalspalte
		var newMarginalPos = jQuery(window).scrollTop() - myHeight;
		
		if (marginalHeight + newMarginalPos > containerHeight) {
			newMarginalPos = containerHeight - naviHeight;
		}
		if (newMarginalPos < 0) {
			newMarginalPos = 0;	
		}
		
		jQuery("#CONT-MARGINAL")
			.stop()
			.animate({"marginTop": + newMarginalPos + "px"}, "slow");
	});
	
	
	//HEADERBILD
	var actualImageWidth = jQuery(window).width();
	var newImageHeight = getNewImageHeight(actualImageWidth);
	
	jQuery('#IMAGE img').height(newImageHeight);
	jQuery('#IMAGE').height(newImageHeight);
	jQuery('.slideElement').height(newImageHeight);
	//jQuery('.slideImage').height(newImageHeight*1.1);
	//jQuery('#IMAGE').width(actualImageWidth);
	

	jQuery(window).resize(function(){
		actualImageWidth = jQuery(window).width();
		newImageHeight = getNewImageHeight(actualImageWidth);
		jQuery('#IMAGE img').height(newImageHeight);
		//alert(jQuery('#IMAGE img').height());
		//ahn 13.10.11
		//jQuery('#IMAGE img').width(actualImageWidth);
		jQuery('#IMAGE').height(newImageHeight);
		jQuery('div#IMAGE .slideElement').height(newImageHeight);
	});
});


function getNewImageHeight(width) {
	var factor = 0.2789473;
	return width*factor;
}


