var m_id=[0];
var m_ind=[0];
var timer_id=null;
var MenuTimeOut=1000;

//var font_color = "#FFFFFF";
//var background_color = "";
//	var hover_font_color = "#999999";
//var hover_background_color = "#FFFFFF";
var font_color = "";
var background_color = "";
var hover_font_color = "";
var hover_background_color = "";

var help_image = "../common/img/arrow_help.gif";

var menuImageNames = new Array("none", "welcome", "ceremony", "reception", "gifts", "collections", "favors", "groom", "under");

if(navigator.appName == 'Microsoft Internet Explorer'){handcursor='hand';}
else{handcursor='pointer';}

function set_over(id) {
 document.getElementById('h'+id).style.color= hover_font_color;
 document.getElementById('h'+id).style.backgroundColor= hover_background_color;
}

function setImgOffExceptingOne(id) {
  var j;
  for(j=0; j<menuImageNames.length; j++) {
    if (j != id) {
      var imageID = menuImageNames[j];
      if (imageID != "none" && imageID != null) {
        set_img(imageID, "_images/" + imageID + "_off.gif");
      }
    }
  }
}

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){
  var imgObj = document.getElementById(id);
  if (imgObj != null) {
    imgObj.src = img;
  }
  //  document.write(img);
}

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;
	}
	var imageID = menuImageNames[m_id2];
	if (imageID != "none") {
		set_img(imageID, "_images/" + imageID + "_on.gif");
	}
}

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() {
  var j;
  for(j=0; j<menuImageNames.length; j++) {
    var imageID = menuImageNames[j];
    if (imageID != "none" && imageID != null) {
      set_img(imageID, "_images/" + imageID + "_off.gif");
    }
  }
  if (m_id.length>2) {
    hide_ms(m_id.length-1);
    timer_id=setTimeout('m_hide()',MenuTimeOut);
  }
  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');
    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();
    m_hide();
}

document.onclick=m_do_hide;

function toggle(id)
{ 
  if (document.getElementById)
    st = document.getElementById(id).style;
  else
    st = document.all[id].style;
  if (st.display == 'none' || !st.display) st.display='block';
  else st.display='none';
}

function m_over2(m_id1,m_id2){
	m_rtimer();
	if (m_ind[m_id1]!=null)
		hide_ms2(m_ind[m_id1]+1);
	if (m_id2!=0) {
		m_visibility(m_id2,'visible');
m_visibility(1,'visible');
		m_ind[m_id2]=m_id.length;
		m_id[m_id.length]=m_id2;
	}
	var imageID = menuImageNames[m_id2];
	if (imageID != "none") {
		set_img(imageID, "_images/" + imageID + "_on.gif");
	}
}
function hide_ms2(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;
}
