/* ###################################################### # JAVASCRIPT POPUPS ROUTINE VERSION #7 07-Feb-2001 # # Written by Mike McGrath [mike_mcgrath@lineone.net] # # PC-Tested for Netscape 3.04, 4.61, 6.0, & IE5.5 # # Note: Popups may not cover all form field inputs. # # PLEASE RETAIN THIS NOTICE WHEN COPYING MY SCRIPT. # # THIS SCRIPT IS COPYRIGHT OF MIKE MCGRATH 1998-2001 # ###################################################### */ var pel = null; var box = null; var boxLeft = 0; var boxTop = 0; var boxRight = 0; var boxBottom = 0; var popwidth = 130; var xOffset = -(popwidth / 2); var yOffset = 25; var popupHeight = 45; // this is the height of the popup when there are three lines of text var popupOffsetHeight = yOffset + popupHeight + 5; window.onload = function() { // capture pointer document.onmousemove = get_mouse; // Create the mouseover and mouseout events for each area element var areaElements = document.getElementsByTagName("area"); for (counter = 0; counter < areaElements.length; counter++){ areaElements[counter].onmouseover = popup; areaElements[counter].onmouseout = kill; areaElements[counter].areaName = areaElements[counter].title; areaElements[counter].title = ""; areaElements[counter].alt = ""; } if (document.createElement) { // Create and style Popup Element pel = document.createElement('div'); pel.id ="popup"; document.body.insertBefore(pel,document.body.firstChild); pel.style.position = "absolute"; pel.style.display = "none"; pel.style.zIndex = 1200; pel.style.width = popwidth + "px"; // save reference to popup boundary elements and get dimensions setBox(); // set initial positon of popup pel.style.top = boxTop + "px"; pel.style.left = boxLeft + "px"; } } window.onunload = function() { kill(); document.onmousemove = ""; // Remove the mouseover and mouseout events for each area element var areaElements = document.getElementsByTagName("area"); for (counter = 0; counter < areaElements.length; counter++){ areaElements[counter].onmouseover = ""; areaElements[counter].onmouseout = ""; } } // save reference to popup boundary elements and get dimensions function setBox() { var wrapper = null; box = document.getElementById('wcMap') || document.getElementById('tabMap'); boxLeft = getXY(box)[0]; boxTop = getXY(box)[1]; boxRight = boxLeft + box.offsetWidth - popwidth; boxBottom = boxTop + box.offsetHeight - popupHeight; } // Based on the Position.realoffset function in the prototype library by sam stephenson function getXY(el) { var x = 0, y = 0; do { y += el.offsetTop || 0; x += el.offsetLeft || 0; el = el.offsetParent; } while (el) return [x,y]; } // set dynamic coords function get_mouse(e) { var x, y; if (!e) e = window.event; if (e.pageX) { x = e.pageX; y = e.pageY; } else if (e.clientX) { x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft); y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop); } if (!pel) return; setBox(); if(x) { if(parseInt(pel.style.left) != x) { tempX = x + xOffset; if(tempX < boxLeft) { // constrain the popup to the inside left of the map tempX = parseInt(pel.style.left) - (parseInt(pel.style.left) - boxLeft); } if(tempX > boxRight) { // constrain the popup to the inside right of the map tempX = parseInt(pel.style.left) - (parseInt(pel.style.left) - boxRight); } pel.style.left = tempX + "px"; } } if(y) { if(parseInt(pel.style.top) != y) { tempY = y + yOffset; if(tempY > boxBottom) { // constrain the popup to the inside bottom of the map tempY = tempY - popupOffsetHeight; } pel.style.top = tempY + "px"; } } } // write content & display function popup(e) { var temp = new Array(); var maxLength = 0; // get message to display msg = this.areaName; temp = msg.split(' '); //find out the most lengthy word of the popup string for (i=0; i maxLength) { maxLength = temp[i].length; } } // need to split the single word into two if it has 20 or more characters if (maxLength >= 20) { whereIS = msg.lastIndexOf("-"); newFirst = msg.substring(0,whereIS); newLast = msg.substring(whereIS+1); newMsg = newFirst + "- " + newLast; var content = ''+ newMsg+''; } else { var content = ''+ msg +''; } if(!pel) return; pel.innerHTML = content; pel.style.display = "block"; } function kill() { if(!pel) return; pel.style.display = "none"; }