$(document).ready(function(){
    
	
	 var apetito = {
		 		
   		carouselMove : function(sDirection)
 	    {
 	    	$("#flip").jcoverflip(sDirection, '1', false);
 	    	$('.roll-layer').hide();
 	    },
 	    
 	    setCurrent : function(sDirection)
 	    {
 	    	if ( sDirection == 'next' )
    		{
 	    		var iCurrent = parseInt($("#currentSliderObject").val());
 	    		var iNewCurrent = parseInt(iCurrent+1);
 	    		$("#currentSliderObject").val(iNewCurrent);
    		}
 	    	else
 	    	{
 	    		var iCurrent = parseInt($("#currentSliderObject").val());
 	    		var iNewCurrent = parseInt(iCurrent-1);
 	    		$("#currentSliderObject").val(iNewCurrent);
 	    	} 	    	
 	    },
 	    
 	    getCurrent : function()
 	    {
 	    	return $("#currentSliderObject").val();
 	    },
 	    
 	    loadCorrectSite : function()
 	    {
 	    	var sHash = window.location.hash;
 	    	var sCheckItem = $('#FuerSie');
 	    	
 	    	if( sCheckItem.hasClass('check') && sHash == '#FuerSie' )
 	    	{
 	    		$('.tag-nav-02').click();
 	    	}
 	    }
 	    
    
    }


    $('.teaser-box .opener').click(function(){
    	$(this).next('.content').find('div').slideToggle();
    });
    
    $(".nav-inf-left-02, .nav-inf-right-02").click(function(){
		$(".product-info-02, .con-product-02").fadeOut(1, function(){
			$(".product-info, .con-product").fadeIn(1);
		});
	});

    $(".nav-inf-left, .nav-inf-right").click(function(){
		$(".product-info, .con-product").fadeOut(1, function(){
			$(".product-info-02, .con-product-02").fadeIn(1);
		});
	});
    
    /* Layer :: F�r Sie */ 
    $(".packshotbig").click(function(){
		$(".roll-layer").show();
	});
    
    /* Navigation Marke*/ 
    $(".tag-nav-02").click(function(){
    	
    	jQuery( '#flip' ).jcoverflip({
            current: 2,
            beforeCss: function( el, container, offset ){
              return [
                $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 325 - 110*offset + 20*offset )+'px', bottom: '20px' }, { } ),
                $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,150-20*offset*offset) + 'px' }, {} )
              ];
            },
            afterCss: function( el, container, offset ){
              return [
                $.jcoverflip.animationElement( el, { left: ( container.width( )/2 + 180 + 110*offset )+'px', bottom: '20px' }, { } ),
                $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,150-20*offset*offset) + 'px' }, {} )
              ];
            },
            currentCss: function( el, container ){
              return [
                $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 140 )+'px', bottom: 0 }, { } ),
                $.jcoverflip.animationElement( el.find( 'img' ), { width: '300px' }, { } )
              ];
            }
          });

    	
		$(".tag").fadeOut(1, function(){
			$(".tags").fadeIn(1);
			$(".tag-nav-01").removeClass('active');
			$(".tag-nav-02").addClass('active');
		});
	});
        
    $(".tag-nav-01").click(function(){
		$(".tags").fadeOut(1, function(){
			$(".tag").fadeIn(1);
			$(".tag-nav-02").removeClass('active');
			$(".tag-nav-01").addClass('active');
		});
	});
    
    
    $(".tag-nav-03").click(function(){
		$(".tags").fadeOut(1, function(){
			$(".tag").fadeIn(1);
			$(".tag-nav-04").removeClass('active');
			$(".tag-nav-03").addClass('active');
		});
	});
    
    $(".tag-nav-04").click(function(){
		$(".tag").fadeOut(1, function(){
			$(".tags").fadeIn(1);
			$(".tag-nav-03").removeClass('active');
			$(".tag-nav-04").addClass('active');
		});
	});
    
    
    $(".link-for").click(function(){
    	
    	$('.tag-nav-02').click();
    	return false;
    	
    	/*
    	$(".tag").fadeOut(1, function(){
			$(".tags").fadeIn(1);
			$(".tag-nav-01").removeClass('active');
			$(".tag-nav-02").addClass('active');
		});
		*/
    });
    
    $(".assortment").click(function(){
    	
    	$('.tag-nav-02').click();
    	return false;
    	
    	/*
    	$(".tag").fadeOut(1, function(){
			$(".tags").fadeIn(1);
			$(".tag-nav-01").removeClass('active');
			$(".tag-nav-02").addClass('active');
		});
		*/
		
    });
    
    $(".more").click(function(){
    	$(".tags").fadeOut(1, function(){
			$(".tag").fadeIn(1);
			$(".tag").removeClass('active');
			$(".tags").addClass('active');
		});
    });
    
    
    /* Slider */
    $('.assort-arrwow-left').click(function() {
    
        $(this).next().animate({width: 'toggle'});
    
      });
    
    /* Browser Class for Body */
    var sAgent = navigator.userAgent.toLowerCase();
	if(sAgent.match('chrome')){ $('body').addClass('chrome'); };
	if(sAgent.match('safari') && !sAgent.match('chrome')){ $('body').addClass('safari'); };
	
	/* jCarousel Flag */
	var bCarouselInit = false;
	
	/* Clipflow */
	
	$('body.marke .arrow-right-pro').click(function(){
		$("#ul-coverflow").jcoverflip('next', '1', false);
		apetito.carouselMove('next');
		apetito.setCurrent('next');
		
		if ( apetito.getCurrent() == 8 )
		{
			$(this).addClass('grey');
		}
		else
    	{
    		$('body.marke .arrow-left-pro').removeClass('grey');
    	}
		
		return false;
	});

	
    $('body.marke .arrow-left-pro').click(function(){
    	apetito.carouselMove('previous');
    	apetito.setCurrent('previous');
    	
    	if ( apetito.getCurrent() == 0 )
		{
    		$(this).addClass('grey');
		}
    	else
    	{
    		$('body.marke .arrow-right-pro').removeClass('grey');
    	}
    	
		return false;
	});
    
    
    
    $('ul#flip li a').live('mouseover', function(){
    	
    	var sBottom = $(this).parent('li').css('bottom');
    	if( sBottom == '0px' ){	
	    
    		var _oSelf		= $(this);
	 		var _sRelation	= _oSelf.attr('rel');
	 	
	 		
			$('#'+_sRelation).show();
	    }
 		return false;
    });
    
    $('ul#flip li').live('mouseleave', function(){
    	
    		var _oSelf		= $(this).find('a');
	 		var _sRelation	= _oSelf.attr('rel');
	 	
	 		
			$('#'+_sRelation).hide();
	    
 		return false;
    });
  
    
    $('ul#flip').click(function(){
    	$('.roll-layer').hide();
    });
    
    
    apetito.loadCorrectSite();
       
	
});

