$(document).ready(function () {
$.ajax({
'url': '/blocks/category/phone/planSelectionFacetRenderer.jsp',
dataType: 'html',
type: 'POST',
success: function (data) {
$(".box-content.int-disp-none-mob").prepend(data);
}
});
var currentConfigurator;
var consentsAccepted = false;
$(window).load(function () { // Do the code in the {}s when the
if ($(".renewalHeaderLoading").length) {
$(".renewalHeaderLoading").removeClass('renewalHeaderLoading');
}
if ($(".renewalContentLoading").length) {
$(".renewalContentLoading").removeClass('renewalContentLoading');
}
if ($("#loadingRenewal").length) {
$("#loadingRenewal").hide();
}
// window has loaded
$("#loader").fadeOut("fast"); // Fade out the #loader div
});
$("a[href$='#discount_abonament']").on('shown.bs.tab', function () {
var carousel = $('#discount_abonament .owl-carousel').data('owlCarousel');
carousel._width = $('#discount_abonament .owl-carousel').width();
carousel.invalidate('width');
carousel.refresh();
});
$("a[href$='#telefon_abonament']").on('shown.bs.tab', function () {
var carousel = $('#telefon_abonament .owl-carousel').data('owlCarousel');
carousel._width = $('#telefon_abonament .owl-carousel').width();
carousel.invalidate('width');
carousel.refresh();
});
// Change tabs on click
$(".abonamente-tab li .abonamente-tab-link").on("click", function () {
if ($(this).parent().hasClass("active")) {
return;
}
$(this).parent().siblings().removeClass("active");
$(this).parent().addClass("active");
var tabPanes = $(this).parent().parent().nextAll(".tab-content");
var tabPaneToShow = $(this).data("show-tab-pane");
tabPanes.find(".active").removeClass("active").fadeOut("fast");
$("#" + tabPaneToShow).addClass("active").fadeIn("fast").delay(100);
});
$("#confirmModalButton").on("click", function () {
$("#renewalConfiguratorSubmitOrder").click();
});
$(".openConfirmModal").on("click", function () {
var planName = $(this).parent().find("#planDisplayName").attr("data");
var monthlyPrice = $(this).parent().find("#monthlyOfferPrice").attr("data");
var duration = $(this).parent().find("#duration").attr("data");
var complexOfferId = $(this).parent().find("#complexOfferId").attr("data");
var selectedRateplan = $(this).parent().find("#selectedRateplan").attr("data");
var planDetails = "" + planName + " (" + monthlyPrice + " Euro/lună)";
$('#'+$("#renewalConfiguratorSubmitOrder").parent().attr("id")+' input#cid').val(complexOfferId);
$('#'+$("#renewalConfiguratorSubmitOrder").parent().attr("id")+' input#selectedRateplan').val(selectedRateplan);
$('#'+$("#renewalConfiguratorSubmitOrder").parent().attr("id")+' input#selectedMonthlyPrice').val(monthlyPrice);
$('#planDetails').html(planDetails);
$('strong#duration').html(duration + " luni");
});
// Tab 1 (renewal)
// on renewal tab click get the renewal tab content (Not logged/eligible
// message.each or configurator)
$(".abonamentreinnoiretab-pts").on("click", function () {
currentConfigurator = $(this).parents(".configurator-produs");
if (consentsAccepted == false && $(this).data('accepted-marketing-consent') == true){
consentsAccepted = true;
}
if (($(this).data('accepted-marketing-consent') == false || $(this).data('consents-empty') == true) && consentsAccepted == false){
$('#consentRenewalMobileJourneyModal').modal('show');
} else {
dataLayer.push({'event': 'vezi-pret/reinnoire-abonament'});
resetTabsContent(currentConfigurator);
getRenewalPlansSlider(currentConfigurator);
}
});
$("#consentRenewalMobileModalForm").validate({
ignore : ".ignore-js-validation",
highlight : function(element, errorClass, validClass) {
return $(element).closest(".control-group").removeClass("success").addClass("error");
},
unhighlight : function(element, errorClass, validClass) {
return $(element).closest(".control-group").removeClass("error").addClass("success");
},
success : function(label) {
return $(label).closest("form").find(".valid").removeClass("invalid");
},
errorPlacement : function(error, element) {
return element.closest("div").find(".error-wrapper").html(error.text());
}
});
$("#changeConsentStatusRenewal").on("click", function () {
if($("#consentRenewalMobileModalForm").valid() == true) {
var changeConsentStatusForm = $("#consentRenewalMobileModalForm");
if (changeConsentStatusForm.length > 0) {
changeConsentStatusForm.ajaxForm({
async: true,
success: function (data) {
dataLayer.push({'event': 'vezi-pret/reinnoire-abonament'});
resetTabsContent(currentConfigurator);
getRenewalPlansSlider(currentConfigurator);
consentsAccepted = true;
$('#consentRenewalMobileJourneyModal').modal('hide');
}, error: function (jqXHR, textStatus, errorThrown) {
}
});
}
}
});
$('#consent_renewal_mobile_journey_cancel').click(function(event) {
$('#consentRenewalMobileJourneyModal').modal('hide');
return false;
});
// Tab 2 (New Plan)
$(".abonamentnoutab-pts").on("click", function () {
dataLayer.push({'event': 'vezi-pret/abonament-nou'})
var currentConfigurator = $(this).parents(".configurator-produs");
resetTabsContent(currentConfigurator);
getNewPlanSlider(currentConfigurator);
});
// -------------------------------------------------------
// Listing Page: On "Vezi Pret" click
// -------------------------------------------------------
jQuery(".show-config").bind("click", function () {
dataLayer.push({'event': 'vezi-pret'})
var current = jQuery(this);
// reset everything
if (!current.hasClass("active")) {
if (jQuery(document).width() > 720) {
setTimeout(function() {
jQuery('html, body').animate({ scrollTop: current.closest('.product-item').offset().top - 80 }, 500);
}, 100);
}
jQuery("#listing .configurator-produs").hide();
jQuery(".reinnoireabonament").html("");
jQuery(".abonamentnou").html("");
current.parent().css("padding-bottom", "10");
current.html('Vezi preţ ');
jQuery(".show-config").each(function () {
if (jQuery(this) != current) jQuery(this).removeClass("active");
jQuery(this).parent().css("padding-bottom", "10");
jQuery(this).css({"padding-bottom": "6", "border-bottom": "0", "border-radius": "4px"});
jQuery(this).html('Vezi preţ ');
});
var currentConfigurator = current.parent().parent().parent().parent().find(".configurator-produs");
if (current.hasClass("active")) {
current.parent().css("padding-bottom", "10");
current.css({"padding-bottom": "6", "border-bottom": "0", "border-radius": "4px"});
current.html('Vezi preţ ');
current.removeClass("active");
currentConfigurator.hide();
current.parent().parent().parent().parent().parent().parent().css("border-bottom-width", "1");
}
else {
current.parent().css("padding-bottom", "0");
current.css({"padding-bottom": "6", "border-bottom": "0", "border-radius": "4px 4px 0px 0px"});
current.html('Vezi preţ');
current.addClass("active");
currentConfigurator.show();
currentConfigurator.parent().css("border-bottom-width", "0");
preselectTabByUserStatus(currentConfigurator.data("selected-product"));
}
}
});
$(".configurator-produs .planDuration").on("click", function () {
if ($(this).hasClass("active")) {
return
}
// remove active from other links
$(this).siblings().removeClass("active");
$(this).addClass("active");
var duration = $(this).data("duration");
var currentConfigurator = $(this).parents(".configurator-produs");
// update duration
currentConfigurator.data("duration", duration);
var activeTab = currentConfigurator.find(".abonamente-tab li.active a");
resetTabsContent(currentConfigurator);
// Get the active tab and make the corresponding ajax call (renewal or
// new plan)
if (activeTab.hasClass("abonamentreinnoiretab-pts")) {
// get renewal slider
getRenewalPlansSlider(currentConfigurator);
} else if (activeTab.hasClass("abonamentnoutab-pts")) {
// get renewal slider
getNewPlanSlider(currentConfigurator);
}
});
// -------------------------------------------------------
// Product Details Page: On document ready
// show the correspondig tab
// -------------------------------------------------------
if ($('#product-details').length > 0) {
preselectTabByUserStatus($(".configurator-produs").data("selected-product"));
}
// slider configurator
var slider_configurator = $(".bonus-slides").bxSlider({
minSlides: 2,
maxSlides: 8,
controls: true,
infiniteLoop: false,
nextText: '',
prevText: '',
nextSelector: '#slider-next-bonus',
prevSelector: '#slider-prev-bonus',
responsive: true,
moveSlides: 1,
auto: false,
pager: false,
slideMargin: 45,
slideWidth: 90
});
hover_effect(".bonus-slides li");
/*
* $("#configurator .bonus-slides li").bind("hover", function () {
* $("#abonamentfilter").val(($(this).attr("data"))).change();
* $("#bonus_value").html($("#test" + $(this).attr("data") + "
* .listing-prices strong").html());
*
* $.ajax({ url: '../listing/ajax/listingphones.html', beforeSend: function () {
* $('#listing').html(''); }, success:
* function (data) { $("#listing").html(data); }
*
* });
*/
$("#abonamentfilter").bind("change", function () {
var abonament_id = $(this).val();
var new_descriere_id = "#test" + $(this).val();
$("#bonus_value").html($("#test" + $(this).val() + " .listing-prices strong").html());
$("#configurator .bonus-slides .active").removeClass("active");
$("#configurator .bonus-slides li[data='" + abonament_id + "']").addClass("active");
$(".abonamente-container").find(".active").removeClass("active");
$(".abonamente-container").find(".in").removeClass("in");
$(new_descriere_id).addClass("in");
$(new_descriere_id).addClass("active");
/*
* $.ajax({ url: '../listing/ajax/listingphones.html', beforeSend:
* function () { $('#listing').html(''); }, success: function (data) { $("#listing").html(data); }
*
* });
*/
if ($("#configurator .bonus-slides li[data='" + abonament_id + "']").is(':first-child')) {
$("#configurator .bonus-slides li[data='" + abonament_id + "']").parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if ($("#configurator .bonus-slides li[data='" + abonament_id + "']").is(':last-child')) {
$("#configurator .bonus-slides li[data='" + abonament_id + "']").parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
$("#configurator .bonus-slides li[data='" + abonament_id + "']").parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
})
$("#configurator").css("visibility", "visible");
// product slides
var realSlider = $("ul.product-slides").bxSlider({
speed: 1000,
pager: false,
nextText: '',
prevText: '',
responsive: true,
infiniteLoop: false,
hideControlOnEnd: true,
onSlideBefore: function ($slideElement, oldIndex, newIndex) {
changeRealThumb(realThumbSlider, newIndex);
}
});
var realThumbSlider = $("ul#bxslider-pager").bxSlider({
minSlides: 3,
maxSlides: 3,
slideWidth: 156,
slideMargin: 0,
moveSlides: 1,
pager: false,
speed: 1000,
nextSelector: '#slider-next-product',
prevSelector: '#slider-prev-product',
infiniteLoop: false,
hideControlOnEnd: true,
responsive: true,
nextText: '',
prevText: '',
onSlideBefore: function ($slideElement, oldIndex, newIndex) {
$("#bxslider-pager .active").removeClass("active");
$slideElement.addClass("active");
}
});
linkRealSliders(realSlider, realThumbSlider);
if ($(".product-media #bxslider-pager li").length < 3) {
$(".product-media #slider-prev-product").remove();
$(".product-media #slider-next-product").remove();
}
function linkRealSliders(bigS, thumbS) {
$("ul#bxslider-pager").on("click", "a", function (event) {
event.preventDefault();
var newIndex = $(this).parent().attr("data-slideindex");
bigS.goToSlide(newIndex);
});
}
function changeRealThumb(slider, newIndex) {
var $thumbS = $("#bxslider-pager");
$thumbS.find('.active').removeClass("active");
$thumbS.find('li[data-slideindex="' + newIndex + '"]').addClass("active");
}
$(".reinnoireabonament .abonamente-slides").bxSlider({
minSlides: 2,
maxSlides: 8,
controls: true,
infiniteLoop: false,
nextText: '',
prevText: '',
nextSelector: '#slider-next',
prevSelector: '#slider-prev',
responsive: true,
moveSlides: 1,
auto: false,
pager: false,
slideMargin: 10,
slideWidth: 90
});
$(".abonamentnou .abonamente-slides").bxSlider({
minSlides: 2,
maxSlides: 8,
controls: true,
infiniteLoop: false,
nextText: '',
prevText: '',
nextSelector: '#slider-next3',
prevSelector: '#slider-prev3',
responsive: true,
moveSlides: 1,
auto: false,
pager: false,
slideMargin: 10,
slideWidth: 90
});
$(".close-config").bind("click", function () {
// reset everything
$(".configurator-produs").hide();
/*
* $(".reinnoireabonament").html(""); $(".abonamentnou").html("");
*/
$(".abonamentnoutab").removeClass("active");
$(".abonamentreinnoiretab").addClass("active");
$(this).parent().parent().parent().parent().parent().find(".item-price .action .show-config").css({
"padding-bottom": "6",
"border-bottom": "0",
"border-radius": "4px"
});
$(this).parent().parent().parent().parent().parent().find(".item-price .action .show-config").html('Vezi preţ ');
$(this).parent().parent().parent().parent().parent().find(".item-price .action .show-config").removeClass("active");
$(this).parent().parent().parent().parent().parent().find(".item-price .action").css("padding-bottom", "10");
$(this).parent().parent().parent().parent().parent().find(".configurator-produs").hide();
$(this).parent().parent().parent().parent().parent().parent().parent().css("border-bottom-width", "1");
})
if ($("#listing").hasClass("user-not-eligible") && $(".reinnoireabonament ").hasClass("active")) {
$(".not-eligible").hide();
} else {
$(".not-eligible").show();
}
$(".list-grid").bind("click", function () {
$("#listing").addClass("grid");
$(".list-grid").addClass("list-grid-active");
$(".list-list").removeClass("list-list-active");
$(".grid .product-item .pull-right").removeClass("span3");
$(".grid .product-item .pull-right").addClass("span7");
})
$(".list-list").bind("click", function () {
$("#listing").removeClass("grid");
$(".list-grid").removeClass("list-grid-active");
$(".list-list").addClass("list-list-active");
$(" .product-item .pull-right").addClass("span3");
$(" .product-item .pull-right").removeClass("span7");
})
$(".abonamente-slides li").each(function () {
if ($(this).hasClass("active") && $(this).is(':first-child')) {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if ($(this).hasClass("active") && $(this).is(':last-child')) {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
});
$(".go-to-config").bind("click", function () {
$('html, body').animate({scrollTop: $(".go-to-config").offset().top - 10}, 300);
$("#pdpRenewalTab").trigger("click");
if ($("#planConfigurator").hasClass("active in")) {
console.log("Already choosen");
}
else {
$("#planConfigurator").addClass("active in");
}
});
$(".abonamentnou_button").bind("click", function () {
$(".abonamente-tab li .abonamente-tab-link").trigger("click");
$("#abonamentnoutab-pts").trigger("click");
$('html, body').animate({scrollTop: $(".abonamentnou_button").offset().top - 10}, 300);
if ($("#planConfigurator").hasClass("active in")) {
console.log("Already choosen");
}
else {
$("#planConfigurator").addClass("active in");
}
})
$(".abonamente-slides li").bind("click", function () {
if ($(this).parent().is(':first-child')) {
$(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if ($(this).parent().is(':last-child')) {
$(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
$(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
});
$("#adv").hide();
hover_effect(".abonamente-slides li");
if ($("#single-product-wrapper .product-media h1").html() != undefined) {
if ($(document).width() < 720) {
if ($("#single-product-wrapper .product-info h1").html().length > 0 && $("#single-product-wrapper .product-info h1").html() != undefined) {
$("#single-product-wrapper .product-media").prepend("
" + $("#single-product-wrapper .product-info h1").html() + "
");
$("#single-product-wrapper .product-info h1").remove();
}
$("#slider-prev-product").css("left", (($("#single-product-wrapper .bx-wrapper").width() - 468) / 2) - 9.5);
$("#slider-next-product").css("right", (($("#single-product-wrapper .bx-wrapper").width() - 468) / 2) - 19.5);
}
else {
if ($("#single-product-wrapper .product-media h1").html().length > 0 && $("#single-product-wrapper .product-info h1").html() != undefined) {
$("#single-product-wrapper .product-info").prepend("" + $("#single-product-wrapper .product-media h1").html() + "
");
$("#single-product-wrapper .product-media h1").remove();
}
}
}
if ($("#single-product-wrapper .product-media h1").html() != undefined) {
$(window).resize(function () {
if ($(document).width() < 720) {
if ($("#single-product-wrapper .product-info h1").html.length > 0 && $("#single-product-wrapper .product-info h1").html() != undefined) {
$("#single-product-wrapper .product-media").prepend("" + $("#single-product-wrapper .product-info h1").html() + "
");
$("#single-product-wrapper .product-info h1").remove();
}
$("#slider-prev-product").css("left", (($("#single-product-wrapper .bx-wrapper").width() - 468) / 2) - 9.5);
$("#slider-next-product").css("right", (($("#single-product-wrapper .bx-wrapper").width() - 468) / 2) - 19.5);
}
else {
if ($("#single-product-wrapper .product-media h1").html().length > 0 && $("#single-product-wrapper .product-info h1").html() != "undefined") {
$("#single-product-wrapper .product-info").prepend("" + $("#single-product-wrapper .product-media h1").html() + "
");
$("#single-product-wrapper .product-media h1").remove();
}
}
});
}
$(".abonament-alege").bind("click", function (e) {
// onAbonamentClick($(this));
showOverlay();
var planId = $(this).parent().find(".planIdHidden").attr("data");
var complexOfferId = $(this).parent().find(".complexOfferId").attr("data");
var formId = 'planForm-' + planId + '-' + complexOfferId;
$('form#' + formId + ' input#planFormSubmit-' + planId + '-' + complexOfferId).click();
});
jQuery(".complexOfferId").each(function () {
var complexOfferId = $(this).attr("data");
var planId = $(this).parent().find(".planIdHidden").attr("data");
var formId = 'planForm-' + planId + '-' + complexOfferId;
$('form#' + formId).ajaxForm({
async: true,
dataType: 'json',
success: function (data) {
var txt = JSON.stringify(data);
var ret = jQuery.parseJSON(txt);
if (ret != undefined) {
updatePageAfterPlanChange(ret);
}
hideOverlay();
}, error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus + ": " + errorThrown);
hideOverlay();
}
});
});
if (document.getElementById("pleaseSelectmsg") != null) {
var sponsoredPlanId = $(this).find(".sponsoredPlanHidden").attr("data");
var productType = $(this).find(".productTypeHidden").attr("data");
$.ajax({
'url': '/blocks/product/plan/json/productPlanJson.jsp?sponsoredPlanId=' + sponsoredPlanId + '&productType=' + productType,
dataType: 'json',
type: 'POST',
success: function (jsonData) {
var txt = JSON.stringify(jsonData);
var planJSON = jQuery.parseJSON(txt);
var pleaseSelectmsg = document.getElementById("pleaseSelectmsg").value;
$("#sortplan2").append('');
if (planJSON != undefined && planJSON['plansArray'].length > 0) {
var plansListJsonArray = planJSON['plansArray'];
$.each(plansListJsonArray, function (i, plansList) {
$("#sortplan2").each(function () {
$(this).append('');
});
});
} else {
$(this).append('');
}
},
error: function (xhr, status, error) {
console.log(error);
$(this).append('');
}
});
}
documentReadyFunctions();
retrievePhones();
});
//retrieve the phone blocks starting from ${begin} in batches of ${batchSize}
var begin= 0;
var batchSize = 9;
var theFirstPlanHasBeenSelected = false;
function retrievePhones() {
$('#listingLoadingIcon').show();
$.post('/blocks/renewal/searchResultsAjax.jsp',
{ begin: begin, batchSize : batchSize, journeyStep: 'configurator'},
function(response) {
$('#listingLoadingIcon').hide();
$('#listingLoadingIcon').before(response);
// increment begin for the next call
begin = begin + batchSize;
if (!theFirstPlanHasBeenSelected){
theFirstPlanHasBeenSelected = true;
$("#abonament-alege-id-1").click();
}
}
);
}
function updatePageAfterPlanChange(ret) {
// change Renewal Configurator part
var planId = ret['selectedPlanId'];
var complexOfferId = $("#telefon_abonament div[data='" + planId + "']").parent().find("#complexOfferId").attr("data");
var formId = 'planForm-' + planId + '-' + complexOfferId;
onAbonamentPreselect($('#' + formId));
$('.planDetails').attr("data");
var selectedPlanName = ret['selectedPlanName'];
var selectedMonthlyPlanPrice = $("#telefon_abonament div[data='" + planId + "']").parent().find("#monthlyOfferPrice").attr("data");
var selectedDuration = ret['selectedDuration'].replace('m', '');
var planDetails = selectedPlanName + " (" + selectedMonthlyPlanPrice + " Euro/lună)";
$('.planTitle').removeClass('hidden');
$('.planDetails').html(planDetails);
$('.duration').html(selectedDuration + " luni");
// change Search Results part
$.each(ret['phones'], function (i, phone) {
if ($(".thirdCol #price-" + phone.id).length > 0) {
$(".thirdCol #price-" + phone.id + " p").html(phone.newPriceHtml);
}
});
// change forms [plan]
$('form[id^=durationForm] input[name$=itemId]').each(function (i, el) {
el.value = ret['selectedPlanId'];
});
$('form[id^=renewalForm-] input[name$=planId]').each(function (i, el) {
el.value = ret['selectedPlanId'];
});
$('form[id^=renewalForm-] input[name$=complexOfferId]').each(function (i, el) {
el.value = complexOfferId;
});
// change forms [discount]
$.each(ret['phones'], function (i, phone) {
if ($("form#renewalForm-" + phone.id).length > 0) {
$('form[id^=renewalForm-] input[name$=deviceDiscount]').each(function (i, el) {
el.value = ret['deviceDiscount'];
});
}
});
}
function selectConfiguratorDuration(durationFormId) {
$('#' + durationFormId).click();
}
function documentReadyFunctions() {
$("#listing .reinnoireabonament .bx-wrapper li").click(function () {
populateRenewalSliderData(this);
});
$("#listing .abonamentnou .bx-wrapper li").click(function () {
populateNewSliderData(this);
});
//preselected by sponsored plan logic active plan
var preselected = $('.abonament-li.active');
if (preselected.size() == 1) {
populateNewSliderData(preselected);
} else {
//selecting the cheapest one
var min = 0;
var minElement;
$('.abonament-li').each(function () {
var newPrice = $(this).find(".newPriceHidden").attr("data");
var price = parseFloat(newPrice);
if (min == 0 || price < min) {
min = price;
minElement = this;
}
});
populateNewSliderData(minElement);
}
function populateNewSliderData(thisElement) {
var planlabel = $(thisElement).find(".abonament-details h3").html();
var planUrl = $(thisElement).find(".planUrlHiddenNou").attr("data");
var planlabelLink = "" + planlabel + "";
var bonuses = $(thisElement).find(".planKeyFeaturespc").html();
var bonusescont = $(thisElement).find(".planKeyFeaturespc ul").html();
$("#planandduration2").html(planlabelLink);
if (bonusescont != undefined && !isEmpty((bonusescont).trim())) {
$("#plankeyfeatures2").html(bonuses);
} else {
$("#plankeyfeatures2").html("No description found");
}
var nowPrice = $(thisElement).find(".nowPriceHidden").attr("data");
var sponsoredPrice = $(thisElement).find(".sponsoredPriceNouHidden").attr("data");
var sponsoredPriceInt = $(thisElement).find(".finalSponsoredPriceNouIntHidden").attr("data");
var oldPrice = $(thisElement).find(".oldPriceHidden").attr("data");
var newPrice = $(thisElement).find(".newPriceHidden").attr("data");
var oldIntPrice = $(thisElement).find(".oldPriceIntHidden").attr("data");
var oldFractPrice = $(thisElement).find(".oldPriceFractHidden").attr("data");
var newIntPrice = $(thisElement).find(".newPriceIntHidden").attr("data");
var newFractPrice = $(thisElement).find(".newPriceFractHidden").attr("data");
if (oldPrice != undefined && oldIntPrice != 0 && newPrice != undefined && newIntPrice != 0 && newIntPrice != oldIntPrice) {
$("#finalSponsoredPriceNouIntStike").html("" + oldIntPrice + "" + oldFractPrice + "Lei");
$("#strikeDivId").show();
} else {
$("#strikeDivId").hide();
$("#finalSponsoredPriceNouIntStike").html("");
}
if (newIntPrice != undefined && newIntPrice != 0) {
$("#finalSponsoredPriceNouInt").html(newIntPrice);
} else {
$("#finalSponsoredPriceNouInt").html("N/A");
}
if (newFractPrice != undefined) {
$("#finalSponsoredPriceNoufract").html(newFractPrice);
} else {
$("#finalSponsoredPriceNoufract").html("");
}
$(thisElement).removeClass("tab-visible");
$("#test" + $(thisElement).parent().attr("data")).removeClass("content-visible");
$("#bonus-slides-id").find(".active").removeClass("tab-invisible");
$("#test" + $(thisElement).parent().parent().find(".active").attr("data")).removeClass("content-invisible");
$("#bonus-slides-id").find(".active").removeClass("active");
$(thisElement).addClass("active");
var complexOfferId = $(thisElement).find(".complexOfferId").attr("data");
var planId = $(thisElement).find(".planIdHiddenNou").attr("data");
var productId = $('#productToCart').attr("data");
initializeJourneyForm(productId, planId, complexOfferId);
}
function populateRenewalSliderData(thisElement) {
var planLabel = $(thisElement).find(".abonament-details h3").html();
var planUrl = $(thisElement).find(".planUrlHiddenNou").attr("data");
var planLabelLink = "" + planLabel + "";
var bonuses = $(thisElement).find(".planKeyFeaturespc").html();
var bonusescont = $(thisElement).find(".planKeyFeaturespc ul").html();
$("#planandduration").html(planLabelLink);
if (bonusescont != undefined && !isEmpty((bonusescont).trim())) {
$("#plankeyfeatures").html(bonuses);
} else {
$("#plankeyfeatures").html("No benefits description found");
}
var price = $(thisElement).find(".retentionPriceHidden").attr("data");
if (price != undefined) {
$("#renewalPrice").html('renwal' + price);
} else {
$("#renewalPrice").html("N/A");
}
var priceInt = $(thisElement).find(".renewalPriceIntHidden").attr("data");
var oldPrice = $(thisElement).find("#oldPriceRenewalHidden").attr("data");
var newPrice = $(thisElement).find(".newPriceRenewalHidden").attr("data");
var oldIntPrice = $(thisElement).find(".oldPriceRenewalIntHidden").attr("data");
var oldFractPrice = $(thisElement).find(".oldPriceRenewalFractHidden").attr("data");
var newIntPrice = $(thisElement).find(".newPriceRenewalIntHidden").attr("data");
var newFractPrice = $(thisElement).find(".newPriceRenewalFractHidden").attr("data");
if (oldPrice != undefined && oldIntPrice != 0 && newPrice != undefined && newIntPrice != 0 && newIntPrice != oldIntPrice) {
$("#renewalPriceIntIntStike").html("" + oldIntPrice + "" + oldFractPrice + "Lei");
$("#strikeRenewalDivId").show();
} else {
$("#strikeRenewalDivId").hide();
$("#renewalPriceIntIntStike").html("");
}
if (newIntPrice != undefined && newIntPrice != 0) {
$("#renewalPriceInt").html(newIntPrice);
} else {
$("#renewalPriceInt").html("N/A");
}
if (newFractPrice != undefined) {
$("#finalSponsoredPriceNoufract").html(newFractPrice);
} else {
$("#finalSponsoredPriceNoufract").html("");
}
if (newFractPrice != undefined) {
$("#renewalPriceFract").html(newFractPrice);
} else {
$("#renewalPriceFract").html("");
}
$(thisElement).removeClass("tab-visible");
$("#test" + $(thisElement).parent().attr("data")).removeClass("content-visible");
$("#bonus-slides-id").find(".active").removeClass("tab-invisible");
$("#test" + $(thisElement).parent().parent().find(".active").attr("data")).removeClass("content-invisible");
$("#bonus-slides-id").find(".active").removeClass("active");
$(thisElement).addClass("active");
var selectedPlanId = $(thisElement).find(".planIdHiddenRenewal").attr("data");
$(".selectedPlanIdHidden").html(selectedPlanId);
var complexOfferId = $(thisElement).find(".complexOfferId").attr("data");
var planId = $(thisElement).find(".planIdHiddenRenewal").attr("data");
var productId = $('#productToRenewalCart').attr("data");
initializeJourneyForm(productId, planId, complexOfferId);
var deviceDiscount = $(thisElement).find(".deviceDiscountHidden").attr("data");
var complexOfferId = $(thisElement).find(".complexOfferId").attr("data");
var productToCart = $('#productToRenewalCart').attr("data");
var renewalForm = $('#renewalForm');
renewalForm.find('#pkg0-deviceId').val(productToCart);
renewalForm.find('#pkg0-planId').val(planId);
renewalForm.find('#pkg0-deviceDiscount').val(deviceDiscount);
renewalForm.find('#pkg0-complexOfferId').val(complexOfferId);
}
$('#renew-continue').click(function () {
var renewalType = $('#renew-confirm').data('subsidy');
if (renewalType == 'billDiscount') {
$('form#discountFacturaForm' + ' input#discountFacturaFormButton').click();
} else if (renewalType == 'freeBenefit') {
$('form#freeBenefitForm' + ' input#freeBenefitFormButton').click();
}
$('#renew-continue').addClass('disabled');
showOverlay();
});
$('#discountFacturaForm').ajaxForm({
async: true,
dataType: 'json',
success: function (data) {
$('#renew-continue').removeClass('disabled');
hideOverlay();
$('#discountFacturaForm').find('.alert').remove();
$('#renew-confirm').modal('hide');
if (data.isStatusSuccess) {
$('#renew-success').modal();
} else {
$(data.errorMessages).each(function (i, text) {
console.log("data.error " + i + ": " + text);
var message = $('
');
message.find('strong').text(text);
$('#discountFacturaForm').find('.form-actions').after(message);
});
}
}, error: function (jqXHR, textStatus, errorThrown) {
console.log("error: " + textStatus);
$('#renew-continue').removeClass('disabled');
hideOverlay();
}
});
$('#freeBenefitForm').ajaxForm({
async: true,
dataType: 'json',
success: function (data) {
$('#renew-continue').removeClass('disabled');
hideOverlay();
$('#freeBenefitForm').find('.alert').remove();
$('#renew-confirm').modal('hide');
if (data.isStatusSuccess) {
$('#renew-success').modal();
} else {
$(data.errorMessages).each(function (i, text) {
console.log("data.error " + i + ": " + text);
var message = $('
');
message.find('strong').text(text);
$('#freeBenefitForm').find('.form-actions').after(message);
});
}
}, error: function (jqXHR, textStatus, errorThrown) {
console.log("error: " + textStatus);
$('#renew-continue').removeClass('disabled');
hideOverlay();
}
});
$('#new-basket-prod-button, #renew-basket-prod-button').click(function () {
showOverlay();
var duration = $(this).parents(".configurator-produs").data("duration");
$("#duration").val(duration);
if ($(this).is('#new-basket-prod-button')) {
console.log("NEW!!");
$("#startStep").val("postpaidPhoneToPlan");
clickEvent('planNouFormSubmit');
} else if ($(this).is('#renew-basket-prod-button')) {
$("#startStep").val("renewalPhoneToPlan");
clickEvent('submitAddToBasket');
console.log("renewal!!");
}
});
}
function onAbonamentPreselect(thisElement) {
$(".owl-oferte").find(".active").removeClass("active");
$(thisElement).parent().addClass("active");
var planId = $(thisElement).parent().find(".planIdHidden").attr("data");
$("#selectedPlan").attr("data", planId);
var discount = $(thisElement).parent().find(".discountIntHiddenId").attr("data");
$("#bonus_value").html(discount);
var planDescription = $(thisElement).parent().find(".planDescriptionHidden").attr("data");
var billDiscountValue = $(thisElement).parent().find(".billDiscountValue").attr("data");
var billNotDiscountValue = $(thisElement).parent().find(".billNotDiscountValue").attr("data");
var billWithDiscount = billNotDiscountValue;
if (billDiscountValue != null && billDiscountValue > 0) {
billWithDiscount = billNotDiscountValue - billDiscountValue;
}
// keep only two decimals
billWithDiscount = Math.floor(billWithDiscount * 100) / 100;
var freeBenefitDescription = $(thisElement).parent().find(".freeBenefitDescription").attr("data");
var freeBenefitValue = $(thisElement).parent().find(".freeBenefitValue").attr("data");
$("#placeForMonthlyBillDiscounted").html(billWithDiscount);
$("#placeForMonthlyBillNotDiscounted").html(billNotDiscountValue);
if (freeBenefitDescription != null && freeBenefitDescription.indexOf("National/International Minutes") > -1) {
$("#placeForMinutesId").html(freeBenefitValue);
$("#placeForMinutesId2").html(freeBenefitValue);
} else $("#placeForMinutesId").html(0);
$("#placeForplanDescription").html(planDescription);
$("#placeForplanDescription2").html(planDescription);
$("#placeForMAFee").html(billNotDiscountValue);
$("#placeForMAFee2").html(billNotDiscountValue);
$("#placeForBonus").html(discount);
$("#placeForBonus2").html(discount);
$("#placeForplanDescriptionConfirm").html(planDescription);
$("#placeForplanDescriptionSuccess").html(planDescription);
$("#placeForMonthlyBillNotDiscountedConfirm").html(billNotDiscountValue);
$("#placeForMonthlyBillNotDiscountedSuccess").html(billNotDiscountValue);
$("#placeForMonthlyBillDiscountSuccess").html(billDiscountValue);
$("#placeForMonthlyBillDiscountS").html(billDiscountValue);
$("#placeForMonthlyBillDiscount2").html(billDiscountValue);
$("#placeForMonthlyBillDiscountConfirm").html(billDiscountValue);
}
function onAbonamentPreselectNou(thisElement) {
var nowPrice = $(thisElement).parent().find(".nowPriceHidden").attr("data");
$("#nowPrice").html(nowPrice);
var sponsoredPrice = $(thisElement).parent().find(".sponsoredPriceNouHidden").attr("data");
var sponsoredPriceInt = $(thisElement).parent().find(".finalSponsoredPriceNouIntHidden").attr("data");
var oldPrice = $(thisElement).find(".oldPriceHidden").attr("data");
var newPrice = $(thisElement).find(".newPriceHidden").attr("data");
var oldIntPrice = $(thisElement).find(".oldPriceIntHidden").attr("data");
var oldFractPrice = $(thisElement).find(".oldPriceFractHidden").attr("data");
var newIntPrice = $(thisElement).find(".newPriceIntHidden").attr("data");
var newFractPrice = $(thisElement).find(".newPriceFractHidden").attr("data");
if (oldPrice != undefined && oldIntPrice != 0 && newPrice != undefined && newIntPrice != 0 && newIntPrice != oldIntPrice) {
$("#finalSponsoredPriceNouIntStike").html("" + oldIntPrice + "" + oldFractPrice + "Lei");
$("#strikeDivId").show();
} else {
$("#strikeDivId").hide();
$("#finalSponsoredPriceNouIntStike").html("");
}
if (newIntPrice != undefined && newIntPrice != 0) {
$("#finalSponsoredPriceNouInt").html(newIntPrice);
} else {
$("#finalSponsoredPriceNouInt").html("N/A");
}
if (newFractPrice != undefined) {
$("#finalSponsoredPriceNoufract").html(newFractPrice);
} else {
$("#finalSponsoredPriceNoufract").html("");
}
}
function onAbonamentPreselectRenewal(thisElement) {
var renewalPrice = $(thisElement).parent().find(".newPriceRenewalHidden").attr("data");
$("#renewalPrice").html(renewalPrice);
var priceInt = $(thisElement).parent().find(".newPriceRenewalIntHidden").attr("data");
if (priceInt != undefined && priceInt != 0) {
$("#renewalPriceInt").html(priceInt);
} else {
$("#renewalPriceInt").html("N/A");
}
var priceFract = $(thisElement).parent().find(".newPriceRenewalFractHidden").attr("data");
if (priceFract != undefined) {
$("#renewalPriceFract").html(priceFract);
} else {
$("#renewalPriceFract").html("");
}
}
function clickCumparaButton(planId) {
var planFormButtonId = 'planFormSubmit-' + planId;
clickEvent(planFormButtonId);
}
function addPlanAndPhoneToBasket(productid) {
var productFormId = 'productFormButton-' + productid;
clickEvent(productFormId);
}
function addToBasketConfiguratorPage(productId) {
$("#submitAddToBasket_" + productId).click();
}
function onAbonamentClick(elementId) {
// var selectedPlanId=$('#sortplan').val();//id
var planId = $(elementId).parent().find(".planIdHidden").attr("data");
$('#itemIdFieldSelectPlanForm').val(planId);// sto val tis formas
var planFormId = 'planFormSubmit-' + planId;
clickEvent(planFormId);
}
function onAbonamentProdusClick(elementId) {
var planId = $(elementId).parent().find(".planIdHidden").attr("data");
var planFormId = 'planFormSubmit-' + planId;
clickEvent(planFormId);
}
function onSelectPlanDropdownList() {
var selectedPlanId = $('#sortplan').val();// id
$('#itemIdFieldSelectPlanForm').val(selectedPlanId);// sto val tis formas
clickEvent('selectPlanDropdownListFormSubmit');
}
$("a[href='#discountfactura']").on("click", function () {
$(".filters-sidebar, .listing-wrapper").hide();
});
$("a[href='#minutenationale']").on("click", function () {
$(".filters-sidebar, .listing-wrapper").hide();
});
$("a[href='#discountproduse']").on("click", function () {
$(".filters-sidebar, .listing-wrapper").show();
});
function preselectTabByUserStatus(productId) {
var isLoggedIn = $("#renewalUserInfo").data("is-logged-in");
var isEligibleForRenewal = $("#renewalUserInfo").data("is-eligible-for-renewal");
$("#configurator-produs-" + productId).find(".abonamentnoutab-pts").trigger("click");
/* if (isLoggedIn && isEligibleForRenewal) {
$("#configurator-produs-" + productId).find(".abonamentreinnoiretab-pts").trigger("click");
} else {
$("#configurator-produs-" + productId).find(".abonamentnoutab-pts").trigger("click");
}*/
}
function getRenewalPlansSlider(currentConfigurator) {
var renewalTabContainer = currentConfigurator.find(".reinnoireabonament ");
jQuery.ajax({
url: '/blocks/product/phone/fragments/renewalPlansSlider.jsp',
data: {
'productId': currentConfigurator.data("selected-product"),
'selectedPlanId': currentConfigurator.data("selected-rate-plan"),
'duration': currentConfigurator.data("duration"),
'journeyStep': currentConfigurator.data("journey-step")
},
beforeSend: function () {
var loadermsg = document.getElementById("renewalloadermsg").value;
renewalTabContainer.html('' + loadermsg + '');
},
success: function (data) {
renewalTabContainer.html(data);
if (renewalTabContainer.find("ul#listing")) {
jQuery(".abonamente-slides li").bind("click", function () {
if (jQuery(this).parent().is(':first-child')) {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if (jQuery(this).parent().is(':last-child')) {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
});
var slider = renewalTabContainer.find(".abonamente-slides").bxSlider({
minSlides: 2,
maxSlides: 8,
controls: true,
infiniteLoop: false,
nextText: '',
prevText: '',
nextSelector: '#slider-next',
prevSelector: '#slider-prev',
responsive: true,
moveSlides: 1,
auto: false,
pager: false,
slideMargin: 10,
slideWidth: 90,
});
hover_effect(".abonamente-slides li");
bindPlanSelectionButtonEvent(true);
initializeSelectedOrSuggestedPlan(true);
documentReadyFunctions();
$("#startStep").val("renewalPhoneToPlan");
//activation slider
var productId = currentConfigurator.data("selected-product");
var activationSliderData = $('#renewalSliderData').html();
$('.renewalSliderBanner_prod_' + productId).html(activationSliderData);
//activation slider
}
if ($(".abonamente-slides li.renewal.active").length) {
var devicePrice = $(".abonamente-slides li.renewal.active").children(".abonament-pret.price-final").children("strong").html();
var devicePriceDecimal = $(".abonamente-slides li.renewal.active").children(".abonament-pret.price-final").children("sup").html();
var planPrice = $(".abonamente-slides li.renewal.active").children(".abonament-details").children("p").html();
$(".price-wrapper.renewal").html("" + devicePrice + ""+"" + devicePriceDecimal +"Lei");
$(".price-info.renewal").html("(" + planPrice + ")");
}
},
});
}
function getNewPlanSlider(currentConfigurator) {
var newPlanTabContainer = currentConfigurator.find(".abonamentnou ");
jQuery.ajax({
url: '/blocks/product/phone/fragments/newPlansSlider.jsp',
data: {
'productId': currentConfigurator.data("selected-product"),
'selectedPlanId': currentConfigurator.data("selected-rate-plan"),
'duration': currentConfigurator.data("duration")
},
beforeSend: function () {
var loadermsg = document.getElementById("renewalloadermsg").value;
newPlanTabContainer.html('' + loadermsg + '');
},
success: function (data) {
newPlanTabContainer.html(data);
jQuery(".abonamente-slides li").bind("click", function () {
if (jQuery(this).parent().is(':first-child')) {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if (jQuery(this).parent().is(':last-child')) {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
jQuery(this).parent().parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
});
var slider = newPlanTabContainer.find(".abonamente-slides").bxSlider({
minSlides: 2,
maxSlides: 8,
controls: true,
infiniteLoop: false,
nextText: '',
prevText: '',
nextSelector: '#slider-next3',
prevSelector: '#slider-prev3',
responsive: true,
moveSlides: 1,
auto: false,
pager: false,
slideMargin: 10,
slideWidth: 90,
});
hover_effect(".abonamente-slides li");
bindPlanSelectionButtonEvent(false);
initializeSelectedOrSuggestedPlan(false);
documentReadyFunctions();
var productId = currentConfigurator.data("selected-product");
var activationSliderData = $('#activationSliderData').html();
$('.activationSliderBanner_prod_' + productId).html(activationSliderData);
},
});
}
function resetTabsContent(currentConfigurator) {
currentConfigurator.find(".reinnoireabonament ").html("");
currentConfigurator.find(".abonamentnou ").html("");
}
function hover_effect(li_hover) {
$(li_hover).click(
function () {
if (!$(this).hasClass("active")) {
$(this).parent().find(".active").addClass("tab-invisible");
$("#test" + $(this).parent().find(".active").attr("data")).addClass("content-invisible");
$(this).parent().find(".active").removeClass("tab-visible");
$("#test" + $(this).parent().find(".active").attr("data")).removeClass("content-visible");
}
$("#test" + $(this).parent().find(".tab-visible").attr("data")).addClass("content-invisible");
$(this).parent().find(".tab-visible").addClass("tab-invisible");
$("#test" + $(this).parent().find(".tab-visible").attr("data")).removeClass("content-visible");
$(this).parent().find(".tab-visible").removeClass("tab-visible");
$(this).addClass("tab-visible");
$($("#test" + $(this).attr("data"))).addClass("content-visible");
$(this).removeClass("tab-invisible");
$($("#test" + $(this).attr("data"))).removeClass("content-invisible");
if ($(this).is(':first-child')) {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "0px 6px 6px 6px",
"-moz-border-radius": "0px 6px 6px 6px",
"-webkit-border-radius": "0px 6px 6px 6px"
});
}
else if ($(this).is(':last-child')) {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px 0px 6px 6px",
"-moz-border-radius": "6px 0px 6px 6px",
"-webkit-border-radius": "6px 0px 6px 6px"
});
}
else {
$(this).parent().parent().parent().parent().find(".abonamente-container").css({
"border-radius": "6px",
"-moz-border-radius": "6px",
"-webkit-border-radius": "6px"
});
}
// }
}, function () {
}
);
}
function initializeJourneyForm(productId, planId, complexOfferId) {
var planForm = $('#planFormNou');
planForm.find('.finalPlanIdHidden').val('phoneId=' + productId + ',planId=' + planId);
planForm.find('#complexOfferId').val(complexOfferId);
}
function bindPlanSelectionButtonEvent(isRenewal) {
var specificId = undefined;
var planId = 'none';
var productId = 'none';
var sponsoredPlanId = 'none';
var complexOfferId = 'none';
$(".abonament-li").each(function () {
if (isRenewal === true) {
planId = $("#" + this.id).find(".planIdHiddenRenewal").attr("data");
productId = $('#productToRenewalCart').attr("data");
sponsoredPlanId = $("#" + this.id).find(".renewalSponsoredPlanIdHidden").attr("data");
complexOfferId = $("#" + this.id).find(".complexOfferId").attr("data");
} else {
planId = $("#" + this.id).find(".planIdHiddenNou").attr("data");
productId = $('#productToCart').attr("data");
sponsoredPlanId = $("#" + this.id).find(".sponsoredPlanIdHidden").attr("data");
complexOfferId = $("#" + this.id).find(".complexOfferId").attr("data")
}
if (planId == sponsoredPlanId) {
specificId = "#" + this.id;
}
});
if (specificId != undefined) {
var planLabel = $(specificId).find(".abonament-details h3").html();
var planUrl = $(specificId).find(".planUrlHiddenNou").attr("data");
var planLabelLink = "" + planLabel + "";
var bonuses = $(specificId).find(".planKeyFeaturespc").html();
var bonusescont = $(specificId).find(".planKeyFeaturespc ul").html();
if (isRenewal === true) {
var priceInt = $(specificId).find(".renewalPriceIntHidden").attr("data");
var priceFract = $(specificId).find(".renewalPriceFractHidden").attr("data");
var oldPrice = $(specificId).find(".oldPriceRenewalHidden").attr("data");
var oldIntPrice = $(specificId).find(".oldPriceRenewalIntHidden").attr("data");
var oldFractPrice = $(specificId).find(".oldPriceRenewalFractHidden").attr("data");
var newPrice = $(specificId).find(".newPriceRenewalHidden").attr("data");
var newIntPrice = $(specificId).find(".newPriceRenewalIntHidden").attr("data");
var newFractPrice = $(specificId).find(".newPriceRenewalFractHidden").attr("data");
var renewalPrice = $(specificId).find(".retentionPriceHidden").attr("data");
if (renewalPrice != undefined) {
$("#renewalPrice").html(renewalPrice);
} else {
$("#renewalPrice").html("N/A");
}
if (priceInt != undefined) {
$("#renewalPriceInt").html(priceInt);
} else {
$("#renewalPriceInt").html("N/A");
}
if (priceFract != undefined) {
$("#renewalPriceFract").html(priceFract);
} else {
$("#renewalPriceFract").html("");
}
if (oldPrice != undefined && oldIntPrice != 0 && newPrice != undefined && newIntPrice != 0 && newIntPrice != oldIntPrice) {
$("#renewalPriceIntIntStike").html("" + oldIntPrice + "" + oldFractPrice + "Lei");
$("#strikeRenewalDivId").show();
} else {
$("#strikeRenewalDivId").hide();
$("#renewalPriceIntIntStike").html("");
}
if (newIntPrice != undefined && newIntPrice != 0) {
$("#renewalPriceInt").html(newIntPrice);
} else {
$("#renewalPriceInt").html("N/A");
}
if (newFractPrice != undefined) {
$("#finalSponsoredPriceNoufract").html(newFractPrice);
} else {
$("#finalSponsoredPriceNoufract").html("");
}
if (newFractPrice != undefined) {
$("#renewalPriceFract").html(newFractPrice);
} else {
$("#renewalPriceFract").html("");
}
$("#planandduration").html(planLabelLink);
if (isEmpty((bonusescont).trim())) {
$("#plankeyfeatures").html("No benefits description found");
}
else {
$("#plankeyfeatures").html(bonuses);
}
var selectedPlanId = $(this).parent().find(".selectedPlanId").attr("data");
$(".renewalSelectedPlanIdHidden").html(selectedPlanId);
} else {
var nowPrice = $(specificId).find(".nowPriceHidden").attr("data");
$("#nowPrice").html(nowPrice);
var sponsoredPriceInt = $(specificId).find(".finalSponsoredPriceNouIntHidden").attr("data");
var oldPrice = $(specificId).find(".oldPriceHidden").attr("data");
var newPrice = $(specificId).find(".newPriceHidden").attr("data");
var oldIntPrice = $(specificId).find(".oldPriceIntHidden").attr("data");
var oldFractPrice = $(specificId).find(".oldPriceFractHidden").attr("data");
var newIntPrice = $(specificId).find(".newPriceIntHidden").attr("data");
var newFractPrice = $(specificId).find(".newPriceFractHidden").attr("data");
if (oldPrice != undefined && oldIntPrice != 0 && newPrice != undefined && newIntPrice != 0 && newIntPrice != oldIntPrice) {
$("#finalSponsoredPriceNouIntStike").html("" + oldIntPrice + "" + oldFractPrice + "Lei");
$("#strikeDivId").show();
} else {
$("#strikeDivId").hide();
$("#finalSponsoredPriceNouIntStike").html("");
}
if (newIntPrice != undefined && newIntPrice != 0) {
$("#finalSponsoredPriceNouInt").html(newIntPrice);
} else {
$("#finalSponsoredPriceNouInt").html("N/A");
}
if (newFractPrice != undefined) {
$("#finalSponsoredPriceNoufract").html(newFractPrice);
} else {
$("#finalSponsoredPriceNoufract").html("");
}
$("#planandduration2").html(planLabelLink);
if (isEmpty((bonusescont).trim())) {
$("#plankeyfeatures2").html("No benefits description found");
} else {
$("#plankeyfeatures2").html(bonuses);
}
var selectedPlanId = $(this).find(".selectedPlanId").attr("data");
$(".selectedPlanIdHidden").html(selectedPlanId);
}
initializeJourneyForm(productId, planId, complexOfferId);
}
}
function initializeSelectedOrSuggestedPlan(isRenewal) {
// Select and display current rateplan
var crp = "none";
if (isRenewal === true) {
crp = $(".renewalSponsoredPlanIdHidden").attr("data");
} else {
crp = $(".sponsoredPlanIdHidden").attr("data");
}
// var crp = $(".configurator-produs").data("selected-rate-plan");
$(".planIdHidden").each(function () {
if ($(this).attr("data") == crp) {
$(this).parent().addClass("active");
} else {
}
});
}
function renewBillDiscount() {
$('#renew-confirm').data('subsidy', 'billDiscount');
$('#renew-confirm').modal();
}
function renewFreeBenefit() {
$('#renew-confirm').data('subsidy', 'freeBenefit');
$('#renew-confirm').modal();
}
function reloadPage(elementId) {
/* setting currently changed option value to option variable */
var option = $(elementId).find('option:selected').val();
var url = window.location.href;
if (option == "select") {
console.log(option);
} else {
window.location.href = URL_add_parameter(location.href, 'plprm', option);
}
}
function URL_add_parameter(url, param, value) {
var hash = {};
var parser = document.createElement('a');
parser.href = url;
var parameters = parser.search.split(/\?|&/);
for (var i = 0; i < parameters.length; i++) {
if (!parameters[i])
continue;
var ary = parameters[i].split('=');
hash[ary[0]] = ary[1];
}
hash[param] = value;
var list = [];
Object.keys(hash).forEach(function (key) {
list.push(key + '=' + hash[key]);
});
parser.search = '?' + list.join('&');
return parser.href;
}
function openLoginPopupRenewalAuthlink(e) {
if (typeof e !== 'undefined') {
e.preventDefault();
}
var height = 510;
var width = 790;
var top = (screen.height / 2) - (height / 2);
var left = (screen.width / 2) - (width / 2);
var loginUrl = $("#login_link_class_renewal").data("popup-href");
window.open(loginUrl, "Telekom_Login", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left).focus();
}
function openLoginPopupProductPageAuthlink(e) {
if (typeof e !== 'undefined') {
e.preventDefault();
}
var height = 510;
var width = 790;
var top = (screen.height / 2) - (height / 2);
var left = (screen.width / 2) - (width / 2);
var loginUrl = $("#login_link_class_productpage").data("popup-href");
window.open(loginUrl, "Telekom_Login", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left).focus();
}
function openLoginPopupTopBlockLeftAuthlink(e) {
if (typeof e !== 'undefined') {
e.preventDefault();
}
var height = 510;
var width = 790;
var top = (screen.height / 2) - (height / 2);
var left = (screen.width / 2) - (width / 2);
var loginUrl = $("#login_link_class_topblockLeft").data("popup-href");
window.open(loginUrl, "Telekom_Login", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left).focus();
}
function openLoginPopupPlanListingAuthlink(e) {
if (typeof e !== 'undefined') {
e.preventDefault();
}
var height = 510;
var width = 790;
var top = (screen.height / 2) - (height / 2);
var left = (screen.width / 2) - (width / 2);
var loginUrl = $("#login_link_class_planlisting").data("popup-href");
window.open(loginUrl, "Telekom_Login", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left).focus();
}