

function getElemRefs(id) {
 var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
 if (el) el.css = (el.style)? el.style : el;
 return el;
}


var currentDiv;

var origWidth, origHeight;
if (document.layers) {
 origWidth = window.innerWidth; origHeight = window.innerHeight;
 window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyrNote;
function popLayersNote(id) {
currentDiv=id;
  if (cur_lyrNote) hideLayerNote(cur_lyrNote);
  showLayerNote(id);
  cur_lyrNote = id;
}

function showLayerNote(id) {
  var lyrNote = getElemRefs(id);
  if (lyrNote && lyrNote.css) lyrNote.css.visibility = "visible";
}

function hideLayerNote(id) {
  var lyrNote = getElemRefs(id);
  if (lyrNote && lyrNote.css) lyrNote.css.visibility = "hidden";
}

function getElemRefs(id) {
 var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
 if (el) el.css = (el.style)? el.style : el;
 return el;
}


function hideDiv(e)
{
 if (!e) var e = window.event
 if(currentDiv != undefined)
 {
  	var div = getElemRefs(currentDiv);

  	if(!isClicked(div,e))
  	{
  		hideLayerNote(currentDiv);
  		currentDiv=null;
 	}
 }
}

function isClicked(div,e)
{
 var t;
 if (document.all)
 	t = window.event.srcElement;
 else
 	t = e.originalTarget;
 while (t.parentElement != null) {
  if (t.id==div.id) {
   return true;
  }
  t = t.parentElement;
 }
 return false;
}


document.onmouseup = hideDiv;

