// JavaScript Document
	
	$(document).ready(function()
	{
		/** START READY CODE
		**/ 
		
     $(window).scroll(function () {   
         var offset = $(document).scrollTop()-280;
		
         if($(document).scrollTop() > 285 && $('#sidebar').height() < $('#rexshop-output').height()-200)
		 {
		 $('#sidebar-content').animate({top:offset+"px"},{duration:500,queue:false});  
		 }
		 else
		 {
		 $('#sidebar-content').animate({top:"0px"},{duration:500,queue:false});  
		 }
     }); 

		$('#offers-container').css('display', 'block');
		$('#manufacturers-container').css('display', 'block');
		$('#search-container').css('display', 'block');
		
		$('#offers-container').hide();
		$('#manufacturers-container').hide();
		$('#search-container').hide();
				
		$('a#offers').click(function()
		{
			if($('#offers-container').is(':visible'))
			{
				//$('#offers-container').animate({'height': 'hide', 'opacity': 'hide'});
				$('#offers-container').hide();
			}
				else
			{
				//$('#offers-container').animate({'height': 'show', 'opacity': 'show'});
				$('#offers-container').show();
			}
			$('#manufacturers-container').hide();
			$('#search-container').hide();
		});
		
		$('a#manufacturers').click(function()
		{
			if($('#manufacturers-container').is(':visible'))
			{
				//$('#manufacturers-container').animate({'height': 'hide', 'opacity': 'hide'});
				$('#manufacturers-container').hide();
			}
				else
			{
				//$('#manufacturers-container').animate({'height': 'show', 'opacity': 'show'});
				$('#manufacturers-container').show();
			}
			$('#offers-container').hide();
			$('#search-container').hide();
		});

		$('a#search').click(function()
		{
			if($('#search-container').is(':visible'))
			{
				//$('#search-container').animate({'height': 'hide', 'opacity': 'hide'}, 0);
				$('#search-container').hide();
			}
				else
			{
				//$('#search-container').animate({'height': 'show', 'opacity': 'show'}, 0);
				$('#search-container').show();
			}
			$('#offers-container').hide();
			$('#manufacturers-container').hide();
		});
		
		/*
		images = new Array('image_01.jpg', 'image_02.jpg', 'image_03.jpg', 'image_04.jpg');
		$('#welcome-bg').css('opacity', 0);
		$('#welcome-bg').css('background-image', 'url(http://www.willi-rothfuss.de/files/xmas2009.jpg)');
		$('#welcome-bg').css('background-position', '-100px');
		$('#welcome-bg').animate(
          { 
            backgroundPosition: 0
          }, {duration:5000,queue:false,easing:"easeOutExpo"});
		$('#welcome-bg').animate(
          { 
			opacity: 1
          }, {duration:1000,queue:false,easing:"easeInOutExpo"});
		/**
		**/
		
		
		//$('#welcome-content').css('background-image', 'url(http://kunden.mediastuttgart.de/000085/files/'+images[Math.round(Math.random()*4)]+')');
		//$('#welcome-content').css('background-position', '0 -100px');
		
		$('#hersteller-selector-dropdown').hide();
		
		/*
		
		$('#hersteller-selector a.trigger').hover(function()
		{
			clearTimeout(hersteller_timeout);
		});
		
		*/
		
		$('#hersteller-selector a.trigger').click(function()
		{
			if($('#hersteller-selector-dropdown').is(':visible'))
			{
				$('#close-trigger').remove();
				$('#hersteller-selector-dropdown').hide();
				$(this).css('border-bottom', '1px solid #E1E1E1');
				$('#hersteller-selector-dropdown').css('margin-top', '0px')
				$('#hersteller-selector-dropdown').css('-moz-border-radius-topleft', '3px')
				$(this).css('-moz-border-radius-bottomleft', '4px')
				$(this).css('-moz-border-radius-bottomright', '4px')
				$(this).css('margin-bottom', '0px')
			}else{
				$('body').append('<div id="close-trigger" style="width:100%;height:100%;position:absolute;top:0;left:0;z-index:1;"></div>');
				$('#close-trigger').click(function()
				{
					$('#hersteller-selector-dropdown').hide();
					$('#hersteller-selector a.trigger').css('border-bottom', '1px solid #E1E1E1');
					$('#hersteller-selector-dropdown').css('margin-top', '0px')
					$('#hersteller-selector-dropdown').css('-moz-border-radius-topleft', '3px')
					$('#hersteller-selector a.trigger').css('-moz-border-radius-bottomleft', '4px')
					$('#hersteller-selector a.trigger').css('-moz-border-radius-bottomright', '4px')
					$('#hersteller-selector a.trigger').css('margin-bottom', '0px')
					$(this).remove();
				});
				$('#hersteller-selector-dropdown').show();
				$(this).css('border-bottom', 'none');
				$('#hersteller-selector-dropdown').css('margin-top', '-2px');
				$('#hersteller-selector-dropdown').css('-moz-border-radius-topleft', '0px')
				$(this).css('margin-bottom', '1px')
				$(this).css('-moz-border-radius-bottomleft', '0px')
				$(this).css('-moz-border-radius-bottomright', '0px')
			}
		});
		
		/** PRODUCT IMAGES
		**/
		
		$("a.product-images").fancybox(
		{
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 350,
			'zoomOpacity': true,
			'overlayShow': true,
			'overlayOpacity': 0.5,
			'easingIn': 'easeOutExpo',
			'easingOut': 'easeInBack',
			'hideOnContentClick': true
		});

	});
	
	
	
	
	
