(function($) {
  $(window).load(function() {
    $('.sponsors-slides, .community-logo-slideshow').cycle({
      fx: 'fade',
      speed: 'slow',
      timeout: 6000,
      cleartypeNoBg: true
    });
  });

  $.getQueryParam = function(query_string, key) {
    var match = query_string.match(RegExp(key + "=([^&]+)"));

    return match && match[1];
  };

  $.setQueryParam = function(query_string, key, value) {
    return query_string.replace(RegExp(key + "=([^&]*)"), key + "=" + value);
  };

  $(".gallery-thumbs").tnGalleryNav();

  $("a[href*=#view]").click(function() {
    $.tnGallery.activate(this);
  });

  $(function() {
    var m = window.location.href.match(/(#view.*)$/),
        $a = null;

    if (m) {
      $a = $("a[href=" + m[1] + "]");

      $.tnGallery.activate($a);
    }
  });

  $(".main-pic a").lightBox({ fixedNavigation:true });

  $(".community-logos nav.prev-next a").live("click", function() {
    $.get($(this).attr("href"), function(html) {
      $("section.community-logos").replaceWith(html);
    });

    return false;
  });


})(jQuery);
