
var popupWindow = null;

function popup(url,width,height) {

 if(popupWindow!=null)
  {
  if (typeof(popupWindow) == "object")
   popupWindow.close();
//   popupWindow = null;
  }
        var width=width;
        var height=height;
        var top  = (screen.height - height) / 2;
        var left = (screen.width  - width)  / 2;
        $popup='popup'+width+'x'+height;
    popupWindow = window.open(url,$popup,'toolbar=no,menubar=no,scrollbars=no,resize=no,titlebar=no,resizable=no,width='+width+',height='+height+',top='+top+',left='+left+'');
        popupWindow.focus();
}


function showsel(obj,name,arr_id) {
 var id;
//		  alert(arr_id.length);
    for(j=0; j< arr_id.length; j++){
 document.getElementById(name+arr_id[j]).style.display='none';
 }
 id=obj.options[obj.selectedIndex].value;
 document.getElementById(name+id).style.display='';
 document.getElementById('sel'+name+id).click();
}


var m_id=[0];
var m_ind=[0];
var timer_id=null;
var menuNTimeOut=1000;

function m_over(m_id1,m_id2)
{
    m_rtimer();

    if (m_ind[m_id1]!=null)
        hide_ms(m_ind[m_id1]+1);

    if (m_id2!=0)
    {
	m_visibility(m_id2,'visible');
	m_ind[m_id2]=m_id.length;
	m_id[m_id.length]=m_id2;
    }
}

function m_out()
{
    if (timer_id!=null)
	return;

    if (m_id.length==1)
	return;

    timer_id=setTimeout('m_hide()',menuNTimeOut);
}

function m_in()
{
    m_rtimer();
}

function m_hide()
{
    if (m_id.length>2)
    {
	hide_ms(m_id.length-1);
	timer_id=setTimeout('m_hide()',menuNTimeOut);
    }
    else
    {
	hide_ms(1);
	timer_id=null;
    }
}

function hide_ms(i)
{
    var j;

    for(j=m_id.length-1;j>=i;j--)
    {
	m_ind[m_id[j]]=null;
	m_visibility(m_id[j],'hidden');
    }
    
    m_id.length=i;
}

function m_visibility(id,visibility)
{
    if (document.getElementById)
	document.getElementById('menuN'+id).style.visibility=visibility;
    else
        document.all['dropmenuN'+id].style.visibility=visibility;
}

function m_rtimer()
{
    if (timer_id!=null)
    {
	clearTimeout(timer_id);
	timer_id=null;
    }
}

function m_do_hide()
{
    m_rtimer();
    hide_ms(1);
}


document.onclick=m_do_hide;

