// Copyright (c) Digita West 2005
// Last revision 04-07-2005 8:55am - covet

var m_timer = new Array();
var m_tops = new Array();

var m_speed = 5;  // How many pixels to move the menu
var m_ttl = 10;   // How often (in ms) to update the menu.
var m_offset = 22; // Menu vertical position offset.

// --------------------------------------------------------
// Only called if the menu hasn't been initialized yet.
// (The menu is offscreen at start, this function positions
// it at it's start point)

function menu_init(o_id)
{
if (m_bNS4) return;

mb_object = document.getElementById('menubar');

m_object = document.getElementById(o_id);

if (o_id == "searchbox") 
	{
	m_object.style.visibility="visible";
//	m_tops[o_id]=0;
//	m_tops[o_id]=20;
	m_tops[o_id]= 0 -  parseInt(m_object.offsetHeight);
	}
	else
	{
	m_tops[o_id]= 0 -  parseInt(m_object.offsetHeight) + m_offset;
	}

m_object.style.top = m_tops[o_id] + "px";
}


// --------------------------------------------------------

function init_menus()
{

menu_init('button.company');
menu_init('button.services');
menu_init('button.support');
menu_init('searchbox');
}


// --------------------------------------------------------
// onMouseOver event, starts extending the menu by setting
// a periodic call to menu_pull()

function menu_slide(o_id)
{
if (m_bNS4) return;

m_object = document.getElementById(o_id);

if (!m_tops[o_id]) menu_init(o_id);

// Remove any other events that might be pending (ie. retracting)
if (window.m_timer[o_id]) {
	clearInterval(m_timer[o_id]);
	}

m_timer[o_id] = setInterval("menu_pull('" + o_id + "')", m_ttl);
}


// --------------------------------------------------------
// onMouseOut event, starts retracting the menu by setting
// a periodic call to menu_push()

function menu_retract(o_id)
{
if (m_bNS4) return;

m_object = document.getElementById(o_id);

// Remove any other events that might be happening (ie. extending)
if (window.m_timer[o_id]) {
	clearInterval(m_timer[o_id]);
	}

m_timer[o_id] = setInterval("menu_push('" + o_id + "')", m_ttl);
}


// --------------------------------------------------------
// Called every m_ttl ms, extends the menu.

function menu_pull(o_id)
{
m_object = document.getElementById(o_id);

y = parseInt(m_object.style.top);

y += m_speed;

var m_toffset=m_offset;

if (o_id=="searchbox") 
	{
	m_toffset=0;
	}

// If we're fully extended stop and remove the event.
if (y > m_tops[o_id] + parseInt(m_object.offsetHeight) - m_toffset) 
	{
	y = m_tops[o_id] + parseInt(m_object.offsetHeight) - m_toffset;
	clearInterval(m_timer[o_id]);
	}
	
m_object.style.top = y + "px";
}


// --------------------------------------------------------
// Called every m_ttl ms, retracts the menu.

function menu_push(o_id)
{
m_object = document.getElementById(o_id);

y = parseInt(m_object.style.top);
y -= m_speed;

// If we're fulling retracted then stop and remove the event.
if (y < m_tops[o_id]) {
	y = m_tops[o_id];
	clearInterval(m_timer[o_id]);
	}

m_object.style.top = y + "px";
}

