/*
@version $Revision: 1.1.1.1 $

inspiration from:  http://inspire.server101.com/js/m/ 
for functions mSet, mBlur, mShow, mHide

*/

var mItem = [];
var mTime = [];
var mWait = 250;

// Function that sets the styles and blur events
// for the navigation menu
function mSet(ul, c) {
if (document.getElementById) {

  // get all the <td> tags hiding beneath the element with 
  // id 'ul'.  In our usage this is 'mx' and refers to all 
  // <ul> elements under the <table id="mx"></table> tags
	ul = document.getElementById(ul).getElementsByTagName('ul');
  
  // some variables
	var i, j, e, a, f, b;
  // set m = to the size of the array
	var m = mItem.length;
  
  // for each <ul> tag
	for (i = 0; i < ul.length; i++) {
  
    // only deal with <ul> tags with an id attribute
    // for example <ul id="12345"></ul>
		if (e = ul[i].getAttribute('id')) {
      // this will actually grow the array since
      // we add e (the current <ul>) at index m.  m is set to the 
      // current length of the array.
			mItem[m] = e;
      
      // set the <ul> class to argument c. (for us it is "m")
      //e.className = c;
      
      // reset variable e to the parent element of <ul>
      // in this case it is the parent <td> tag
			e = ul[i].parentNode;
      
      // set the parent <td> class to argument c. (for us it is "m")
			e.className = c;

      // set new functions tied to the <ul> id
			f = new Function('mShow(\'' + mItem[m] + '\');');
			b = new Function('mBlur(\'' + mItem[m] + '\');');
      
      // set the onmouseover event for the parent <td> tag
			e.onmouseover = f;
			e.onmouseout = b;
      
      // get all the links for the <td> tag and set their 
      // onfocus and onblur events as well
			a = e.getElementsByTagName('a');
			for (j = 0; j < a.length; j++) {
				a[j].onfocus = f;
				a[j].onblur = b;
			}
			m++;
		}
	}
}}



function mShow(id) {
	for (var i = 0; i < mItem.length; i++) {
		if (document.getElementById(mItem[i]).style.display != 'none') {
			if (mItem[i] != id) mHide(mItem[i]);
			else mClear(mItem[i]);
		}
	}
	document.getElementById(id).style.display = 'block';
}


function mHide(id) {
	mClear(id);
	document.getElementById(id).style.display = 'none';
}


function mBlur(id) {
	mTime[id] = setTimeout('mHide(\'' + id + '\');', mWait);
}


function mClear(id) {
	if (mTime[id]) {
		clearTimeout(mTime[id]);
		mTime[id] = null;
	}
}


function swapImage(id, imageSrc)
{
  if (document.images)
  {
    var imgElement = document.getElementById(id);

    imgElement = document.getElementById(id);
    imgElement.src = imageSrc;
  }
}

