var promoOffers = new Array; promoOffers[1] = new Array; promoOffers[1][0] = new Array(8, '', '', '', '', '', ''); promoOffers[1][1] = new Array(2, '', '', '', '', '', ''); promoOffers[1][2] = new Array(3, '', '', '', '', '', ''); promoOffers[1][3] = new Array(4, '', '', '', '', '', ''); promoOffers[3] = new Array; promoOffers[3][0] = new Array(16, '', '', '', '', '', ''); promoOffers[3][1] = new Array(13, '', '', '', '', '', ''); promoOffers[3][2] = new Array(14, '', '', '', '', '', ''); promoOffers[3][3] = new Array(15, '', '', '', '', '', ''); promoOffers[4] = new Array; promoOffers[4][0] = new Array(20, '', '', '', '', '', ''); promoOffers[4][1] = new Array(17, '', '', '', '', '', ''); promoOffers[4][2] = new Array(41, '', '', '', '', '', ''); promoOffers[4][3] = new Array(40, '', '', '', '', '', ''); promoOffers[5] = new Array; promoOffers[5][0] = new Array(33, '', '', '', '', '', ''); promoOffers[5][1] = new Array(32, '', '', '', '', '', ''); promoOffers[5][2] = new Array(31, '', '', '', '', '', ''); promoOffers[5][3] = new Array(30, '', '', '', '', '', ''); promoOffers[7] = new Array; promoOffers[7][0] = new Array(38, '', '', '', '', '', ''); promoOffers[7][1] = new Array(37, '', '', '', '', '', ''); promoOffers[7][2] = new Array(36, '', '', '', '', '', ''); promoOffers[7][3] = new Array(35, '', '', '', '', '', ''); var costs = new Array; costs[2] = new Array; costs[2][1] = new Array(100, 100, 100, 100); costs[2][2] = new Array(75, 75, 75, 75); costs[3] = new Array; costs[3][1] = new Array(275, 137.5, 275, 137.5); costs[3][2] = new Array(250, 125, 250, 125); costs[3][3] = new Array(300, 150, 300, 150); costs[4] = new Array; costs[4][1] = new Array(300, 150, 300, 150); costs[4][2] = new Array(275, 137.5, 275, 137.5); costs[4][3] = new Array(350, 175, 350, 175); costs[8] = new Array; costs[8][1] = new Array(0, 0, 0, 0); costs[8][2] = new Array(0, 0, 0, 0); costs[8][5] = new Array(0, 0, 0, 0); costs[13] = new Array; costs[13][1] = new Array(100, 100, 100, 100); costs[13][2] = new Array(75, 75, 75, 75); costs[14] = new Array; costs[14][1] = new Array(275, 137.5, 275, 137.5); costs[14][2] = new Array(250, 125, 250, 125); costs[14][3] = new Array(300, 150, 300, 150); costs[15] = new Array; costs[15][1] = new Array(300, 150, 300, 150); costs[15][2] = new Array(275, 137.5, 275, 137.5); costs[15][3] = new Array(350, 175, 350, 175); costs[17] = new Array; costs[17][1] = new Array(100, 100, 100, 100); costs[17][2] = new Array(75, 75, 75, 75); costs[30] = new Array; costs[30][1] = new Array(300, 150, 300, 150); costs[30][2] = new Array(275, 137.5, 275, 137.5); costs[30][3] = new Array(350, 175, 350, 175); costs[31] = new Array; costs[31][1] = new Array(275, 137.5, 275, 137.5); costs[31][2] = new Array(250, 125, 250, 125); costs[31][3] = new Array(300, 150, 300, 150); costs[32] = new Array; costs[32][1] = new Array(100, 100, 100, 100); costs[32][2] = new Array(75, 75, 75, 75); costs[35] = new Array; costs[35][1] = new Array(300, 150, 300, 150); costs[35][2] = new Array(275, 137.5, 275, 137.5); costs[35][3] = new Array(350, 175, 350, 175); costs[36] = new Array; costs[36][1] = new Array(275, 137.5, 275, 137.5); costs[36][2] = new Array(250, 125, 250, 125); costs[36][3] = new Array(300, 150, 300, 150); costs[37] = new Array; costs[37][1] = new Array(100, 100, 100, 100); costs[37][2] = new Array(75, 75, 75, 75); costs[40] = new Array; costs[40][1] = new Array(300, 150, 300, 150); costs[40][2] = new Array(275, 137.5, 275, 137.5); costs[40][3] = new Array(350, 175, 350, 175); costs[41] = new Array; costs[41][1] = new Array(275, 137.5, 275, 137.5); costs[41][2] = new Array(250, 125, 250, 125); costs[41][3] = new Array(300, 150, 300, 150); function subscriptionCostsUpdate() { var sectorID = $F('SubscriptionActSmartRetailChannel'); var productID = $F('SubscriptionProduct'); var paymentMethodID = $RF('SubscriptionPaymentMethod'); if (sectorID == '' || productID == '' || paymentMethodID == null) { $('listprice', 'discount-wrapper').invoke('hide'); $('discounts').update(); $('finalpricevalue').update(); return; } promo = promoOffers[sectorID][productID]; if (costs[promo[0]] && costs[promo[0]][paymentMethodID]) { prices = costs[promo[0]][paymentMethodID]; } else { $('listprice', 'discount-wrapper').invoke('hide'); $('discounts').update(); $('finalpricevalue').update(); return; } additionalRetailOutlets = $F('SubscriptionAdditionalRetailOutlets'); if (isUnsignedInteger(additionalRetailOutlets)) { intAdditionalRetailOutlets = parseInt(additionalRetailOutlets, 10); } else { intAdditionalRetailOutlets = 0; } listPrice = prices[0] + (prices[1] * intAdditionalRetailOutlets); finalPrice = prices[2] + (prices[3] * intAdditionalRetailOutlets); listPrice = listPrice.toFixed(2); finalPrice = finalPrice.toFixed(2); $('finalpricevalue').update( finalPrice); // Is list price the same as final price? If so there aren't any promotions if (!(promo[1] && promo[2]) && !(promo[3] && promo[4]) && !(promo[5] && promo[6])) { $('listprice', 'discount-wrapper').invoke('hide'); $('discounts').update(); } else { discountHTML = ''; if (promo[1] || promo[2]) { discountHTML += '' + promo[1] + '
' + promo[2] + ''; } if (promo[3] || promo[4]) { discountHTML += '' + promo[3] + '
' + promo[4] + ''; } if (promo[5] || promo[6]) { discountHTML += '' + promo[4] + '
' + promo[6] + ''; } $('discounts').update(discountHTML); $('listpricevalue').update(listPrice); $('listprice', 'discount-wrapper').invoke('show'); } } function isUnsignedInteger(s) { return (s.toString().search(/^[0-9]+$/) == 0); } // Courtesy of Aaron's Thoughts // http://aaron.xavisys.com/using-prototype-javascript-to-get-the-value-of-a-radio-group/ function $RF(el, radioGroup) { if($(el).type && $(el).type.toLowerCase() == 'radio') { var radioGroup = $(el).name; var el = $(el).form; } else if ($(el).tagName.toLowerCase() != 'form') { return false; } var checked = $(el).getInputs('radio', radioGroup).find( function(re) {return re.checked;} ); return (checked) ? $F(checked) : null; }