
  // Script to break out of frames incase another website has encased us, and make sure we are at www...
  // so that cookies don't disappear when we switch.
  // Copyright, Mike 2005

  var redirect = false;  // Redirect users to www.
  var breakout = false;  // Break out of frames

  // 1. Generate desired URL
  var url = window.location.href;
  var http = false;
  var https = false;

  if ((url.substring(0,7)) == "http://") {
    url = url.substring(7);
    http = true;
  }
  else if ((url.substring(0,8)) == "https://") {
    url = url.substring(8);
    https = true;
  }

  if ((url.substring(0,4)) != "www.") {
    url = "www." + url;
    redirect = true;
  }

  if (https == true) url = "https://" + url;
  else if (http == true) url = "http://" + url;

  // 2. Detect frameset
  try {
    var topurl = top.location.href;  // Get access denied exception only if is a different domain (except Konqueror)
    if (topurl != window.location.href) breakout = true;  // If accessed double check URL is different (solves Konqueror)
  }
  catch(e) {
    if (self != top) breakout = true;  // Shouldn't be necessary, but the object comparison seems to work
  }

  // 3. Do redirect
  if (breakout == true) {  // Perform both actions
    try {
      top.location = url;  // NS6 + Konqueror don't support .href writing. Should except if non .href not supported
    }
    catch(e) {
      top.location.href = url;  // Would prefer this but ho hum
    }
  }
  else {
    if (redirect == true) {
      window.location.href = url;  // Non frames www. redirect only required
    }
  }
