//--- Declared Variables
var iactive = "";
var icategory = "";
var imenu = "";
var browser = navigator.appName;

//--- This is for the menu
document.WM = new Object();
document.WM.hirelist = new Object();
document.WM.hirelist.expandos = new Array();
document.WM.hirelist.heights = new Array();
document.WM.hirelist.names = new Array();

function WM_toggle(id) {
	if (document.getElementById) {
		if(document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = 'block';
			var tagID = 'i' + document.getElementById(id).id;
			var tags = document.getElementsByName(tagID);
			for(i = 0; i < tags.length; i++) {
				if (tags[i].tagName == 'A') {
					tags[i].className = 'links_menu_active';
					tags[i].style.borderTop = '1px solid #F9E08C';
					//tags[i].style.textDecoration = 'None';
					tags[i].style.backgroundImage = "url(/images/arrow_up.gif)";
					tags[i].style.backgroundRepeat = 'no-repeat'; 
					tags[i].style.backgroundPosition = '160px 5px';
					tags[i].style.lineHeight = '20px'; 
				}
			}
		} 
		else {
			document.getElementById(id).style.display = 'none';
			var tagID = 'i' + document.getElementById(id).id;
			var tags = document.getElementsByName(tagID);
			for(i = 0; i < tags.length; i++) {
				if (tags[i].tagName == 'A') {
					tags[i].className = 'links_menu';
					tags[i].style.borderTop = '1px solid #024930';
					//tags[i].style.textDecoration = 'None';
					tags[i].style.backgroundImage = "url(/images/arrow_down.gif)";
					tags[i].style.backgroundRepeat = 'no-repeat'; 
					tags[i].style.backgroundPosition = '160px 5px';
					tags[i].style.lineHeight = '20px'; 
				}
			}
		}
	} 
	else if(document.layers) {
		if(parseInt(id + 1)){
			ditem = id + 1;
		} 
		else {
			ditem = document.WM.hirelist.names[id];
		}
		
		if(document.WM.hirelist.expandos[ditem].clip.bottom == 0) {
			document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
		} 
		else {
			document.WM.hirelist.expandos[ditem].clip.bottom = 0;
		}
		
		WM_align();
	}
}

function WM_align() {
	var i,j,stupid_netscape_array_infinate_loop_error;
	stupid_netscape_array_infinate_loop_error = document.WM.hirelist.expandos.length;

    for(i=0; i<stupid_netscape_array_infinate_loop_error; i++) {
	 	j = i + 1;
   			
   	 	if(document.WM.hirelist.expandos[j]) {
   	 		if(document.layers) {
   	 			document.WM.hirelist.expandos[j].top = document.WM.hirelist.expandos[i].top + document.WM.hirelist.expandos[i].clip.bottom;
	 		}
		}
	}
}

function WM_initialize_toolbar(){
	if(document.layers) {
		for(i=0; i<document.layers['container'].document.layers.length; i++) {
			document.WM.hirelist.expandos[i] = document.layers['container'].document.layers[i];
   	    		document.WM.hirelist.names[document.layers['container'].document.layers[i].name] = i;
   	    		document.WM.hirelist.heights[i] = document.WM.hirelist.expandos[i].clip.bottom;
   		}

   		for (p=0;p<document.WM.hirelist.expandos.length;p=p+2) {
   	    		WM_toggle(p);
   		}
		document.layers['container'].visibility = 'visible';

	} 
	else if (document.getElementsByTagName && document.getElementById) {
	
		var contained = document.getElementById('container').getElementsByTagName('*');

   		for(i = 0; i < contained.length; i++) {
			if (contained[i].id.substring(0,11) == 'submenu_drp') {
				var tagID = contained[i].title;

				if (browser == "Microsoft Internet Explorer") {
					var tags = document.getElementsByName(tagID)[0]; 
				}
				else {
					var tags = document.getElementsByName(tagID)[0]; 
				}
				//alert(tags.className)
				tags.className = 'links_menu';
				//tags.style.width = '100%';
				tags.style.backgroundImage = 'url(/images/arrow_down.gif)';
				tags.style.backgroundRepeat = 'no-repeat'; 
				tags.style.backgroundPosition = '160px 5px';
				tags.style.lineHeight = '20px';
				
			}

   		    if(contained[i].className == 'menu') {
   				contained[i].style.display = 'none';
   		    }
   		}
   		document.getElementById('container').style.visibility = 'visible';
	}

	if (iactive.length > 0) {
		if (browser == "Microsoft Internet Explorer") {
			var nodeObj = document.getElementById(iactive);
			//nodeObj.style.borderTop = '1px solid #BBBBBB';
			//nodeObj.style.borderBottom = '1px solid #BBBBBB';
			nodeObj.style.textDecoration = 'underline';
			nodeObj.style.color = '#FFFFFF';
			//nodeObj.style.backgroundColor = '#FAFAFA';
		}
		else {
			var nodeObj = document.getElementsByName(iactive);
			for(i = 0; i < nodeObj.length; i++) {
				if (nodeObj[i].tagName == 'A') {
					//nodeObj[i].style.borderTop = '1px solid #BBBBBB';
					//nodeObj[i].style.borderBottom = '1px solid #BBBBBB';
					nodeObj[i].style.textDecoration = 'underline';
					nodeObj[i].style.color = '#FFFFFF';
					//nodeObj[i].style.backgroundColor = '#FAFAFA';
					
				}
			}
		}
	}
}

//--- Write the status function
function statusMenu(desc) {
	window.status = desc;
}

//--- Activate expand menus
function LinkActive(menu) { //Active Link
	WM_toggle(menu); return false
}