String.prototype.regexmatch = function(format) {
  var result = format.exec(this);
  return !result ? null : (result.length === 1 ? result[0] : (result.length === 2 ? result[1] : result));
};

var _gaq = _gaq || [];

$(document).
ready(
  function() {
    if (document.domain.regexmatch(/^[\w\-]+\.\w+$/)) {
      _gaq.push(['_setAccount', 'UA-16801690-1']);
      _gaq.push(['_trackPageview']);
    }
/*
    'links-info-on.png',        'links-info-off.png'
    'links-nieuwsbrief-on.png', 'links-nieuwsbrief-off.png'
    'links-steun-on.png',       'links-steun-off.png'
    'menu-home-on.png',         'menu-home-off.png'
    'menu-info-on.png',         'menu-info-off.png'
    'menu-nieuws-on.png',       'menu-nieuws-off.png'
    'menu-nieuwsbrief-on.png',  'menu-nieuwsbrief-off.png'
    'menu-steun-on.png',        'menu-steun-off.png'
    'menu-contact-on.png',      'menu-contact-off.png'
*/
    var huidigepagina = window.location.href.regexmatch(/([\w-]+)[^\/]*$/);

    $('#links img, #menu img').
    hover(
      function() {
        $(this).
        attr('src',
          function(index, val) {
            $(this).
            data('original_src', val);

            return val.replace(/-off\./, '-on.', val);
          }
        );
      },
      function() {
        $(this).
        attr('src',
          function(index, val) {
            return $(this).data('original_src');
          }
        );
      }
    );

    $('#sociaal a').
    click(
      function() {
        window.open($(this).attr('href'));
        return false;
      }
    );

    $('.fotos').
    wrap('<div class="fotogalerij"></div>').
    before('<div class="galerij"></div>').
    find('img').
      click(
        function() {
          $(this).
          closest('.fotogalerij').
            find('.galerij').
              empty().
              append(
                $(this).
                clone()
              ).
            end().
            find('.active').
              removeClass('active').
            end().
          end().
          addClass('active');
        }
      ).
      eq(0).
        click().
      end().
    end();
  }
);

