/*
ns dc       http://purl.org/dc/elements/1.1/
dc:date     2006-11-15
dc:creator  benjamin nowack
*/

if(!window["js_libs"]){window.js_libs={};}

window.js_libs["contextmenu"]={
	onload : function(){
    try { contextmenu_hide(); } catch(e) {};
    addEvent(elByTag('body'), 'click', 
      function(e) {
        contextmenu_clear();
      }
    );
	} 
}

function contextmenu_get_div() {
  if (!elById('contextmenu')) {
    div = document.createElement("div");
    div.id = 'contextmenu';
    elByClass('page').appendChild(div);
  }
  return elById('contextmenu');
}

function contextmenu_render(val){
  try {clearTimeout(window.contextmenuTO)} catch(e) {}
  var div = contextmenu_get_div();
  var move = div.style.display != 'block' ? 1 : 0
  div.style.display = "none";
  div.innerHTML = val;
  div.style.left = (parseInt(window.m_x) + 5) +'px';
  div.style.top = (parseInt(window.m_y) + 5) +'px';
  div.style.display = "block";
}

function contextmenu_clear(){
  try {clearTimeout(window.contextmenuTO)} catch(e) {}
  var div = contextmenu_get_div();
  window.contextmenuTO = window.setTimeout(function(){ div.innerHTML = ''; div.style.display = 'none'; }, 50);
}

