if (typeof(browseOriginMouse) != "undefined") {
	browseOriginMouse =  0;
}

panelWidth = 190;
arrowWidth  = 20;

function updateDetailPanel(theId) {

	// populate and show the main panel
	dPanel = document.getElementById('divDetailPanel');
	preventCache = new Date().getTime();
	
	if (dPanel.title != theId) {
		dPanel.innerHTML = '';
		ajax_loadContent('divDetailPanel','dsp_flyout.cfm?id=' + theId + 'dt=' + preventCache);
		dPanel.title = theId;
	}
	if (dPanel.style.visibility != 'visible')	dPanel.style.visibility = 'visible';

	// set location and show arrow panel
	dPanel = document.getElementById('divDetailArrow');
	dPanel.style.visibility = 'visible';
	
}

function placeDetailPanel(theId) {
	
	thisMouseX = mouseX;
	thisMouseY = mouseY;
	
	dPanel = document.getElementById('divDetailPanel');	

	if (dPanel.style.visibility != "visible") {
		
		// update location of arrow based on mouse location
		dPanelA = document.getElementById('divDetailArrow');	
		newY = thisMouseY - dpaTopOffset - browseOriginMouse;
		newX = thisMouseX - dpaLeftOffset;
		dPanelA.style.top = newY + 'px';
		dPanelA.style.left = newX + 'px';
	
		// update location of detail panel based on mouse location
		newY = thisMouseY - dpTopOffset - browseOriginMouse;
		if ((thisMouseY+detailHeight) > (getScrollY()+getScreenHeight())) {
			// will be off screen, move up panel
			newY = thisMouseY - dpTopOffsetAlt - browseOriginMouse;
		}
		newX = thisMouseX - dpLeftOffset;
		dPanel.style.top = newY + 'px';
		dPanel.style.left = newX + 'px';
	
		// update location of arrow based on mouse location
		dPanelA = document.getElementById('divDetailArrow');	
		newY = thisMouseY - dpaTopOffset - browseOriginMouse;
		newX = thisMouseX - dpaLeftOffset;
		dPanelA.style.top = newY + 'px';
		dPanelA.style.left = newX + 'px';

		// update content & show
		updateDetailPanel(theId);
		
	}
}


function placeDetailPanelTimed(theId) {
	tId2 = setTimeout('placeDetailPanel(\''+theId+'\')', 600);
}

function closeDetailPanelTimed() {
	clearTimeout(tId2);
	tId = setTimeout('closeDetailPanel()', 300);
}

function keepDetailPanelOpen() {
	clearTimeout(tId);
}

function closeDetailPanel() {
	// show paneltwo scrolls
	panelTwo = document.getElementById('divPanelTwo');
	if (panelTwo && panelTwo.style.overflow == 'hidden') panelTwo.style.overflow = 'auto';
	// hide main panel
	dPanel = document.getElementById('divDetailPanel');
	dPanel.style.visibility = 'hidden';
	// hide arrow panel
	dPanelA = document.getElementById('divDetailArrow');
	dPanelA.style.visibility = 'hidden';
	// replace top, left values to default location, if moved
	if (typeof(dpLeftDefault) != "undefined" && dPanel.style.left != (dpLeftDefault + "px")) {
		dPanel.style.left = dpLeftDefault + "px";
		dPanel.style.top = dpTopDefault + "px";
		dPanelA.style.left = dpaLeftDefault + "px";
	}
}

function initMouseWatcher() {
	isIE = document.all?true:false;
	if (!isIE) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMousePosition;
}

function attachDetailPanelToMouse() {
	isIE = document.all?true:false;
	if (!isIE) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = setDetailPanelLocation;
}

function getMousePosition(e) {
	var _x;
	var _y;
	if (!isIE) {
		_x = e.pageX;
		_y = e.pageY;
	}
	if (isIE) {
		_x = event.clientX + document.documentElement.scrollLeft;
		_y = event.clientY +document.documentElement.scrollTop;
	}
	mouseY = _y;
	mouseX = _x;
	return true;
}

function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}

function getScreenHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}