function hw_unloadFunc(){
  top.isHyperwaveDocument=false;
}

function setHW_MainframeUrl(url)
{
  if (window.name=="HW_Mainframe")
  {
    top.isHyperwaveDocument=true;
    var theurl=url;
    if (theurl.charAt(0)!="/")
      theurl="/"+theurl;
    setCookie("HW_MainframeUrl",theurl,null);
    window.onunload = hw_unloadFunc;
  }
}

function reload_navigation() {
  if (top.frames.length == 0) return;
  if (!top.tv_is_hidden && top.frames.HW_Subframe && top.frames.HW_Subframe.frames["HW_Navigationframe"] && top.frames.HW_Subframe.frames["HW_Navigationframe"].location.href) {
    top.frames.HW_Subframe.frames["HW_Navigationframe"].location.replace("/wavemaster.internal/v6.4/components/frameset/ui/naviframe_static.html");
  }
  
  if (typeof rf !="undefined" && typeof rf.sonload =="function")
    rf.sonload();
}

function stripURL (anURL)
{
  var ret_url = anURL || "";
  if (ret_url.indexOf(";")!=-1)
     ret_url = ret_url.substring(0,ret_url.indexOf(";"));
  if (ret_url.indexOf("?")!=-1)
    ret_url = ret_url.substring(0,ret_url.indexOf("?"));
  return ret_url;
}


function checkFrameSet () 
{
  var add_url = "";

  add_url += (top.location.search.length > 1 ? top.location.search : '');
  add_url += (top.location.hash.length > 1 ? top.location.hash : '');

  var uri = gCurrentUrl;
  if (self.innerHeight==0 && self.innerWidth==0) {
    return;
  }
  if (top.frames.length==0) 
  {
    setCookie("HW_MainframeUrl", "", null);

    var kvm = new com.hyperwave.util.KeyValueMap();
    kvm.addParameterString(top.location.href);
    if (kvm.containsKey("action")) {
      setCookie("HW_RequestedUrlA", kvm.getOneValue("action"), null);
      setCookie("HW_RequestedUrlP", kvm.getOneValue("Parameter"), null);
    }
    else {
      setCookie("HW_RequestedUrlA", "", new Date(0));
      setCookie("HW_RequestedUrlP", "", new Date(0));
    }

    uri = stripURL(uri);
    var context = (top.gCurrentContext!="")?"&ctx="+top.gCurrentContext:"";
    top.location.replace(uri + ";internal&action=buildframes.action&Parameter=" + gUnique + context + add_url);
  }
  if (typeof cf !="undefined" && typeof cf.sonload =="function")
    cf.sonload();
}

function reload_userblock ()
{
  var ss_editmode = gSSEditmode;
  if (typeof(top.frames.HW_Staticframe)=="object" && top.frames.HW_Staticframe.lasteditmode != ss_editmode)
  {
    if (top.frames.HW_Staticframe.clearMenu)
      top.frames.HW_Staticframe.clearMenu();
    var uri = stripURL(gCurrentUrl);
    top.frames.HW_Staticframe.location.replace(uri+";internal&action=userblock.action&Parameter="+gUnique);
  }
  
  if (typeof ru !="undefined" && typeof ru.sonload =="function")
    ru.sonload();
}

