$(document).ready(function() {
	
	/* Header */
	$('ul#topnavmenue li a').hover(
			function() {
				$(this).addClass('active');
				$(this).next('div.dropdown_menu').stop(true, true);

				$(this).next('div.dropdown_menu').delay(300).slideDown('slow');
			},
			function() {
				$(this).next('div.dropdown_menu').stop(true, true);
				$(this).next('div.dropdown_menu').slideUp('fast');
				$(this).removeClass('active');
			}
	)
	
	$('div.dropdown_menu').hover(
			function() {
				$(this).stop(true, false);
				$(this).prev('a').addClass('active');
			},
			function() {
                if (!$(this).hasClass('login-drop-fixed'))
                {
				    $(this).slideUp('fast');
				    $(this).prev('a').removeClass('active');
                }
			}
	);
    
    $('#box_login_username').focus(
        function(){
            $('.login-drop').addClass('login-drop-fixed');
    });
    
    $('#box_login_username').blur(
        function(){
            $('.login-drop').removeClass('login-drop-fixed');
    });
    
    $('#box_login_password').focus(
        function(){
            $('.login-drop').addClass('login-drop-fixed');
    });
    
    $('#box_login_password').blur(
        function(){
            $('.login-drop').removeClass('login-drop-fixed');
    });
	
	/* Content */
	$('.navi_box_link').click(function() {	
		$('.navi_content').slideUp();
		if ($(this).next('.navi_content').css('display') != 'block')
		{			
			$(this).next('.navi_content').slideDown();
		}
		
		return false;
	});
	
	$('.preview_link_middle').click(function() {	
		preview_link_id = $(this).attr('id');
		$('.preview_link_middle').removeClass('active');
		$(this).addClass('active');
		$('.preview_link_navi').removeClass('active');
		$('.preview_link_navi#'+preview_link_id).addClass('active');
		$('.preview_content_navi').slideUp('slow');
		$('.preview_link_navi#'+preview_link_id).next('.preview_content_navi').slideDown('slow');
		$('.preview_content_middle').css('display','none');
		$('.preview_content_middle#content_'+preview_link_id).slideDown('slow');
		return false;
	});
	
	$('.preview_link_navi').click(function() {	
		preview_link_id = $(this).attr('id');
		$('.preview_link_middle').removeClass('active');
		$('.preview_link_middle#'+preview_link_id).addClass('active');
		$('.preview_link_navi').removeClass('active');
		$(this).addClass('active');
		$('.preview_content_navi').slideUp('slow');
		$('.preview_link_navi#'+preview_link_id).next('.preview_content_navi').slideDown('slow');
		$('.preview_content_middle').css('display','none');
		$('.preview_content_middle#content_'+preview_link_id).fadeIn('slow');
		return false;
	});
	
	$('a.shortcut_link.interaction_link').hover(
			function() {
                $(this).stop();
				$(this).animate({
					marginLeft: '-152px',
					width: 		'140px'
				}, 200, function() {
					$(this).children('span').fadeIn(200);
					$(this).children('span').css('display', 'block');
				});
			},
			function() {
				 var item = this;
                $(this).stop();
                $(this).children('span').fadeOut(200, function() {
				  $(item).animate({
						marginLeft: '-30px',
						width: 		'18px'
				  }, 100);
			  });
				  $('.shortcut_link.interaction_link span').css('display', 'none');
				}
	);
	
	$('.hide_content.bluearticle').css('display', 'none');
	$('.hide_content.bluearticle').addClass('whitearticle');
	$('.whitearticle').removeClass('bluearticle');
	
	$('.product_link').click(function() {	
		if (!$(this).hasClass('interaction_link'))
		{
			$('.product_link').removeClass('active');
			$(this).addClass('active');
		}
		/*if ($('.'+$(this).attr('id')).css('display') != 'block')
		{
			$('.whitearticle').slideUp();
			$('.'+$(this).attr('id')).slideDown();
		}*/
	});
    
    $('.desc_link').click(function() {    
        $('.desc_text').hide();
        $('.'+$(this).attr('id')).fadeIn('slow');  
    });    
	
	var url = document.location.toString();
	if (url.match('#')) { 
	  var anchor = url.split('#')[1];
	  /*if ($('.link_'+anchor.substr(4)).css('display') != 'block')
	  {
		  $('.whitearticle').css('display', 'none');
		  $('.link_'+anchor.substr(4)).css('display', 'block'); 
	  } */
	  if (!$('#link_'+anchor.substr(4)).hasClass('interaction_link'))
	  {
		  $('#link_'+anchor.substr(4)).addClass('active');
	  }
	}
	
	$('a[href*=#]').bind('click', function(event) 
	{
		if ($(this).hasClass('interaction_link'))
		{
			event.preventDefault();
			var ziel = $(this).attr('href');
			
			if ($.browser.opera) 
			{
				var target = 'html';
			}
			else
			{
				var target = 'html,body';
			}
			$(target).animate(
				{
					scrollTop: $(ziel).offset().top
				}, 2000 , function ()
				{
					location.hash = ziel;
				});
			return false;
		}
	});
	
	/*height = $('#description_container').height();

	if (height > 180)
	{
		$('#description_container').height(180);
		//$('#description_container').after('<a href="" id="show_more_link">mehr</a>');*
        
        $('#show_more_link').show();
	}*/
    
    /*$('#show_more_link').click(function() {
        $('.description_container').animate({
            height: $('#description_long_version').height() + 'px'
        },1000);
        $(this).fadeOut();
        $('#show_less_link').show();  
        return false;
    }) ;
    
    $('#show_less_link').click(function() {
        $('.description_container').animate({
            height: '180px'
        },1000);
        $('#show_more_link').fadeIn();    
        $(this).fadeOut();
        return false;
    }) */
    
    $('.product-information').mouseenter(function() {  
        $('#ccproduktname' + $(this).attr('id')).hide();
        $('#ccproduktbeschreibung' + $(this).attr('id')).show();
    });
    
    $('.product-information').mouseleave(function() {  
        $('#ccproduktbeschreibung' + $(this).attr('id')).hide();  
        $('#ccproduktname' + $(this).attr('id')).show();
    });
    
    $('a#descansicht').toggle(function() {
            $('div.desc1b').css('display','none');
            $('div.desc1a').fadeIn('slow');
            $('a#descansicht').html('minimieren');
            /*$('a#descansicht').addClass(desc_div);*/
            }, function() {
        $('div.desc1b').fadeIn('slow'); 
        $('div.desc1a').css('display','none');
        $('a#descansicht').html('mehr Details');
      });
      
      var setistoffen = 0;
      
      $('.setdown').click(function() {
          
        $('.inlineset').slideUp('fast');

        if (setistoffen != 0 && $(this).attr('setbox') == setistoffen)
        {
            setistoffen = 0; 
        }
        else
        {
            $('#' + $(this).attr('setbox')).slideDown('slow');   
            setistoffen = $(this).attr('setbox');
        }
      });
});
