$(document).ready(function () {
    var isMobileDevice = $('#TargetDevice').attr("data-value").toLowerCase();
    //code for only one accordion
    /*$(".custom-accordion").click(function(){
	if($(".rsx-expandable-section").find(".glyphicon-plus")){
    $(".glyph-icon-expand").toggleClass("glyphicon-plus").toggleClass("glyphicon-minus");
	}*/

    //custom accordion begins
    $(".custom-accordion").each(function () {
        var $currentAccordion = $(this);
        $currentAccordion.click(function () {
            /*if($this.find(".glyphicon-plus")){*/
            $currentAccordion.find(".glyph-icon-expand").toggleClass("glyphicon-plus").toggleClass("glyphicon-minus");
            $currentAccordion.find(".glyphiconPlus").toggleClass("glyphicon-expander").toggleClass("glyphicon-collapse");
            /*}*/
        });
    });


    $(window).resize(function () {

        //custom accordion begins
        $(".custom-accordion").each(function () {
            var $currentAccordion = $(this);
            $currentAccordion.click(function () {
                /*if($this.find(".glyphicon-plus")){*/
                $currentAccordion.find(".glyph-icon-expand").toggleClass("glyphicon-plus").toggleClass("glyphicon-minus");
                /*}*/
            });
        });


    });

    var windowWidth = $(window).width();
    if (windowWidth <= 519) { // additional check for to match for VD for tablet
        $("#help0").addClass("rsx-expandable-section-content");
        $("#help1").addClass("rsx-expandable-section-content");
        $("#help2").addClass("rsx-expandable-section-content");
        $("#help3").addClass("rsx-expandable-section-content");
    } else {
        $("#help0").removeClass("rsx-expandable-section-content");
        $("#help1").removeClass("rsx-expandable-section-content");
        $("#help2").removeClass("rsx-expandable-section-content");
        $("#help3").removeClass("rsx-expandable-section-content");
    }
    $(window).resize(function () {
        // windowWidth = $(window).width();
        if (windowWidth <= 519) { // additional check for to match for VD for tablet
            $("#help0").addClass("rsx-expandable-section-content");
            $("#help1").addClass("rsx-expandable-section-content");
            $("#help2").addClass("rsx-expandable-section-content");
            $("#help3").addClass("rsx-expandable-section-content");
        } else {
            $("#help0").removeClass("rsx-expandable-section-content");
            $("#help1").removeClass("rsx-expandable-section-content");
            $("#help2").removeClass("rsx-expandable-section-content");
            $("#help3").removeClass("rsx-expandable-section-content");
        }
    }
    );

    $(window).on('load resize orientationchange', contactUsCellHeight_reset);

    //code for radio buttons selection starts
    //help radio
    $('input[name="help"]').on('change', function () {
        var helpValue = $('input[name="help"]:checked').val();
        if (helpValue == 'shop') {
            DeSelect2ndLayerForON();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();



        }
        else if (helpValue == 'support') {
            DeSelect2ndLayerForON();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();


        }
        else if (helpValue == 'mybill') {
            DeSelect2ndLayerForON();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();


        }
        else if (helpValue == 'Escalate') {
            DeSelect2ndLayerForON();
            omnitureCallONothers('Escalate a complaint');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-escalate').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpValue == 'somethingelse') {
            DeSelect2ndLayerForON();
            omnitureCallONothers('General inquiries');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-something').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }

        else {
            DeSelect2ndLayerForON();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('#adn-start').offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(0).offset().top - 75)
            }, 500);
        }

    });

    function DeSelect2ndLayerForON() {
        $('input[name="services"]').parent().removeClass('rsx-active');
        $('input[name="services-support"]').parent().removeClass('rsx-active');
        $('input[name="services-mybill"]').parent().removeClass('rsx-active');
    }
    //var JSONObj = { "shop": "Shop or order", "support": "Technical Support or repair", "mybill": "My Bill or account changes", "Escalate": "Escalate a complaint", "somethingelse": "something else" };

    var JSONObj = [
  { "value": "Shopping or orders", "code": "shop" },
  { "value": "Technical support or repair", "code": "support" },
  { "value": "Your bill or account", "code": "mybill" },
  { "value": "Escalate a complaint", "code": "Escalate" },
  { "value": "General inquiries", "code": "somethingelse" }
    ];
    function omnitureCallON(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    function ReturnValue(Jsonobj, param) {
        var triage1selectedval = "";
        if (param.length > 0) {
            triage1selectedval = param[0].value;
        }
        for (var i = 0; i < Jsonobj.length; i++) {
            // look for the entry with a matching `code` value
            if (Jsonobj[i].code == triage1selectedval) {
                return Jsonobj[i].value
            }
        }

    }

    function omnitureCallONothers(oSRG1value) {
        var oSRG = oSRG1value;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: 'Contact-us:' + oSRG

            });
        }

    }
    //code for services radio
    $('input[name="services"]').on('click', function () {
        var servicesValue2 = $('input[name="services"]:checked').val();

        if (servicesValue2 == 'Bundles') {
            omnitureCallON('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn').toggleClass("rsx-hide contactus-active");
            $('#display-adn1').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesValue2 == 'Business-shop') {
            omnitureCallON('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn').toggleClass("rsx-hide contactus-active");
            $('#display-shopbusiness').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesValue2 == 'Smart-Home-shop') {
            omnitureCallON('Smart-Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn').toggleClass("rsx-hide contactus-active");
            $('#display-smarthome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesValue2 == 'Residential') {
            omnitureCallON('Residential services');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn').toggleClass("rsx-hide contactus-active");
            $('#display-shopResidential').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }

        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
    });

    function omnitureCallONSupport(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }
    //code for services radio-Support
    $('input[name="services-support"]').on('click', function () {
        var servicesValueSupport = $('input[name="services-support"]:checked').val();
        if (servicesValueSupport == 'Bundles-support') {
            omnitureCallONSupport('Bundles');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportbundles').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueSupport == 'Homephone-support') {
            omnitureCallONSupport('Home phone');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportHomephone').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesValueSupport == 'Internet-support') {
            omnitureCallONSupport('Internet');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportInternet').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueSupport == 'BellTV-support') {
            omnitureCallONSupport('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportBellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueSupport == 'Smart-Home-support') {
            omnitureCallONSupport('Smart-Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-smarthome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueSupport == 'Mobility-support') {
            omnitureCallONSupport('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportMobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueSupport == 'Business-support') {
            omnitureCallONSupport('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-support').toggleClass("rsx-hide contactus-active");
            $('#display-supportBusiness').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }

    });

    function omnitureCallONMybill(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }
    //code for services radio-Mybill
    $('input[name="services-mybill"]').on('click', function () {
        var servicesValueMyBill = $('input[name="services-mybill"]:checked').val();
        if (servicesValueMyBill == 'Mobility-mybill') {
            omnitureCallONMybill('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-mybill-mobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueMyBill == 'Internet-mybill') {
            omnitureCallONMybill('Internet');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-Internetmybill').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueMyBill == 'BellTV-mybill') {
            omnitureCallONMybill('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-mybillBellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueMyBill == 'Homephone-mybill') {
            omnitureCallONMybill('Home phone');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-mybillHomephone').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueMyBill == 'Smart-Home-mybill') {
            omnitureCallONMybill('Smart-Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-smarthome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesValueMyBill == 'Combination-mybill') {
            omnitureCallONMybill('Any combination of services');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-mybillCombination').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesValueMyBill == 'Business-mybill') {
            omnitureCallONMybill('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-mybill').toggleClass("rsx-hide contactus-active");
            $('#display-mybillBusiness').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }

    });

    //code for help-allaint
    $('input[name="help-Aliant"]').on('change', function () {
		if ($('input[name="help-Aliant"]:checked').val() == "somethingelse"){
			var activeID = "help-aliant_" + $('input[name="help-Aliant"]:checked').val();
			hashURL(activeID);
		}
		handleHashHelpAliant();
    });

    function handleHashHelpAliant() {
        var helpAliant = $('input[name="help-Aliant"]:checked').val();
        if (helpAliant == 'support') {
            DeSelect2ndLayerForAliant();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpAliant == 'shop') {
            DeSelect2ndLayerForAliant();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpAliant == 'mybill') {
            DeSelect2ndLayerForAliant();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpAliant == 'Escalate') {
            DeSelect2ndLayerForAliant();
            omnitureCallAliantothers('Escalate a complaint');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-escalate').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpAliant == 'somethingelse') {
            DeSelect2ndLayerForAliant();
            omnitureCallAliantothers('General inquiries');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-something').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }

        else {
            DeSelect2ndLayerForAliant();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();

        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('#aliant-start').offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(0).offset().top - 75)
            }, 500);
        }
	}
    function DeSelect2ndLayerForAliant() {
        $('input[name="services-aliant"]').parent().removeClass('rsx-active');
        $('input[name="services-aliant-shop"]').parent().removeClass('rsx-active');
        $('input[name="services-aliant-mybill"]').parent().removeClass('rsx-active');
    }
    //aliant region

    var JSONObjAliant = [
{ "value": "Shopping or orders", "code": "shop" },
{ "value": "Technical support or repair", "code": "support" },
{ "value": "Your bill or account", "code": "mybill" },
{ "value": "Escalate a complaint", "code": "Escalate" },
{ "value": "General inquiries", "code": "somethingelse" }
    ];
    function omnitureCallAliant(oSRG1value) {
        var oSRG = ReturnValue(JSONObjAliant, $('input[name="help-Aliant"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }


    //code for help-allaint- 2-container







    function omnitureCallAliantothers(oSRG1value) {
        var oSRG = oSRG1value;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: 'Contact-us:' + oSRG

            });
        }

    }

    $('input[name="services-aliant-shop"]').on('click', function () {
		var activeID = "help-aliant_" + $('input[name="help-Aliant"]:checked').val() + "_" + "services-aliant-shop_" + $('input[name="services-aliant-shop"]:checked').val();
		hashURL(activeID);
		handleHashServicesAliantShop();
    });

    function handleHashServicesAliantShop() {
        var servicesAliantShop = $('input[name="services-aliant-shop"]:checked').val();
        if (servicesAliantShop == 'AliantBundles') {
            omnitureCallAliantShop('Bundles');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-Bundles').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }

        else if (servicesAliantShop == 'AliantMobility') {
            omnitureCallAliantShop('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-AliantMobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliantShop == 'AliantBellTV') {
            omnitureCallAliantShop('Bell Tv');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-AliantBellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesAliantShop == 'AliantHomephone') {
            omnitureCallAliantShop('Home Phone');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-ShopHomePhone').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliantShop == 'AliantHomeSecurity') {
            omnitureCallAliantShop('Home Security');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-ShopHomeSecurity').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else if (servicesAliantShop == 'AliantBusiness') {
            omnitureCallAliantShop('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-Business').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else if (servicesAliantShop == 'AliantInternet') {
            omnitureCallAliantShop('Internet');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-Shopcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-shope-internet').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();

        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
	}

    function omnitureCallAliantShop(oSRG1value) {
        var oSRG = ReturnValue(JSONObjAliant, $('input[name="help-Aliant"]:checked'));
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    $('input[name="services-aliant"]').on('click', function () {
		var activeID = "help-aliant_" + $('input[name="help-Aliant"]:checked').val() + "_" + "services-aliant_" + $('input[name="services-aliant"]:checked').val();
		hashURL(activeID);
		handleHashServicesAliant();
    });

    function handleHashServicesAliant() {
        var servicesAliant = $('input[name="services-aliant"]:checked').val();
        if (servicesAliant == 'Internet') {
            omnitureCallAliant('Internet');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-Internet').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliant == 'BellTV') {
            omnitureCallAliant('Bell Tv');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-BellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliant == 'Homephone') {
            omnitureCallAliant('Home Phone');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-Homephone').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliant == 'HomeSecurity') {
            omnitureCallAliant('Home Securiey');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-HomeSecurity').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else if (servicesAliant == 'Mobility') {
            omnitureCallAliant('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-Mobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliant == 'AliantBellTV') {
            omnitureCallAliant('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-AliantBellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliant == 'Business') {
            omnitureCallAliant('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-container').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillBusiness').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();

        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
	}
	
    function omnitureCallAliantMybill(oSRG1value) {
        var oSRG = ReturnValue(JSONObjAliant, $('input[name="help-Aliant"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    $('input[name="services-aliant-mybill"]').on('click', function () {
		var activeID = "help-aliant_" + $('input[name="help-Aliant"]:checked').val() + "_" + "services-aliant-mybill_" + $('input[name="services-aliant-mybill"]:checked').val();
		hashURL(activeID);
		handleHashServicesAliantMyBill();		
    });

    function hashURL(activeID) {
        var newHashValue = "";
        var targetIDAliant = "targetIDAliant=";
        var hashValue = window.location.hash;
        if (hashValue.indexOf(targetIDAliant) >= 0) {
            var match = hashValue.split('&');
            for (var a in match) {
                var variable = match[a];
                if (variable.indexOf(targetIDAliant) >= 0) {
                    variable = targetIDAliant + activeID;
                }
                if (isEmpty(newHashValue)) {
                    newHashValue = variable;
                } else {
                    newHashValue = newHashValue + "&" + variable;
                }
            }
        } else {
            if (isEmpty(hashValue)) {
                newHashValue = targetIDAliant + activeID;
            } else {
                newHashValue = hashValue + "&" + targetIDAliant + activeID;
            }
        }
        window.location.hash = newHashValue.replace("#", "");
    };
	
	function isEmpty(value) {
        return (value == null || value.length === 0);
    };

	
    function handleHashServicesAliantMyBill() {
        var servicesAliantMybill = $('input[name="services-aliant-mybill"]:checked').val();
        if (servicesAliantMybill == 'mybillBellTV') {
            omnitureCallAliantMybill('Bell Tv');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillBellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliantMybill == "mybillInternet") {
            omnitureCallAliantMybill('Internet');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillInternet').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }

        else if (servicesAliantMybill == "mybillHomePhone") {
            omnitureCallAliantMybill('Home Phone');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillHomePhone').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesAliantMybill == "mybillHomeSecurity") {
            omnitureCallAliantMybill('Home Security');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillHomeSecurity').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else if (servicesAliantMybill == "mybillBusiness") {
            omnitureCallAliantMybill('Business');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-mybillBusiness').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else if (servicesAliantMybill == 'mybillMobility') {
            omnitureCallAliantMybill('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-aliant-2-MYbillcontainer').toggleClass("rsx-hide contactus-active");
            $('#display-aliant-2-AliantMybillMobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();

        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
	}

    $('input[name="help-Roc"]').on('change', function () {
        var helpRoc = $('input[name="help-Roc"]:checked').val();
        if (helpRoc == 'shop') {
            DeSelect2ndLayerForROC();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();
        }
        else if (helpRoc == 'support') {
            DeSelect2ndLayerForROC();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Support').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpRoc == 'mybill') {
            DeSelect2ndLayerForROC();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Mybill').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpRoc == 'Escalate') {
            DeSelect2ndLayerForROC();
            omnitureCallROCothers('Escalate a complaint');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-escalate').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else if (helpRoc == 'somethingelse') {
            DeSelect2ndLayerForROC();
            omnitureCallROCothers('General inquiries');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-adn-something').toggleClass("rsx-hide contactus-active");
            caretToggleLayer1();

        }
        else {
            DeSelect2ndLayerForROC();
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();



        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('#ROC-start').offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(0).offset().top - 75)
            }, 500);
        }

    });

    function caretToggleLayer1() {

        if ($('#custom-caret').hasClass("rsx-hide")) {
            $('#custom-caret').toggleClass("rsx-hide contactus-show");
        }
        if ($('#custom-caret-blue').hasClass("rsx-hide")) {
            $('#custom-caret-blue').toggleClass("rsx-hide contactus-show");
        }
        if ($('#custom-caret1').hasClass("contactus-show")) {
            $('#custom-caret1').toggleClass("contactus-show rsx-hide");
        }
        if ($('#custom-caret-blue1').hasClass("contactus-show")) {
            $('#custom-caret-blue1').toggleClass("contactus-show rsx-hide");
        }
    }
    function caretToggleLayer2() {

        $('div[id^="custom-caret"]').each(function (i) {
            if ($(this).hasClass("rsx-hide")) {
                $(this).toggleClass("rsx-hide contactus-show");
            }
        });
    }
    function hideCaret() {

        $('div[id^="custom-caret"]').each(function (i) {
            if ($(this).hasClass("contactus-show")) {
                $(this).toggleClass("contactus-show rsx-hide");
            }
        });
    }

    function DeSelect2ndLayerForROC() {
        $('input[name="services-Roc"]').parent().removeClass('rsx-active');
        $('input[name="services-Roc-support"]').parent().removeClass('rsx-active');
        $('input[name="services-Roc-Mybill"]').parent().removeClass('rsx-active');
    }


    function omnitureCallROC(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help-Roc"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    function omnitureCallROCothers(oSRG1value) {
        var oSRG = oSRG1value;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: 'Contact-us:' + oSRG

            });
        }

    }

    $('input[name="services-Roc"]').on('click', function () {
        var servicesRoc = $('input[name="services-Roc"]:checked').val();
        if (servicesRoc == 'BellTV') {
            omnitureCallROC('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-BellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesRoc == 'ShopMobility') {
            omnitureCallROC('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Mobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        } else if (servicesRoc == 'ShopSmart') {
            omnitureCallROC('Smart Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-SmartHome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }

        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();

        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
    });


    function omnitureCallROCSupport(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help-Roc"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    $('input[name="services-Roc-support"]').on('click', function () {
        var servicesrocSupport = $('input[name="services-Roc-support"]:checked').val();
        if (servicesrocSupport == 'BellTV') {
            omnitureCallROCSupport('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Support').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Support-BellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();


        }
        else if (servicesrocSupport == 'BellMobility') {
            omnitureCallROCSupport('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Support').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Support-Mobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        } else if (servicesrocSupport == 'BellSmart') {
            omnitureCallROCSupport('Smart Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Support').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Support-SmartHome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();
        }
        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }
    });


    function omnitureCallROCMybill(oSRG1value) {
        var oSRG = ReturnValue(JSONObj, $('input[name="help-Roc"]:checked'));;
        var oSRG1 = oSRG1value;
        var s_OSRG = "";
        s_OSRG = 'Contact-us:' + oSRG + ':' + oSRG1;
        if (typeof s_oTrackPage != "undefined") {
            s_oTrackPage({
                s_oAPT: "192-0-0",
                s_oSRG: s_OSRG

            });
        }

    }

    $('input[name="services-Roc-Mybill"]').on('click', function () {
        var servicesrocMybill = $('input[name="services-Roc-Mybill"]:checked').val();
        if (servicesrocMybill == 'MybillBellTV') {
            omnitureCallROCMybill('TV');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Mybill').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Mybill-BellTV').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }
        else if (servicesrocMybill == 'MybillMobility') {
            omnitureCallROCMybill('Mobility');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Mybill').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Mybill-Mobility').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        } else if (servicesrocMybill == 'MybillSmart') {
            omnitureCallROCMybill('Smart Home');
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            $('#display-Roc-2-Mybill').toggleClass("rsx-hide contactus-active");
            $('#display-Roc-2-Mybill-SmartHome').toggleClass("rsx-hide contactus-active");
            caretToggleLayer2();

        }


        else {
            $(".margin-top-12-adn").each(function (i) {
                if (!$(this).hasClass("rsx-hide")) {
                    $(this).toggleClass("contactus-active rsx-hide");
                }
            });
            hideCaret();
        }
        if (isMobileDevice == 'false') {
            $(document).scrollTop($('.margin-top-12-adn.contactus-active').eq(0).offset().top);
        }
        else if (isMobileDevice == 'true') {
            $('html, body').animate({
                scrollTop: ($('.margin-top-12-adn.contactus-active').eq(1).offset().top - 75)
            }, 500);
        }

    });



    $(".page-code_prsshpwls-landing").click(function () {
        $('#autocomplete-search-results').children().empty();
    });

    //validation code starts
    $("#login").on("click", function () {
        var username = $("#USER").val().trim();
        var password = $("#PASSWORD").val().trim();
        var retunstatus = true;
        if (username == "" || username == null) {
            $("#USER").addClass("rsx-error");
            $("#usernameerror").show();
            retunstatus = false;
        }
        if (password == "" || password == null) {
            $("#PASSWORD").addClass("rsx-error");
            $("#pwderror").show();

            retunstatus = false;
            // return false;
        }
        if (retunstatus) {
            return true;
        } else {
            return false;
        }

    });
	
	function driveResultsAliant(){
		//Contact-us#targetIDAliant=help-Aliant_services-aliant_Business
		var hashValue = window.location.hash;
		if(!hashValue){
			return;
		}
		hashValue = decodeURI(hashValue);
		var targetIDAliant = "targetIDAliant=";
		if (hashValue.indexOf(targetIDAliant) >= 0) {
			var match = hashValue.split('&');
			var contactHelpGotoID = "";
			var contactHelpGotoValue = "";
			var contactServicesGotoID = "";
			var contactServicesGotoValue = "";
			for (var a in match) {
				var variable = match[a];
				if (variable.indexOf(targetIDAliant) >= 0) {
					var goToIdcontactID = variable.replace(targetIDAliant, "");		
					goToIdcontactID = goToIdcontactID.replace("#", "");
					var goToIdcontactArray = goToIdcontactID.split("_");
					contactHelpGotoID = (goToIdcontactArray[0]||"").trim();
					contactHelpGotoValue=(goToIdcontactArray[1]||"").trim();
					contactServicesGotoID = (goToIdcontactArray[2]||"").trim();
					contactServicesGotoValue = (goToIdcontactArray[3]||"").trim();
					console.log("contactServicesGotoValue: " + contactServicesGotoValue);				
				}
			}
			try{
				$("input[name=" + contactHelpGotoID + " i][value=" + contactHelpGotoValue + " i]").prop('checked', true);
				$("input[name=" + contactServicesGotoID + " i][value=" + contactServicesGotoValue + " i]").prop('checked', true);
			}
			catch (err){
				//for IE
				contactHelpGotoID = mapIDValue("ID1", "", contactHelpGotoID);
				contactHelpGotoValue = mapIDValue("VAL1", "", contactHelpGotoValue);
				contactServicesGotoID = mapIDValue("ID2", "", contactServicesGotoID);
				contactServicesGotoValue = mapIDValue("VAL2", contactHelpGotoValue, contactServicesGotoValue);
				$("input[name=" + contactHelpGotoID + "][value=" + contactHelpGotoValue + "]").prop('checked', true);
				if(contactHelpGotoValue!="somethingelse"){
					$("input[name=" + contactServicesGotoID + "][value=" + contactServicesGotoValue + "]").prop('checked', true);
				}
			}
			handleHashHelpAliant();
			if(contactServicesGotoID){
				switch(contactServicesGotoID.toLowerCase()) {
				  case "services-aliant-shop":
					handleHashServicesAliantShop();
					break;
				  case "services-aliant":
					handleHashServicesAliant();
					break;
				  case "services-aliant-mybill":
					handleHashServicesAliantMyBill();
					break;
				  default:
				}			
			}
		}
	}

	function mapIDValue(category, parentVal, value){
		var result = "";
		switch(category) {
		  case "ID1":
			if(value && value.toLowerCase().trim()=="help-aliant"){
				result = "help-Aliant";
			}
			break;
		  case "VAL1":
			if(value){
				result = value.toLowerCase().trim();
			}
			break;
		  case "ID2":
			if(value){
				result = value.toLowerCase().trim();
			}
			break;
		  case "VAL2":
			//parent val: shop, support, mybill, somethingelse
			if(value){
				var val2Mobility ="Mobility";
				var val2Internet ="Internet";
				var val2HomeSecurity ="HomeSecurity";
				var val2Business ="Business";
				var val2BellTV ="BellTV";
				var val2HomePhone ="Homephone";
				value = value.toLowerCase().trim();
				switch(parentVal) {
					case "shop":
						val2Mobility = "Aliant" + val2Mobility;
						val2Internet = "Aliant" + val2Internet;
						val2HomeSecurity = "Aliant" + val2HomeSecurity;
						val2Business = "Aliant" + val2Business;
						break;
					case "support":
						//Aliant if BellTV, otherwise empty
						val2BellTV = "Aliant" + val2BellTV;
						break;
					case "mybill":
						//mybill
						val2Mobility = "mybill" + val2Mobility;
						val2Internet = "mybill" + val2Internet;
						val2HomeSecurity = "mybill" + val2HomeSecurity;
						val2Business = "mybill" + val2Business;
						val2BellTV = "mybill" + val2BellTV;
						val2HomePhone = "mybill" + val2HomePhone;
						break;
					case "somethingelse":
						break;
					default:
				}
				switch(value) {
					case val2Mobility.toLowerCase().trim():
						result = val2Mobility;
						break;
					case val2Internet.toLowerCase().trim():
						result = val2Internet;
						break;
					case val2HomeSecurity.toLowerCase().trim():
						result = val2HomeSecurity;
						break;
					case val2Business.toLowerCase().trim():
						result = val2Business;
						break;
					case val2BellTV.toLowerCase().trim():
						result = val2BellTV;
						break;
					case val2HomePhone.toLowerCase().trim():
						if(parentVal=="mybill"){
							result = "mybillHomePhone";
						}
						else{
							result = val2HomePhone;
					}
						break;
					default:
				}
			}
			break;
		  default:
		}
		return result;
	}
    //validation code ends

    driveResultsAliant();

    BELL.support.echat.init();
});


//code for radio buttons selection ends

function contactUsCellHeight() {
    var total_listRows = 0;
    $('.contactCellSameHeight').css('height', '')
    $('.contact-details').each(function (i) {
        var group = $(this);
        if (group.is(':visible')) {
            if (total_listRows < group.find('.contactCellSameHeight').length) { total_listRows = group.find('.contactCellSameHeight').length }

            group.find('.contactCellSameHeight').each(function (j) {
                $(this).addClass('list-dynamicIndex' + j)
            });

        }
    });
    for (var i = 0; i < total_listRows; i++) {
        var maxHeight = Math.max.apply(null, $('.list-dynamicIndex' + i).map(function () {
            return $(this).height();
        }).get());
        $('.list-dynamicIndex' + i).css('height', maxHeight + 'px')
        $('.list-dynamicIndex' + i).removeClass('list-dynamicIndex' + i)
    }
}
function contactUsCellHeight_reset() {

    if ($('.container').width() < 1200) {
        if ($('.container').width() < 960) {
            if ($('.container').width() < 520) { // additional check for to match for VD for tablet
                $('.contactCellSameHeight').css('height', '');
            }
            else {
                contactUsCellHeight();
            }
        }
        else {
            contactUsCellHeight();
        }
    }
    else {
        contactUsCellHeight();
    }
}



// code ported over from \LiveContent\Web\Styles\RSX\shop\js\shop-echat.js
// to hide/show Chat live buttons based on agent's availability
var BELL = (function (bell, $) {

    bell.support = bell.support || {};

    bell.support.echat = {
        // Selectors
        eChatBody: ".js-tc-chat-live",
        eChatBodyParent: ".js-tc-container",
        interval: 1000,
        timeout: 60000,

        init: function () {
            var self = this;

            self.hideParentContainers();
            
            $(window).load(function () {
                self.divCheckTCShow();
            });

            $(".js-replace-province").on("click", function (e) {
                try {
                    var $this = $(this);
                    var prov = $(".js-current-province").first().text().trim().toLowerCase();
                    var href = $this.attr("href").replace("prov=nb", "prov=" + prov);
                    $this.attr("href", href);
                } catch (e) {
                    console.error("Error updating province", e);
                }
            });
        },

        divCheckTCShow: function () {
            var self = this;
            $(self.eChatBody).each(function () {
                var $this = $(this);
                var handle = setInterval(function () { self.divCheckShow($this, self.eChatBodyParent, handle); }, self.interval);
                setTimeout(function () { clearInterval(handle); }, self.timeout);
            });
        },

        hideParentContainers: function () {
            var self = this;

            $(self.eChatBody).each(function (index) {
                try {
                    var $this = $(this);
                    console.info("bell.support.echat: hide parent container of " + $this.attr("id"));
                    $this.closest(self.eChatBodyParent).hide();
                } catch (e) {
                    console.error(e);
                }
            });
        },

        divCheckShow: function ($this, parent, handle) {
            try {
                if ($this.contents().length > 0) {
                    var first = $this.contents().first();
                    if (first.length > 0 && first[0].innerText.trim().length > 0) {
                        console.info("bell.support.echat: show parent container of " + $this.attr("id"));
                        $this.closest(parent).show();
                        clearInterval(handle);
                    }
                }
            } catch (e) {
                console.error(e);
            }
        },
    };

    return bell;

})(BELL || {}, jQuery);