function loadCookie() {
  //
  // PTCP Search Engine Capture - Production Version
  //
  // Un-comment the four lines below for initializing of testing.  Erases cookies.
  //
  //eraseCookie("status-3");
  //eraseCookie("searchurl-3");
  //eraseCookie("searchterm-3");
  //eraseCookie("searchlandingpage-3");
  var days = 1; // Cookie expires in 1 day
  //alert("Initial onLoad Status: " + readCookie("status-3")); 
  //alert("Initial onLoad URL: " + readCookie("searchurl-3")); 
  //alert("Initial onLoad Search Term: " + readCookie("searchterm-3"));
  //alert("Initial onLoad Landing Page: " + readCookie("searchlandingpage-3"));
  // 
  //  If Cookies exist, load variables
  //
  if (readCookie("status-3")) {
    var status = readCookie("status-3");
	var searchterm = readCookie("searchterm-3");
    var searchurl = readCookie("searchurl-3");
  	var searchlandingpage = readCookie("searchlandingpage-3");
  }
  //
  //  If Cookies don't exist, gather information and create them
  //
  else {
    // Set Status Cookie
    var status = "NoSubmit";
    createCookie("status-3", status, days);
	// Set Current Page Name
	var sPath = window.location.pathname;
    var searchlandingpage = sPath.substring(sPath.lastIndexOf('/')+1);
    createCookie("searchlandingpage-3", searchlandingpage, days);
	// Determine Referring URL and Keywords
    var ref = document.referrer;
	//alert ("ref: " + ref);
    var firstsplit = ref.split("?");
	//alert ("firstsplit[0]: " + firstsplit[0]);
	//alert ("firstsplit[1]: " + firstsplit[1]);
	if (firstsplit[1]) {
      var secondsplit = firstsplit[1].split("&");
      var thirdsplit;
      var keyWord;
      for (i=0; i<10; i++) {
	    if (secondsplit[i]) {
	      thirdsplit = secondsplit[i].split("=");
          if (thirdsplit[0] == "q") {
            keyWord = thirdsplit[1];
          }
          if (thirdsplit[0] == "p") {
            keyWord = thirdsplit[1];
          }
        }
	  }
    }
    createCookie("searchurl-3", firstsplit[0], days);
    createCookie("searchterm-3", keyWord, days);
  }
  // Display Cookies at end of onLoad
  //alert("Final onLoad Status: " + readCookie("status-3"));
  //alert("Final onLoad URL: " + readCookie("searchurl-3"));
  //alert("Final onLoad Search Term: " + readCookie("searchterm-3"));
  //alert("Final onLoad Landing Page: " + readCookie("searchlandingpage-3"));
}
function submitCookie() {
  var days = 1; // Cookie expires in 1 day
  //alert("Initial onSubmit Status: " + readCookie("status-3")); 
  //alert("Initial onSubmit URL: " + readCookie("searchurl-3")); 
  //alert("Initial onSubmit Search Term: " + readCookie("searchterm-3"));
  //alert("Initial onSubmit Landing Page: " + readCookie("searchlandingpage-3")); 
  // Check for Existence of Cookie
  if (readCookie("status-3")) {
    var status = readCookie("status-3");
  //  alert("Initial Setting: " + status);
  }
  // Set Initial Status
  var status = "Submit";
  // Write Value to Cookie
  createCookie("status-3", status, days);
  if (readCookie("searchurl-3")) {
    var searchurl = readCookie("searchurl-3");
	document.form1.searchURL.value = searchurl;
  }
  if (readCookie("searchterm-3")) {
    var keyWord = readCookie("searchterm-3");
	var keyWordLength;
    var keyWordLeft;
    var keyWordRight;
    for (i=0; i<10; i++) {
      x = keyWord.indexOf("+");
	  if (x != -1) {
	    keyWordLength = keyWord.length;
	    keyWordLeft = keyWord.substring(0,x);
	    keyWordRight = keyWord.substring(x+1,keyWordLength);
	    searchKeywords = keyWordLeft + " " + keyWordRight;
	  }
    }
	document.form1.searchKeywords.value = keyWord;
  }
  if (readCookie("searchlandingpage-3")) {
    var searchlandingpage = readCookie("searchlandingpage-3");
	document.form1.searchLandingPage.value = searchlandingpage;
  }
  //alert("Final onSubmit Status: " + readCookie("status-3"));
  //alert("Final onSubmit URL: " + searchurl);
  //alert("Final onSubmit Search Term: " + searchKeywords);
  //alert("Final onSubmit Landing Page: " + searchlandingpage);
  //alert("Submit happens next");
}
//
// Cookie Scripts written by Scott Andrew from 
// http://www.yourhtmlsource.com/javascript/cookies.html#convenientscripts
// 
function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}


