var onLink = false;
var onForm = false;
var inForm = false;
var full = true;

function newclass (the_ids, c) {
  var b = "";
  var a = the_ids.split(', ');
  for (var j = 0; j < a.length; j++) {
    b = a[j];
    var target_id = window.document.getElementById(b);
    target_id.className = c;
  }
  return (false);
}

function head_detect (z) {
  if (z.length > 1) {  full = false;  }
}

function hfl () {				// hide both forms and links
  if (full) {
    newclass ('GF, PF', 'UMDhide');
    newclass ('GL, PL', 'UMDoff');
  } else {
    newclass ('GcF, PcF', 'UMDhide');
    newclass ('GcL, PcL', 'UMDoff');
  }
}

function cloak () {				// hide if not in form or over form or link
  if (!(inForm) && !(onForm) && !(onLink)) {  hfl ();  }
}

function onL (frm) {					// on link
  onLink = true;
  head_detect (frm);
  hfl ();
  var g = frm + "L";  var h = frm + "F";
  if (full) {  newclass (g, 'UMDon');  } else {  newclass (g, 'UMDon_compact');  }
  newclass (h, 'UMDshow');
}  

function offL (frm) {					// off link
  onLink = false;
  head_detect (frm);
  var theTimer = setTimeout("cloak()",7000);
}

function inF (frm) {					// in form
  inForm = true;
  head_detect (frm);
}

function outF (frm) {					// out of form
  inForm = false;
  head_detect (frm);
  var theTimer = setTimeout("cloak()",7000);
}

function onF (frm) {					// on form
  onForm = true;
  head_detect (frm);
}

function offF (frm) {					// off form
  onForm = false;
  head_detect (frm);
  var theTimer = setTimeout("cloak()",5000);
}

