// Original JavaScript code by Duncan Crombie: dcrombie@chirp.com.au
// Please acknowledge use of this code by including this header.

  var bikky = document.cookie;

  function getCookie(name) { // use: getCookie("name");
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1;
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1) endstr = bikky.length;
    return unescape(bikky.substring(index, endstr));
  }

  var today = new Date();
  var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days
  var expired = new Date(today.getTime() - 28 * 24 * 60 * 60 * 1000); // less 28 days

  function setCookie(name, value) { // use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) +
        "; domain=" + document.domain +
        "; expires=" + expiry.toGMTString();
    bikky = document.cookie; // update bikky
    return getCookie(name) != null; // return false if the cookie was refused
  }

  function deleteCookie(name) { // use: deleteCookie("name");
    document.cookie=name + "=null; expires=" + expired.toGMTString(); // delete cookie
    bikky = document.cookie; // update bikky
    document.forms[0].cookieContent.value = formatCookie(); // display cookie content
  }

  function makeCookie() { // make sure the cookie is set
    var form = document.forms[0];
    while (!setCookie(form.targetcookie.value, form.content.value)) {
      if (!confirm('The cookie was not accepted by your browser\nYou must allow cookies to use this page')) {
        alert('By refusing our harmless cookie strings\nyou are preventing this page from operating correctly\nCome back when you are ready to cooperate');
        history.back(); // take them out of the page
        break;
      }
    }
    form.cookieContent.value = formatCookie(); // display cookie content
  }

  function formatCookie() {
    var retValue = "";
    with (bikky) {
      for (var i=0; i < length; i++)
        retValue += (charAt(i) != " ") ? charAt(i) : "\n";
    }
    return retValue;
  }
  var screenW = 1024, screenH = 786;

  if (parseInt(navigator.appVersion) > 3) 
  {
    screenW = screen.width;
    screenH = screen.height;
  }
  else if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 3) && navigator.javaEnabled())
  {
    var jToolkit = java.awt.Toolkit.getDefaultToolkit();
    var jScreenSize = jToolkit.getScreenSize();
    screenW = jScreenSize.width;
    screenH = jScreenSize.height;
  }
  setCookie("screenW", screenW);
  setCookie("screenH", screenH);
