// function popupWindow() // function: To open a popup window with parent/child ability. // parameters: urlStr- the URL of the file to load into the popup window (string) // childWindow- object reference to the popup window (string) // windowName- a string reference to the popup window (string) // W- the width in pixels // H- the height in pixels // T- boolean flag to display the toolbar ('yes' or 'no') // L- boolean flag to display the location field // M- boolean flag to display the menubar // S- boolean flag to display the scrollbars // R- boolean flag to allow the popup to be resized // ST- boolean flag to display the status bar // webtvPage- boolean flag for whether or not there should be an in-line // version of the page instead of a popup for webtv users ('yes' or 'no') // webtvMsg- message that appears in the status bar if no in-line page // version of the popup for webtv users (string) function popupWindow(urlStr, childWindow, windowName, W, H, T, L, M, S, R, ST, webtvPage, webtvMsg) { if (navigator.appVersion.indexOf("WebTV") != -1) { if (webtvPage) { window.location = urlStr; } else { window.status = webtvMsg; } } else { windowFeature = "width=" + W + ",height=" + H + ",toolbar=" + T + ",location=" + L + ",menubar=" + M + ",scrollbars=" + S + ",resizable=" + R + ",status=" + ST; childWindow = new Object(); childWindow = window.open(urlStr, windowName, windowFeature); childWindow.focus(); if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion) < 4)) { // IE3 does not support parent/child browser relationships } else { childWindow.opener = self.parent; } } return childWindow; } function getStyleObject(objectId) { // cross-browser function to get an object's style object given its id if(document.getElementById && document.getElementById(objectId)) { // W3C DOM return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { // MSIE 4 DOM return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { // NN 4 DOM.. note: this won't find nested layers return document.layers[objectId]; } else { return false; } } // getStyleObject function changeObjectVisibility(objectId, newVisibility) { // get a reference to the cross-browser style object and make sure the object exists var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; return true; } else { // we couldn't find the object, so we can't change its visibility return false; } } // changeObjectVisibility function moveObject(objectId, newXCoordinate, newYCoordinate) { // get a reference to the cross-browser style object and make sure the object exists var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.left = newXCoordinate; styleObject.top = newYCoordinate; return true; } else { // we couldn't find the object, so we can't very well move it return false; } } // moveObject // store variables to control where the popup will appear relative to the cursor position // positive numbers are below and to the right of the cursor, negative numbers are above and to the left var xOffset = 30; var yOffset = -5; function showPopup (targetObjectId, eventObj) { var IfrRef = document.getElementById("ifrm_"+targetObjectId); var DivRef = document.getElementById(targetObjectId); if(eventObj) { // hide any currently-visible popups hideCurrentPopup(); // stop event from bubbling up any farther eventObj.cancelBubble = true; // move popup div to current cursor position // (add scrollTop to account for scrolling for IE) var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0); var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0); moveObject(targetObjectId, newXCoordinate, newYCoordinate); // and make it visible if( changeObjectVisibility(targetObjectId, 'visible') ) { // if we successfully showed the popup // store its Id on a globally-accessible object window.currentlyVisiblePopup = targetObjectId; IfrRef.style.width = DivRef.offsetWidth; IfrRef.style.height = DivRef.offsetHeight; IfrRef.style.top = DivRef.style.top; IfrRef.style.left = DivRef.style.left; IfrRef.style.zIndex = DivRef.style.zIndex - 1; IfrRef.style.display = "block"; return true; } else { // we couldn't show the popup, boo hoo! return false; } } else { // there was no event object, so we won't be able to position anything, so give up return false; } } // showPopup function hideCurrentPopup(targetObjectId) { var IfrRef = document.getElementById("ifrm_"+targetObjectId); // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup if(window.currentlyVisiblePopup) { changeObjectVisibility(window.currentlyVisiblePopup, 'hidden'); window.currentlyVisiblePopup = false; IfrRef.style.display = "none"; } } // hideCurrentPopup function openPop(url, popwidth, popheight) { var features = "width=" + popwidth + ",height=" + popheight + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no"; window.open(url,'pop',features); } function openDemo(url, popwidth, popheight) { var features = "width=" + popwidth + ",height=" + popheight + ",location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no"; window.open(url,'pop',features); }