﻿jQuery.noConflict();
jQuery(document).ready(function() {

	jQuery(window).unbind("resize");
	jQuery(window).bind("resize", setContentSize);
    
    // minimale Größen
    var minWidth = 1280;
			
	// Funktion zur Berechnung der neuen Größen bei Browserfensteränderung
	function setContentSize() {
	    
		var backImageFrame = jQuery('div#background_image_frame');
		var backImage = jQuery('img.background_image');
		
	    var contentFrame = jQuery('div#content_frame');
		var minContentHeight = jQuery('div#logo').outerHeight() + jQuery('div#main_content').outerHeight();
			       
	    var tempContentHeight = jQuery(window).height() - jQuery('div#navi_bar').height() - jQuery('div#copyright').height();	    				
	    var newContentHeight = Math.max(tempContentHeight, minContentHeight);
		var windowWidth = jQuery(window).width();
	    var windowHeight = jQuery(window).height();

		// Bildseitenverhältnis
		var imgRatio = 1280 / 768;
	    
	    // Bild skalieren
	    if (windowWidth > 1280) {
	    	backImage.width(windowWidth);
			backImage.height(windowWidth/imgRatio);
	    }

		// Ändern der betroffenen Elemente	    
	  
//		backImageFrame.height(windowHeight);
		contentFrame.height(newContentHeight);		
	}

	// Funktion beim ersten Start ausführen
	jQuery(function() {
    	setContentSize();
	});


	//Hover für die Navi
	
	var linkColor = '#ffffff';
	var linkHover = '#e3ace5';
	
	if (jQuery('div#frame').hasClass('purple')) {
		linkColor = '#5c1a5a';
		linkHover = '#cb39c7';
	} 
	
	jQuery('div#navi_items a').hover(function() {
		jQuery(this).stop(true, true).animate({
			color: linkHover
		}, 300);
	}, function() {
		jQuery(this).stop(true, true).animate({
			color: linkColor
		}, 300);
	});
	
	// Gallery-Skripts
 
 var sliderWidth = 0;
 var bigFrameContent = '';
 var imgDisplay, imgActive, imgTemp;
 var imgCount = 0;
 jQuery('img.gallery_thumb').each(function(e) {
  sliderWidth += 150;
  imgDisplay = 'none';
  if (imgCount == 0) {
   imgDisplay = 'block';
   imgActive = 'img.gallery_img_1';
  }
  imgCount++;
  var thisClass = 'gallery_img_'+imgCount;
  jQuery('div#gallery_bigImage').append('<img src="' + jQuery(this).attr('src') + '" style="display: '+imgDisplay+'; position: absolute; top: 0; left: 250px; z-index: 1;" class="'+thisClass+'"/>'); 
  
  // thumbnails-mouseover
  
  jQuery(this).hoverIntent(function (e) {
   imgTemp = 'img.'+thisClass;
   if (imgTemp == imgActive) return;
   jQuery(imgTemp).css("z-index", "3").fadeIn('fast', function(F) {
    jQuery(imgActive).css("z-index", "1").hide();
    imgActive = imgTemp;
    jQuery(imgTemp).css("z-index", "2");
   });
  }, function () {
   // maybe something
  });
 }); 
 
 // gallery-navigation setup
 
 jQuery('div#gallery_slide').width(sliderWidth);

 var newMarginLeft = 0;
 var minMarginLeft;
 minMarginLeft = (sliderWidth-600)*-1;
 
 if (sliderWidth <= 800) {
  jQuery('div#gallery_slide_left').hide();
  jQuery('div#gallery_slide_right').hide();
 } else {
  
  jQuery('div#gallery_slide_right').hover(function() {
   newMarginLeft -=400;
   if (newMarginLeft < minMarginLeft) newMarginLeft = minMarginLeft;
   jQuery('div#gallery_slide').animate({ "marginLeft": newMarginLeft }, 1000);
  }, function() {
  });  
  
  jQuery('div#gallery_slide_left').hover(function() {
   newMarginLeft +=400;
   if (newMarginLeft >= 0) newMarginLeft = 0;
   jQuery('div#gallery_slide').animate({"marginLeft": newMarginLeft }, 1000);
  }, function() {
  });
 }
		
});
