/******************* * GLOBAL SETTINGS * *******************/ document.onclick = checkClickLocation; /******************** * GLOBAL VARIABLES * ********************/ //var baseServletURL = "http://localhost:8080/mslib/servlet/ExchangeRateServlet?"; //var baseServletURL = "http://dev.onepetro.org/mslib/servlet/ExchangeRateServlet?"; var currencyList; var returnedPrices; var request; var currOptsDiv = null; var currHelpDiv = null; var ajaxPage = true; // DAL Adding cross-browser width finder var Viewport = {}; if (window.innerWidth) { // All browsers but IE Viewport.getWidth = function() { return window.innerWidth; }; } else if (document.documentElement && document.documentElement.clientWidth) { // These functions are for IE6 when there is a DOCTYPE Viewport.getWidth = function() { return document.documentElement.clientWidth; }; } else if (document.body.clientWidth) { // These are for IE4, IE5, and IE6 without a DOCTYPE Viewport.getWidth = function() { return document.body.clientWidth; }; } // End DAL /*************************** * Client-called Functions * ***************************/ function initPage() { var urlQuery = "GetCurrencyList=true" if(ajaxPage) { urlQuery += "&pricecodes="; for (i=0; i" + currencyList[i][1] + ""; } optsBody += ""; currOptsDiv.innerHTML = optsBody; showCurrencyHelp(id); currOptsDiv.style.display = "block"; } /********************************* * App Specific Helper Functions * *********************************/ function checkClickLocation(e){ if (currOptsDiv) { if (currOptsDiv.ignoreNextClick) { currOptsDiv.ignoreNextClick = false; } else { var theTarget = getTarget(e); if (theTarget != currOptsDiv){ currOptsDiv.parentNode.removeChild(currOptsDiv); currOptsDiv = null; currHelpDiv.parentNode.removeChild(currHelpDiv); currHelpDiv = null; } } } return true; } function getUserCurrency() { var cookieCurrency = readCookie("onepetro_user_currency"); if (cookieCurrency) return cookieCurrency; else return "USD"; } function setUserCurrency(curr) { return createCookie("onepetro_user_currency", curr, 3650); } function showCurrencyHelp(id) { var x = getX(id); var y = getY(id); var scrollPos = 0; if (checkBrowser() != "ie") { //scrollPos = currOptsDiv.scrollTop; } if (currHelpDiv) { currHelpDiv.parentNode.removeChild(currHelpDiv); } currHelpDiv = document.createElement('DIV'); currHelpDiv.style.display = "none"; currHelpDiv.className = "curr_help_box"; currHelpDiv.style.position = "absolute"; currHelpDiv.style.top = (y-scrollPos) + "px"; // DAL get browser width and find which half link is in var w = Viewport.getWidth(); var pos = 145; if (w) { if (w < 990) { pos = (x < 495) ? 145 : -432; } else { pos = (x*2 < w) ? 145 : -432; } } // currHelpDiv.style.left = (x + 145) + "px"; currHelpDiv.style.left = (x + pos) + "px"; // End DAL changes document.body.appendChild(currHelpDiv); helpBody = "
" + "You may choose to pay for your purchase in US Dollars, Euros, or British Pounds. Your credit card will be billed in the currency you select. This allows many customers outside the US to avoid currency conversion charges from their credit card company.
" + "
" + "Documents are priced in US Dollars, and will be converted to other currencies based on a daily conversion rate. Thus, the price of a document in Euros or Pounds may vary slightly on a daily basis.
" + "
" + "Once you have made a currency selection, a cookie will be written to your computer. Unless you delete the cookie, the next time you return to OnePetro from that computer, prices will automatically be displayed in your chosen currency. You can always change your currency selection." + "
"; currHelpDiv.innerHTML = helpBody; currHelpDiv.style.display = "block"; } function changeCurr(curr) { var urlQuery = "pricecodes="; for (i=0; i 0) { currencies = currencies[0].getElementsByTagName("Currency"); currencyList = new Array(currencies.length); for(i = 0; i 0) { prices = prices[0].getElementsByTagName("PRICE"); for(i=0; i" +currDisp+" " +nonMemPr +"" +""; }else { res = "" +"" +societyCode+" Member Price: "+currDisp+" " +memPr +"
" +societyCode+" NonMember Price: "+currDisp+" " +nonMemPr +"" +"" } return res; } /**************************** * Generic Helper Functions * ****************************/ function asyncQuery(qurl) { request = null; if (checkBrowser() == "ie") { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch(error) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch(NoActiveX) { request = null; } } } if (!request && typeof XMLHttpRequest != "undefined") { request = new XMLHttpRequest(); } if (request) { request.onreadystatechange = asyncResponse; request.open("GET", qurl, true); request.send(null); } } function asyncResponse() { //process away if(request.readyState == 4) { if(request.status == 200) { parseResponse(request); } } } function getTarget(e){ var value; if (checkBrowser() == "ie"){ value = window.event.srcElement; } else{ value = e.target; } return value; } function checkBrowser(){ var theAgent = navigator.userAgent.toLowerCase(); if(theAgent.indexOf("msie") != -1){ if(theAgent.indexOf("opera") != -1){ return "opera"; } else{ return "ie"; } } else if(theAgent.indexOf("netscape") != -1){ return "netscape"; } else if(theAgent.indexOf("firefox") != -1){ return "firefox"; } else if(theAgent.indexOf("mozilla/5.0") != -1){ return "mozilla"; } else if(theAgent.indexOf("\/") != -1){ if (theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla'){ return navigator.userAgent.substr(0,theAgent.indexOf('\/')); } else{ return "netscape"; } } else if(theAgent.indexOf(' ') != -1){ return navigator.userAgent.substr(0,theAgent.indexOf(' ')); } else{ return navigator.userAgent; } } function getX(objct){ var curleft = 0; var obj = objct; if (obj.offsetParent){ while (obj.offsetParent){ curleft += obj.offsetLeft - obj.scrollLeft; obj = obj.offsetParent; } } else if (obj.x){ curleft += obj.x; } return curleft; } function getY(objct){ var curtop = 0;var curtop = 0; var obj = objct; if (obj.offsetParent){ while (obj.offsetParent){ curtop += obj.offsetTop - obj.scrollTop; obj = obj.offsetParent; } } else if (obj.y){ curtop += obj.y; } return curtop; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }