/* Copyright 2009 Google, Inc. All Rights Reserved. */
var googleMore = function() {
  var tagNavLinks = function() {
    var links = document.getElementById('nav').getElementsByTagName('a');

    for (var i = 0, len = links.length; i < len; i++) {
      var link = links[i];
      link.onclick = qs(link);
    }
  };

  var tagProductLinks = function() {
    var links = document.getElementById('products').getElementsByTagName('a');

    for (var i = 0, len = links.length; i < len; i++) {
      var link = links[i];
      link.onclick = callGA(link.href);
    }
  };

  var callGA = function(target) {
    return function() { pageTracker._trackPageview(target); };
  };

  var qs = function(el) {
    return function() {
      if (window.RegExp && window.encodeURIComponent) {
        var qe = encodeURIComponent(document.gs.q.value);
        if (el.href.indexOf('q=') != -1) {
          el.href = el.href.replace(new RegExp('q=[^&$]*'), 'q=' + qe);
        } else {
          el.href += '&q=' + qe;
        }
      }
      return 1;
    };
  };

  var init = function() {
    document.gs.reset();
    tagNavLinks();
    tagProductLinks();
  };

  return {
    'init': init
  };
}();
