var topshouldbe = "/humanphysspace/index.html"
var topshouldbe2 = "/humanphysspace/indexb.html"
var topshouldbe3 = "/humanphysspace/"

//var topshouldbe = "/HumanPhysSpace/index.html"
//var topshouldbe2 = "/HumanPhysSpace/indexb.html"
//var topshouldbe3 = "/HumanPhysSpace/"

var topis = top.location.pathname.substring(top.location.pathname).toLowerCase()
//alert( topis )

if (two=="drz") {
two=2
//alert(focusnum + " " + type + " " + one + " " + two)
if ((topis!=topshouldbe) && (topis!=topshouldbe2) && (topis!=topshouldbe3)) { 
//alert(topis)
//    alert("b4 checkcookie: " + s)
  if (CheckCookie()) {
//alert("cookie from page top BAD: " + document.cookie)
    var s = "NSBRILoad=true="+ focusnum + type + one + two
    document.cookie="NSBRILoad=true="+ focusnum + type + one + two
    document.cookie="NSBRI=false="+focusnum+type+one+two+";path=/HumanPhysSpace/"
    if (parent.frames.length == 0)
      window.top.location.replace("../index.html")
    else
      window.open("../index.html", "_top")
  }
} else {
//    alert("else topis!=...: " + s)
  if (document.cookie) {
//alert("cookie from page top GOOD: " + document.cookie)
    loadtmp = document.cookie
    var loadtmp2 = loadtmp.split(";")
    for(var i=0; i<loadtmp2.length; ++i) {
      var loadtmp3 = loadtmp2[i].split("=")
      if (loadtmp3[0]=="NSBRILoad")
        if (loadtmp3[1]=="true")  
          if (loadtmp3[2].charAt(1) == type) {
            document.cookie="NSBRILoad=false=" + focusnum + type + one + two
            window.location.reload(true);
          } 
    }
  }
}


} //end drz test


function goBack() {         
  document.cookie="NSBRILoad=false="+ focusnum + type + one + two
  document.cookie="NSBRI=true=false="+ focusnum + type + one + two + ";path=/HumanPhysSpace/"
  window.history.back()
}

function CheckCookie() {
  if (document.cookie) {
    nsbritmp = document.cookie
    var nsbritmp2 = nsbritmp.split(";")     
    for(var i=0; i<nsbritmp2.length; ++i) {
      var nsbritmp3 = nsbritmp2[i].split("=")
      if (nsbritmp3[0]=="NSBRI")
        if (nsbritmp3[1]=="true")
          return true
        else
          if (nsbritmp3[2].charAt(1)==type) {
            goBack();
            return false;
          }  
    }
  }
  return true
}

