function getSearchTerms() {
        var searchEngines = new Array();
        searchEngines["^http://www\.google.*$"] = "q";
        searchEngines["^http://www.googel.fi.*$"] = "q";
        searchEngines["^http://.*search.msn.co.*results.*$"] = "q";
        searchEngines["^http://.*\.mysearch.com/jsp/GGmain.jsp?searchfor=.*$"] = "searchfor";
        searchEngines["^http://search.freeserve.com/.*$"] = "q";
        searchEngines["^http://aolsearch.aol.co.*$"] = "query";
        searchEngines["^http://search.yahoo.com.*$"] = "va";
        searchEngines["^http://search.yahoo.com.*$"] = "p";
        searchEngines["^http://www.bbc.co.uk/cgi-bin/search/.*"] = "q";
        searchEngines["^http://www.tiscali.co.uk/search/results.php.*$"] = "query";
        searchEngines["^http://www.altavista.com/web/results.*$"] = "q";
        searchEngines["^http://search.hotbot.co.uk/cgi-bin/pursuit.*$"] = "query";
        searchEngines["^http://www.excite.co.uk/search/web/results.*$"] = "q";
        searchEngines["^http://uk.search.yahoo.com/search.*$"] = "p";
        searchEngines["^http://search.wanadoo.*$"] = "q";
        searchEngines["^http://www.daddyhunt.com.*$"] = "q";

		var searchEngineNames = new Array();
		searchEngineNames["^http://www\.google.*$"] = "g";
		searchEngineNames["^http://www.googel.fi.*$"] = "g";
		searchEngineNames["^http://.*search.msn.co.*results.*$"] = "m";
		searchEngineNames["^http://.*\.mysearch.com/jsp/GGmain.jsp?searchfor=.*$"] = "mysearch";
		searchEngineNames["^http://search.freeserve.com/.*$"] = "freeserve";
		searchEngineNames["^http://aolsearch.aol.co.*$"] = "a";
		searchEngineNames["^http://search.yahoo.com.*$"] = "y";
		searchEngineNames["^http://search.yahoo.com.*$"] = "y";
		searchEngineNames["^http://www.bbc.co.uk/cgi-bin/search/.*"] = "bbc";
		searchEngineNames["^http://www.tiscali.co.uk/search/results.php.*$"] = "tiscali";
		searchEngineNames["^http://www.altavista.com/web/results.*$"] = "a";
		searchEngineNames["^http://search.hotbot.co.uk/cgi-bin/pursuit.*$"] = "h";
		searchEngineNames["^http://www.excite.co.uk/search/web/results.*$"] = "e";
		searchEngineNames["^http://uk.search.yahoo.com/search.*$"] = "y";
		searchEngineNames["^http://search.wanadoo.*$"] = "wanadoo";
		searchEngineNames["^http://www.daddyhunt.com.*$"] = "d";
		
        for (exp in searchEngines) {
                var re = new RegExp(exp);
                if (re.test(document.referrer)) {
                        var qs = new Querystring(document.referrer.substring(document.referrer.lastIndexOf("?") + 1));
						var terms = qs.get(searchEngines[exp]);
                        if (terms != null) {
							setCookie("searchEngine", searchEngineNames[exp]);
							setCookie("searchTerms", terms);
						}
                }
        }
		if (getCookie("searchTerms") != null) {
			document.write(Math.floor(Math.random()*100));
			document.write(getCookie("searchEngine"));
			document.write(":");
			document.write(getCookie("searchTerms"));
			document.write(Math.floor(Math.random()*100));
		}
}












/* Client-side access to querystring name=value pairs
        Version 1.2.3
        22 Jun 2005
        Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
        this.params = new Object()
        this.get=Querystring_get

        if (qs == null)
                qs=location.search.substring(1,location.search.length)

        if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
        qs = qs.replace(/\+/g, ' ')
        var args = qs.split('&') // parse out name/value pairs separated via &

// split out each name=value pair
        for (var i=0;i<args.length;i++) {
                var value;
                var pair = args[i].split('=')
                var name = unescape(pair[0])

                if (pair.length == 2)
                        value = unescape(pair[1])
                else
                        value = name

                this.params[name] = value
        }
}

function Querystring_get(key, default_) {
        // This silly looking line changes UNDEFINED to NULL
        if (default_ == null) default_ = null;

        var value=this.params[key]
        if (value==null) value=default_;

        return value
}

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
