var all_menus=[];var have_active='';var donothide=false;
function allmenus_hide(e) {if (e && e.button && e.button != 1 && e.type == 'click')return;if(have_active && !donothide) {for(var i=0;i<all_menus.length;i++) hide_menu(all_menus[i]);have_active='';}donothide=false;return;}if (window.attachEvent){document.attachEvent('onclick', allmenus_hide);window.attachEvent('onresize', allmenus_hide);}else if (document.addEventListener){document.addEventListener('click', allmenus_hide, false);window.addEventListener('resize', allmenus_hide, false);}else{window.onclick = allmenus_hide;window.onresize = allmenus_hide;}
function fetch_offset(obj){if(!obj) return { 'left' : 0, 'top' : 0 };var left_offset = obj.offsetLeft;var top_offset = obj.offsetTop;while ((obj = obj.offsetParent) != null){left_offset += obj.offsetLeft;top_offset += obj.offsetTop;}return { 'left' : left_offset, 'top' : top_offset };}
function init_menu(id) {var obj=document.getElementById(id);if(!obj) return;obj.style.display = 'none';obj.onclick = function() {donothide=true;};var i;for(i=0;i<all_menus.length;i++) if(all_menus[i]==id) break;if(i>=all_menus.length) all_menus[all_menus.length]=id;}
function show_menu(id,par,ho,mid) {var dX=0; var dY=0;if(have_active==id) {hide_menu(id);return;}if(!ho){ho=0;}if(mid){dX=document.getElementById(mid).offsetLeft;dY=document.getElementById(mid).offsetTop;}else{}allmenus_hide();var obj=document.getElementById(id);if(!obj) return;if(!par) par=obj.parentNode; else par=document.getElementById(par);var pos=fetch_offset(par);obj.style.left = (pos['left']-dX) + 'px';obj.style.top = (pos['top']+par.offsetHeight+3-ho-dY) + 'px';var ww=document.body && document.body.clientWidth>0 ? document.body.clientWidth : window.innerWidth-window.pageXOffset;obj.style.display = '';obj.style.visibility = 'visible';try { if (pos['left'] + obj.offsetWidth > ww) {pos['left'] = ww - obj.offsetWidth-5;obj.style.left = pos['left'] + 'px';}} catch(e) {}setTimeout("have_active='"+id+"';",100);}
function hide_menu(id) {var obj=document.getElementById(id);if(!obj) return;obj.style.display = 'none';obj.style.visibility = 'hidden';have_active='';}

