Month' : (t == 3 ? '3 Months' : (t == 6 ? '6 Months' : (t == 12 ? '1 Year' : ''))); var price1m = formatDollarsAndCents(calculateValueAfterDiscount(9.95)) + ' USD'; var price3m = formatDollarsAndCents(calculateValueAfterDiscount(23.95)) + ' USD'; var price6m = formatDollarsAndCents(calculateValueAfterDiscount(42.95)) + ' USD'; var price12m = formatDollarsAndCents(calculateValueAfterDiscount(77.95)) + ' USD'; var price = t == 1 ? price1m : (t == 3 ? price3m : (t == 6 ? price6m : (t == 12 ? price12m : ''))); continuePurchaseOnPaymentPage({ m : m, t : t, pm : pm, logo : getPaymentLogo(m), term: term, price: price }) } function continuePurchaseOnPaymentPage(params) { var $paymentPageForm = $('') for (var p in params) $('').attr('name', p).attr('value', params[p]).appendTo($paymentPageForm) $('').attr('name', 'continuePurchaseOnPaymentPage').attr('value', true).appendTo($paymentPageForm) $paymentPageForm.hide().appendTo($('body')).submit() } function openPaymentGateway(m, t) { $('#payment-loading').show(); $.get('/rest/payment/' + m + '/' + '107' + '/' + t, {couponDiscountId: couponDiscountId || 0}, function(data){ $('body').css('cursor', ''); if (data.redirect) { if (data.window) { window.location.href = data.redirect; } else { var height = m.indexOf('ecomm_') === 0 ? 450 : 300 var paymentC = $('#payment-gateway-content') if (paymentC.closest('.p_window').length) paymentC.css({maxHeight: '300px', overflowY: 'auto', overflowX: 'hidden'}) paymentC.html(''); if (typeof gcPopup !== "undefined") gcPopup.calculatePosition() } } else if (data.errorMsg) { alert(data.errorMsg); $('#payment-loading').hide() } }, "json" ); } function getPaymentInfoAndRedirect(met, term, plan) { if (typeof plan == 'undefined') { plan = '107'; } $('body').css('cursor', 'wait'); $.get('/rest/payment/' + met + '/' + plan + '/' + term, {couponDiscountId: couponDiscountId || 0}, function(data){ $('body').css('cursor', ''); if (data.redirect) { window.location.href = data.redirect; } }, "json" ); } function showResellersPage() { self.location.href='/resellers.jsp'; } var couponDiscount = 0; var couponDiscountId = -1; function clearData(){ couponDiscount = 0; couponDiscountId = -1; refreshPrice(); } function showInfoAboutAppliedCoupon(couponTitle){ $("#appliedDiscountCoupon").show(); $("#couponTitle").html("" + couponTitle + ""); $("#coupon_discount_invalid").hide(); $("#couponcodeForDiscountDiv").hide(); refreshPrice(); } function hideDiscountCouponLink(){ $("#enterCouponDiscountLink").hide(); $("#couponcodeForDiscountDiv").show(); $("#couponcodeForDiscount").val(""); clearData(); } function closeAppliedCoupon(){ $("#appliedDiscountCoupon").hide(); $("#enterCouponDiscountLink").show(); clearData(); } function applyDiscountCoupon() { clearData(); $.getJSONAndProcessError('/web/coupons/canApplyDiscountForExistingUser', {couponCode: $("#couponcodeForDiscount").val()}, function onSuccess(data) { if (data.status == 'ok') { couponDiscount = data.coupon.discount; couponDiscountId = data.coupon.id; showInfoAboutAppliedCoupon(data.coupon.couponTitle); refreshPrice(); $(".upgradeLink").focus(); } else { $.getJSON('/web/coupons/applyPromoCodeForExistingUser', {couponCode:$("#couponcodeForDiscount").val()}, function onSuccess(data) { if (data.status == 'ok') { location.reload(); } else { $("#appliedDiscountCoupon").hide(); $("#coupon_discount_invalid").show(); } } ) } }, function onError() { } ); return false; } function formatDollars(newValue) { if (isNaN(newValue)){ newValue = "0"; } newValue = Math.floor(newValue * 100 + 0.50000000001); return Math.floor(newValue / 100).toString(); } function formatCents(newValue) { if (isNaN(newValue)){ newValue = "0"; } newValue = Math.floor(newValue * 100 + 0.50000000001); var cents = newValue % 100; if (cents < 10) { return "0" + cents.toString(); } return cents; } function formatDollarsAndCents(newValue) { return formatDollars(newValue) + "." + formatCents(newValue); } function refreshPrice() { var element = document.getElementById("premiumColumnSelect"); otherSubscrPlan(element.options[element.selectedIndex].value, element.options[element.selectedIndex].getAttribute('cost')); } function otherSubscrPlan(p, c) { var originalPrice = parseFloat(c); var newPrice = calculateValueAfterDiscount(originalPrice); var dollar = formatDollars(newPrice); var cent = formatCents(newPrice); var cost = dollar + "" + cent + ""; $(".premiumColumnPriceA2").html(cost); fixForEcomm(p) } function fixForEcomm(monthe) { if (parseInt(monthe) > 3) $('div.blockC .jsIsNotEcomm').hide() else $('div.blockC .jsIsNotEcomm').show() } function calculateValueAfterDiscount(originalValue) { var value = originalValue; if (typeof(couponDiscountId) != 'undefined' && couponDiscountId != -1) { value = originalValue * (100 - couponDiscount) / 100; } return value; } function roundAmount(originalValue) { return Math.round(originalValue * 100) / 100 } function getAmountControl(form) { if (form.a3