function menuOver(obj, menuitem, tabnumber)
{
	if(tabnumber == selectedItem)return;

	if(menuitem == -1)menuitem = 1;

//	var color = document.getElementById("m" + menuitem + "color").currentStyle.backgroundColor;
	var color = getStyle(document.getElementById("m" + menuitem + "color"), "background-color");
	
	obj.bgColor = color;
	obj.style.backgroundColor = color;
//	obj.style.background = "images/button_mask.gif";
}//end: menuOver()

function menuOut(obj, menuitem, tabnumber)
{
	if(menuitem == -1)return;
	if(tabnumber == selectedItem)return;
//	var color = document.getElementById("bgcolor").currentStyle.backgroundColor;
	var color = getStyle( document.getElementById("bgcolor"), "background-color" );
	
	obj.bgColor = color;
	obj.style.backgroundColor = color;
//	obj.style.background = "images/button_mask.gif";
}
			

function menuInit()
{
	//read the elements that should have been set to the css color elements
	if(themeColor == -1)themeColor = 1;
//	var color = document.getElementById("m" + themeColor + "color").currentStyle.backgroundColor;
	var color = getStyle(document.getElementById("m" + themeColor + "color"), "background-color");
//	var bgcolor = document.getElementById("bgcolor").currentStyle.backgroundColor;
	var bgcolor = getStyle(document.getElementById("bgcolor"), "background-color");
	//set all the tags that need a background color set.
	var mb = document.getElementById("menubar");
	var mt = document.getElementById("menutable");
	var mh = document.getElementById("mainheading");
	var mu = document.getElementById("menuunderline");
	var si = document.getElementById("menu" + selectedItem + "item");
   var a = document.getElementById("selected_menu_item");
   
	if(mb){
		mb.style.backgroundColor = bgcolor;
		mb.bgColor = bgcolor;
	}
	if(mt){
		mt.style.backgroundColor = bgcolor;
		mt.bgColor = bgcolor;
	}
	if(mh) mh.style.backgroundColor = color;
	if(mu) mu.style.backgroundColor = color;
	if(si){
		si.bgColor = color;
		si.style.backgroundColor = color;
	}

   //set the selected item link to match the theme color
   if(a){
      if( a.color ) a.color = bgcolor;
      if( a.style.color ) a.style.color = bgcolor;
   }//end: if
   
}//end: menuInit()


/* method to set the style property for an element
 * USAGE:
 * objId    = element id.
 * style    = the style to be changed.
 * value    = the value assigned to the style.
*/
function setStyle(el, style, value){
   el.style[style]= value;
}


//method to read style tags from the major browsers		
function getStyle(el, style) {
   if(!document.getElementById) return;
   if(!el) return;
   if(!style) return;
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}
/** toCamelCase(input)
 * Converts string input to a camel cased version of itself.
 * For example:
 * toCamelCase("z-index"); // returns zIndex
 * toCamelCase("border-bottom-style"); // returns borderBottomStyle.
 */
function toCamelCase(s) {
	for(var exp = toCamelCase.exp; 
		exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()) );
	return s;
}
toCamelCase.exp = /-([a-z])/;
