/**
     * Zeigt an, ob der Layer sichbar ist
     * => Es darf nur einen geben
     */
    var stickyisvisible = '0'
    /**
     * Die ID des aktuellen Inhalts im Layer
     */
    var currentstickyid = ''
    /**
     * Diese ID muss ausgeblendet sein, bevor eine
     * andere im Layer angezeigt werden kann
     */
    var hideBefore      = ''
      
    /**
     * Controller für StickyLayer()
     *
     * @param   stickyid 
     * @author  Daniel Kuhnke
     * @version 1.0, 30.10.2007, doc
     * @see     StickyLayer()
     */   
    showSticky = function (stickyid)
    {          
      
      /**
       * Wartezeit in Millisekunden, bis die Funktion StickyLayer() aufgerufen 
       * wird. Muss nur größer 0 sein, wenn vorher noch ein Layer versteckt werden soll.
       */
      var WaitTime = 0;
      
      /**
       * Newsletter-Layer muss versteckt werden, bevor ein anderer Layer angezeigt wird,
       * damit der Layer nicht "flackert"
       */ 
      hideBefore = 'newsletter';      
//      alert('stickyisvisible: '+stickyisvisible+' currentstickyid: '+currentstickyid+' stickyid: '+stickyid+' hideBefore: '+hideBefore);
      if (stickyisvisible == 1 && currentstickyid == hideBefore && stickyid != hideBefore) 
      { 
        StickyLayer(hideBefore);
        WaitTime = 1000;
      }    
      
      /**
       * Weiterempfehlen-Layer muss versteckt werden, bevor ein anderer Layer angezeigt wird,
       * damit der Layer nicht "flackert"
       */
      hideBefore = 'ProductRecommendation';
      if (stickyisvisible == 1 && currentstickyid == hideBefore && stickyid != hideBefore) 
      { 
        StickyLayer(hideBefore);
        WaitTime = 1000;        
      }
      
      /**
       * AGB/FAQ/Versand-Layer muss versteckt werden, bevor ein anderer Layer angezeigt wird,
       * damit der Layer nicht "flackert"
       */
      hideBefore = currentstickyid;
      if (stickyisvisible == 1 && currentstickyid != 'newsletter' && currentstickyid != 'ProductRecommendation' 
      && (stickyid == 'newsletter' || stickyid == 'ProductRecommendation')) 
      {
        StickyLayer(hideBefore);
        WaitTime = 1000;
      }
      
      /**
       * Den eigentlichen Layer anzeigen bzw. verstecken
       * 
       * => WaitTime-Verzögerung ist nur notwendig, wenn vorher ein anderer 
       *    Layer versteckt wird. Ohne die Verzögerung werden Verstecken 
       *    und Anzeigen gleichzeitig ausgeführt :(
       */ 
      setTimeout(function () { StickyLayer(stickyid); }, WaitTime);
    }
    
    
    /**
     * Blendet den Layer ein oder aus
     *
     * @param   stickyid 
     * @author  Daniel Kuhnke
     * @version 1.1, 30.10.2007, doc
     * @return  Layer
     */   
    StickyLayer = function (stickyid)
    {      
      var firstClick = 0
      var newsletterLink = 0
      contentSrc = $('Layer-'+stickyid).href      
      if (contentSrc == '#' || contentSrc == '')
      {
        return false
      }      
      
      if (stickyid == 'ProductRecommendation')
      {
        $('sticky').className = 'ProductRecommendationSticky'
      }
      else if (stickyid == 'newsletter')
      {
        $('sticky').className = 'newsletterSticky'
      }
      else
      {
        $('sticky').className = ''
      }
      
      if (stickyid == 'ProductRecommendation')
      {
        $('sticky-text-content').innerHTML = '<iframe src="'+contentSrc+'" width="100%" height="490" frameborder="0" scrolling="auto"><\/iframe>'      
      }
      else if (stickyid == 'newsletter')
      {
        $('sticky-text-content').innerHTML = '<iframe src="'+contentSrc+'" width="100%" height="546" frameborder="0" scrolling="auto"><\/iframe>'  
      }
      else
      {
        $('sticky-text-content').innerHTML = '<iframe src="'+contentSrc+'" width="100%" height="526" frameborder="0" scrolling="auto"><\/iframe>'      
      }

      if (currentstickyid != '' && currentstickyid != 'ProductRecommendation' && currentstickyid != 'newsletter')
      {
        $(currentstickyid).className = ''        
      }
      else if(currentstickyid == '' && stickyid == 'newsletter')
      {
        currentstickyid = stickyid
        firstClick = 1
        newsletterLink = 1
      }
      else
      {
        currentstickyid = stickyid
        firstClick = 1
      }
      updateStickyheader(stickyid)
      if(stickyid != 'ProductRecommendation' && stickyid != 'newsletter')
      {
        $(stickyid).className = 'active'
      }
      if (stickyid == currentstickyid || (stickyid != currentstickyid && stickyisvisible == 0) || stickyid == 'newsletter' || stickyid == 'ProductRecommendation')
      {
        new Effect.toggle($('sticky'),'appear', {delay: 0, duration: 0.2})
        if (stickyisvisible == 1)
        {
          setTimeout("toggleSelectboxesVisibility('show')", 500)
          stickyisvisible = 0
          $('NavigationTop').style.zIndex = 99
        }
        else
        {
          setTimeout("toggleSelectboxesVisibility('hide')", 200)
          stickyisvisible = 1
          $('NavigationTop').style.zIndex = 5;             
        }
      }      
      if(stickyid == 'newsletter' && firstClick == 1 && newsletterLink == 0)
      {
        resetActiveClass()
      }
      else if (currentstickyid != stickyid || firstClick == 1)
      {
        resetActiveClass()
        setActiveClass(stickyid)
      }
      else 
      {
        resetActiveClass()
      }
      currentstickyid = stickyid
    }
    
    updateStickyheader = function (stickyid)
    {
      $('Layer1').style.display = 'none'
      $('Layer2').style.display = 'none'
      $('Layer3').style.display = 'none'
      $('Layer6').style.display = 'none'
      $('Layer4').style.display = 'none'
      $('Layer5').style.display = 'none'
      $('Layer5').style.visibility = 'hidden'
            
      if (stickyid == 'impressum' || stickyid == 'agb' || stickyid == 'datenschutz' || stickyid == 'faq')
      {
        $('Layer1').style.display = 'block'
      }      
      if (stickyid == 'kontakt')
      {        
        $('Layer2').style.display = 'block'
      }
      if (stickyid == 'teilnahme')
      {        
        $('Layer6').style.display = 'block'
      }
      if (stickyid == 'versandkosten' || stickyid == 'sichererversand')
      {
        $('Layer3').style.display = 'block'
      }
      if (stickyid == 'ProductRecommendation')
      {
        $('Layer4').style.display = 'block'
      } 
      if (stickyid == 'newsletter')
      {
        $('Layer5').style.display = 'block'
        $('Layer5').style.visibility = 'visible'
      }       
    }
    
    resetActiveClass = function ()
    { 
      linkids = new Array('datenschutz', 'sichererversand', 'agb', 'impressum', 'faq', 'kontakt','newsletter','teilnahme');
      for (var i=0; i<linkids.length; ++i)
      {
        if($('Layer-'+linkids[i]) != null)
        {
          $('Layer-'+linkids[i]).className = ''
        }
      }  
    }
    
    setActiveClass = function (stickyid)
    {       
      if($('Layer-'+stickyid) != null && stickyid != 'ProductRecommendation')
      {
        if(stickyid == 'versandkosten')
        {
          $('Layer-sichererversand').className = 'Active'
        }
        else if(stickyid == 'newsletter')
        {
          $('Layer-newsletter').className = 'sub-active'
        }
        else
        {
          $('Layer-'+stickyid).className = 'Active'
        }
      }
    }

    toggleMiniBasket = function ()
    {
      if ($('mini-state').alt == '[+]')
      {
        $('mini-state').alt = '[-]'
        $('mini-state').src = '/WebRoot/leonardodb/Images/Layout/nav_wk_minus.gif'
      }
      else
      {
        $('mini-state').alt = '[+]'
        $('mini-state').src = '/WebRoot/leonardodb/Images/Layout/nav_wk_plus.gif'
      }
      new Effect.toggle($('sub-mini-basket-inner-layer'),'blind')
    }    
    
    hideMiniBasket = function ()
    {
      if ($('mini-state').alt == '[-]')
      {
        new Effect.toggle($('sub-mini-basket-inner-layer'),'blind')
      }      
    }
    
    showMiniBasket = function ()
    {
      if ($('mini-state').alt == '[+]')
      {
        new Effect.toggle($('sub-mini-basket-inner-layer'),'blind')
      }      
    }
    
    ToggleHandmadeLayer = function ()
    {
        new Effect.toggle($('HandmadeLayer'),'appear')
    }
    
    TogglePayPalLayer = function ()
    {
        new Effect.toggle($('PayPalLayer'),'appear')
    }
    
    ToggleConranLayer = function ()
    {
        new Effect.toggle($('ConranLayer'),'appear')
    }
    
    ToggleEMLayer = function ()
    {
        new Effect.toggle($('EMLayer'),'appear')
    }
    
    ToggleMWLayer = function ()
    {
        new Effect.toggle($('MiracelWhipLayer'),'appear')
    }
    
    ToggleNLLayer = function ()
    {
        new Effect.toggle($('NLLayer'),'appear')
    }
    
    ToggleHinweisLayer = function ()
    {
        new Effect.toggle($('hinweis-layer'),'appear')
    }
    
    ToggleStoreLayer = function ()
    {
        new Effect.toggle($('StoreLayer'),'appear')
    }
    
    ShowLongText = function ()
    {
        new Effect.toggle($('LongText'),'appear')
    }
    
    ShowLongTextGewinnspiel = function ()
    {
        $('ShortTextGewinnspiel').style.display = 'none'
        new Effect.SlideDown('LongTextGewinnspiel')
    }
    
    ShowPaymentNotes = function ()
    {
        new Effect.BlindDown('PaymentNotesText')
    }
    
    SwitchPreviewImage = function (displayNumber, AmountImages)
    {
      for (var i = 0; i < AmountImages; i++)
      {
        $('PreviewArea'+i).style.zIndex = 1
      }
      $('PreviewArea'+displayNumber).style.zIndex = 99
      var ImageLink = $('PreviewArea'+displayNumber).getAttribute('href')
      $('PreviewZoomLink').href = ImageLink
      
    }
    
    toggleSelectboxesVisibility = function(action)
    {
      if ((document.all) && (navigator.userAgent.indexOf('Opera')== -1))
      {
        var selectboxList = document.getElementsByTagName('select')
        if(selectboxList.length > 0)
        {
          for (var i=0; i<selectboxList.length; i++)
          {
            var SelId = 'Selectbox'+i
            if (selectboxList[i].id) { SelId = selectboxList[i].id }
            selectboxList[i].id = SelId
            
            if (action == 'hide')
            { 
//              Element.setOpacity(SelId, 0.5);
              $(SelId).style.visibility = 'hidden'
            }
            else
            {
//              Element.setOpacity(SelId, 0.9);
              $(SelId).style.visibility = 'visible'
            }          
          }
        }
      }
    }
    
    function change_on(imgid)
    {	 
    	document.getElementById(imgid).src = "/WebRoot/leonardodb/Images/Layout/"+imgid+"_a.jpg";
    }
    
    function change_off(imgid)
    {
    	document.getElementById(imgid).src= "/WebRoot/leonardodb/Images/Layout/"+imgid+".jpg";
    }