function makeArray(n) { this.length=n; for (var i=0; n>i; i++) this[i]=0; return this; } // The following lines are generated by XSLT processor var maxCurrency = 2; var currencyCodes=new makeArray(maxCurrency); var currencySymbols=new makeArray(maxCurrency); var currencyCountries=new makeArray(maxCurrency); var currencyExchangeRates=new makeArray(maxCurrency); currencyCodes[0] = "124"; currencySymbols[0] = "CAD"; currencyCountries[0] = "CAD Dollars"; currencyExchangeRates[0] = 1; currencyCodes[1] = "840"; currencySymbols[1] = "US$"; currencyCountries[1] = "US Dollars"; currencyExchangeRates[1] = 1; // Function to correct for 2.x Mac date bug. Call this function to // fix a date object prior to passing it to SetCookie. // IMPORTANT: This function should only be called *once* for // any given date object! See example at the end of this document. function FixCookieDate (date) { var base = new Date(0); var skew = base.getTime(); // dawn of (Unix) time - should be 0 if (skew > 0) // Except on the Mac - ahead of its time date.setTime (date.getTime() - skew); } // This is used by SetCookie() var expdate = new Date (); FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object! expdate.setTime (expdate.getTime() + (183 * 24 * 60 * 60 * 1000)); // 1/2 year from now function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return document.cookie.substring(offset, endstr); } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (clen>i) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return ""; } // will set the expire date to expdate by default function SetCookie (name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + expdate.toGMTString()) + ((path) ? "; path=" + path : '; path=/') + ((domain) ? "; domain=" + domain : '') + ((secure) ? "; secure" : ''); } function getListValue(list) { var listValue = ""; if ( list.selectedIndex != -1 ) { listValue = list.options[ list.selectedIndex ].value; } return( listValue ); } // returns index to the currency, returns -1 if not found function findCurrency(currency) { // Canadian currency hack if ( currency == "124" ) return -1; for (var i=0; maxCurrency>i; i++) { if (currency==currencyCodes[i]) return i; } if (i>=maxCurrency) return -1; } // returns Currency Country based on Code // returns "**Currency Code Not Found**" if code is invalid function getCurrencyCountry(code) { var cIndex=findCurrency(code); if (cIndex==-1) return "**Currency Code Not Found**"; return currencyCountries[cIndex]; } // returns Currency Symbol based on Code // returns "**Currency Code Not Found**" if code is invalid function getCurrencySymbol(code) { var cIndex=findCurrency(code); if (cIndex==-1) return "**Currency Code Not Found**"; return currencySymbols[cIndex]; } function fmtPriceWithCommas(value) { var re = /(-?\d+)(\d{})/; var num = ""; amount = Math.round(value*Math.pow(10,2))/Math.pow(10,2); amount -= 0; num += (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount); while (re.test(num)) { num = num.replace(re,"$1,$2"); } return num; } // returns converted currency amount // returns -999 if currency not found. function getPrice(currency, amount) { var cIndex=findCurrency(currency); if (cIndex==-1) return -999; var converted = amount * currencyExchangeRates[cIndex]; return fmtPriceWithCommas(converted); } function updateCurrency(currencyCode) { if ( currencyCode == 0 ) currencyCode=""; SetCookie("DispCurr", currencyCode); // forces reloading of page history.go(0); } // defines current currency code by reading cookie var currentCurrencyCode=GetCookie("DispCurr"); if (findCurrency(currentCurrencyCode)==-1) { currentCurrencyCode=""; SetCookie("DispCurr", currentCurrencyCode); } // Open up the window to display approximate price idea function popUpApproxPriceWindow(sUrl) { var iWidth; var iHeight; iWidth = (window.screen.width/2) - 140; iHeight = (window.screen.height/2) - 80; var win2 = window.open("","Window2","height=250,width=300,resizable=no,left=" + iWidth + ",top=" + iHeight + ",screenX=" + iWidth + ",screenY=" + iHeight + ",scrollbars=yes"); win2.focus(); win2.location.href = (sUrl ? sUrl : '/approxprice.htm'); } function writeCurrencySelector() { document.write ( ''); } function displayPrice(price) { if (findCurrency(currentCurrencyCode)>0) { document.write( getCurrencySymbol(currentCurrencyCode)); document.write( getPrice(currentCurrencyCode,price) ); document.write( ' (Estimated price<' ); document.write( '/a>)'); document.write( '
' ); } }