  function seetickets()
  {
    // check the query string - this should over-ride the cookie
    if (query.match("filler2"))
    {
      // the query string has a referal key, retain it in all page links
      
      // extract the filler2 code
      var pairs = query.split('&');

      for (i = 0; i < pairs.length; i++)
      {
        var parts = pairs[i].split('=');
        aPairs[parts[0]] = parts[1];
      }

      // aPairs['filler2'] now has our referal code
      // Loop over any anchor hrefs and form actions and insert the filler2 code
      
      alterAttributes(links, "href", query);
      alterAttributes(forms, "action", query);
      
      var cookieName = "filler2";
      var cookieValue = aPairs['filler2'];
      var theCookie = cookieName + "=" + cookieValue;
      document.cookie = theCookie;
    }
    // no query string?  check for a cookie
    else
    {
      aPairs['filler2'] = getCookie('filler2');

      if (aPairs['filler2'] != false)
      {
        alterAttributes(links, "href", "filler2=" + aPairs['filler2']);
      }
    }
  }

  function alterAttributes(elements, attribute, code)
  {
    for (i = 0; i < elements.length; i++)
    {
      var the_link = escape(elements[i].getAttribute(attribute));

      var joiner = "?";
      if (the_link.indexOf(escape(joiner)) != -1)
      {
        joiner = "&";
      }

      if (the_link.indexOf(code) == -1)
      {
        elements[i].setAttribute(attribute, unescape(the_link) + unescape(joiner) + "filler2=" + aPairs["filler2"]);
      }
    }
  }

  function getCookie(searchName)
  {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++)
    {
      var cookieCrumbs = cookies[i].split("=");
      var cookieName = cookieCrumbs[0];
      var cookieValue = cookieCrumbs[1];

      if (cookieName == searchName)
      {
        return cookieValue;
      }
    }
    return false;
  }

  var aPairs = [];
  var query = window.location.search.substring(1);
  var links = document.getElementsByTagName("a");
  var forms = document.getElementsByTagName("form");

  seetickets();
