// VARS
var cookieName = "iso-terms";

// INITIAL FOCUS
function setFocus() {
  document.loginForm.j_username.select();
  document.loginForm.j_username.focus();
}

// COOKIES CHECK
function checkCookies() {
  if (document.cookie.indexOf('JSESSIONID') == -1) {
    var cookieExplanation = window.document.getElementById('cookie');
    cookieExplanation.style.display='block';
    var submitButton = window.document.getElementById('submit');
    submitButton.disabled = true;
  }
}

// TERMS CHECK
function checkTerms() {
  if(document.loginForm.terms.checked == true) {
	$('loginForm').action="j_security_check";
    return true;
  }
  alert("You must accept the terms and conditions.");
  return false;
}
function setTerms() {
  setCookie(cookieName, document.loginForm.terms.checked, 2050, 1, 1);
}
function getTerms() {
  if(getCookie(cookieName) == "true") {
    document.loginForm.terms.checked = true;
  }
}

// COOKIES
function setCookie (name, value, exp_y, exp_m, exp_d) {
  var cookie_string = name + "=" + escape ( value );
  if (exp_y) {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
  document.cookie = cookie_string;
}
function getCookie (cookie_name) {
  var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');
  if (results)
    return (unescape (results[1]));
  else
    return null;
}

// LOST PASSWORD
function notifyLost() {
  alert("You will be forwarded to the ISO Global Directory application ... \nPlease use the appropriated action in order to recover your username/password");
}