$(window).load(function () {
  
function findMaxValue(element){
    var maxValue = undefined;
    $(element).each(function(){
        var val = parseInt($(this).height());
        if (maxValue === undefined || maxValue < val) {
            maxValue = val;
        }
    });
    return maxValue;
}
 
  	var item = $('.teaserTasche');
    maxValue = findMaxValue(item);
   // alert(maxValue);
    
    $('.wrapTasche').css('height', maxValue+12);
    //$('.wrapTasche').css('background-color', 'red');
    $('.teaserTasche').css({
    
    'position':'absolute',
    'bottom':'0px',
    'right':'0px'
    
    });
    
    
    $(".detail").each(function(){
	
	var imgDetailHeight;
	var imgDetailWidth;
	
	imgDetailHeight = $(this).children(".detailBox").height();
	imgDetailWidth = $(this).children(".detailBox").width();
	
	$(this).children('div').css('height',imgDetailHeight);
	
	
	var left;
	var top;
	
	left = (imgDetailWidth/2)-38;
	top = (imgDetailHeight/2);
	
	
	left = Math.round(left);
	top = Math.round(top);
	
	
	
	
	$(this).children(".workTitle").children('.zoom').css({
		'marginLeft':left,
		'marginTop':top		
	});
	

	
	});

    
});

$(document).ready(function(){





$('.kollektionSpecial').eq(0).css({"border":"0","margin-top":"0px"});
$('.kollektionSpecial').eq(1).css({"border":"0","margin-top":"0px"});
$('.kollektionSpecial').eq(2).css({"border":"0","margin-top":"0px"});

$('.EN').hide();
$('.submitSuc').hide(); 

$('#DE').click(function(){
	$('.EN').hide();
	$('.DE').fadeIn('slow');
	$('#DE').addClass('languageLinkInactive');
	$('#EN').removeClass('languageLinkInactive');
	});

$('#EN').click(function(){
	$('.DE').hide();
	$('.EN').fadeIn('slow');
	$('#EN').addClass('languageLinkInactive');
	$('#DE').removeClass('languageLinkInactive');
	});


$('.trenner:last').hide();
$('.divide:last').hide();
	
	
		
	$(':input').live('focus mouseup', function(e) {
if (e.type == 'focusin') {
this.select();
}

if (e.type == 'mouseup') {
return false;
}
});





	//alert('hello');
	$(":input").focus(function(){
    // Check for the change
    if(this.value == this.defaultValue){
        this.select();
    }
});
	  
	 	
	
	$('.lightBox').simpleLightbox();
	
	$('.topScroller').hide();

		
	
		$(".detail").hover(function() {
		$(this).children('.detailBox').fadeTo(250, 0.3); 
		$(this).children('.workTitle').fadeIn(250);
			}, function() {
		$(this).children('.detailBox').fadeTo(250, 1); 
		$(this).children('.workTitle').fadeOut(250);
		
	});
	
	
    	
    	
        
  
       
   
    
    
    
	
		
	$(".teaserTasche").css({'opacity':'0.8'}); // This sets the opacity of the thumbs to fade down to 60% when the page loads

	$(".teaserTasche").hover(function(){
		$(this).stop().fadeTo(250, 1); // This should set the opacity to 100% on hover
	},function(){
   		$(this).stop().fadeTo("slow", 0.8); // This should set the opacity back to 60% on mouseout
	});
    
 	


	$('.kollektion_item:first').css('borderTop','none');
	$('.kollektion_item:last').css('borderBottom','none');
	
	//Top SCROLLER
	
	$("#top").click(function(e) {
	e.preventDefault();
  $.scrollTo( 0, 1500 ,{offset:-81, easing:'easeInOutExpo' });
	});
	
	//Top SCROLLER
	
	$("#termine").click(function(e) {
	e.preventDefault();
  	$.scrollTo( $('.termine'), 1500 ,{offset:-80, easing:'easeInOutExpo' });
	
	});
	
	$("#kollektion").click(function(e) {
	e.preventDefault();
  $.scrollTo( $('.kollektion'), 1500 ,{offset:-236, easing:'easeInOutExpo' });
});

		$("#wir").click(function(e) {
	e.preventDefault();
  $.scrollTo( $('.wir'), 1500 ,{offset:-162, easing:'easeInOutExpo' });
});

	$("#presse").click(function(e) {
	e.preventDefault();
  	$.scrollTo( $('.presse'), 1500 ,{ easing:'easeInOutExpo', onAfter:function(){
  	//alert('bin da');
  	$('.menu').slideToggle('2000','easeInOutExpo');
  	
  	}});
  	
  
});
	
	
	$("#footer").click(function(e) {
	e.preventDefault();
  $.scrollTo( $('#footerScroll'), 1500 ,{ easing:'easeInOutExpo' });
});

	
	//****
	

	
	
	
	//********
	
	$('.koll2').hide();
	

	
	
	$(window).scroll(function(){
	  
	   /*  for( i=1; i <= num; i++){
	     
	       if ( $("#"+i).offset().top >= scrollY+185 ) 
        { count++;}
        else if ( $("#"+i).offset().top <= scrollY+185 )
        {  count--;}
      

	     
 }*/


         
	
	
	
	var offset = $('.kollektionIndex').offset();
	
	var pos = $(window).scrollTop();
	var posShift = pos + 80;
	
	
		if (pos > 600	) {
		
		$('.topScroller').animate(
    	{ opacity: 'show' }, // what we are animating
    	{ duration: 'slow', // how fast we are animating
          easing: 'easeOutExpo', // the type of easing
        });
  	}
  	else
  	{  
  
  		$('.topScroller').animate(
    	{ opacity: 'hide' }, // what we are animating
    	{ duration: 'slow', // how fast we are animating
          easing: 'easeOutExpo', // the type of easing
        });
	}
	
	
	//----
	
	if ( posShift < offset.top )
	{ 
	
    	//alert('hello');
    	$('.koll1').show();
    	$('.koll2').hide();
    	$('.kollektionIndex').css('opacity','1');
    	$('.kollektionHeader').css('background-color','rgba(255,255,255,0.97)');
	
		
	
	}else
	{	
		$('.koll2').show();
    	$('.koll1').hide();
		
    	$('.kollektionHeader').css('background-color','rgba(237,237,234,0.9)');
		
		$('.kollektionIndex').css('opacity','0');
			
	}
	 
	

	
	});
	


	
		

});
