function registerGalleryMenu()
{
  $('#galley-menu-next a').click(
    function()
    {
      $.get(
        this.href,
        {
          json: 1
        },
        function (data)
        {
          $('#teaser-image').html(data.teaserImage);
          $('#detail-content').html(data.detailContent);
          registerNextLink();
        },
        'json'
      );
      return false;
    }
  );
  $('#gallery-menu-print a').click(
    function()
    {
      self.print();
      return false;
    }
  );
}


jQuery(
  function()
  {
    $("#mainmenu").superfish(
      {
        autoArrows:   false,
        delay:        0,
        hoverClass:   'sfHover',
        speed:        'fast'
      }
    );

    for (val in static) {
      $('#' + val).focus(
        function()
        {
          if (this.value == static[val])
            this.value = '';
        }
      ).blur(
        function()
        {
          if (this.value == '')
            this.value = static[val];
        }
      ).val(static[val]);
    }

    if ($('.scrollable-items').size()) {
      $('.scrollable-items').css('position', 'absolute');
      $('#thumbnail-box .scrollable').css('overflow', 'hidden').scrollable(
        {
          clickable:  false,
          item:       'a',
          size:       4
        }
      ).find('a').click(
        function()
        {
          $(this).parent().find('a.selected').removeClass('selected');
          $(this).addClass('selected');

          $.get(
            this.href,
            {
              json: 1
            },
            function (data)
            {
              $('#banderole, #mainmenu li.selected a[id]').css('background-color', data.bgColor ? data.bgColor : '#A2AD00');
              $('#teaser-content').html(data.teaserContent);
              $('#feature-links').html(data.leftColumn);
              $('#content-wrapper').html(data.bodyContent);
              $('#teaser-image').html(data.teaserImage);
              $('#detail-image').replaceWith(data.detailImage);
              $('#detail-content').html(data.detailContent);
              registerGalleryMenu();
            },
            'json'
          );
          return false;
        }
      );
    }
    registerGalleryMenu();

    $('a[href^=#]').click(
      function()
      {
        $('html, body').animate({scrollTop: $($(this).attr('href')).offset().top - 10}, 250);
        return false;
      }
    );
    $('a.google-link').live('click', function(){this.target='_blank';});
    $('#retailer-search-form').submit(
      function()
      {//alert($('#zip-code').val() +' '+ static['zip-code']);
        if ($('#zip-code').val() == static['zip-code'])
          return false;
      }
    )
  }
);

