/** * Javacript mainly used for the Imagelibrary at the moment. * Takes X and Y coordinates, height and width, a URL and a relative to (element ID). * creates and shows (the url in) a new layer on the screen. Relative to the mouse and the specified element * If no element is given the "body-content" element is used * Lars Larsson, 2007-02-13 */ function showLayer(xPos,yPos,height,width,url, relativeTo) { var domElmnt; var htmlTemplateCode = ""; if(relativeTo == '' || relativeTo == null) { relativeTo = document.getElementById('body-content'); } else { relativeTo = document.getElementById(relativeTo); } domElmnt = document.getElementById('generatedLayer'); //Check if there is an layer already if(!domElmnt) { //If not domElmnt = document.createElement('div'); //Create a new div domElmnt.id = 'generatedLayer'; //Give it an ID document.getElementsByTagName('body')[0].appendChild(domElmnt); //Append it to the document domElmnt.style.display='none'; //Make the div hidden until the content is retrieved } htmlTemplateCode += "
"; htmlTemplateCode = htmlTemplateCode.replace(/{database}/,dbPath); domElmnt.innerHTML = htmlTemplateCode; document.getElementById('popup-container-body').innerHTML = ''; var layerXPos = function() { var relativeToX = relativeTo.offsetLeft; var x = (relativeToX + 50); return x; } var layerYPos = function() { var relativeToY = relativeTo.offsetTop; var y = (yPos - (Math.round(height/2))); return y; } domElmnt.style.display='block'; domElmnt.style.zIndex='10000'; domElmnt.style.position='absolute'; domElmnt.style.top=layerYPos(); domElmnt.style.left=layerXPos(); domElmnt.style.height=height; domElmnt.style.width=width; domElmnt.style.overflow='visible'; domElmnt.style.border='1px solid'; domElmnt.style.background = 'rgb(255,255,255)'; } var mouseXCoord = 0; var mouseYCoord = 0; function getMouseXY(e) { if (!e) var e = window.event; if (e.pageX || e.pageY) { mouseXCoord = e.pageX; mouseYCoord = e.pageY; } else if (e.clientX || e.clientY) { mouseXCoord = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; mouseYCoord = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } } document.onmousemove = getMouseXY;