// MouseOver and MouseOut functions for BOL and INTRANET menu functionality
function setClassOnMouseOver(elm) {
	elm.className = 'hover';
} // endof setClassOnMouseOver

function setClassOnMouseOut(elm) {
	elm.className = '';
} // endof setClassOnMouseOut

function setOpacity(opacity, id) {
    var panel = document.getElementById(id).style;
    panel.opacity = (opacity / 100);
    panel.MozOpacity = (opacity / 100);
    panel.KhtmlOpacity = (opacity / 100);
    panel.filter = "alpha(opacity=" + opacity + ")";
}

/* 
 bugfix for ie
 checks to see if obj has a class attribute
 returns value of the class, or false if it has none
*/
function hasClass(obj) {
	var result = false;
	if (obj.getAttributeNode("class") != null) {
		result = obj.getAttributeNode("class").value;
	}
	return result;
}   

/*
'paints' each row in a dataTable class
*/

function initDataTable(id) {
	var table = document.getElementById(id);
		if(!table) return;

	// check to make sure that we're using an actual data table (ie, class="data")
	if(hasClass(table) != 'data') return;

	// get all tr's in table
	var tBody = table.getElementsByTagName('tbody');

	// get trs
	var tRows = tBody[0].getElementsByTagName('tr');

	for(var i = 0; i < tRows.length; i++)
	{
		var off;
		if(hasClass(tRows[i]) == 'altRow') {					// if row is altrow
			tRows[i].onmouseout = function() { this.style.backgroundColor = '#eeeeee'; return false; }
			tRows[i].onmouseover = function() { this.style.backgroundColor = '#ffc'; return false; }
		} else if(hasClass(tRows[i]) == 'row') {				// if row is row (row your boat)
			tRows[i].onmouseout = function() { this.style.backgroundColor = '#dddddd'; return false; }
			tRows[i].onmouseover = function() { this.style.backgroundColor = '#ffc'; return false; }
		}
				
	}		

}

function ShowSuperToolTip(parentObj, e)
{
		var tipX, tipY;
		toolTipIFrame = document.getElementById('SuperToolTipIFrame');
		toolTip = document.getElementById('SuperToolTip');
		toolTipText = document.getElementById('ToolTipText');	
		var content = parentObj.title;
		
		// add a close button at the end of the tooltip content
		// notes: <p></p> does not work here
		content = content + '<br><br><a href="javascript:HideSuperToolTip();"><strong>Close</strong></a>';

		toolTipText.innerHTML = content;
		toolTipIFrame.className = 'SuperToolTip_on';
		toolTip.className = 'SuperToolTip_on';
		
		// set top - default to setting the top at e.y - (offsetHeight + 5)
		tipY = e.clientY - (toolTip.offsetHeight + 15);		
		if(tipY < 0) {
			tipY = e.clientY + 15;
		}


		// set left - default to setting left at e.x + 5)
		tipX = e.clientX + 15;
		if((tipX + toolTip.offsetWidth) > document.body.offsetWidth) {
			tipX = e.clientX - (toolTip.offsetWidth + 20);
		}

			// we're using IE, which handles pageX/Y differently... 
			if(document.all) {
				tipX += document.body.scrollLeft;
				tipY += document.body.scrollTop;
			} else {
				tipX += window.scrollX;
				tipY += window.scrollY;
			}

		// set position
		toolTip.style.left = tipX + 'px';
		toolTip.style.top = tipY + 'px';	

		// FIXED: IE Bugs: Select element get display on top of the tooltip
		// set IFrame position to the exact tooltip position
		toolTipIFrame.style.left = tipX + 'px';
		toolTipIFrame.style.top = tipY + 'px';
		// set IFrame height and width to be the same as tooltip's width and height
		toolTipIFrame.style.height = toolTip.offsetHeight;
		toolTipIFrame.style.width = toolTip.offsetWidth;
}

function HideSuperToolTip()
{
	toolTipIFrame = document.getElementById('SuperToolTipIFrame');
	toolTip = document.getElementById('SuperToolTip');	
	toolTipText = document.getElementById('ToolTipText');	

	// clear position

	toolTipText.innerHTML = '&nbsp';
	toolTipIFrame.className = 'SuperToolTip_off';
	toolTip.className = 'SuperToolTip_off';
}
// displays options for each taskbar drop down menu
// relies on protoype.js 
function togglePanelOptions(divid, divClass, arrow) {
	var selPanel = $(divid);
	var selArrow = $(arrow);
   
	var documentClick = document;
	if (selPanel.className != divClass + '_on') {
		selPanel.className = divClass + '_on';
		selArrow.innerHTML = '&#x25B2;';		

		var checkDoc = function() {
			documentClick.onclick = function(e) {
			if(!(e&&e.button==2)) {
				selPanel.className = divClass;
				selArrow.innerHTML = '&#x25bc;';
				documentClick.onclick = null;
		}
    }    
		};
		setTimeout(checkDoc,1);
	} 
}
// resets taskbar to only display 1 drop down menu at a time
// relies on protoype.js 
function resetPanel() {
	$('jump_to_options').style.display == 'none';
	$('jump_to_options').className = 'jump_panel_options';
	$('admin_options').style.display == 'none';
	$('admin_options').className = 'admin_panel_options';
	$('my_records_options').style.display == 'none';	
	$('my_records_options').className = 'records_panel_options';
	$('system_options').style.display == 'none';	
	$('system_options').className = 'system_panel_options';
} // end of resetPanel

