var productImages = []; // Preloaded image. ID = 1640 productImages[1640] = new Image(); productImages[1640].src="/image/product/medium/img_3747.jpg"; productImages[1640].alt = "Cheap Kids 1"; function swapImage(image) { document.prodImageMain.src = productImages[image].src; document.getElementById("prodImageMainAlt").innerHTML = productImages[image].alt; } /** * Sort the prices for the product * @return lowest price */ function getFromPrice() { fromPrice.sort(function(a,b){return a - b}); return fromPrice[0].toFixed(2); } /** * Sort the prices for the product * @return highest price */ function getToPrice() { fromPrice.sort(function(a,b){return b - a}); return fromPrice[0].toFixed(2); } /** * Percentage off * @param price Original product price * @param specialPrice on special/sale price * @return Str Text string displaying percentage if percentage is greater than 0% */ function getDiscountPercentage(price, specialPrice) { var discount; // Make sure there is a difference in price if(price - specialPrice <= 0) { return ' (No Discount)'; } discount = ((price - specialPrice)/price)*100; discount = Math.round(discount); if(discount > 0) { return ' (' + discount + '% off)' } return ''; }