var visits = getCookie("TNBJJCookie");
var passwordValid = 0;
// if the cookie wasn't found, this is your first visit
if (!visits) {
  password = window.prompt("\nPlease enter your password","");
  switch(password)
  {
     case(password = "admin1234"): passwordValid=1; break
     case(password = "xguard"): passwordValid=1; break


     default: alert("Invalid Password. \nRemember your password is case-sensitive!");break
  }   
    
  if(passwordValid==1)
  {
     visits=1;
     setCookie("TNBJJCookie", visits);
     window.location="http://www.tnbjj.com/StudentResources.html";
  }
  else  window.location="http://www.tnbjj.com/resources.html";
} else {
  window.location="http://www.tnbjj.com/StudentResources.html";
}
// name - name of the cookie value - value of the cookie
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") + "; path=/" +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
   
}
// name - name of the desired cookie
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

