/** * This is called when the user clicks on the seal. It displays the * the seal information in a separate, size browser window * @param link The link to opn in the separate window */ function displaySealInfo(link) { link += '&l='+document.location; var wnd = window.open(link,"trustme","location=1,status=1,toolbar=0,width=800,height=600,resizable=1"); } /** * When the user moves the mouse outside of the seal image/link, this * function will be called. If the seal popup is visible, it will be * hidden and if it's in the middle of the delay, the delay will be * cancelled. */ function leaveSealInfo() { overSeal = false; $('trustme_popup').hide(); } function leaveSealImage() { overSeal = false; } /** * This is called when the user hovers the mouse over the * seal image. It makes the ajax request */ function requestSealInfo() { overSeal = true; if (haveSealInfo) { showPopup(''); } else if (!inSealRequest) { inSealRequest = true; showPopup(requestUrl + 'seal_popup.php?d='+domainId+'&t='+sealType); } } /** * Does the work of adding the popup to the DOM and starts a 1 second * timer. When the timer expires the popup will be displayed as long * as the user is still hovering the mouse over the seal image. * @param contentHtml The html to display in the popup. */ function showPopup(contentLocation) { if (!$('trustme_popup')) { haveSealInfo = true; var sealElement = $('seal_link'); var page = getPageSize(); var elementPosition = sealElement.cumulativeOffset(); var boxWidth = 265; var boxHeight = 220; var boxLeft = elementPosition.left; var boxTop = elementPosition.top + sealElement.getHeight(); pageHeight = page.pageHeight; pageWidth = page.pageWidth; if ((boxTop + boxHeight) > pageHeight) { boxTop -= ((boxTop+boxHeight)-pageHeight); // Subtract some padding just in case boxTop -= 50; } if ((boxLeft + boxWidth) > pageWidth) { boxLeft -= ((boxLeft+boxWidth)-pageWidth); // Subtract some padding just in case boxLeft -= 50; } var trustmePopup= new Element('div',{'id':'trustme_popup'}); trustmePopup.setStyle({ margin:"0px", padding:"10px", border:"1px solid #ccc", width:boxWidth+"px", height:boxHeight+"px", fontFamily:"Verdana,Tahoma,Arial", fontSize:"11px", backgroundColor:"#FFF", position:"absolute", left:boxLeft+'px', zIndex:'1000', display:'none', top:boxTop+'px'}); //trustmePopup.innerHTML = contentHtml; var n_iframe1=document.createElement('iframe'); n_iframe1.setAttribute('width',boxWidth); n_iframe1.style.border="none"; n_iframe1.setAttribute('scrolling','no'); n_iframe1.setAttribute('id','trustme_popup_inner'); n_iframe1.setAttribute('height',boxHeight); n_iframe1.setAttribute('frameBorder','0'); n_iframe1.setAttribute('allowtransparency','true'); n_iframe1.setAttribute('marginheight','0'); n_iframe1.setAttribute('marginwidth','0'); n_iframe1.setAttribute('src',contentLocation); trustmePopup.appendChild(n_iframe1); document.body.appendChild(trustmePopup); Event.observe('trustme_popup_inner','mouseout',leaveSealInfo); } new PeriodicalExecuter(onDisplay,1); } /** * Gets the actual size of the page */ function getPageSize(parent) { parent = parent || document.body; var windowWidth, windowHeight; var pageHeight, pageWidth; if (parent != document.body) { windowWidth = parent.getWidth(); windowHeight = parent.getHeight(); pageWidth = parent.scrollWidth; pageHeight = parent.scrollHeight; } else { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } } return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight}; } /** * Called when the timer expires. It displays the popup if the user * is still hovering the mouse over the seal */ function onDisplay(pe) { pe.stop(); if (overSeal) { //alert($('trustme_popup')); $('trustme_popup').show(); } } var overSeal = false; var inSealRequest = false; var haveSealInfo = false; jQuery(document).ready(function(){ Event.observe(window, 'load', function() { Event.observe('seal_link','mouseover',requestSealInfo); Event.observe('seal_link','mouseout',leaveSealImage); }); });