// 0=above, 1=below, 2=beside icon // get window sizes var winSize = searchshield.viewPortSize(); var windowX = winSize[0]; var windowY = winSize[1]; // Must know if there is a horizontal scroll bar for Firefox // for proper flyover positioning near bottom edge var scrollYWidth = winSize[2]; var scrollBarX = winSize[2] > 0 ? true : false; // get the exact size of the flyover var flyoverSize = searchshield.elementSize(flyover); var flyoverX = flyoverSize[0]; var flyoverY = flyoverSize[1]; flyover.style.width = flyoverX + "px"; // get the bounding rect for image(s) var imgRect = imageElem.getBoundingClientRect(); // half width/height (center) of element bounding rect var halfX = (imgRect.right - imgRect.left) / 2; var halfY = (imgRect.bottom- imgRect.top) / 2; // element the mouse is over, get the center position var posX = searchshield.offsetLeft(imageElem) + halfX; var posY = searchshield.offsetTop(imageElem) + halfY; var pageOffsetX = 0; var pageOffsetY = 0; var hasParentFrame = false; // normalize pos to 0 -- get amount of scrolling in browser window var scroll = searchshield.scrollSize(imageElem); pageOffsetX = scroll[0]; pageOffsetY = scroll[1]; hasParentFrame = scroll[2]; posX -= pageOffsetX; posY -= pageOffsetY; //compensate for Firefox 3 if (posX < imgRect.left) posX = imgRect.left+halfX; // setup the offsets var offsetX = posX; var offsetY = posY; // calc where to display on page if ((windowX - posX) > posX) { // right //offsetX += halfX; offsetX = imgRect.right + 3; locateX = 1; } else { //left //offsetX -= (flyoverX + halfX); offsetX = imgRect.left - flyoverX - 3; } if ((windowY - posY) > posY) { // below if (posY < (windowY/4)) { offsetY -= halfY; locateY = 1; } else { offsetY -= (flyoverY / 2) - halfY; locateY = 2; } } else { // above if ((windowY - posY) < (windowY/4)) { offsetY -= (flyoverY - halfY); } else { offsetY -= (flyoverY / 2) + halfY; locateY = 2; } } // make sure we aren't off the screen if (offsetY < 0) offsetY = 0; if ((offsetY + flyoverY) > windowY) { offsetY = windowY - flyoverY; } else if (scrollBarX && ((windowY - (posY + halfY)) < scrollYWidth)) { //verdict overlaps the horizontal scrollbar offsetY = windowY - (flyoverY + scrollYWidth); } // add page offsets back - if not in frame if (!hasParentFrame) { offsetX += pageOffsetX; offsetY += pageOffsetY; } //posX += pageOffsetX; //posY += pageOffsetY; //var paddedOffsetX = 0; //provide space between icon and flyover //var padX = 3; //if (locateX == 0) // paddedOffsetX = offsetX - padX; //else // paddedOffsetX = offsetX + padX; // set where to put the flyover flyover.style.top = offsetY + "px"; flyover.style.left = offsetX + "px"; avglsinlineflyover.display(); }, display: function () { var div = document.getElementById('XPLSS_InlineFlyover'); if (div == null) return; // show the flyover div.style.visibility = "visible"; }, imageExists: function(element) { if (element) { // check next siblings children var sibling = element.nextSibling; if ((sibling == null) || (sibling.getElementsByTagName == null)) return false; var images = sibling.getElementsByTagName("IMG"); if (images == null) return false; for (var i = 0; i < images.length; i++) { if (images[i].id == "avg_ls_image")