function searchResult(selectedTerm) {
    try {
        digitalData.product.data.selectedTerm = selectedTerm;
        _satellite.track("search-result-click");
    } catch (e) {
        console.log(e);
    }
}
function searchTopResult(searchKeyowrd) {
    try {
        digitalData.product.data.searchKeyowrd = searchKeyowrd;
        _satellite.track("searched-keyword-click");
    } catch (e) {
        console.log(e);
    }
}


$(document).ready(function () {



    $(".govtScheme a").click(function () {
        $(this).parents(".govtScheme").toggleClass("arrow");
        $(".govtSchemeSub").slideToggle();
    });

    $(document).mouseup(function (e) {
        var container = $(".govtSchemeSub, .dropdown-menu, .claim-dropdown-menu");
        if (!container.is(e.target) && container.has(e.target).length === 0) {
            container.hide();
            $(".govtScheme").removeClass("arrow");
        }
    });
    $('.dropdown-menu').slideDown();
    $(".getInTouch a").click(function () {
        // $(this).parents(".govtScheme").toggleClass("arrow");
        $(".dropdown-menu").slideToggle();
        /*24sep event tracking code*/
        dataLayer.push({
            'event': 'GetInTouch'
        });
    });

    $(".claimAssistance a").click(function () {
        // $(this).parents(".govtScheme").toggleClass("arrow");
        $(".claim-dropdown-menu").slideToggle();
    });
    $('.searchPopup .closePop').click(function () { $('.searchPopup').hide(); });
    $('#searchPop .closePop').click(function () { $('.searchPopup').hide(); });
});

/*Adobe Analytics Start */

function menuInteraction(menuTitle, componentName, agentimdCode, levelNo) {
    try {
        digitalData.product.data = digitalData.product.data || {};
        digitalData.product.data.menuTitle = menuTitle || "",
            digitalData.product.data.componentName = componentName || "",
            digitalData.product.data.agentimdCode = agentimdCode || "",   //pass empty for other than agent pages
            digitalData.product.data.levelNo = levelNo || "",   //pass the level no where the clicked item exist
            _satellite.track('menu-interaction')
    } catch (er) { }
}

function ctaInteraction(ctaText, componentName) {
    try {
        digitalData.product.data = digitalData.product.data || {};
        digitalData.product.data.ctaText = ctaText || "",
            digitalData.product.data.componentName = componentName || "",
            _satellite.track('cta-interaction')
    } catch (er) { }
}

function headerenquiryClick(ctaText) {
    try {
        digitalData.product = digitalData.product || {};
        digitalData.product.data = digitalData.product.data || {};
        digitalData.product.data.ctaText = ctaText || "",
            _satellite.track('header-enquiry-click')
    } catch (er) { }
}

var headerSub = document.querySelector(".sub-menu-link")
headerSub.addEventListener("click", function (e) {
    var levelNo = "top nav bar"
    var currentVal = e.target.innerText.trim();
    menuInteraction(currentVal, 'header', '', levelNo) //add the componenetName
})

var arylevel = new Array();
var humbugMenuSection = document.querySelector("nav ul");
humbugMenuSection.addEventListener("click", function (e) {
    if (arylevel.length == 0) {
        var levelNo = "Level 1";
        var currentVal = e.target.innerText.trim();
        menuInteraction(currentVal, 'header', '', levelNo) //add the componenetName
    }

})

var subMenuSection = document.querySelectorAll(".sumMenuSec .iconSec a");
for (let i = 0; i < subMenuSection.length; i++) {
    const element = subMenuSection[i];
    element.addEventListener("click", function (e) {
        var levelNo = "Level 2";
        arylevel.push(levelNo)
        var currentVal = e.target.innerText.trim();
        menuInteraction(currentVal, 'header', '', levelNo) //add the componenetName
    })
}

var subMenuSection = document.querySelectorAll(".links ul a");
for (let i = 0; i < subMenuSection.length; i++) {
    const element = subMenuSection[i];
    element.addEventListener("click", function (e) {
        var levelNo = "Level 3";
        arylevel.push(levelNo)
        var currentVal = e.target.innerText.trim();
        menuInteraction(currentVal, 'header', '', levelNo) //add the componenetName
    })
}

var caringlyVal = document.querySelector(".formaction .btn")
caringlyVal.addEventListener('click', function (e) {
    var temp = e.currentTarget.textContent.trim();
    try {
        var headerName = temp;
        var headerCompo = 'header'
        ctaInteraction(headerName, headerCompo);
    } catch (error) {
        console.log(error);
    }
})

var respectSeniorSection = document.querySelectorAll('.ph-numbers-header .headnumdiv p')
for (let i = 0; i < respectSeniorSection.length; i++) {
    var element = respectSeniorSection[i];
    element.addEventListener('click', function (e) {
        try {
            var headerEnquiryVal = e.target.innerText.split("  ")[0].trim()
            if (headerEnquiryVal == '1800-209-0144') {
                headerEnquiryVal = e.currentTarget.innerText.split("  ")[0].trim()
            } else if (headerEnquiryVal.replaceAll(" ", "") == "+917507245858") {
                headerEnquiryVal = e.currentTarget.innerText.split("  ")[1].trim()
            } else if (headerEnquiryVal == '9152007550') {
                headerEnquiryVal = e.currentTarget.innerText.trim();
            }
            headerenquiryClick(headerEnquiryVal)
        } catch (error) {
            console.log(error);
        }
    })
}

$('.numbers-assi li').click(function (e) {
    var currentVal = e.delegateTarget.innerText.replaceAll("\n", " ").replace(/ +/g, " ")
    if (currentVal != "Claim Assistance Numbers") {
        try {
            headerenquiryClick(currentVal)
        } catch (error) {
            console.log(currentVal);
        }
    }
})


/*Adobe Analytics End */

$("#searchpopupclose").click(function () {
    $('.searchPopup').hide();
});


var redirectionObject = {
    "car insurance": "https://www.bajajallianz.com/motor-insurance/car-insurance-online.html",
    "car insurance online": "https://www.bajajallianz.com/motor-insurance/car-insurance-online.html",
    "third party car insurance": "https://www.bajajallianz.com/motor-insurance/third-party-car-insurance-online.html",
    "car insurance policy": "https://www.bajajallianz.com/motor-insurance/car-insurance-online.html",
    "third party car insurance online": "https://www.bajajallianz.com/motor-insurance/third-party-car-insurance-online.html",
    "four wheeler insurance": "https://www.bajajallianz.com/motor-insurance/car-insurance-online.html",
    "motor insurance": "https://www.bajajallianz.com/motor-insurance.html",
    "motor insurance online": "https://www.bajajallianz.com/motor-insurance.html",
    "vehicle insurance": "https://www.bajajallianz.com/motor-insurance.html",
    "vehicle insurance online": "https://www.bajajallianz.com/motor-insurance.html",
    "commercial vehicle insurance": "https://www.bajajallianz.com/motor-insurance/commercial-vehicle-insurance.html",
    "two wheeler insurance": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-online.html",
    "two wheeler insurance online": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-online.html",
    "2 wheeler insurance": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-online.html",
    "bike insurance": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-online.html",
    "bike insurance online": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-online.html",
    "third party insurance for bike": "https://www.bajajallianz.com/motor-insurance/two-wheeler-insurance-third-party.html",
    "health insurance": "https://www.bajajallianz.com/health-insurance-plans.html",
    "health insurance plans": "https://www.bajajallianz.com/health-insurance-plans.html",
    "medical insurance": "https://www.bajajallianz.com/health-insurance-plans.html",
    "health insurance policy": "https://www.bajajallianz.com/health-insurance-plans.html",
    "family health insurance": "https://www.bajajallianz.com/health-insurance-plans/family-health-insurance-india.html",
    "home insurance": "https://www.bajajallianz.com/home-insurance.html",
    "travel insurance": "https://www.bajajallianz.com/travel-insurance-online.html",
    "travel insurance online": "https://www.bajajallianz.com/travel-insurance-online.html",
    "cyber insurance": "https://www.bajajallianz.com/cyber-insurance.html",
    "cyber insurance in india": "https://www.bajajallianz.com/cyber-insurance.html"
}




winW = $(window).width();
function responsiveSubMenu() {
    if (winW < 1024) {

        $('.mainHeader nav > ul > li > a').click(function () {

            //$(this).parent().find('.sumMenuSec').slideToggle();
            $(this).parent().siblings().find('.sumMenuSec').slideUp(2000);
            $("body,html").animate({ scrollTop: $("header").offset().top }, 800);
        });

        //$('.mainHeader nav ul li .sumMenuSec .container > ul > li div.iconSec h5 a').attr('href', 'javascript:;');
        //$('.mainHeader nav ul li .sumMenuSec .container > ul > li div.iconSec h5 a').removeAttr('target');

        $('.mainHeader nav ul li .sumMenuSec > ul > li div.iconSec p').off().click(function () {
            $(this).parents("li").siblings().find(".links").slideUp();
            $(this).parents(".iconSec").next().slideToggle();
            $(this).toggleClass('deviceMenuOpen').parents('li').siblings().find('p').removeClass('deviceMenuOpen');

            /*if ($(this).hasClass('deviceMenuOpen')) {
                $(this).removeClass('deviceMenuOpen');
                $(this).parent().next().slideUp();
            } else {
                $(this).toggleClass('deviceMenuOpen').parents('li').siblings().find('h5').removeClass('deviceMenuOpen');
                $(this).parent().next().slideDown();
                $(this).parent().parent().siblings().find('.links').slideUp();
            }*/
        });

        $('.menuOverlay').click(function () {
            $('.mainHeader nav').removeClass('active');
            $('.humbugMenu').removeClass("close");
            $(this).hide();
        })

        var lLinks = $('.sumMenuSec .container > ul > li').length;
        for (i = 0; i <= lLinks; i++) {
            if ($('.sumMenuSec .container > ul > li').eq(i).find('.links li').length == 0) {
                $('.sumMenuSec .container > ul > li').eq(i).find('.links').remove();
                $('.sumMenuSec .container > ul > li').eq(i).find('p').addClass('noSubLinksSign');
            }


        }

        $(".callBackMobNumber,.setRenewalMobile").attr("type", "tel");

    }

}

$(function () {
    //readDeviceOrientation();

    // Header
    $('.mainHeader nav > ul > li').mouseenter(function () {

        //     $(this).parent().toggleClass("open").siblings().removeClass("open");
        //  $('.menuOverlay').fadeIn(100);
        // $(".sumMenuSec").animate({marginTop: "-=50px"});

        //   $(this).siblings().animate({marginTop: "-=50px"}).slideDown(300);
        //   $('.menuOverlay').animate({display: 'block !important'})

    });



    $('.mainHeader nav > ul > li').mouseleave(function () {
        //      $('.mainHeader nav > ul > li').removeClass("open"); 

        //  $('.menuOverlay').css({opacity: "0;", visibility: "hidden;", 'z-index':'2;'})

        //    $('.menuOverlay').fadeOut(100);

        //  $(this).parent().removeClass("open");
        //    $(this).siblings().animate({marginTop: "0px"}).slideUp(30);
    });

    winW = $(window).width();
    winH = $(window).height();
    if (winW < 768) {
        $('.mainHeader nav > ul > li > a').click(function () {
            $(this).parent().toggleClass("open").siblings().removeClass("open");

        });
    }


    //   $('.mainHeader .sumMenuSec .closeBtn').click(function () {
    //       $('.mainHeader nav > ul > li').removeClass("open");
    //   });

    $('.humbugMenu').click(function (e) {
        e.stopPropagation();
        $(this).next().toggleClass("active");
        $('.menuOverlay').toggle();
        $(this).toggleClass("close");


    })

    $('.searchSec .searchClick').click(function () {
        $(this).parents('.rightBottom').toggleClass('searchActive');
        $(".searchSec .inputbox input").focus();
        $(this).fadeOut();
    });

    $('.searchSec .closeBtn').click(function () {
        $(".searchSec .inputbox input").val('').blur();
        $(this).parents('.rightBottom').removeClass('searchActive');
        $('.searchClick').fadeIn();
    });
    $('.getInTouch .selectedText').click(function () {
        $(".transOverlay").css("display", "block");
        //console.log('anc');
        $(this).toggleClass('active')
        $(this).parents('.getInTouch').find('.dropdown-menu').slideToggle();
    });

    //Notification Click

    var notifyLenght = $('.dropdown-menu-notify ul li').length;
    for (i = 0; i <= notifyLenght; i++) {
        $('.notification span').text(i);
    }

    $(document).on("click", "#searchPop .closePop", function () {
        $('.searchPopup').hide();
    });

    $(document).on("click swipe touchstart", ".transOverlay", function () {
        //console.log(123)
        $(".notification").removeClass('active');
        $(".notification").parents('.notificationWrap').find('.dropdown-menu-notify').slideUp();
        $('.getInTouch .selectedText').removeClass('active')
        $('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').slideUp();

        $('.callback-content').css('display', 'none');
        $('.callback-content').removeClass('callbackActive');
        $('.communicationSec').find('.callBack').fadeIn(300);

        $(".transOverlay").css("display", "none");
        $(".mainHeader").removeClass("zIndex");
    })

    $('.notification').click(function () {
        $(".transOverlay").css("display", "block");
        if (!$(this).hasClass('active')) {
            $(this).addClass('active');
            $(this).parents('.notificationWrap').find('.dropdown-menu-notify').slideDown();
        }
        else {
            $(this).removeClass('active');
            $(this).parents('.notificationWrap').find('.dropdown-menu-notify').slideUp();
        }

        //$(this).toggleClass('active');
        //$(this).parents('.notificationWrap').find('.dropdown-menu-notify').slideToggle();
    });


    $(".searchSec, .notificationWrap .dropdown-menu-notify, .getInTouch .dropdown-menu, .popupSec, .callback-content").addClass("activePopup");

    /*$(document).on("click touchstart", function(e) {
        if ($(e.target).closest('.activePopup').length <= 0 ) {
            $('.activePopup .closeBtn, .activePopup .closePop').click();
            return false;
        }
    });*/

    // $(".searchSec, .notificationWrap .dropdown-menu-notify, .getInTouch .dropdown-menu, .popupSec, .callback-content").addClass("activePopup");

    $("body").append("<div class='transOverlay'></div>");




    $(document).on("click touchstart swipe", function (e) {
        if ($(e.target).closest('.searchSec').length === 0) {
            $(".searchSec .inputbox input").val('').blur();
            $('.searchSec .closeBtn').click();
        }
        /*if ($(e.target).closest('.activePopup').is(":visible")) {
            $('.activePopup .closeBtn, .activePopup .closePop').click();
            return false;
        }*/

    });



    /* $(document).on("click touchstart", function(e) {
         //console.log(2234)
         if ($(e.target).closest('.notification').length <= 0) {
             $('.notification').removeClass('active')
             $('.notification').parents('.notificationWrap').find('.dropdown-menu-notify').slideUp();

         }
     });

     $(document).on("click touchstart", function(e) {
         //console.log(223456456)
         if ($(e.target).closest('.getInTouch').length <= 0) {
             if($('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').is(":visible")) {
                 $('.getInTouch .selectedText').removeClass('active')
                 $('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').slideUp();
             }
         }
     });*/

    var keycode_esc = 27;
    $(document).keyup(function (e) {
        if (e.keyCode == keycode_esc) {
            $('.popupSec .closePop,.bodyOverlay').click();
            if ($('.searchActive').length) {
                $(".searchSec .inputbox input").val('');
                $('.searchSec .closeBtn').click();
                $(".searchSec .inputbox input").blur();
            }

            if ($('.callbackActive').length) {
                $('.callback-content .closebtn').click();
                $('.communicationSec').find('.callBack').show();
            }

            if ($('.mainHeader nav > ul > li.open').length) {
                $('.mainHeader .sumMenuSec .closeBtn').click();
            }

            if ($('.notificationWrap .notification.active').length) {
                $('.notificationWrap .notification').click();
                $(".transOverlay").css("display", "none");
            }

            if ($('.getInTouch .selectedText.active').length) {
                $('.getInTouch .selectedText').removeClass('active')
                $('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').slideUp();
                $(".transOverlay").css("display", "none");
            }

        }
    });

    $(document).on("click touchstart", function (event) {
        //console.log(event)
        if (event.isTrigger !== 3) {
            if ($(event.target).closest('.customSelect .selectedText').length === 0 && $(event.target).closest('.selectMulty').length === 0) {

                $('.selectMulty').slideUp();
            }
        }
    });





    responsiveSubMenu();
    customSelect();


    //     $(document).on("click touchstart", function(e) {
    //         console.log(e);
    //         if ($(e.target).closest('.customSelect .selectedText').length <= 0) {
    //             $('.selectMulty').slideUp();
    //         }

    //         if ($(e.target).closest('.notification').length <= 0) {
    //             $('.notification').removeClass('active')
    //             $('.notification').parents('.notificationWrap').find('.dropdown-menu-notify').slideUp();

    //         }
    // console.log($(e.target));
    //         if ($(e.target).closest('.getInTouch').length <= 0) {
    //             console.log($('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').is(":visible"));
    //             if($('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').is(":visible")) {
    //                 $('.getInTouch .selectedText').removeClass('active')
    //                 $('.getInTouch .selectedText').parents('.getInTouch').find('.dropdown-menu').slideUp();
    //             }
    //         }
    // 	});


    $('.btn').each(function () {
        if ($(this).text() == "") {
            $(this).hide();
        }
    });

});


/*function customSelect() {
    $(".customSelect").each(function () {
        $(this).find('.selectedText').text($(this).find('select option:selected').val());
        $(this).find('select').change(function () {
            $(this).parent().find('.selectedText').text($(this).parent().find('select option:selected').val());

            //Limited text for select title            
            var selectText = $('.protectWheel .selectedText').text().length;
            if (selectText > 12) {
                var selTextval = ($(this).parent().find('select option:selected').val().slice(0, 10)) + '...';
                $('.protectWheel .selectedText').text(selTextval)
            }
        })
    })
}*/

function customSelect() {

    var elemSelect = "";

    $('.selectMulty').attr('style', '')
    if ($('.customSelect').length > 0) {
        $('.customSelect').each(function () {
            $(this).find('.selectedText').text($(this).find('select option:selected').val());
        })
    }

    $(document).on('click', '.selectMulty li', function () {

        var $this = $(this);
        $(elemSelect).children("option").each(function () {
            if ($(this).text() == $this.text().trim()) {
                $(this).attr("selected", true).change();
            } else {
                $(this).attr("selected", false)
            }
        });
        $(elemSelect).parent().find('.selectedText').text($(this).text());
        //$(elemSelect).parent().find('.selectedText').text($(elemSelect).find('option:selected').val());
        $('.selectMulty').slideUp();
    });

    $(document).on('click', '.customSelect .selectedText', function () {

        $('.selectMulty .innerWrap ul').empty();
        elemSelect = $(this).parent().find("select");
        $(this).parent().find("select option").each(function () {
            if ($(this).css("display") != 'none') {
                var createLI = "<li>" + $(this).text() + "</li>";
                $(".selectMulty .innerWrap ul").append(createLI);
            }

        });

        var selectMultyLeft = $(this).offset().left;
        var selectMultyTop = $(this).offset().top;
        var _this = $(this);
        $('.selectMulty').css({
            'left': selectMultyLeft,
            'top': selectMultyTop + _this.outerHeight()
        });

        $('.selectMulty').show();
    });
}

/*********On Window Resize Event*********/

$(window).resize(function () {
    if (this.resizeTO) clearTimeout(this.resizeTO);
    this.resizeTO = setTimeout(function () {
        $(this).trigger('resizeEnd');
    }, 300);
});

$(window).bind('resizeEnd', function () {
    if (winW !== $(window).width()) {
        winW = $(window).width();
        winH = $(window).height();
        if (winW < 768) {
            readDeviceOrientation();
        }
    }
});

// Home page

function popCenter() {
    var widthW = $(window).width();
    var heightW = $(window).height();
    setTimeout(function () {
        //console.log(((heightW - $(".popupSec:visible").outerHeight()) / 2) + $(window).scrollTop());
        $(".popupSec").css({ "left": (widthW - $(".popupSec:visible").outerWidth()) / 2 + "px", "top": ((heightW - $(".popupSec:visible").outerHeight()) / 2) + $(window).scrollTop() });
        /*if ($(window).height() > $(".popupSec").outerHeight()) {
            $(".popupSec").css("top", (heightW - $(".popupSec:visible").outerHeight()) / 2 + "px");
        } else {
            $(".popupSec").css("top", 50);
        }*/
    }, 100);
    /*$('html,body').css('overflow','hidden');	
    var popup_H = $('.popupSec').outerHeight();
    if(popup_H > $(window).outerHeight()){
        popup_H = $(window).outerHeight() - 100+'px';
        //alert(popup_H)
        $('.popupSec').css({'overflow-y:scroll'});
    }*/

}
/*Search popup code start */
$('.search').click(function () {
    $('.bodyOverlay,.searchPopup').fadeIn();
    // Analytics AJ27
    $('.keyword-search').find('a').on("click", function () {
        try {
            var searchKeyowrd = this.text;
            searchTopResult(searchKeyowrd);
        } catch (e) {
            console.log(e);
        }
    })
    // Analytics AJ27
    popCenter();
});


function searchresult() {
    var input, filter, ul, li, a, i, txtValue;
    input = document.getElementById("inpusearch");
    filter = input.value.toUpperCase();
    ul = document.getElementById("searchresult");
    li = ul.getElementsByTagName("li");
    if (input.value != "" && input.value.length >= 3) {

        var url = "/content/bagic/search." + input.value + ".json"
        $.get(url, function (data) {
            var liHtml = "";
            data = typeof (data) == "string" ? JSON.parse(data) : data;
            data = data.searchResult;
            data = data.reverse();
            data.forEach(function (eachObject) {
                //if(eachObject[jsHelper.objectKeys(eachObject)].indexOf("amp") == -1){
                //  liHtml += '<li style="display:block"><a  href="'+eachObject[jsHelper.objectKeys(eachObject)]+'.html">'+jsHelper.objectKeys(eachObject)+'</a></li>';
                // }
                if (eachObject[Object.keys(eachObject)].indexOf("amp") == -1) {
                    liHtml += '<li style="display:block"><a data-call="list" href="' + eachObject[Object.keys(eachObject)] + '.html">' + Object.keys(eachObject) + '</a></li>';
                }



            });
            if (liHtml) {
                $("#searchresult").html(liHtml);
                $(".searchresult").show();
            }
            $('[data-call="list"]').click(function (el) {
                var temp = el.currentTarget.innerText;

                try {
                    var selectedTerm = temp;
                    searchResult(selectedTerm);
                } catch (e) {
                    console.log(e);
                }
            })
        });

        /* for (i = 0; i < li.length; i++) {
         a = li[i].getElementsByTagName("a")[0];
         txtValue = a.textContent || a.innerText;
         if (txtValue.toUpperCase().indexOf(filter) > -1) {
             li[i].style.display = "block";
             $(".searchresult").show();
             console.log( li[i]);
         } else {
             li[i].style.display = "none";
         }
     }*/


    } else {
        $(".searchresult").hide();
        $(".searchresult").find("li").hide()
    }

}
$(".search img").click(function () {
    $(".inpusearch").val();
});
/*Search popup code end */
function readDeviceOrientation() {
    switch (window.orientation) {
        case 0:
            // Portrait 
            break;
            alert('Portrait 0')

        case 180:
            // Portrait (Upside-down)
            alert('Portrait 180 => Upside-down')
            break;

        case -90:
            // Landscape (Clockwise)
            alert('Better view in Portrait -90 => Clockwise')
            break;

        case 90:
            // Landscape  (Counterclockwise);
            alert('Better view in Portrait 90 => Counterclockwise')
            break;
    }
}
/** Adobe Analytics Start **/


// if ($("#searchresult li").length != 0) {
//     $("#searchresult").find("li").on("click",function (e) {
//         var temp = e.currentTarget.textContent

//         try {
//             var selectedTerm = temp;
//             searchResult(selectedTerm);
//         } catch (e) {
//             console.log(e);
//         }
//     })
// }



function searchRedirection() {
    var value = $('.inpusearch').val();
    var searchKeyword = value.toLocaleLowerCase();
    var propertyVar = redirectionObject.hasOwnProperty(searchKeyword);
    var url;
    if (propertyVar) {
        url = redirectionObject[searchKeyword].valueOf()
        window.location.href = url;
    } else {
        searchresult();
    }

};

/** Adobe Analytics End **/

setTimeout(function () {
    $('.searchPopup .closePop').click(function () { $('.searchPopup').hide(); });
}, 1000);


//Rupali 01-09-23


const iconSecElements = document.querySelectorAll('.iconSec')


try {
    for (let i = 0; i < iconSecElements.length; i++) {
        const iconSecElement = iconSecElements[i];
        const pElement = iconSecElement.querySelector('p');
      
        if (
          iconSecElement.nextElementSibling &&
          iconSecElement.nextElementSibling.classList.contains('links')
        ) {
          pElement.classList.remove('no-after')
        } else {
          pElement.classList.add('no-after')
        }
      }
      
} catch (error) {
    console.log(error)
}

function RequestCallback(mobileNo, selectedProduct, enquiryFor) {
    try {
        _satellite.track('request-call-back-submit', { mobileNo: mobileNo, selectedProduct: selectedProduct, enquiryFor: enquiryFor });
    } catch (e) {
        console.log(e);
    }
}

// =========== --21-9-2023 ============================================
$(document).ready(function () {
    $('.whatsappno[for="theft"]').hide();
    $('.requestCallBack.afterwhatsappconsent').before('<style>.disclaimerandwhatsapp .check-box {text-align: left;}.popupSec.disclaimerContentWraplanding.activePopup.active,.popupSec.disclaimerPrivcy.activePopup.active{text-align:left;width:50%;color:#000;border-radius:15px;top:200px!important;left:294px!important;position:fixed}input.setRenewalPolicy::placeholder{color:#ccc}.disclaimerContentWraprequest-closePop span:first-child,.disclaimerContentWraprequest-closePop span:nth-child(2),.disclaimerrequest-closePop span:first-child,.disclaimerrequest-closePop span:nth-child(2){font-size:62.5%;-webkit-text-size-adjust:100%;font-family:AllianzSans;color:#005596;cursor:pointer;padding:0;outline:0;list-style:none;-webkit-tap-highlight-color:transparent;box-sizing:border-box;-webkit-font-smoothing:antialiased;display:block;background:#000;height:3px;transition:.5s;position:relative}.disclaimerandwhatsapp input[type=checkbox]{opacity:1!important;width:auto}.popupSec.disclaimerPrivcy.activePopup.active{height:253px}.popupSec.disclaimerContentWraplanding.activePopup.active{height:220px}.popupSec.disclaimerContentWraprequest,.popupSec.disclaimerrequest{position: fixed; left: 50%!important; top: 50%!important; height: auto; padding:2%;    width: 95%; transform: translate(-50%,-50%); background-color: #fff; z-index: 99999;}.disclaimerContentWraprequest-closePop,.disclaimerrequest-closePop{width:20px;position:absolute;height:20px;right:15px;top:2%;cursor:pointer;z-index:9999}.disclaimerContentWraprequest-closePop span:first-child,.disclaimerrequest-closePop span:first-child{margin:0;border:none;border-radius:0;width:100%;transform:rotate(47deg);top:10px}.disclaimerContentWraprequest-closePop span:nth-child(2),.disclaimerrequest-closePop span:nth-child(2){margin:0 0 5px;border:none;border-radius:0;width:100%;transform:rotate(-45deg);top:7px}.disclaimerandwhatsapp .check-box label{width:auto;float:inherit}.fieldBox.disclaimerandwhatsapp{padding:2%;}.whatsappno {position: inherit; padding-left: inherit; top: 8px;}.authorizeBtnSec p {font-size: 2rem;color:black;}.authorizeBtnSec {color:black;}.whatsappno.active:before,.whatsappno:before{display:none;}.callback-content .check-box label a {font-size: 13px; color: #757575;}.check-box div {margin: 2% 0;}.callback-content {zoom: 85% !important;max-width: 325px !important;} .callback-content .fieldBox.checkInputBox label {line-height: 1.5 !important; font-weight: normal !important; font-size: 13px !important;} @media only screen and (max-width: 480px) {.callback-content {zoom: 100% !important;}.callback-content .check-box {display: block;}.callback-content .check-box div {padding-left: 0;}.fieldBox.afterwhatsappconsent {padding-top: 0px !important;}.popupSec.disclaimerContentWraprequest, .popupSec.disclaimerrequest {padding: 10% 2%;}}</style><sly data-sly-test="${\'general-insurance-videos/motor-insurance/two-wheeler-long-term-policy-video.html\' in request.requestURI }"><style>@media screen and (max-width:480px){.commercialInsuranceForm{top:75%;}.iframe-section iframe{margin-bottom:126%;}.authorizeBtnSec .whatsappno {margin-left: 0;}}</style></sly> <!-- ============ 6-7-2023 checkboxes ================= -->            <div class="fieldBox disclaimerandwhatsapp">              <div class="check-box">                <div>                  <input type="checkbox" id="agreedata1" name="" value="Agree" checked="">                  <label for="agreedata1" style="font-size:13px;">                    <a href="javascript:;" class="MoreClick-landing"> &nbsp; I agree to the data privacy policy</a>                  </label>                </div>                <br>                <div>                  <input type="checkbox" id="agreedata2" name="" value="Policy" checked="">                  <label for="agreedata2" class="whatsappno" style="font-size:13px;">                    <a href="javascript:;" class="landingClick"> &nbsp; I want to get my quote and policy details on&nbsp;                      <span>                        <img src="/content/dam/bagic/index/whatsapp-header.png" class="whatsicon">                      </span>                    </a>                  </label>                </div>              </div>              <!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --><script>$(".landingClick,.landingClick:not(:checked)").click(function(){$(".bodyOverlay").fadeIn(),$(".disclaimerContentWraprequest").show()}),$(".MoreClick-landing").click(function(){$(".bodyOverlay").fadeIn(),$(".disclaimerrequest").show()}),$("#agreedata2").on("change",function(){$(this).is(":checked")||($(".bodyOverlay").fadeIn(),$(".disclaimerContentWraprequest").show())}),$(".disclaimerrequest-closePop").click(function(){$(".disclaimerrequest").hide(),$(".bodyOverlay").fadeOut()}),$(".disclaimerContentWraprequest-closePop").click(function(){$(".disclaimerContentWraprequest").hide(),$(".bodyOverlay").fadeOut()});</script>');
});
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

(function ($, window, document, undefined) {
    $.fn.addPlaceholder = function (options) {
        var settings = $.extend({
            events: true,
            IE: true
        }, options);

        function phBehaviour(_this, isShowLable, selfEvent) {
            if (isShowLable == "true") {
                if (selfEvent == false) {
                    $(_this).prev(".lblplaceholder").addClass("active");
                    $(_this).parents(".inputBox").addClass("focused");
                    $(_this).siblings(".cc").fadeIn();
                } else {
                    $(_this).prev(".lblplaceholder").removeClass("active");
                    $(_this).parents(".inputBox").removeClass("focused");
                    $(_this).siblings(".cc").hide();
                }
            } else {
                if (selfEvent == false) {
                    $(_this).prev(".lblplaceholder").hide();
                } else {
                    $(_this).prev(".lblplaceholder").show();
                }
            }
        }
        function placeHolderFontSize(_this) {
            _this.prev(".placeholder").css("font-size", (parseInt(_this.css("font-size")) / 10) + "rem");
        }

        return this.each(function () {
            var a = $(this).attr("placeholder");
            var showlabel = $(this).attr("data-label");
            $(this).attr("placeholder", "");
            //alert($(this).val());
            if ($(this).val() == "") {
                $(this).before("<div class='lblplaceholder'>" + a + "&nbsp;</div>")
                if ($(this).val() != "") {
                    phBehaviour(this, showlabel, true)
                }
            } else {
                $(this).before("<div class='lblplaceholder'>" + a + "</div>");
                if (showlabel == "true") {
                    $(this).prev(".lblplaceholder").addClass("active");
                    $(this).parents(".inputBox").addClass("focused");
                    $(this).siblings(".cc").show();
                } else {
                    $(this).prev(".lblplaceholder").hide();
                }
            }

            $(this).focus(function (e) {
                if ($(this).val() == "") {
                    phBehaviour(this, showlabel, false)
                } else {
                    phBehaviour(this, showlabel, false)
                }
            });
            $(this).blur(function (e) {
                console.log($(this))
                if ($(this).val() == "") {
                    $(this).val(""); /*IF its is a number field it does accept alphabets but inavalidate it as wrong characters while keeping value as blank. try commenting this line & inputing alphabets on "number" type field*/
                    phBehaviour(this, showlabel, true);
                } else {
                    phBehaviour(this, showlabel, false);
                }
            });

        });
    }
})(jQuery);
$(function () {


    $(".inputNum").keypress(function (event) {
        return validateNumber(event);
    });
    var callbackscrollTop
    $(window).scroll(function () {
        callbackscrollTop = $(window).scrollTop();
    });

    $('.footerRequestCall').click(function () {
        $('.callBack').click();
    });
    $('.callBack').click(function () {
        $('.callback-content').animate({
            'right': '0px'
        }, 500);

        $(this).parents('.communicationSec').find('.callBack').fadeOut(300);
        $('.callback-content').addClass('callbackActive');
        $('.callback-content').fadeIn(500);
        if ($(window).width() <= 1024) {
            var offsetTopCallback = $(this).offset().top;
            if (offsetTopCallback < 350) {
                $('.callback-content').css('top', offsetTopCallback + 170 + "px");
            } else {
                $('.callback-content').css('top', offsetTopCallback - 170 + "px");
            }
        }
        $(".transOverlay").show();
        if ($(window).width() == 320) {
            $(".mainHeader").addClass("zIndex");
        }
    });
    $('.callback-content .closebtn').click(function () {
        $(this).parents('.callback-content').animate({
            'right': '-500px'
        }, 500);
        $('.callback-content').fadeOut(500);
        $('.callback-content').removeClass('callbackActive');
        $('.communicationSec').find('.callBack').fadeIn(300);
        $(".transOverlay").hide();
        $(".mainHeader").removeClass("zIndex");
    });

    $(".lblinput").addPlaceholder();
    $("select").each(function () {
        if ($(this).prop('selectedIndex') != "0") {
            $(this).parents('.selectBox').addClass('focused');
        }
        $(this).siblings(".selectedValue").text($(this).find("option:selected").text())
    });

    if ($('.callback-content select option').length == 1) {
        $(".callback-content select").prop('disabled', 'disabled');
        $(".callback-content select").parents('.selectBox').addClass('focused');
        if ($(".callback-content select").prop('disabled')) {
            $('.callback-content .selectedValue').addClass('disabledSelect');
        } else {
            $('.callback-content .selectedValue').removeClass('disabledSelect');
        }
    }

    $(document).on('change', 'select', function (e) {
        var _this = $(this).parents('.selectBox').find('.selectedValue');
        $(this).siblings(".selectedValue").text($(this).find("option:selected").text());
        if ($(this).prop('selectedIndex') != "0") {
            $(this).parents('.selectBox').addClass('focused');
        } else {
            $(this).parents('.selectBox').removeClass('focused');
        }
    });


    //Request callback disclamier popup show
    $('.requestMoreClick').click(function () {
        $('.bodyOverlay').css('z-index', '100');
        $('.bodyOverlay,.disclaimerContentWrap').addClass('active').fadeIn();
        popCenter();
    });

    //Request callback disclamier popup hide
    $(document).on('click', '.popupSec.disclaimerContentWrap .closePop,.bodyOverlay', function () {
        $('.bodyOverlay').css('z-index', '99');
        $('.bodyOverlay,.disclaimerContentWrap').removeClass('active').fadeOut();

    });
    $('.popupSec .closePop').click(function () {
        $('.bodyOverlay').css('z-index', '99');
        $('.bodyOverlay,.popupSec').fadeOut();
    });

    $('.callback-content .btn').click(function () {
        callBackRedirect();
    });


    $('.callBackMobNumber').on('blur', function () {
        var callBackphone = $('.callBackMobNumber').val();
        callBackintRegex = /^[6-9][0-9]{9}$/;
        if ((!callBackphone.length == 10) || (!callBackintRegex.test(callBackphone))) {
            $('.callBackMobNumber').parents('.inputBox').next('.errorMsg').show();
        } else {
            $('.callBackMobNumber').parents('.inputBox').next('.errorMsg').hide();
        }
    });
    $('.callback-content select').on('change', function () {
        setTimeout(function () {
            if ($('.callback-content .selectedValue').text() == "Enquiry for") {
                $('.callback-content select').next('.errorMsg').show();
            } else {
                $('.callback-content select').next('.errorMsg').hide();
            }
        }, 300)
    });
    $('.callback-content input[type="checkbox"]').on('change', function () {
        var callBackCheck = $('.callback-content input[type="checkbox"]#self');
        if (!$(callBackCheck).is(":checked")) {
            $('.callback-content input[type="checkbox"]#self').parents('.inputBox').next('.errorMsg').show(); return false;
        } else {
            $('.callback-content input[type="checkbox"]#self').parents('.inputBox').next('.errorMsg').hide();
        }
    });
    /*$(document).on("click touchstart", function(e) {
        //  if (($(e.target).closest('.callback-content').length) === 0 && ($(e.target).closest('.communicationSec').length === 0) && ($(e.target).closest('.banner-bottomTab ul li').length === 0) && ($(e.target).closest('.tabs li').length === 0)) {
        if (($(e.target).closest('.callback-content').length) === 0 && ($(e.target).closest('.communicationSec').length === 0) && ($(e.target).closest('.banner-bottomTab ul li').length === 0) && ($(e.target).closest('.tabs li').length === 0) && ($(e.target).closest('.disclaimerContentWrap .closePop').length === 0) && ($(e.target).closest('.bodyOverlay').length === 0)) {
            // $('.callback-content').animate({
            //     'right': '-500px'
            // }, 500);
            // $('.callback-content').css('display', 'none');
            // $('.callback-content').removeClass('callbackActive');
            // $('.communicationSec').fadeIn(300);
        }
    });*/
    $(document).on('change', 'select', function (e) {
        var _this = $(this).parents('.selectBox').find('.selectedValue');
        $(this).siblings(".selectedValue").text($(this).find("option:selected").text());
        if ($(this).prop('selectedIndex') != "0") {
            $(this).parents('.selectBox').addClass('focused');
        } else {
            $(this).parents('.selectBox').removeClass('focused');
        }
    });
    $(document).on("ui:requetsCallback", function (e, obj) {
        var uiObj = obj.data;
        var callback = obj.cb;
        //var reqObj = apiConfig.WEB_SALES_CORP_LP_LOG.getEmptyRequestObj();
        //reqObj = apiConversionUtility.webSalesCorpLPLog.parseWebSalesCorpLPLogUiObjToReqObj(uiObj, reqObj);
        console.log("reqObj", reqObj);
        var reqObj = {
            "requestJson": uiObj
        };
        apiUtility.webSalesCorpLPLog(reqObj)
            .then(function (response) {
                //uiObj = apiConversionUtility.webSalesCorpLPLog.parseWebSalesCorpLPLogResObjToUiObj(response.responseJson, uiObj);
                if (response.msg == "Y") {
                    callback(true, response);
                } else {
                    callback(false, response);
                }
            })
            .catch(function (error) {
                callback(false, uiObj);
            })
    });
    /*$(document).on('keypress keyup', ".inputChar", function(e) {
        var thisVal = $(this).val();
        var regOne = new RegExp("^[a-zA-Z]+$");
        var regex = new RegExp("^[a-zA-Z'. ,-]+$");
        var kCd = e.keyCode || e.which;
        if ($(window).width() < 1280) {
            if (kCd == 0 || kCd == 229) {
                kCd = getKeyCode($(this).val());
                if (thisVal.length == 1) {
                    if (!(regOne.test(kCd))) {
                        $(this).val('');
                        return false;
                    }
                }
                if (!regex.test(kCd)) {
                    $(this).val($(this).val().substr(0, $(this).val().length - 1));
                    return false;
                }
            }
        }
        var key = String.fromCharCode(!e.charCode ? e.which : e.charCode);
        if (thisVal.length == 0) {
            if (!(regOne.test(key))) {
                return false;
            }
        }
        if (!(regex.test(key) || (e.charCode == 0))) {
            return false;
        }
    });*/
    var getKeyCode = function (str) {
        if (str.length > 1) {
            return str.charAt(str.length - 1);
        } else {
            return str.charAt(0);
        }
    };
    $(document).on('keypress keyup', ".inputChar", function (e) {
        var thisVal = $(this).val();
        var regOne = new RegExp("^[a-zA-Z]+$");
        var regex = new RegExp("^[a-zA-Z' ]+$");
        var kCd = e.keyCode || e.which;
        if ($(window).width() < 1280) {
            if (kCd == 0 || kCd == 229) {
                kCd = getKeyCode($(this).val());
                if (thisVal.length == 1) {
                    if (!(regOne.test(kCd))) {
                        $(this).val('');
                        return false;
                    }
                }
                if (!regex.test(kCd)) {
                    $(this).val($(this).val().substr(0, $(this).val().length - 1));
                    return false;
                }
            }
        }
        var key = String.fromCharCode(!e.charCode ? e.which : e.charCode);
        if (thisVal.length == 0) {
            if (!(regOne.test(key))) {
                return false;
            }
        }

        if (!(regex.test(key) || (e.charCode == 0))) {
            return false;
        }
    });
    /* if($('.callBackName').val()=='' || $('.callBackName').val().trim().length < 2){
            $('.callBackName').parents('.inputBox').next('.errorMsg').show();
        }else {
             $('.callBackName').parents('.inputBox').next('.errorMsg').hide();
        }*/
    $('.callBackName').on('blur', function () {
        /*var callBackNameval = $('.callBackName').val();
        //var callBack_name_regex = /^[a-zA-Z'. ,-]{2,150}$/;
        var callBack_name_regex = new RegExp("^[a-zA-Z'. ,-]+$");

        //Validating Name Field.
        if (!callBackNameval.match(callBack_name_regex) || callBackNameval.length < 2) {
            $('.callBackName').parents('.inputBox').next('.errorMsg').show();
        } else {
            $('.callBackName').parents('.inputBox').next('.errorMsg').hide();
        }*/
        if ($('.callBackName').val() == '' || $('.callBackName').val().trim().length < 2) {
            $('.callBackName').parents('.inputBox').next('.errorMsg').show();
        } else {
            $('.callBackName').parents('.inputBox').next('.errorMsg').hide();
        }
    });


    $('#rcback').on('change', function () {
        if ($('#rcback').val() == "-1") {
            $('#errorrcback').show();
            // alert("not selected");
            // return false;
        }
        else {
            $('#errorrcback').hide();
            //  alert("selected");
        }

    });

    $('#enqfor').on('change', function () {
        if ($('#enqfor').val() == "-1") {
            $('#errorenqfor').show();
            return false;
        }
        else {
            $('#errorenqfor').hide();
        }


    });

});

var callbackObject = {};
function callBackRedirect() {
    /*Adobe-Analytics-Starts*/
    var mobno = $(".callBackMobNumber").val();
    var encmobNo = window.btoa(mobno);
    var enquiryFor = jsHelper.toString($("#enqfor option:selected").text()); // jsHelper.toString($("#rcback option:selected").text());
    var selectedProduct = jsHelper.toString($('#rcback option:selected').text());
    RequestCallback(encmobNo, selectedProduct, enquiryFor);
    callbackObject.dataPrivacy = jsHelper.toString($('#agreedata1').is(':checked') ? 'Y' : 'N')
    callbackObject.whatsappYN = jsHelper.toString($('#agreedata2').is(':checked') ? 'Y' : 'N')
    //AK11 18-09-23
    // callbackObject.param1 = getURLParams().param1;
    // callbackObject.param2 = getURLParams().param2;
    // callbackObject.param3 = getURLParams().param3;
    // callbackObject.src  = getURLParams().src;
    callbackObject.src = getURLParams().src;
    callbackObject.gclid = getURLParams().gclid; //AK11 17-11

    /*Adobe-Analytics-Ends*/

    /* var callBackNameval = $('.callBackName').val();
     var callBack_name_regex = /^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$/;*/
    // /^[a-zA-Z'. ,-]{2,150}$/;
    var flag1, flag2, flag3, flag4;
    //Validating Name Field.
    /*if (!callBackNameval.match(callBack_name_regex) || callBackNameval.length < 2) {
        $('.callBackName').parents('.inputBox').next('.errorMsg').show();
        flag1 = false;
    } else {
        $('.callBackName').parents('.inputBox').next('.errorMsg').hide();
        callbackObject["name"] = callBackNameval;
        flag1 = true;
    }*/

    var callBackNameval = $('.callBackName').val();
    if ($('.callBackName').val() == '' || $('.callBackName').val().trim().length < 2) {
        $('.callBackName').parents('.inputBox').next('.errorMsg').show();
        flag1 = false;
    } else {
        $('.callBackName').parents('.inputBox').next('.errorMsg').hide();
        callbackObject["name"] = callBackNameval;
        flag1 = true;
    }

    //Validating Mobile Number
    var callBackphone = $('.callBackMobNumber').val();
    callbackObject.mobileNo = $('.callBackMobNumber').val();
    callBackintRegex = /^[6-9][0-9]{9}$/;
    if ((!callBackphone.length == 10) || (!callBackintRegex.test(callBackphone))) {
        $('.callBackMobNumber').parents('.inputBox').next('.errorMsg').show();
        flag2 = false;
    } else {
        $('.callBackMobNumber').parents('.inputBox').next('.errorMsg').hide();
        callbackObject["number"] = callBackphone;
        flag2 = true;
    }


    //Validating Product list

    if ($('#rcback').val() == "-1") {
        $('#rcback').next('.errorMsg').show();
        // alert("not selected");
        // return false;
    }
    else {
        $('#rcback').next('.errorMsg').hide();
        //  alert("selected");
    }


    //Validating Enquiry Option
    //alert($('#enqfor').val());
    if ($('#enqfor').val() == "-1") {
        $('#errorenqfor').show();
        // alert("not selected");
        return false;
    }
    else {
        $('#errorenqfor').hide();
        //  alert("selected");
    }

    var callBackProuct = $('.callback-content .selectedValue').val();
    if ($(callBackProuct).text() == "Product") {
        $('.callback-content select').next('.errorMsg').show();
        flag3 = false;
    } else {
        $('.callback-content select').next('.errorMsg').hide();
        callbackObject["productId"] = callBackProuct;
        flag3 = true;
    }
    //Validating checkbox
    var callBackCheck = $('.callback-content input[type="checkbox"]#self');
    if (!$(callBackCheck).is(":checked")) {
        $('.callback-content input[type="checkbox"]#self').parents('.inputBox').next('.errorMsg').show();
        flag4 = false;
    } else {
        $('.callback-content input[type="checkbox"]#self').parents('.inputBox').next('.errorMsg').hide();
        callbackObject["agree"] = callBackCheck ? true : false;
        flag4 = true;
    }
    if (flag1 && flag2 && flag3 && flag4) {
        callbackObject["productDataSource"] = fecthdata("productDataSource");
        callbackObject["productDeptId"] = fecthdata("productDeptId");
        callbackObject["pageproductId"] = fecthdata("productId");

        $(".loader").show();
        //romil 28 june new service call back
        var callBackEmail = "test@test.com"
        var reqObj = apiConfig.WEB_SALES_CORP_LP_LOG.getEmptyRequestObj();
        reqObj["p_user_nm"] = PGSUtil.encrypt(callBackNameval);
        reqObj["p_user_mob"] = PGSUtil.encrypt(callBackphone);
        reqObj["p_user_eml"] = PGSUtil.encrypt(callBackEmail);
        reqObj["p_notes"] = $('#enqfor').val();
        reqObj["p_gcl_id"] = callbackObject.gclid ? callbackObject.gclid.replaceAll("%20", " ") : "";  //AK11 17-11
        reqObj["p_prod_cd"] = callbackObject["pageproductId"] //$('#rcback').val();
        reqObj["p_data_source"] = callbackObject.src ? callbackObject.src : callbackObject["productDataSource"]
        //AK11 18-09-23
        reqObj["param1"] = callbackObject.param1 ? callbackObject.param1.replaceAll("%20", " ") : ""
        reqObj["param2"] = callbackObject.param2 ? callbackObject.param2.replaceAll("%20", " ") : ""
        reqObj["param3"] = callbackObject.param3 ? callbackObject.param3.replaceAll("%20", " ") : ""
        if ($('#rcback option:selected').text() == "Car Insurance VPAY Add-on cover") {
            reqObj["p_prod_cd"] = "1877" // 03 July 23 RM11
            reqObj["p_data_source"] = callbackObject.src ? callbackObject.src : "WS_Pri_Car_vpay_package"
        }
        if ($('#rcback').val() == "9910") {
            reqObj["p_dept_cd"] = "148910" // 08 Sep 22 RM11 24-04-23 ///15000
        }
        if (getURLParams().utm_source == "GoogleBrandBagic") {
            reqObj["p_dept_cd"] = "5598"
        }
        reqObj["p_agree"] = $('#self').is(":checked") ? "Y" : "N";
        reqObj["p_ip_addsr"] = callbackObject.whatsappYN;
        reqObj["p_maritalstatus"] = callbackObject.dataPrivacy
        if (callbackObject.whatsappYN == 'Y') {
            whatsappTrigger()
        }

        //28 june new service call back;
        $(document).trigger("ui:requetsCallback", {
            data: reqObj,
            cb: function (status, response) {
                $(".loader").hide();
                if (status) {
                    //TODO success
                    //console.log('Thank you');

                    $('.bodyOverlay,.callbackthankyou').fadeIn();
                    $('html').addClass('bodyScrollHide');
                    popCenter();
                    $('.callBackName,.callBackMobNumber ').val('');
                    $('.callback-content .closebtn').click();


                    var p_name = $(".selectedValue").text();

                    if (p_name == '') {
                        var p_name = $("#rcback").val();
                    }

                    /*Data layer code 23 sep start */
                    dataLayer.push({
                        'Product': p_name,
                        'event': 'ReqstCallBack'
                    });
                    /*Data layer code 23 sep end */

                } else {
                    //TODO error
                    //console.log('Sorry');
                }
            }
        });
    }
}
//AK11 10_08 
function whatsappTrigger() {
    //loaderToggle(true);
    //petData.mobileNo = $('#mobileNo').val();
    //$('.whatsappno').hasClass('active') ? 'Y' : 'N';
    reqObj = apiConfig.GET_WHATSAPP_CONSCENT_HEALTH.getEmptyRequestObj()
    reqObj.mobileNo = jsHelper.toString(callbackObject.mobileNo)
    reqObj.whatsappYN = jsHelper.toString(callbackObject.whatsappYN)
    $(document).trigger('api.whatsappTrigger', {
        uiObj: reqObj,
        cb: function (e, response) {
            try {
                if (e === true) {
                    //loaderToggle(false);
                } else {
                    // loaderToggle(false);
                }
            } catch (error) {
                console.error(error);
            }
        }
    });
}
/************** Random BusinessCorelationId Number ****************/
var getBusinessCorelationId = function () {
    return 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
$(document).on("api.whatsappTrigger", function (event, data) {
    var uiObj = data.uiObj;
    var callback = data.cb;
    reqObj = {
        "requestJson": uiObj
    }
    reqObj.headerJson = { "BusinessCorelationId": getBusinessCorelationId() }
    apiUtility.whatsAppconnscentHealth(reqObj)
        .then(function (response) {
            if (response) {
                callback(true, response);
            } else {
                callback(false, response);
            }
        })
        .catch(function (err) {
            console.log("Get Records Opus Catch listener is triggered");
            callback(false, err)
        });
});

/*-------Meta Name Starts----*/
function fecthdata(attribute) {
    var metaContent = $('meta[name=' + attribute + ']').attr("content");
    return metaContent;
}
/*-------Meta NameEnd----*/

function validateEmail(sEmail) {
    var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (filter.test(sEmail)) {
        return true;
    } else {
        return false;
    }
}
function validateNumber(event) {
    var charCode = event.which;
    if (charCode > 47 && charCode < 58 || charCode == 0 || charCode == 8) {
        return true;
    } else {
        return false;
    }
};

$(window).resize(function () {
    if (this.resizeTO) clearTimeout(this.resizeTO);
    this.resizeTO = setTimeout(function () {
        $(this).trigger('resizeEnd');
    }, 300);
});
$(window).bind('resizeEnd', function () {
    winW = $(window).width();
    winH = $(window).height();
    popCenter();
});