var m_id=[0];
var m_ind=[0];
var timer_id=null;
var MenuTimeOut=1000;

var font_color = "#ffffff";
var background_color = "#000000";
var hover_font_color = "#ffffff";
var hover_background_color = "#1f95d2";
var is_nav ;
var is_minor;

var help_image = "/pp2/view/common/img/arrow_help.gif";

function set_over(id) {
 document.getElementById('h'+id).style.color= hover_font_color;
 document.getElementById('h'+id).style.backgroundColor= hover_background_color;
}

function reset_over(id) { 
 if (document.getElementById('h'+id).src){
   document.getElementById('h'+id).src = help_image;
 }
 else{
  document.getElementById('h'+id).style.color= font_color;
  document.getElementById('h'+id).style.backgroundColor= background_color;
 }
}

function set_img(id, img){
 document.getElementById(id).src = img;
}

function m_over(m_id1,m_id2)
{
	
	setSelectVisibility(false);


    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()',MenuTimeOut);
}

function m_in()
{
    m_rtimer();
}

function m_hide()
{
    if (m_id.length>2)
    {
	hide_ms(m_id.length-1);
	timer_id=setTimeout('m_hide()',MenuTimeOut);
    }
    else
    {
	hide_ms(1);
	timer_id=null;
    }
setSelectVisibility(true);
}

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');
	reset_over(m_id[j]);
    }
    
    m_id.length=i;
}

function m_visibility(id,visibility)
{
    if (document.getElementById)
	document.getElementById('menu'+id).style.visibility=visibility;
    else
        document.all['dropmenu'+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);
	setSelectVisibility(true);
}


function setSelectVisibility(hideSelects) {
	if (document.all){
	
		if (document.forms["appointmentForm"] != null){
			var obj = document.forms["appointmentForm"].elements["apt.service.msID"];
			if (obj != null){
				if (hideSelects){
					obj.style['display'] = "block";
				}
				else{
					obj.style['display'] = "none";
				}
			}
		}
	}
}

document.onclick=m_do_hide;


