//SETTING UP OUR POPUP var popupStatus = 0; function loadCurrencyConverter(){ $("body").append("
\
\
\
\
\
\
\
Currency Conversion
\
\
\
\
\
\
\
\
\
"); $(".currency").append(" "); $(".currency").click(function (e) { $(this).contents().not("[nodeType=1]").wrap(""); price = $(this).find(".price").text().replace(/[^0-9.]/g,''); x = e.pageX; //this.offsetTop; y = e.pageY; //this.offsetLeft; positionPopup(e,x,y) $("#currency-converter-display").click(disablePopup); loadCurrencyDataHTML(price); $('#currency-converter-display').css({left:leftVal,top:topVal}); }); } function loadCurrencyDataHTML(price){ var options = {price: price, id:"nsession"}; $("#currency-converter-display-inner").load("http://www.chapelbooks.com/shop/chapel/currency.html", options ); loadPopup(); } function positionPopup(e,x,y){ topVal=y+"px"; leftVal=x+"px"; } function loadPopup(){ if(popupStatus==0){ $("#currency-converter-display").fadeIn("slow"); popupStatus = 1; } } function disablePopup(){ if(popupStatus==1){ $("#currency-converter-display").fadeOut("slow"); popupStatus = 0; } } $(document).ready(function(){ loadCurrencyConverter(); });