var ccbn_mozMouseX, ccbn_mozMouseY;
var ccbn_appName=navigator.appName;

var ccbn_offsetX=0;
var ccbn_offsetY=0;

var ccbn_popover_width;

function ccbnCloseObj(id){ ccbnShowHide(ccbnGetObj(id),CCBN_HIDE); }

function ccbnEObj(){return(ccbn_appName=="Netscape"?'event':'\'\'');}

function ccbnGetMouseXY(e) {

  if(ccbn_appName!="Netscape") { // grab the x-y pos.s if browser is IE
    if ((!document.compatMode || document.compatMode == 'BackCompat') && document.body && typeof document.body.scrollLeft != 'undefined'){
        ccbn_scrollLeft = document.body.scrollLeft;
        ccbn_scrollTop = document.body.scrollTop;
     }
     else{
        ccbn_scrollLeft = document.documentElement.scrollLeft;
        ccbn_scrollTop = document.documentElement.scrollTop;
    }
    ccbn_tempX = event.clientX + ccbn_scrollLeft;
    ccbn_tempY = event.clientY + ccbn_scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    ccbn_tempX = e.pageX;
    ccbn_tempY = e.pageY;
  }  

  // catch possible negative values in NS4
  if (ccbn_tempX < 0){ccbn_tempX = 0}
  if (ccbn_tempY < 0){ccbn_tempY = 0}  

  ccbn_mozMouseX = ccbn_tempX;
  ccbn_mozMouseY = ccbn_tempY;
  return true;
}

function ccbnGetCSSValue(selector){
       var ccbn_sheetList = document.styleSheets;
       var ccbn_ruleList;
       var ccbn_i, ccbn_j;
	   
       for (ccbn_i=ccbn_sheetList.length-1;ccbn_i >=0;ccbn_i--)
       {
           if(ccbn_sheetList[ccbn_i].rules) ccbn_ruleList = ccbn_sheetList[ccbn_i].rules;
		   else ccbn_ruleList = ccbn_sheetList[ccbn_i].cssRules;

           for (ccbn_j=0; ccbn_j<ccbn_ruleList.length; ccbn_j++)
           {
               if (ccbn_ruleList[ccbn_j].selectorText == selector)
               {
			   	   var ccbn_cssValue = ccbn_ruleList[ccbn_j].style.cssText.toLowerCase();
				   return ccbn_cssValue.replace(/; /g, ';');
               }   
           }
       }
}

function ccbnMoveObj(objectID,e) {
	var ccbn_x = ccbn_mozMouseX + ccbn_offsetX;
	var ccbn_y = ccbn_mozMouseY + ccbn_offsetY;
	var ccbn_px=ccbn_appName=="Netscape"?'px':'';
	var ccbn_cssValue;
	
	ccbn_browser_x = ccbnGetBrowserDimensions(CCBN_GET_X);
	
	//if the global variable for the popover width has not yet been set, get the width
	if(ccbn_popover_width == null || isNaN(ccbn_popover_width)){
		ccbn_cssValue = ccbnGetCSSValue(".ccbnPopover");
		ccbn_popover_width = parseInt( ccbn_cssValue.substring(ccbn_cssValue.lastIndexOf(";width: ")+8,ccbn_cssValue.length));
		 if(ccbn_popover_width == null || isNaN(ccbn_popover_width)){ ccbn_popover_width = 300;}
	}
	
	//if the div is too wide to fit in the window, put it to the left of the node
	if(ccbn_x+ccbn_popover_width > ccbn_browser_x) ccbn_x -= ccbn_popover_width;	
	
	//move the object
	ccbnDoMove(objectID, ccbn_x, ccbn_y, ccbn_px);
}

function ccbnOpenObj(id){ ccbnStopTimer(); ccbnForceHide(); ccbnMoveObj(id,ccbnEObj()); ccbnShowHide(ccbnGetObj(id),CCBN_SHOW);}

// If NS then set up for mouse capture
if(ccbn_appName=="Netscape"){ document.captureEvents(Event.MOUSEMOVE); }

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = ccbnGetMouseXY;

