String.prototype.trim = function(){return this.replace(/^\s+|\s+$/, ''); }; String.prototype.endsWith = function(match){return ((this.substring(this.length - match.length) == match) ? true : false);} String.prototype.startsWith = function(match){return ((this.substring(0, match.length) == match) ? true : false);} function processProductLinkClick_FP(recID,itemID,forwardURL) { document.resultForm_FPMR.recID.value = recID; document.resultForm_FPMR.itemID.value = itemID; document.resultForm_FPMR.forwardURL.value = forwardURL; document.resultForm_FPMR.submit(); } function processProductLinkClick_SR(recID,itemID,forwardURL) { document.searchResultForm.recID.value = recID; document.searchResultForm.itemID.value = itemID; document.searchResultForm.forwardURL.value = forwardURL; document.searchResultForm.submit(); } function processProductLinkClick_AFP(recID,itemID,forwardURL) { document.resultForm_AFPMR.recID.value = recID; document.resultForm_AFPMR.itemID.value = itemID; document.resultForm_AFPMR.forwardURL.value = forwardURL; document.resultForm_AFPMR.submit(); } function processProductLinkClick_HFP(recID,itemID,forwardURL) { document.resultForm_HFPMR.recID.value = recID; document.resultForm_HFPMR.itemID.value = itemID; document.resultForm_HFPMR.forwardURL.value = forwardURL; document.resultForm_HFPMR.submit(); } function processOnClick() { if (document.searchForm.keyword.value == '') alert('Please enter a search keyword'); else document.searchForm.submit(); } function getComponentURL(page) { var oPath = document.location.pathname; if (oPath.endsWith('results.jspd')) oPath = oPath.replace(/results.jspd/g,'component.jspd?fpage=cnt&cpage=' + page); else if (oPath.endsWith('indexpage.jspd')) oPath = oPath.replace(/indexpage.jspd/g,'component.jspd?fpage=cnt&cpage=' + page); else if (oPath.endsWith('categoryIndex.jspd')) oPath = oPath.replace(/categoryIndex.jspd/g,'component.jspd?fpage=cnt&cpage=' + page); else if (oPath.endsWith('detail.jspd')) oPath = oPath.replace(/detail.jspd/g,'component.jspd?fpage=cnt&cpage=' + page); else if (oPath.endsWith('home.jspd')) oPath = oPath.replace(/home.jspd/g,'component.jspd?fpage=cnt&cpage=' + page); else oPath = '/hp/aus/shoppingtc/component.jspd?fpage=cnt&cpage=' + page; //alert(oPath); return oPath; } function getStoreFrontsURL() { var oPath = document.location.pathname; if (oPath.endsWith('results.jspd')) oPath = oPath.replace(/results.jspd/g,'component.jspd?fpage=sfbx&Ne=863&N=0'); else if (oPath.endsWith('indexpage.jspd')) oPath = oPath.replace(/indexpage.jspd/g,'component.jspd?fpage=sfbx&Ne=863&N=0'); else if (oPath.endsWith('categoryIndex.jspd')) oPath = oPath.replace(/categoryIndex.jspd/g,'component.jspd?fpage=sfbx&Ne=863&N=0'); else if (oPath.endsWith('detail.jspd')) oPath = oPath.replace(/detail.jspd/g,'component.jspd?fpage=sfbx&Ne=863&N=0'); else if (oPath.endsWith('home.jspd')) oPath = oPath.replace(/home.jspd/g,'component.jspd?fpage=hsfbx&Ne=863&N=0'); else oPath = '/hp/aus/shoppingtc/component.jspd?fpage=hsfbx&Ne=863&N=0'; //alert(oPath); return oPath; } function replaceInnerHTML(elementId, strURL) { var xmlHttpReq = false; var response = ''; var xmlHttpReq; // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } xmlHttpReq.open('POST', strURL, true); xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttpReq.onreadystatechange = function() { if (xmlHttpReq.readyState == 4) { if (xmlHttpReq.status == 200) { response = xmlHttpReq.responseText; replaceHTML(elementId,response); } } } xmlHttpReq.send(getQueryStr()); } function getQueryStr() {} function replaceHTML(elementId, HTML) { oDiv = document.getElementById(elementId); oDiv.innerHTML = HTML; } function processProductLinkClick(recID,itemID,forwardURL) { document.resultForm.recID.value = recID; document.resultForm.itemID.value = itemID; document.resultForm.forwardURL.value = forwardURL; document.resultForm.submit(); } function formatCurrency(num) { if (num != null && num != '') { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + '$' + num + '.' + cents); } else { return ''; } } function doSearch() { document.endecaSearch.submit(); } function resizeImages(elementId) { /*var iwidth = 88; var iheight = 88; //if (elementId == 'search_results') //iheight = 88; var arrImages = new Array(); oDiv = document.getElementById(elementId); if (oDiv != null) { arrImages = oDiv.getElementsByTagName('img'); for (var i = 0; i < arrImages.length; i++) { if (arrImages[i].width > arrImages[i].height) { arrImages[i].width=iwidth; } else { arrImages[i].height=iheight; } } oDiv.style.visibility='visible'; }*/ oDiv = document.getElementById(elementId); if (oDiv != null) { oDiv.style.visibility='visible'; } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } function switchMap(area) { //alert(area); var map_container = document.getElementById("map_container"); var map_images = map_container.getElementsByTagName("img"); for(var i = 0; i < map_images.length; i++) { map_images[i].style.display = "none"; } var map_container = document.getElementById("district_areas"); var map_images = map_container.getElementsByTagName("div"); for(var i = 0; i < map_images.length; i++) { map_images[i].style.display = "none"; } document.getElementById(area + "_map").style.display = "block"; document.getElementById("district_areas_" + area).style.display = "block"; return false; } function onload_switchMap() { var areas = ["west", "central", "north", "south", "farnorth"]; var n = Math.round(Math.random() * 4); switchMap(areas[n]); } function couponTabs() { if ((document.getElementById("local")) && (document.getElementById("national"))) { var national_link = document.getElementById("national"); national_link.onmouseover = function() { document.getElementById("coupon_header").style.backgroundPosition = "-300px"; document.getElementById("coupons_national_content").className = "show_box"; document.getElementById("coupons_local_content").className = "hide_box"; } var local_link = document.getElementById("local"); local_link.onmouseover = function() { document.getElementById("coupon_header").style.backgroundPosition = "0px"; document.getElementById("coupons_local_content").className = "show_box"; document.getElementById("coupons_national_content").className = "hide_box"; } } } function selectReplacement(obj) { obj.className += ' replaced'; var ul = document.createElement('ul'); ul.className = 'selectReplacement'; var opts = obj.options; for (var i=0; i