<!-- hide script from old browsers

var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

offsetX = 12;
offsetY = 12;

var toolTipSTYLE="";

var xx = 0;
var yy = 0;

var divWidth = 0;
var divHeight = 0;

var topPos = 0;
var leftPos = 0;

var winHeight = 0;
var winWidth = 0;

/*var scrollOffsetX = 0;
var scrollOffsetY = 0;*/

function initToolTips()
{

//alert('initToolTips');

  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    //-- NOTE this is now handled in drag_drop.js
	//-- document.onmousemove = moveToMouseLoc;
  }
}

function toolTip(imgObj, tableWidth, msg){
	
//alert('function toolTip msg='+msg);

//-- NOTE If tableWidth == 0 then the width will be determined by the contents of the msg.
//--      Ie Each line of text must end with '<br /> and the width of the twxt will determine the width of the window.

	var table_width = '';
	var td_wrap = '';
	
	if(isNaN(tableWidth)){
		tableWidth = 200;
	}
	
	if(tableWidth<0){
		tableWidth = 200;
	}
	
	if(tableWidth>0){
		table_width = 'width="'+tableWidth+'"';
	}else{
		td_wrap = 'nowrap="nowrap"';
	}
	
	if(toolTip.arguments.length < 1){ // hide
	
		if(ns4){
			toolTipSTYLE.visibility = "hidden";
		}else{
			toolTipSTYLE.display = "none";
		}
	}else{ // show
	
	msg = convert_pound(msg);

	//if(!fg) {fg = "#777777"};
	//if(!bg) {bg = "#FFFFFF"};
	var content =
	//'<table '+table_width+' border="1" cellspacing="0" cellpadding="0" class="tooltip">' +
	'<table '+table_width+' border="1" cellspacing="0" cellpadding="0" class="tooltip">' +
	  '<tr><td valign="bottom"><img id="divHeight" src="../_assets/images/1red" width="1" height="1" border="0" /></td><td '+td_wrap+'>'+
	  msg +
	  '</td><td valign="bottom"><img id="divHeight2" src="../_assets/images/1red" width="1" height="1" border="0" /></td></tr>'+
	  '<tr><td height="1" colspan="3" align="right"><img id="divWidth" src="../_assets/images/1red" width="1" height="1" border="0" /></td>'+
	'</table>';
		
		
		/*toolTipSTYLE.top = topPos;
		toolTipSTYLE.left = leftPos;*/
		
/*tellmeObj = MM_findObj('tellme');
tellmeObj.innerHTML = content;*/
	
		if(ns4){
		  toolTipSTYLE.document.write(content);
		  toolTipSTYLE.document.close();
		  toolTipSTYLE.visibility = "visible";
		}else{
			var toolTipObj = MM_findObj('toolTipLayer');
			
			if(!toolTipObj){
				alert('The Tool Tip div tag is missing from your form.');
			}else{
				toolTipSTYLE.display='block';
				toolTipObj.innerHTML=content;
				
				pos = get_image_position(imgObj);
				
				//-------------------------------------------------------------------------------
				//-- If the cursor is inside the tool tip box then move the box.
				divSize = get_div_width_height();
				loop_buster = 0;
				var move_it = true;
				do{
					loop_buster++;
					if(loop_buster > 10){
						move_it = false;
					}
					
					var divendx = pos[1] + divSize.w + 12;
					var divstartx = pos[1] -4;
					var divendy = pos[0] + divSize.h + 12;
					var divstarty = pos[0] - 12;
					
					//-- If the cursor enters the tool tip box it will cause it to flash
					//-- on and off. To prevent this move the tool tip down.
					if(mousePos.x > divstartx && mousePos.x  < divendx){
						if(mousePos.y > divstarty && mousePos.y  < divendy){
							//alert('in the box '+mousePos.y+' '+pos[1]+' '+ divendy);
							pos[0] = pos[0] + 2;
							pos[1] = pos[1] + 2;
						}else{
							//alert('y= '+mousePos.y+' '+divstarty+' '+ divendy);
							move_it = false;
						}
					}
					
					//show_the_tooltip(pos[0], pos[1]);
					
				} while(move_it == true);
				//-------------------------------------------------------------------------------

				show_the_tooltip(pos[0], pos[1]);
			}
		}
	}
}

/*
function usingDragDrop_moveToMouseLoc(){
	
	var isVisible = true;
	if(ns4){
		if(toolTipSTYLE.visibility == "hidden"){
			isVisible = false;
		}
	}else{
		if(toolTipSTYLE.display == "none"){
			isVisible = false;
		}
	}

	if(ns4||ns6){
		if(e.pageX && e.pageY){
			xx = e.pageX;
			yy = e.pageY;
		}
	}else{
		if(event.x && event.y){
			try{
				xx = event.x + document.body.scrollLeft;
				yy = event.y + document.body.scrollTop;
			}
			catch(err){
				//-- browser may not have loaded completely before using this function.
				xx = 0;
				yy = 0;
			}
		}
	}
	
	//-- get the winHeight and winWidth 
	winSize = windowSize();
	winWidth = winSize[0];
	winHeight = winSize[1];
	
	var scrollOffset = get_scroll_xy();
	var scrollOffsetX = scrollOffset[0];
	var scrollOffsetY = scrollOffset[1];
	
	topPos = yy + offsetY;
	leftPos = xx + offsetX;
	
	if((leftPos - scrollOffsetX + divWidth + 8) > winWidth){
		leftPos = winWidth - divWidth - offsetX;
		//leftPos = xx - divWidth - offsetX;
	}
	
	if((leftPos + divWidth + 8) < xx - offsetX){
		leftPos = xx - divWidth - offsetX - 8;
	}


	if((topPos - scrollOffsetY + divHeight + 8) > winHeight){
		//topPos = winHeight - divHeight - offsetY;
		topPos = yy - divHeight - offsetY - 8;
	}
	
tellMeObj=MM_findObj('tellMe');	
tellMeObj.innerHTML='topPos='+topPos+' yy='+yy+' divHeight='+divHeight+' offsetY='+offsetY+'<br />'+
                    'leftPos='+leftPos+' xx='+xx+' divWidth='+divWidth+' offsetX='+offsetX;
	
	if(isVisible == true){	
		toolTipSTYLE.top = topPos;
		toolTipSTYLE.left = leftPos;
		
	}
}
*/

function windowSize(){
//-- Find the size of the window (including non visible portion if scrolling)
	
	if(typeof( window.innerWidth ) == 'number'){
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	}else{
		if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){
			//IE 6+ in 'standards compliant mode'
			winWidth = document.documentElement.clientWidth;
			winHeight = document.documentElement.clientHeight;
		}else{
			if(document.body && (document.body.clientWidth || document.body.clientHeight)){
				//IE 4 compatible
				winWidth = document.body.clientWidth;
				winHeight = document.body.clientHeight;
			}
		}
	}

	return [winWidth, winHeight];
  
}

function get_scroll_xy() {	
//-- Find out if and how much of the current window is not visible
//-- ie the window has scroll bars and a portion of the window is off screen.
	
	var scrollOffsetX = 0;
	var scrollOffsetY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {
		//-- Netscape compliant
		scrollOffsetY = window.pageYOffset;
		scrollOffsetX = window.pageXOffset;
	}else{
		if(document.body && ( document.body.scrollLeft || document.body.scrollTop)){
			//-- DOM compliant
			scrollOffsetY = document.body.scrollTop;
			scrollOffsetX = document.body.scrollLeft;
		}else{
			if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){
				//-- IE6 standards compliant mode
				scrollOffsetY = document.documentElement.scrollTop;
				scrollOffsetX = document.documentElement.scrollLeft;
			}
		}
	}
  
  return [scrollOffsetX, scrollOffsetY];
}

/*
function moveToMouseLoc(e) {
	if(ns4||ns6) {
		
		x = e.pageX;
		y = e.pageY;
		
		if(tw && (x + offsetX + Number(tw) + 10 > window.innerWidth)){
			x = window.innerWidth - offsetX - Number(tw) - 10;
		}
	}else{
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;

		if (tw && (x + offsetX + Number(tw) + 30 > document.body.offsetWidth)){
			x = document.body.offsetWidth - offsetX - Number(tw) - 30;
		}
	}
	
	toolTipSTYLE.left = x + offsetX;
	toolTipSTYLE.top = y + offsetY + Number(posy);
	
	return true;
}
*/

// end hiding script from old browsers -->

function get_image_position(imgObj){
	
	//-- Find the position on the screen of the tooltip image.
	
	if(ns4){
		//-- In Netscape 4 use the x and y properties of the image
		var imgX = imgObj.x;
		var imgY = imgObj.y;
	}else{
		//-- In IE and Netscape 6+ use the offsetLeft and offsetTop properties
		var imgX = imgObj.offsetLeft;
		var imgY = imgObj.offsetTop;
	}
	
	var imgX = imgObj.offsetLeft;
	var imgY = imgObj.offsetTop;
	
	bodyObj = document.getElementsByTagName('body');
	while(imgObj.offsetParent){
		if(imgObj==bodyObj){
		   break;
		}else{
			imgX=imgX+imgObj.offsetParent.offsetLeft;
			imgY=imgY+imgObj.offsetParent.offsetTop;
			imgObj=imgObj.offsetParent;
		}
	}
	
	//-- Find the height and width of the tooltip box
	//divWidth = tableWidth;
	
	divSize = get_div_width_height();
	divHeight = divSize.h;
	divWidth = divSize.w;
	
//	divHeightObj = MM_findObj('divHeight');
//	if(divHeightObj){
//		if(ns4){
//			divHeight = divHeightObj.y;
//		}else{
//			divHeight = divHeightObj.offsetTop;
//		}
//	}
//	
	divHeight = divHeight + 12;
//	
//	divWidthObj = MM_findObj('divWidth');
//	if(divWidthObj){
//		if(ns4){
//			divWidth = divWidthObj.y;
//		}else{
//			divWidth = divWidthObj.offsetLeft;
//		}
//	}
//	
	divWidth = divWidth + 12;

	//-- Get the total window size (including any that has scrolled off the screen)
	winSize = windowSize();
	
	//-- Get the portion of the window that is scrolled off the screen
	scrollxy = get_scroll_xy() ;
	scrollOffsetX = scrollxy[0];
	scrollOffsetY = scrollxy[1];
	
	topPos = imgY + offsetY;
	leftPos = imgX + offsetX;
	
	if((leftPos - scrollOffsetX + divWidth + 8) > winWidth){
		leftPos = winWidth - divWidth - offsetX;
	}
	
	if((leftPos + divWidth + 8) < imgX - offsetX){
		leftPos = imgX - divWidth - offsetX - 8;
	}
	
	if((topPos - scrollOffsetY + divHeight + 8) > winHeight){
		topPos = imgY - divHeight - offsetY - 8;
	}
	
/*tellMeObj=MM_findObj('tellMe');	
tellMeObj.innerHTML='topPos='+topPos+' imgY='+imgY+' divHeight='+divHeight+' offsetY='+offsetY+'<br />'+
                    'leftPos='+leftPos+' imgX='+imgX+' divWidth='+divWidth+' offsetX='+offsetX;*/

	return [topPos, leftPos];
	
}

function get_div_width_height(){
	//-- Return the width and height of the tool-tip div.
	
	divHeightObj = MM_findObj('divHeight');
	if(divHeightObj){
		if(ns4){
			divHeight = divHeightObj.y;
		}else{
			divHeight = divHeightObj.offsetTop;
		}
	}
	
	divWidthObj = MM_findObj('divWidth');
	if(divWidthObj){
		if(ns4){
			divWidth = divWidthObj.y;
		}else{
			divWidth = divWidthObj.offsetLeft;
		}
	}

	return {h:divHeight, w:divWidth};
	
}

function show_the_tooltip(topPos, leftPos){
	
	var isVisible = true;
	if(ns4){
		if(toolTipSTYLE.visibility == "hidden"){
			isVisible = false;
		}
	}else{
		if(toolTipSTYLE.display == "none"){
			isVisible = false;
		}
	}

	if(isVisible == true){	
		toolTipSTYLE.top = topPos;
		toolTipSTYLE.left = leftPos;
	}
	
}
