/*
 * jQuery selectBox - A cosmetic, styleable replacement for SELECT elements
 *
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
 *
 * v1.2.0
 *
 * https://github.com/marcj/jquery-selectBox 
 */

; (function ($) {
    /////*CRQ371841-WCAG changes start for menu reading order-  Start*/
    $(document).on("keypress", "#main-nav li a", function (event) {
        localStorage.setItem("clickedMainMenuClass", "parentMenu");
        localStorage.setItem("clickedKeyPress", "yes");
    });

    $(document).on("click", "#main-nav li a", function (event) {
        localStorage.setItem("clickedMainMenuClass", "parentMenu");
        localStorage.setItem("clickedKeyPress", "yes");
    });

    $(document).on("click", "#topLinkNavigation li a", function (event) {
        localStorage.setItem("topLinkNavigation", "yes");
    });

    $(document).on("keypress", "#topLinkNavigation li a", function (event) {
        localStorage.setItem("topLinkNavigation", "yes");
    });

    $(document).on("keypress", ".sitePagination li a", function (event) {
        localStorage.setItem("clickedPagination", "yes");
    });
    $(document).on("click", ".sitePagination li a", function (event) {
        localStorage.setItem("clickedPagination", "yes");
    });

    $(document).on("click", "#siteMapNavHolder #siteMapNav a", function (event) {
        localStorage.setItem("topLinkNavigation", "yes");
    });

    $(document).on("keypress", "#siteMapNavHolder #siteMapNav a", function (event) {
        localStorage.setItem("topLinkNavigation", "yes");
    });
    $(window).load(function () {     
//ohhmo change
            
      	$(".ui-autocomplete").each(function(index){
             if($(this).find("li").length === 0)
            	{$(this).attr('aria-hidden', 'true');}
        });
      
        $("#FirstName").css('border', '1px');
        $("#FirstName").css('border-style', 'solid');
        
        $("#LastName").css('border', '1px');
        $("#LastName").css('border-style', 'solid');
        
        $("#Company").css('border', '1px');
        $("#Company").css('border-style', 'solid');
        
        $("#Address").css('border', '1px');
        $("#Address").css('border-style', 'solid');
        
        $("#Email").css('border', '1px');
        $("#Email").css('border-style', 'solid');
        
        $("#City").css('border', '1px');
        $("#City").css('border-style', 'solid');
        
        $("#Phone").css('border', '1px');
        $("#Phone").css('border-style', 'solid');
        
        $("#State").css('border', '1px');
        $("#State").css('border-style', 'solid');
        
        $("#ZipCode").css('border', '1px');
        $("#ZipCode").css('border-style', 'solid');
        
        $("#Fax").css('border', '1px');
        $("#Fax").css('border-style', 'solid');
        
        $("#FindUs").css('border', '1px');
        $("#FindUs").css('border-style', 'solid');
        
        $("#FindUsOther").css('border', '1px');
        $("#FindUsOther").css('border-style', 'solid');
        
        $("#Comments").css('border', '1px');
        $("#Comments").css('border-style', 'solid');

        //ohhmo change - end
   	  /* AMN - 9/24/18 - Display left submenu for Mercy Care */      
		var AZMercysite = $(location).attr('hostname'); 

		if (AZMercysite.indexOf("mercycareaz") != -1) {
		  $('#subNav>nav>ul>li>a[href$="/members/"]').css('display','none');
		  $('#subNav>nav>ul>li>a[href$="/providers"]').css('display','none');
		  $('#subNav>nav>ul>li>a[href$="/members/"]~ul>li').css('display','none');
		  $('#subNav>nav>ul>li>a[href$="/providers"]~ul>li').css('display','none');
		  $('#subNav>nav>ul>li>a[href$="/members/"]~ul>li.active').css('display','block');
		  $('#subNav>nav>ul>li>a[href$="/providers"]~ul>li.active').css('display','block');
		  $('#subNav>nav>ul>li>a[href$="/members/"]~ul>li>ul>li.active').parent().parent().css('display','block');
		  $('#subNav>nav>ul>li>a[href$="/providers"]~ul>li>ul>li.active').parent().parent().css('display','block');  
		}        
	  /* 9/24/18 Ends */  
            
      
        var topLinkNavigation = localStorage.getItem("topLinkNavigation");
        var clickedMainMenuClass = localStorage.getItem("clickedMainMenuClass");
        if (topLinkNavigation != 'yes') {
            if (clickedMainMenuClass != '') {
                var element = $("#main-nav li a.active");
                element.css('outline', 'none !important')
                       .attr("tabindex", 0)
                       .focus();
                localStorage.setItem("clickedMainMenuClass", '');
            }
            else {
                var element = $("#subNav a.active");
                element.css('outline', 'none !important')
                       .attr("tabindex", 0)
                       .focus();
                localStorage.setItem("clickeditem", '');
            }

        }

        localStorage.setItem("topLinkNavigation", '');

        var clickedPagination = localStorage.getItem("clickedPagination");
        if (clickedPagination != '') {
            $('.resultCount').attr('tabindex', '-1').focus();
            localStorage.setItem("clickedPagination", '');
        }

        //Changes for top utility bar
        var utilitylinkBefore = $("#topLinkNavigation div.small").find('li:not(:last)');
        $utilitylinkspan = $("<span aria-hidden='true'>|</span>");
        $utilitylinkspan.css("padding", "0 5px");
        utilitylinkBefore.append($utilitylinkspan);

        $("#subNav ul[role = 'presentation'] .hasChildren[role='menu']").find('a').attr("aria-expanded", "false");
        //$("#subNav ul[role = 'presentation'] .hasChildren").each(function () {
        //    $(this).find("a:first").attr("aria-haspopup", "true");
        //});
        $("#subNav ul[role = 'presentation'] .hasChildren").find("a[class='active']").first().attr("aria-expanded", "true");

        var submenuCount = $("#subNav ul[role = 'presentation'] .hasChildren ul li a").length;

        if (submenuCount >= 1) {
            var subNavCount = 1
            $("#subNav ul[role = 'presentation'] .hasChildren ul li a").each(function () {
                $(this).attr('aria-setsize', submenuCount).attr('aria-posinset', subNavCount);
                subNavCount++;
            });
        }

        $("#subNav li[role = 'menuitem']").removeAttr('role').children('a').attr("role", "menuitem");
        $("#subNav ul[role = 'presentation']").removeAttr('role');
        $("#subNav li a[role = 'menuitem']").each(function () {
            $(this).attr('aria-label', $(this).text()).removeAttr('title');
        });

        //oh hmo changes
        $("#subNav nav ul").each(function () {
            $(this).removeAttr('role');
            $(this).children().removeAttr('role');
            //$("#subNav nav ul li").removeAttrmoveAttr('role');
        });

        $("#main-nav li[role = 'menuitem']").each(function () {
	var text = $(this).text();
            //OhHMO changes
           //$(this).children('a').attr('aria-label', text.replace(':scope {outline:none;}', '')).removeAttr('title').attr('role', 'menuitem')
            $(this).children('a').attr('aria-label', text.replace(':scope {outline:none;}', '')).removeAttr('title');
            //OhHMO changes
            $(this).removeAttr('role');



           // $(this).children('a').attr('aria-label', $(this).text()).removeAttr('title').attr('role', 'menuitem');
           // $(this).removeAttr('role');
        });
        $("#subNav a[role='menuitem']").removeAttr("aria-expanded");
      

        $('#topLinkNavigation nav .functions ul li').find('a').attr('role', 'button');
        //var j = 1;
        //$('#centerContent .articleContent .accordion table').each(function () {
        //    var $table = $("<table id = 'tbl" + j + "'><tr id ='tr" + j + "' ></tr></table>");
        //    var $leftSpan = $("<td valign='top'><ul id = 'ulleft" + j + "'></ul></td>");
        //    var $rightSpan = $("<td valign='top'><ul id = 'ulright" + j + "'></ul></td>");
        //    $(this).parent('div').append($table);
        //    $("#tr" + j + "").append($leftSpan);
        //    $("#tr" + j + "").append($rightSpan);
        //    $(this).find("tr").each(function (index) {
        //        $(this).find("td").each(function (tdindex) {
        //            var firstTdLink = $(this).find('a');
        //            if (firstTdLink.length > 0) {
        //                if (tdindex === 0) {
        //                    $("#ulleft" + j + "").append("<li>" + $(this).html() + "</li>");
        //                }
        //                else if (tdindex === 1) {
        //                    $("#ulright" + j + "").append("<li>" + $(this).html() + "</li>");

        //                }
        //            }
        //            else {
        //                if (tdindex === 0) {
        //                    $("#ulleft" + j + "").append("<h5 aria-level=5 role='heading' align='center'>" + $(this).html() + "</h5>");
        //                }
        //                else if (tdindex === 1) {
        //                    $("#ulright" + j + "").append("<h5 aria-level=5 role='heading' align='center'>" + $(this).html() + "</h5>");

        //                }
        //            }

        //        });

        //    });
        //    $(this).attr("class", "visually-hidden").attr("aria-hidden", "true");
        //    j++;
        //});


        $('#centerContent .articleContent .accordion table ul').each(function () {
            if ($(this).html().length === 0) {
                $(this).parent('td').attr("aria-hidden", "true");
            }
        });

    });

    /////*CRQ371841-WCAG changes start for menu reading order-  end*/

    /////*CRQ371841-WCAG changes start for map-  start*/
    $(window).bind("load", function () {

        $("#map svg").before('<h3 class="header" style="padding-left:0px" aria-level="3" role="heading">Map of Aetna Medicaid Health Plans</h3><title id="UnitedStatesMap">Map of Aetna Medicaid Health Plans</title>')
        .before('<desc id="mapdesc" class="visually-hidden">This map provides links to state-specific plans</desc>')
        .attr({ "role":"group", "aria-labelledby":"UnitedStatesMap" });

        var activeStates = "";
        var activeStatesarray = "";
        $("#planInfo .plans").each(function () {
            $(this).attr('role', 'alertdialog').attr('aria-labelledby', 'mdialog-title');
            $(this).children('h3').attr('id', 'mdialog-title');
            activeStatesarray = $(this).attr('id').split('-');
            activeStates = activeStates + ',' + activeStatesarray[1];
        });
        activeStates = activeStates.substring(1, activeStates.length - 1);
        $("#map svg").each(function () {
            var svg = $(this);
            var state = 0;

            $(svg).find("rect").each(function () {
                $(this).attr("aria-hidden", "true");
            });

            $(svg).find("path").each(function () {
                $(this).attr("aria-hidden", "true");
            });

            $(svg).find("text tspan").each(function () {
                $(this).attr("aria-hidden", "true");
            });

            $(svg).find("text tspan").each(function () {
                var stateID = $(this).attr('id');
                var stateName = $(this).text();
                if (activeStates.indexOf(stateName) != -1) {
                    var planName = $("#state-" + stateName + " h3").text();
                    $(this).removeAttr("aria-hidden");
                    $(this).append("<a class='statenames' href='void' title=" + planName + " id =" + stateName + "  style='cursor:hand' tabindex=0 role='link'>" + planName + "</a>");
                    $(this).children('a').attr("focusable", "true")
                        .focus(function () {
                            $(this).attr("style", 'font-weight:bold;').css('outline-style', 'thin').css('border-color', 'black')
                        });

                    $(this).parent('text')
                    .focus(function () {
                        $(this).attr("style", 'font-weight:bold;').css('outline-style', 'thin')
                    });

                    state++;
                }
            });
            $("#map svg text tspan").each(function () {
                $(this).attr('cursor', 'cursor:hand')
                $(this).children('a').focus(function () {
                    $(this).parent('tspan').animate({ fontSize: '1.5em' }, "slow");
                });

                $(this).children('a').focusout(function () {
                    $(this).parent('tspan').animate({ fontSize: '1em' }, "slow");

                });

                if ($(this).text() === 'DE' || $(this).text() === 'DC' || $(this).text() === 'NH' || $(this).text() === 'RI'
                  || $(this).text() === 'VT' || $(this).text() === 'MA' || $(this).text() === 'CT') {

                    $(this).parent('text').siblings('rect').attr('fill', '#f2f2f2').removeAttr('stroke').attr('stoke', '#f2f2f2').attr('style', 'color:#f2f2f2');
                    $(this).text('');
                }
                if ($(this).children('a').attr('id') === 'NJ' || $(this).children('a').attr('id') === 'MD') {
                    $(this).parent('text').attr('fill', '#f2f2f2');
                   //$(this).parent('text').siblings('rect').attr('fill', '#f2f2f2').removeAttr('stroke').attr('stoke', '#f2f2f2').attr('style', 'color:#f2f2f2');
                   //$(this).text.attr('style', 'color:#f2f2f2');

                }


            });
            $(".statenames").click(function (e) {
                e.preventDefault();
                var stateName = $(this).attr('id');
                if ($("#state-" + stateName).length > 0) {
                    $("#map-overlay").fadeIn(300, function () {
                        $("#state-" + stateName).fadeIn(300, function () {
                            $(".btnCloseMap").fadeIn(20);
                            $("#state-" + stateName).attr('tabindex', '-1');
                            $("#state-" + stateName).children('ul').each(function () {


                                var inputs = $("#state-" + stateName).find('select, input, textarea, button, a,p,div').filter(':visible');
                                var firstInput = inputs.first();
                                var lastInputs = $(".btnCloseMap").find('a');
                                var lastInput = lastInputs.first();
                                /*set focus on first input*/
                                firstInput.focus();

                                /*redirect last tab to first input*/
                                lastInput.on('keydown', function (e) {
                                    if ((e.which === 9 && !e.shiftKey)) {
                                        e.preventDefault();
                                        firstInput.focus();
                                    }
                                });

                                /*redirect first shift+tab to last input*/
                                firstInput.on('keydown', function (e) {
                                    if ((e.which === 9 && e.shiftKey)) {
                                        e.preventDefault();
                                        lastInput.focus();
                                    }
                                });

                            });
                        });
                    });
                }

                return false;
            });


        });

        document.onkeydown = function (evt) {
            evt = evt || window.event;
            if (evt.keyCode == 27) {
                $(".btnCloseMap").click();

            }
        };

    });
    /////*CRQ371841-WCAG changes start for map-  end*/
    /////*CRQ371841-WCAG changes start for header align and  linkbuttons-  start*/
    $(document).ready(function () {
      
        AnchorChanges();
        AlignHeaderTags();
        var logospan = $("#logoSlogan");
        var $logoSpan = "";
        var PlanName = $("#pageTitle .ribbon").text().replace("Welcome to", "");
        var footerPlanName = $('#copyright p').text();
        footerPlanName = footerPlanName.substring(footerPlanName.lastIndexOf('202') + 4, footerPlanName.lastIndexOf(', All'));
        localStorage.setItem("PlanName", footerPlanName.trim());
        /* for aetna title changes
        footerPlanName = footerPlanName.substring(footerPlanName.lastIndexOf('20') + 4, footerPlanName.lastIndexOf(', All'));
        if (PlanName.trim() != "")
        { localStorage.setItem("PlanName", PlanName.trim()); }
        if (localStorage.getItem("PlanName") === "" || localStorage.getItem("PlanName") === null)
        { localStorage.setItem("PlanName", footerPlanName.trim()); } */
        var centerContentHeader = $("#centerContent .articleContent h1").text();

        if (centerContentHeader.trim() === "" || centerContentHeader.trim() === null) {
            centerContentHeader = $("#page-content section div h1").text();
        }

        if (PlanName.trim() != "") {
            $logoSpan = $("<span class='visually-hidden'><h1 role='heading' aria-level=1> " + PlanName.trim() + " - Home</h1></span>");
            document.title = "Home | " + PlanName.trim();
            $("#logoSlogan a img").attr("alt", PlanName.trim() + " Home");

        }
        else {
            if (centerContentHeader.trim() != "") {
                $logoSpan = $("<span class='visually-hidden'><h1 role='heading' aria-level=1>" + localStorage.getItem("PlanName") + " - " + centerContentHeader.trim() + "</h1></span>");

                document.title = centerContentHeader.trim() + " | " + localStorage.getItem("PlanName");
                $('#centerContent').attr('role','main');
            }
            /* FOR NJ TITLE */
            else {
                if (!document.title.includes(localStorage.getItem("PlanName"))) {
                    document.title = document.title + " | " + localStorage.getItem("PlanName");
                }
            }
            $("#logoSlogan a img").attr("alt", localStorage.getItem("PlanName") + " Home");
        }

        logospan.append($logoSpan);
        var element = $("#subNav .active");
        var subselectedspan = "<span class='visually-hidden'>selected</span>";
        element.append(subselectedspan);

        var mainelement = $("#main-nav .active");
        var mainselectedspan = "<span class='visually-hidden'>selected</span>";
        mainelement.append(mainselectedspan);

        var dialogElement = $("#disclaimer");
        dialogElement.parent('div').attr("role", "alertdialog").attr("aria-labelledby", "dialog-title").attr("aria-describedby", "dialog-description");
        var dialogheaderElement = $("#disclaimer h3");
        var dialogdivElement = $("#disclaimer div p");
        dialogElement.removeAttr("role");
        dialogheaderElement.attr("id", "dialog-title").attr('tabindex', '0');
        dialogdivElement.attr("id", "dialog-description");

        var dialogLinkImgElement = $("#disclaimer div a img");
        dialogLinkImgElement.removeAttr("src");
		
        $("#LanguageDropdownList").change(function () {
          var v = $("#LanguageDropdownList option:selected").text();
          var envID = document.getElementById("envID").value;          
          var envPlan = (document.getElementById("envPlan").value == "md-abh") ? "maryland" : (document.getElementById("envPlan").value == "new-jersey") ? "newjersey" : document.getElementById("envPlan").value;                    
          var spanishSubDomain = (document.getElementById("envPlan").value == "new-jersey-hmosnp") ? "newjersey" : (document.getElementById("envPlan").value == "new-jersey") ? "newjersey" : (document.getElementById("envPlan").value == "md-abh") ? "maryland" : (document.getElementById("envPlan").value == "illinois-medicaid") ? "illinois" : document.getElementById("envPlan").value;
          if (envPlan == "mercycareaz") {
                if (v == "English" || v == "Inglés") {
                    location.href = (envID == "QA" || envID == "Dev") ? "https://qawww.mercycareaz.org/find-a-provider" : "https://www.mercycareaz.org/find-a-provider";
                } else if (v == "Español" || v == "Spanish") {
                    location.href = "https://es.search.mercycareaz.org/find-a-provider";
                } else {
                    location.href = " https://ar.search.mercycareaz.org/find-a-provider"
                }
            } else if (envPlan == "newyork") { 
              	if (v == "English" || v == "Inglés" || v == "Angle" || v == "Английский" || v == "英語" || v == "अंग्रेज़ी") {
                    location.href = (envID == "QA" || envID == "Dev") ? "https://qawww.aetnabetterhealth.com/ny/find-provider" : 		"https://www.aetnabetterhealth.com/ny/find-provider";
                } else if (v == "Spanish" || v == "Español" || v == "ИСПАНСКИЙ" || v == "SPANISH" || v == "西班牙語" || v == "स्पैनिश") {
                 location.href = "https://es.newyork.aetnabetterhealth.com/ny/find-provider";                 
                } else if (v == "Russian" || v == "Pусский" || v == "Ruso" || v == "俄語" || v == "रूसी") {                  
                  location.href = "https://ru.newyork.aetnabetterhealth.com/ny/find-provider"; 
                } else if (v == "Chinese" || v == "中文" || v == "Chino"  || v == "Китайский" || v == "चीनी") {                  
                  location.href = "https://ch.newyork.aetnabetterhealth.com/ny/find-provider";                   
                }  else if (v == "Haitian Creole" || v == "Kreyòl ayisyen" || v == "Criollo haitiano" || v == "Гаитянский креольский" || v == "海地克里奧爾語" || v == "हाईटियन क्रियोल") {
                 location.href = "https://fr.newyork.aetnabetterhealth.com/ny/find-provider"; 
                } else if (v == "Hindi" || v == "हिन्दी" || v == "Hindú" || v == "Indi" || v == "Хинди" || v == "印度語") {                  
                 location.href = "https://hi.newyork.aetnabetterhealth.com/ny/find-provider"; 
                }
            } else {
                if (v == "English" || v == "Inglés") {
                    location.href = (envID == "QA" || envID == "Dev") ? "https://qawww.aetnabetterhealth.com/" + envPlan + "/find-provider" : "https://www.aetnabetterhealth.com/" + envPlan + "/find-provider";
                } else {
                 location.href = (envID == "QA" || envID == "Dev") ? (envPlan == "illinois-medicaid") ? "https://es-us-fc8nijck-p.proxy.cqfluency.com/" + envPlan + "/find-provider" : "https://es-us-k9p68lik-p.proxy.cqfluency.com/" + envPlan + "/find-provider" : "https://es." + spanishSubDomain + ".aetnabetterhealth.com/" + envPlan + "/find-provider";
                }
            }
       });
                            
        
        $(".closeDialog").unbind('click').click(function () {
            $("#modalHolder").hide();
            $("#disclaimer .calltoaction a").attr("href", "#");
            $("#disclaimer").removeAttr("tabindex");//CRQ371841-WCAG Changes-added focus
            $("#overlay").removeAttr("tabindex")//CRQ371841-WCAG Changes-added
            $("#skiplink").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
            $("#site").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
            $("#modalHolder").animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
            $("#overlay").fadeOut(300);
            dialogheaderElement.removeAttr("tabindex");
            //return false;
        });

        var topboxHeader = 1;
        $('#topBoxes .boxBg').each(function () {
            $(this).find('.box article').each(function () {
                $(this).find('.header').attr('id', 'topboxHeader' + topboxHeader);
                $(this).find('a').attr('aria-describedby', 'topboxHeader' + topboxHeader);
                topboxHeader++;
            });
        });

        var centerboxHeader = 1;
        $('#centerContent .boxBg').each(function () {
            $(this).find('.box article').each(function () {
                $(this).find('.header').attr('id', 'centerboxHeader' + centerboxHeader);
                $(this).find('a').attr('aria-describedby', 'centerboxHeader' + centerboxHeader);
                centerboxHeader++;

            });
        });
      
      /* AMN 9/18/18 - Added for Mercy Care Starts */      
        var rightBoxHeader = 1;
        $('#rightContent .boxBg').each(function () {
            $(this).find('.box article').each(function () {
                $(this).find('.header').attr('id', 'rightBoxHeader' + rightBoxHeader);
                $(this).find('a').attr('aria-describedby', 'rightBoxHeader' + rightBoxHeader);
                rightBoxHeader++;
            });
        });
      /* 9/18/18 Added for Mercy Care Ends */               
      

        $(this).find('#leftContent .quickLinks a img').attr('alt', ''); //to make Quick links alt=null

        $('#rightContent .boxBg .box .calltoaction').each(function () {
            var readMoreTxt = $(this).find('a').text();
            if (readMoreTxt.indexOf("read more") > -1) {
                $(this).find('a').attr('title', $(this).parent('.newsInfo').find("h3 a").text());
            }
        });

        var closeElement = $('.btnCloseMap');
        $(".btnCloseMap").clone().appendTo("#mapHolder");
        closeElement.remove();

        var menuCount = $('#main-nav li').length;

		//OhHMO changes
       // var cnt = 1;
        //$('#main-nav li').each(function () {
         //   $(this).find('a').attr('aria-setsize', menuCount).attr('aria-posinset', cnt);
         //   cnt++;
       // });
		//OhHMO changes

        //OhHMO changes
        $('#mainNavigation ul').each(function () {
            $(this).removeAttr("role");
        });
        //OhHMO changes

        var pagetitle = $('#pageTitle h3');
        if (pagetitle.text() != "") {
            var skiplinkID = $('#skipMainNavigationDiv')
             $('#page-content section[role="main"]').attr('id', 'mainContainer');
             skiplinkID.attr('href', '#mainContainer');
        }
        else { $('#page-content section').removeAttr('role'); }

        $("#skipMainNavigationDiv").click(function (e) {
            if ($(this).attr('href') === "#mainContainer") {
                $('#mainContainer').focus().attr('tabindex', '-1');
            }
        });
       
        // $('nav[role = "navigation"]').attr('aria-label', 'pagination');
        $('.sitePagination').parent('nav').attr('aria-label', 'pagination');

        $('nav .sitePagination li').each(function () {
            var pageNo = $(this).find('a').text();
            if (pageNo.indexOf('Prev') === -1 && pageNo.indexOf('Next') === -1) {
                $(this).find('a').attr('aria-label', 'Page ' + pageNo);
            }
        });

        $('nav .sitePagination .currentPage a').attr('aria-selected', 'true').append("<span class='visually-hidden'>current page</span>");

    });

    function AlignHeaderTags() {
        var i = 1;
        var texttag = '';
        $(':header').each(function () {
            if (texttag == '' || texttag != $(this).get(0).nodeName) {
                texttag = $(this).get(0).nodeName;
                i++;
            }
            if (i == 6)
            { i = 6; }
            if (!$(this).hasClass('find-a-provider-label') && !$(this).hasClass('few-things-label') && !$(this).hasClass('alternative-provider') && !$(this).hasClass('HeaderFooters') && !$(this).hasClass('ResultFilterOption') && !$(this).hasClass('normal-header') && !$(this).hasClass('header') && !$(this).hasClass('h1Font') && !$(this).hasClass('find-a-provider') && !$(this).hasClass('sokoloff-benjamin') && !$(this).hasClass('prov-detail-header') && !$(this).hasClass('filters-applied') && !$(this).hasClass('RefineSearch') && !$(this).hasClass('directoryInformation') && !$(this).hasClass('alternative-provider-medium') && !$(this).hasClass('bottombar-title')) {
   if(document.getElementById("envPlan") != null) {
   	if(document.getElementById("envPlan").value != "md-abh") {
    	 if ($(this).text().trim() != "") {
                    $(this).attr("role", "heading").attr("aria-level", i);
                }
                else {
                    $(this).attr("role", "heading").attr("aria-level", i).attr('aria-hidden', 'true');
                }
    }
   } else {
   	 if ($(this).text().trim() != "") {
                    $(this).attr("role", "heading").attr("aria-level", i);
                }
                else {
                    $(this).attr("role", "heading").attr("aria-level", i).attr('aria-hidden', 'true');
                }
   }
            }
        }
        );
    }
    // as per new WCAG standards we are making changes to Anchor links.
    function AnchorChanges() {
        $('a[target="_blank"]').each(function () {
            var $pdfSpan = $("<style scoped> :scope {outline:none;}</style> <span class='spaninfo'> PDF Opens In New Window</span>");
            var $excelSpan = $("<style scoped> :scope {outline:none;} </style><span class='spaninfo'> Excel Opens In New Window</span>");
            var $defaultSpan = $("<style scoped> :scope {outline:none;} </style> <span class='spaninfo'> Opens In New Window</span>");
            var href = String($(this).attr("href"));
            var clsNames = String($(this).attr('class'));
            var relNames = String($(this).attr('rel'));
            if (clsNames === "external" || relNames === "external") {
                // $(this).attr('aria-haspopup', 'true');
            }
            else {
                if (href.indexOf(".pdf") > -1) {
                    $(this).append($pdfSpan);
                    $(this).attr('class', 'info');
                }
                else if (href.indexOf(".xsl") > -1) {
                    $(this).append($excelSpan);
                    $(this).attr('class', 'info');
                }
                else {
                    if (href.indexOf("facebook") === -1) {
                     $(this).append($defaultSpan);
                    $(this).attr('class', 'info');
                }
                }
            }
        });

        $("a[href$='.pdf']").each(function () {
            var target = String($(this).attr("target"));
            if (target === 'undefined' || target === null) {
                var pdftext = $(this).text();
                $(this).text(pdftext + " (PDF)");
            }
        });

        $('a').each(function (index, value) {

            if ($(this).html().length === 0) {
                $(this).attr('aria-hidden', 'true');
            }

            var extclsName = String($(this).attr('class'));
            var extrelNames = String($(this).attr('rel'));
            //if (extclsName === "external" || extrelNames === "external") {
            //    $(this).attr('aria-haspopup', 'true');
            //}
            if ($(this).attr('title') === "Go to Apple App Store") {
                $('img', this).attr("alt", "").attr("title", "");
            }

            if ($(this).attr('title') === "google play store") {
                $('img', this).attr("alt", "").attr("title", "");
            }
            var title = String($(this).attr("title"));
            var text = String($(this).text());
            if (title.indexOf("Click here") > -1) {
                var innerTitle = title.replace("Click here", "");
                if (text.indexOf("Click") > -1)
                    $(this).attr('title', innerTitle);
            }


        });

        $('strong').each(function (index, value) {

            if ($(this).html() === "<br>" || $(this).html().length === 0) {
                $(this).attr('aria-hidden', 'true');
            }

        });

        $('#footerLinks li .spacer').each(function (index, value) {

            $(this).closest("li").attr('aria-hidden', 'true');

        });
    }
    /////*CRQ371841-WCAG changes start for header align and  linkbuttons-  end*/


    /////*CRQ371841-WCAG changes start for menu reading order- Commented End*/

    /**
     * SelectBox class.
     *
     * @param {HTMLElement|jQuery} select If it's a jQuery object, we use the first element.
     * @param {Object}             options
     * @constructor
     */
    var SelectBox = this.SelectBox = function (select, options) {
        if (select instanceof jQuery) {
            if (select.length > 0) {
                select = select[0];
            } else {
                return;
            }
        }

        this.typeTimer = null;
        this.typeSearch = '';
        this.isMac = navigator.platform.match(/mac/i);
        options = 'object' === typeof options ? options : {};
        this.selectElement = select;

        // Disable for iOS devices (their native controls are more suitable for a touch device)
        if (!options.mobile && navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i)) {
            return false;
        }

        // Element must be a select control
        if ('select' !== select.tagName.toLowerCase() || 'PlanDropList' == select.id || 'NumPerPage' == select.id || 'Sorting' == select.id || 'DistanceDropList' == select.id || ['LanguageDropdownList', 'PlanDropdownList', 'CountyDropdownList', 'RegionDropdownList','DistanceDropdownList', 'ASAMLevelList'].includes(select.id) || ['providerspeciality','specializedexpertise'].includes(select.name)) { //Add ID to Exclude Select Control
            return false;
        }

        this.init(options);
    }

    /**
     * @type {String}
     */
    SelectBox.prototype.version = '1.2.0';

    /**
     * @param {Object} options
     *
     * @returns {Boolean}
     */
    SelectBox.prototype.init = function (options) {
        var select = $(this.selectElement);
        if (select.data('selectBox-control')) {
            return false;
        }

        var control = $('<a class="selectBox" />')
            , inline = select.attr('multiple') || parseInt(select.attr('size')) > 1
            , settings = options || {}
            , tabIndex = parseInt(select.prop('tabindex')) || 0
            , self = this;

        control
            .width(select.outerWidth())
            .addClass(select.attr('class'))
            .attr('title', select.attr('title') || '')
            .attr('tabindex', tabIndex)
            .css('display', 'inline-block')
            .bind('focus.selectBox', function () {
                if (this !== document.activeElement && document.body !== document.activeElement) {
                    $(document.activeElement).blur();
                }
                if (control.hasClass('selectBox-active')) {
                    return;
                }
                control.addClass('selectBox-active');
                select.trigger('focus');
            })
            .bind('blur.selectBox', function () {
                if (!control.hasClass('selectBox-active')) {
                    return;
                }
                control.removeClass('selectBox-active');
                select.trigger('blur');
            });

        if (!$(window).data('selectBox-bindings')) {
            $(window)
                .data('selectBox-bindings', true)
                .bind('scroll.selectBox', (settings.hideOnWindowScroll) ? this.hideMenus : $.noop)
                .bind('resize.selectBox', this.hideMenus);
        }

        if (select.attr('disabled')) {
            control.addClass('selectBox-disabled');
        }

        // Focus on control when label is clicked
        select.bind('click.selectBox', function (event) {
            control.focus();
            event.preventDefault();
        });

        // Generate control
        if (inline) {
            // Inline controls
            options = this.getOptions('inline');

            control
                .append(options)
                .data('selectBox-options', options).addClass('selectBox-inline selectBox-menuShowing')
                .bind('keydown.selectBox', function (event) {
                    self.handleKeyDown(event);
                })
                .bind('keypress.selectBox', function (event) {
                    self.handleKeyPress(event);
                })
                .bind('mousedown.selectBox', function (event) {
                    if (1 !== event.which) {
                        return;
                    }
                    if ($(event.target).is('A.selectBox-inline')) {
                        event.preventDefault();
                    }
                    if (!control.hasClass('selectBox-focus')) {
                        control.focus();
                    }
                })
                .insertAfter(select);

            // Auto-height based on size attribute
            if (!select[0].style.height) {
                var size = select.attr('size') ? parseInt(select.attr('size')) : 5;
                // Draw a dummy control off-screen, measure, and remove it
                var tmp = control
                    .clone()
                    .removeAttr('id')
                    .css({
                        position: 'absolute',
                        top: '-9999em'
                    })
                    .show()
                    .appendTo('body');
                tmp.find('.selectBox-options').html('<li><a> </a></li>');
                var optionHeight = parseInt(tmp.find('.selectBox-options A:first').html('&nbsp;').outerHeight());
                tmp.remove();
                control.height(optionHeight * size);
            }
            this.disableSelection(control);
        } else {
            // Dropdown controls
            var label = $('<span class="selectBox-label" />'),
                arrow = $('<span class="selectBox-arrow" />');

            // Update label
            label.attr('class', this.getLabelClass()).text(this.getLabelText());
            options = this.getOptions('dropdown');
            options.appendTo('BODY');

            control
                .data('selectBox-options', options)
                .addClass('selectBox-dropdown')
                .append(label)
                .append(arrow)
                .bind('mousedown.selectBox', function (event) {
                    if (1 === event.which) {
                        if (control.hasClass('selectBox-menuShowing')) {
                            self.hideMenus();
                        } else {
                            event.stopPropagation();
                            // Webkit fix to prevent premature selection of options
                            options
                                .data('selectBox-down-at-x', event.screenX)
                                .data('selectBox-down-at-y', event.screenY);
                            self.showMenu();
                        }
                    }
                })
                .bind('keydown.selectBox', function (event) {
                    self.handleKeyDown(event);
                })
                .bind('keypress.selectBox', function (event) {
                    self.handleKeyPress(event);
                })
                .bind('open.selectBox', function (event, triggerData) {
                    if (triggerData && triggerData._selectBox === true) {
                        return;
                    }
                    self.showMenu();
                })
                .bind('close.selectBox', function (event, triggerData) {
                    if (triggerData && triggerData._selectBox === true) {
                        return;
                    }
                    self.hideMenus();
                })
                .insertAfter(select);

            // Set label width
            var labelWidth =
                    control.width()
                  - arrow.outerWidth()
                  - (parseInt(label.css('paddingLeft')) || 0)
                  - (parseInt(label.css('paddingRight')) || 0);

            label.width(labelWidth);
            this.disableSelection(control);
        }
        // Store data for later use and show the control
        select
            .addClass('selectBox')
            .data('selectBox-control', control)
            .data('selectBox-settings', settings)
            .hide();
    };

    /**
     * @param {String} type 'inline'|'dropdown'
     * @returns {jQuery}
     */
    SelectBox.prototype.getOptions = function (type) {
        var options;
        var select = $(this.selectElement);
        var self = this;
        // Private function to handle recursion in the getOptions function.
        var _getOptions = function (select, options) {
            // Loop through the set in order of element children.
            select.children('OPTION, OPTGROUP').each(function () {
                // If the element is an option, add it to the list.
                if ($(this).is('OPTION')) {
                    // Check for a value in the option found.
                    if ($(this).length > 0) {
                        // Create an option form the found element.
                        self.generateOptions($(this), options);
                    } else {
                        // No option information found, so add an empty.
                        options.append('<li> </li>');
                    }
                } else {
                    // If the element is an option group, add the group and call this function on it.
                    var optgroup = $('<li class="selectBox-optgroup" />');
                    optgroup.text($(this).attr('label'));
                    options.append(optgroup);
                    options = _getOptions($(this), options);
                }
            });
            // Return the built strin
            return options;
        };

        switch (type) {
            case 'inline':
                options = $('<ul class="selectBox-options" />');
                options = _getOptions(select, options);
                options
                    .find('A')
                    .bind('mouseover.selectBox', function (event) {
                        self.addHover($(this).parent());
                    })
                    .bind('mouseout.selectBox', function (event) {
                        self.removeHover($(this).parent());
                    })
                    .bind('mousedown.selectBox', function (event) {
                        if (1 !== event.which) {
                            return
                        }
                        event.preventDefault(); // Prevent options from being "dragged"
                        if (!select.selectBox('control').hasClass('selectBox-active')) {
                            select.selectBox('control').focus();
                        }
                    })
                    .bind('mouseup.selectBox', function (event) {
                        if (1 !== event.which) {
                            return;
                        }
                        self.hideMenus();
                        self.selectOption($(this).parent(), event);
                    });

                this.disableSelection(options);
                return options;
            case 'dropdown':
                options = $('<ul class="selectBox-dropdown-menu selectBox-options" />');
                options = _getOptions(select, options);

                options
                    .data('selectBox-select', select)
                    .css('display', 'none')
                    .appendTo('BODY')
                    .find('A')
                    .bind('mousedown.selectBox', function (event) {
                        if (event.which === 1) {
                            event.preventDefault(); // Prevent options from being "dragged"
                            if (event.screenX === options.data('selectBox-down-at-x') &&
                                event.screenY === options.data('selectBox-down-at-y')) {
                                options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
                                self.hideMenus();
                            }
                        }
                    })
                    .bind('mouseup.selectBox', function (event) {
                        if (1 !== event.which) {
                            return;
                        }
                        if (event.screenX === options.data('selectBox-down-at-x') &&
                            event.screenY === options.data('selectBox-down-at-y')) {
                            return;
                        } else {
                            options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
                        }
                        self.selectOption($(this).parent());
                        self.hideMenus();
                    })
                    .bind('mouseover.selectBox', function (event) {
                        self.addHover($(this).parent());
                    })
                    .bind('mouseout.selectBox', function (event) {
                        self.removeHover($(this).parent());
                    });

                // Inherit classes for dropdown menu
                var classes = select.attr('class') || '';
                if ('' !== classes) {
                    classes = classes.split(' ');
                    for (var i in classes) {
                        options.addClass(classes[i] + '-selectBox-dropdown-menu');
                    }
                }
                this.disableSelection(options);
                return options;
        }
    };

    /**
     * Returns the current class of the selected option.
     *
     * @returns {String}
     */
    SelectBox.prototype.getLabelClass = function () {
        var selected = $(this.selectElement).find('OPTION:selected');
        return ('selectBox-label ' + (selected.attr('class') || '')).replace(/\s+$/, '');
    };

    /**
     * Returns the current label of the selected option.
     *
     * @returns {String}
     */
    SelectBox.prototype.getLabelText = function () {
        var selected = $(this.selectElement).find('OPTION:selected');
        return selected.text() || ' ';
    };

    /**
     * Sets the label.
     * This method uses the getLabelClass() and getLabelText() methods.
     */
    SelectBox.prototype.setLabel = function () {
        var select = $(this.selectElement);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        control
            .find('.selectBox-label')
            .attr('class', this.getLabelClass())
            .text(this.getLabelText());
    };

    /**
     * Destroys the SelectBox instance and shows the origin select element.
     *
     */
    SelectBox.prototype.destroy = function () {
        var select = $(this.selectElement);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        var options = control.data('selectBox-options');
        options.remove();
        control.remove();
        select
            .removeClass('selectBox')
            .removeData('selectBox-control')
            .data('selectBox-control', null)
            .removeData('selectBox-settings')
            .data('selectBox-settings', null)
            .show();
    };

    /**
     * Refreshes the option elements.
     */
    SelectBox.prototype.refresh = function () {
      if (('PlanDropList' != this.selectElement.id) || ('DistanceDropList' != this.selectElement.id )) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , type = control.hasClass('selectBox-dropdown') ? 'dropdown' : 'inline'
            , options;

        // Remove old options
        //control.data('selectBox-options').remove();

        // Generate new options
        options = this.getOptions(type);
        control.data('selectBox-options', options);

        switch (type) {
            case 'inline':
                control.append(options);
                break;
            case 'dropdown':
                // Update label
                this.setLabel();
                $("BODY").append(options);
                break;
        }

        // Restore opened dropdown state (original menu was trashed)
        if ('dropdown' === type && control.hasClass('selectBox-menuShowing')) {
            this.showMenu();
        }
      } 
   };

    /**
     * Shows the dropdown menu.
     */
    SelectBox.prototype.showMenu = function () {
        var self = this
            , select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , settings = select.data('selectBox-settings')
            , options = control.data('selectBox-options');

        if (control.hasClass('selectBox-disabled')) {
            return false;
        }

        this.hideMenus();

        // Get top and bottom width of selectBox
        var borderBottomWidth = parseInt(control.css('borderBottomWidth')) || 0;
        var borderTopWidth = parseInt(control.css('borderTopWidth')) || 0;

        // Get proper variables for keeping options in viewport
        var pos = control.offset()
            , topPositionCorrelation = (settings.topPositionCorrelation) ? settings.topPositionCorrelation : 0
            , bottomPositionCorrelation = (settings.bottomPositionCorellation) ? settings.bottomPositionCorellation : 0
            , optionsHeight = options.outerHeight()
            , controlHeight = control.outerHeight()
            , maxHeight = parseInt(options.css('max-height'))
            , scrollPos = $(window).scrollTop()
            , heightToTop = pos.top - scrollPos
            , heightToBottom = $(window).height() - (heightToTop + controlHeight)
            , posTop = (heightToTop > heightToBottom) && (settings.keepInViewport == null ? true : settings.keepInViewport)
            , top = posTop
                  ? pos.top - optionsHeight + borderTopWidth + topPositionCorrelation
                  : pos.top + controlHeight - borderBottomWidth - bottomPositionCorrelation;


        // If the height to top and height to bottom are less than the max-height
        if (heightToTop < maxHeight && heightToBottom < maxHeight) {

            // Set max-height and top
            if (posTop) {
                var maxHeightDiff = maxHeight - (heightToTop - 5);
                options.css({ 'max-height': maxHeight - maxHeightDiff + 'px' });
                top = top + maxHeightDiff;
            } else {
                var maxHeightDiff = maxHeight - (heightToBottom - 5);
                options.css({ 'max-height': maxHeight - maxHeightDiff + 'px' });
            }

        }

        // Save if position is top to options data
        options.data('posTop', posTop);


        // Menu position
        options
            .width(control.innerWidth())
            .css({
                top: top,
                left: control.offset().left
            })
            // Add Top and Bottom class based on position
            .addClass('selectBox-options selectBox-options-' + (posTop ? 'top' : 'bottom'));


        if (select.triggerHandler('beforeopen')) {
            return false;
        }

        var dispatchOpenEvent = function () {
            select.triggerHandler('open', {
                _selectBox: true
            });
        };

        // Show menu
        switch (settings.menuTransition) {
            case 'fade':
                options.fadeIn(settings.menuSpeed, dispatchOpenEvent);
                break;
            case 'slide':
                options.slideDown(settings.menuSpeed, dispatchOpenEvent);
                break;
            default:
                options.show(settings.menuSpeed, dispatchOpenEvent);
                break;
        }

        if (!settings.menuSpeed) {
            dispatchOpenEvent();
        }

        // Center on selected option
        var li = options.find('.selectBox-selected:first');
        this.keepOptionInView(li, true);
        this.addHover(li);
        control.addClass('selectBox-menuShowing selectBox-menuShowing-' + (posTop ? 'top' : 'bottom'));

        $(document).bind('mousedown.selectBox', function (event) {
            if (1 === event.which) {
                if ($(event.target).parents().andSelf().hasClass('selectBox-options')) {
                    return;
                }
                self.hideMenus();
            }
        });
    };

    /**
     * Hides the menu of all instances.
     */
    SelectBox.prototype.hideMenus = function () {
        if ($(".selectBox-dropdown-menu:visible").length === 0) {
            return;
        }

        $(document).unbind('mousedown.selectBox');
        $(".selectBox-dropdown-menu").each(function () {
            var options = $(this)
                , select = options.data('selectBox-select')
                , control = select.data('selectBox-control')
                , settings = select.data('selectBox-settings')
                , posTop = options.data('posTop');

            if (select.triggerHandler('beforeclose')) {
                return false;
            }

            var dispatchCloseEvent = function () {
                select.triggerHandler('close', {
                    _selectBox: true
                });
            };
            if (settings) {
                switch (settings.menuTransition) {
                    case 'fade':
                        options.fadeOut(settings.menuSpeed, dispatchCloseEvent);
                        break;
                    case 'slide':
                        options.slideUp(settings.menuSpeed, dispatchCloseEvent);
                        break;
                    default:
                        options.hide(settings.menuSpeed, dispatchCloseEvent);
                        break;
                }
                if (!settings.menuSpeed) {
                    dispatchCloseEvent();
                }
                control.removeClass('selectBox-menuShowing selectBox-menuShowing-' + (posTop ? 'top' : 'bottom'));
            } else {
                $(this).hide();
                $(this).triggerHandler('close', {
                    _selectBox: true
                });
                $(this).removeClass('selectBox-menuShowing selectBox-menuShowing-' + (posTop ? 'top' : 'bottom'));
            }

            options.css('max-height', '')
            //Remove Top or Bottom class based on position
            options.removeClass('selectBox-options-' + (posTop ? 'top' : 'bottom'));
            options.data('posTop', false);
        });
    };

    /**
     * Selects an option.
     *
     * @param {HTMLElement} li
     * @param {DOMEvent}    event
     * @returns {Boolean}
     */
    SelectBox.prototype.selectOption = function (li, event) {
        var select = $(this.selectElement);
        li = $(li);

        var control = select.data('selectBox-control')
            , settings = select.data('selectBox-settings');

        if (control.hasClass('selectBox-disabled')) {
            return false;
        }

        if (0 === li.length || li.hasClass('selectBox-disabled')) {
            return false;
        }

        if (select.attr('multiple')) {
            // If event.shiftKey is true, this will select all options between li and the last li selected
            if (event.shiftKey && control.data('selectBox-last-selected')) {
                li.toggleClass('selectBox-selected');
                var affectedOptions;
                if (li.index() > control.data('selectBox-last-selected').index()) {
                    affectedOptions = li
                        .siblings()
                        .slice(control.data('selectBox-last-selected').index(), li.index());
                } else {
                    affectedOptions = li
                        .siblings()
                        .slice(li.index(), control.data('selectBox-last-selected').index());
                }
                affectedOptions = affectedOptions.not('.selectBox-optgroup, .selectBox-disabled');
                if (li.hasClass('selectBox-selected')) {
                    affectedOptions.addClass('selectBox-selected');
                } else {
                    affectedOptions.removeClass('selectBox-selected');
                }
            } else if ((this.isMac && event.metaKey) || (!this.isMac && event.ctrlKey)) {
                li.toggleClass('selectBox-selected');
            } else {
                li.siblings().removeClass('selectBox-selected');
                li.addClass('selectBox-selected');
            }
        } else {
            li.siblings().removeClass('selectBox-selected');
            li.addClass('selectBox-selected');
        }

        if (control.hasClass('selectBox-dropdown')) {
            control.find('.selectBox-label').text(li.text());
        }

        // Update original control's value
        var i = 0, selection = [];
        if (select.attr('multiple')) {
            control.find('.selectBox-selected A').each(function () {
                selection[i++] = $(this).attr('rel');
            });
        } else {
            selection = li.find('A').attr('rel');
        }

        // Remember most recently selected item
        control.data('selectBox-last-selected', li);

        // Change callback
        if (select.val() !== selection) {
            select.val(selection);
            this.setLabel();
            select.trigger('change');
        }

        return true;
    };

    /**
     * Adds the hover class.
     *
     * @param {HTMLElement} li
     */
    SelectBox.prototype.addHover = function (li) {
        li = $(li);
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options');

        options.find('.selectBox-hover').removeClass('selectBox-hover');
        li.addClass('selectBox-hover');
    };

    /**
     * Returns the original HTML select element.
     *
     * @returns {HTMLElement}
     */
    SelectBox.prototype.getSelectElement = function () {
        return this.selectElement;
    };

    /**
     * Remove the hover class.
     *
     * @param {HTMLElement} li
     */
    SelectBox.prototype.removeHover = function (li) {
        li = $(li);
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options');

        options.find('.selectBox-hover').removeClass('selectBox-hover');
    };

    /**
     * Checks if the widget is in the view.
     *
     * @param {jQuery}      li
     * @param {Boolean}     center
     */
    SelectBox.prototype.keepOptionInView = function (li, center) {
        if (!li || li.length === 0) {
            return;
        }

        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options')
            , scrollBox = control.hasClass('selectBox-dropdown') ? options : options.parent()
            , top = parseInt(li.offset().top - scrollBox.position().top)
            , bottom = parseInt(top + li.outerHeight());

        if (center) {
            scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() -
                (scrollBox.height() / 2));
        } else {
            if (top < 0) {
                scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop());
            }
            if (bottom > scrollBox.height()) {
                scrollBox.scrollTop((li.offset().top + li.outerHeight()) - scrollBox.offset().top +
                    scrollBox.scrollTop() - scrollBox.height());
            }
        }
    };

    /**
     * Handles the keyDown event.
     * Handles open/close and arrow key functionality
     *
     * @param {DOMEvent}    event
     */
    SelectBox.prototype.handleKeyDown = function (event) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options')
            , settings = select.data('selectBox-settings')
            , totalOptions = 0, i = 0;

        if (control.hasClass('selectBox-disabled')) {
            return;
        }

        switch (event.keyCode) {
            case 8:
                // backspace
                event.preventDefault();
                this.typeSearch = '';
                break;
            case 9:
                // tab
            case 27:
                // esc
                this.hideMenus();
                this.removeHover();
                break;
            case 13:
                // enter
                if (control.hasClass('selectBox-menuShowing')) {
                    this.selectOption(options.find('LI.selectBox-hover:first'), event);
                    if (control.hasClass('selectBox-dropdown')) {
                        this.hideMenus();
                    }
                } else {
                    this.showMenu();
                }
                break;
            case 38:
                // up
            case 37:
                // left
                event.preventDefault();
                if (control.hasClass('selectBox-menuShowing')) {
                    var prev = options.find('.selectBox-hover').prev('LI');
                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
                    i = 0;
                    while (prev.length === 0 || prev.hasClass('selectBox-disabled') ||
                        prev.hasClass('selectBox-optgroup')) {
                        prev = prev.prev('LI');
                        if (prev.length === 0) {
                            if (settings.loopOptions) {
                                prev = options.find('LI:last');
                            } else {
                                prev = options.find('LI:first');
                            }
                        }
                        if (++i >= totalOptions) {
                            break;
                        }
                    }
                    this.addHover(prev);
                    this.selectOption(prev, event);
                    this.keepOptionInView(prev);
                } else {
                    this.showMenu();
                }
                break;
            case 40:
                // down
            case 39:
                // right
                event.preventDefault();
                if (control.hasClass('selectBox-menuShowing')) {
                    var next = options.find('.selectBox-hover').next('LI');
                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
                    i = 0;
                    while (0 === next.length || next.hasClass('selectBox-disabled') ||
                        next.hasClass('selectBox-optgroup')) {
                        next = next.next('LI');
                        if (next.length === 0) {
                            if (settings.loopOptions) {
                                next = options.find('LI:first');
                            } else {
                                next = options.find('LI:last');
                            }
                        }
                        if (++i >= totalOptions) {
                            break;
                        }
                    }
                    this.addHover(next);
                    this.selectOption(next, event);
                    this.keepOptionInView(next);
                } else {
                    this.showMenu();
                }
                break;
        }
    };

    /**
     * Handles the keyPress event.
     * Handles type-to-find functionality
     *
     * @param {DOMEvent}    event
     */
    SelectBox.prototype.handleKeyPress = function (event) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options')
            , self = this;

        if (control.hasClass('selectBox-disabled')) {
            return;
        }

        switch (event.keyCode) {
            case 9:
                // tab
            case 27:
                // esc
            case 13:
                // enter
            case 38:
                // up
            case 37:
                // left
            case 40:
                // down
            case 39:
                // right
                // Don't interfere with the keydown event!
                break;
            default:
                // Type to find
                if (!control.hasClass('selectBox-menuShowing')) {
                    this.showMenu();
                }
                event.preventDefault();
                clearTimeout(this.typeTimer);
                this.typeSearch += String.fromCharCode(event.charCode || event.keyCode);
                options.find('A').each(function () {
                    if ($(this).text().substr(0, self.typeSearch.length).toLowerCase() === self.typeSearch.toLowerCase()) {
                        self.addHover($(this).parent());
                        self.selectOption($(this).parent(), event);
                        self.keepOptionInView($(this).parent());
                        return false;
                    }
                });
                // Clear after a brief pause
                this.typeTimer = setTimeout(function () {
                    self.typeSearch = '';
                }, 1000);
                break;
        }
    };

    /**
     * Enables the selectBox.
     */
    SelectBox.prototype.enable = function () {
        var select = $(this.selectElement);
        select.prop('disabled', false);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }
        control.removeClass('selectBox-disabled');
    };

    /**
     * Disables the selectBox.
     */
    SelectBox.prototype.disable = function () {
        var select = $(this.selectElement);
        select.prop('disabled', true);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }
        control.addClass('selectBox-disabled');
    };

    /**
     * Sets the current value.
     *
     * @param {String}      value
     */
    SelectBox.prototype.setValue = function (value) {
        var select = $(this.selectElement);
        select.val(value);
        value = select.val(); // IE9's select would be null if it was set with a non-exist options value

        if (null === value) { // So check it here and set it with the first option's value if possible
            value = select.children().first().val();
            select.val(value);
        }

        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        var settings = select.data('selectBox-settings')
            , options = control.data('selectBox-options');

        // Update label
        this.setLabel();

        // Update control values
        options.find('.selectBox-selected').removeClass('selectBox-selected');
        options.find('A').each(function () {
            if (typeof (value) === 'object') {
                for (var i = 0; i < value.length; i++) {
                    if ($(this).attr('rel') == value[i]) {
                        $(this).parent().addClass('selectBox-selected');
                    }
                }
            } else {
                if ($(this).attr('rel') == value) {
                    $(this).parent().addClass('selectBox-selected');
                }
            }
        });

        if (settings.change) {
            settings.change.call(select);
        }
    };

    /**
     * Sets the option elements.
     *
     * @param {String|Object} options
     */
    SelectBox.prototype.setOptions = function (options) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control');

        switch (typeof (options)) {
            case 'string':
                select.html(options);
                break;
            case 'object':
                select.html('');
                for (var i in options) {
                    if (options[i] === null) {
                        continue;
                    }
                    if (typeof (options[i]) === 'object') {
                        var optgroup = $('<optgroup label="' + i + '" />');
                        for (var j in options[i]) {
                            optgroup.append('<option value="' + j + '">' + options[i][j] + '</option>');
                        }
                        select.append(optgroup);
                    } else {
                        var option = $('<option value="' + i + '">' + options[i] + '</option>');
                        select.append(option);
                    }
                }
                break;
        }

        if (control) {
            // Refresh the control
            this.refresh();
        }
    };

    /**
     * Disables the selection.
     *
     * @param {*} selector
     */
    SelectBox.prototype.disableSelection = function (selector) {
        $(selector).css('MozUserSelect', 'none').bind('selectstart', function (event) {
            event.preventDefault();
        });
    };

    /**
     * Generates the options.
     *
     * @param {jQuery} self
     * @param {jQuery} options
     */
    SelectBox.prototype.generateOptions = function (self, options) {
        var li = $('<li />'), a = $('<a />');
        li.addClass(self.attr('class'));
        li.data(self.data());
        a.attr('rel', self.val()).text(self.text());
        li.append(a);
        if (self.attr('disabled')) {
            li.addClass('selectBox-disabled');
        }
        if (self.attr('selected')) {
            li.addClass('selectBox-selected');
        }
        options.append(li);
    };

    /**
     * Extends the jQuery.fn object.
     */
    $.extend($.fn, {
        selectBox: function (method, options) {
            var selectBox;

            switch (method) {
                case 'control':
                    return $(this).data('selectBox-control');
                case 'settings':
                    if (!options) {
                        return $(this).data('selectBox-settings');
                    }
                    $(this).each(function () {
                        $(this).data('selectBox-settings', $.extend(true, $(this).data('selectBox-settings'), options));
                    });
                    break;
                case 'options':
                    // Getter
                    if (undefined === options) {
                        return $(this).data('selectBox-control').data('selectBox-options');
                    }
                    // Setter
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.setOptions(options);
                        }
                    });
                    break;
                case 'value':
                    // Empty string is a valid value
                    if (undefined === options) {
                        return $(this).val();
                    }
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.setValue(options);
                        }
                    });
                    break;
                case 'refresh':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.refresh();
                        }
                    });
                    break;
                case 'enable':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.enable(this);
                        }
                    });
                    break;
                case 'disable':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.disable();
                        }
                    });
                    break;
                case 'destroy':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.destroy();
                            $(this).data('selectBox', null);
                        }
                    });
                    break;
                case 'instance':
                    return $(this).data('selectBox');
                default:
                    $(this).each(function (idx, select) {
                        if (!$(select).data('selectBox')) {
                            $(select).data('selectBox', new SelectBox(select, method));
                        }
                    });
                    break;
            }
            return $(this);
        }
    });
})(jQuery);




$.fn.setAllToMaxHeight = function () {
    console.log(this);
    return this.height(Math.max.apply(this, $.map(this, function (e) { return $(e).height(); })));
}

$.fn.equalHeightsNew = function () {
    var currentTallest = 0;
    $(this).each(function (i) {
        if ($(this).innerHeight() > currentTallest) { currentTallest = $(this).innerHeight() }
    });
    $(this).css({ 'height': currentTallest });
    return this;
};


$(function () {
    var ie = (function () {
        var undef,
		v = 3,
        div = document.createElement('div'),
        all = div.getElementsByTagName('i');

        while
		(
			div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
			all[0]
		);

        return v > 4 ? v : undef;
    }());

    $("#centerContent table").removeAttr("width");

    /*******************
	removing selectivizr
	*********************/

   $('select').not("select.pageddl").selectBox({ mobile: true }).change(function () {
        if ($(this).val() != "") {
            $(this).parent().find("span").eq(0).removeClass("field-validation-error").addClass("field-validation-valid");
            $(this).parents(".inputHolder").removeClass("parent-validation-error");
        }
        else {
            var attr = $(this).parent().find('select').attr('data-val-required');
            if (typeof attr !== 'undefined' && attr !== false) {
                $(this).parent().find("span").eq(0).removeClass("field-validation-valid").addClass("field-validation-error");
                $(this).parents(".inputHolder").addClass("parent-validation-error");
            }

        }
        $("span.multiselect-native-select").removeClass("field-validation-valid");
    });


    $(".btnReset").click(function () {
        if (confirm("Do you want to clear the form?")) {

            //$('select').selectBox('value', '');
            //$('select.valZero').selectBox('value', '0');
            $("select").each(function () {
                $(this).val($("option", this).eq(0).val());
            });
            $('select').selectBox('refresh');
            $(".inputHolder").removeClass("parent-validation-error");
            $("select").removeAttr('aria-invalid');
            $("textarea").removeAttr('aria-invalid');
            $("input").removeAttr('aria-invalid');
            $('.field-validation-error').find('span').remove();
        }

    });



    if (ie < 9) {
        try {

            $("body").addClass("lt9-ie");
            $(".sitemap-header ul li:first-child, .sitemap-header > a:first-child, .sitemap-header:first-child, #topLinkNavigation div:first-child").addClass("first-child");
            $(".sitemap-header ul li:last-child, #topLinkNavigation div:last-child").addClass("last-child");
            $("#footerLinks a:last-child, #main-nav li:last-child").addClass("last-child");
            $(".functions li:last-child").addClass("last-child");

            $(".boxBg").each(function (i) {
                if ((i + 1) % parseInt(4, 10) === 0) {
                    $(this).addClass("nth-of-type-4n");
                }
            });

            $(".boxBg:even").addClass("nth-of-type-2n-2");
            if ($(".providerResultsPagination .resultsColumn").length > 0) {
                $(".providerResultsPagination .resultsColumn:nth-child(4n)").addClass("nth-child-4n");
            }
            if ($(".box .button").length > 0) {
                $(".box .button:not(:last-child)").addClass("not-last-child");
            }
            $(".box li.whatsNew:last-child").addClass("last-child");
            try {
                if ($(".table-Data .table-element").length > 0) {
                    $(".table-Data .table-element:nth-child(even)").addClass("even");
                }
                if ($(".table-no-header").length > 0) {
                    $(".table-no-header:nth-child(even)").addClass("even");
                }
                if ($(".table-cell-no-header").length > 0) {
                    $(".table-cell-no-header:nth-child(even)").addClass("even");
                }
                if ($(".table-row").length > 0) {
                    $(".table-row:nth-child(even)").addClass("even");
                }
                if ($(".table-row-cell").length > 0) {
                    $(".table-row-cell:nth-child(even)").addClass("even");
                }
            }
            catch (err) {
            }
            try {
                if ($(".table-Data .table-element").length > 0) {
                    $(".table-Data .table-element:nth-child(odd)").addClass("odd");
                }
                if ($(".table-no-header").length > 0) {
                    $(".table-no-header:nth-child(odd)").addClass("odd");
                }
                if ($(".table-cell-no-header").length > 0) {
                    $(".table-cell-no-header:nth-child(odd)").addClass("odd");
                }
                if ($(".table-row").length > 0) {
                    $(".table-row:nth-child(odd)").addClass("odd");
                }
                if ($(".table-row-cell").length > 0) {
                    $(".table-row-cell:nth-child(odd)").addClass("odd");
                }
            }
            catch (err) {
            }
            if ($(".table-row-cell .td-toplevel").length > 0) {
                $(".table-row-cell .td-toplevel:first-child").addClass("first-child");
            }
            if ($(".table-row-cell .td-toplevel").length > 0) {
                $(".table-row-cell .td-toplevel:last-child").addClass("last-child");
            }
            $("td:empty").addClass("empty");
            $(".providerResultsPagination .resultsColumn select, .formRow input").focus(function () {
                $(this).toggleClass("focus");
            }).blur(function () {
                $(this).toggleClass("focus");
            });
        }
        catch (err) {
        }
    }
    /*******************
	End of Selectivizr
	*********************/



    var marquee = null;

    var pane = $('#provModal .scrollPane');
    pane.jScrollPane({ autoReinitialise: true });
    var api = pane.data('jsp');

    //var api = $('#provModal .scrollPane').jScrollPane().data('jsp');

    $(".active").parent().addClass("active");

    $("a.active").hover(function () {
        $(this).parent().addClass("hover-active");
    }, function () {
        $(this).parent().removeClass("hover-active");
    });

    try {
        $('.back-to-top').fadeOut();
    }
    catch (err) {
    }

    $(".newsInfo").each(function () {
        if ($(this).prev('.newsImage').length < 1) {
            $(this).addClass("NoSibling");
        }
    });


    if ($("#centerContent").next().attr("id") == "leftContent") {
        $("#centerContent").addClass("SiblingLeft");
    }
    else if ($("#centerContent").next().attr("id") == "rightContent") {
        $("#centerContent").removeClass("SiblingLeft").addClass("SiblingRight");
    }
    else if ($("#centerContent").next().attr("id") === undefined) {
        $("#centerContent").removeClass("SiblingLeft,SiblingRight").addClass("NoSibling");
    }

    /* input placeholder */

    if (!Modernizr.input.placeholder) {
        $('[placeholder]').focus(function () {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
            }
        }).blur(function () {
            var input = $(this);
            if (input.val() == '' || input.val() == input.attr('placeholder')) {
                input.addClass('placeholder');
                input.val(input.attr('placeholder'));
            }
        }).blur();
        $('[placeholder]').parents('form').submit(function () {
            $(this).find('[placeholder]').each(function () {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            })
        })
    }

    $('a[rel="external"],.external').unbind('click').click(function (e) {
        if ($.trim($("#modalHolder").html()) != '') {
            var element = $(this).parent();
            e.preventDefault();
            var url = $(this).attr("href");
            $("#disclaimer .calltoaction a").attr("href", url);
            $("#overlay").fadeIn(300);
            $("#modalHolder").show();
            $("#modalHolder").attr('tabindex', '-1');
            $("#modalHolder").animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
            $("#disclaimer").attr("tabindex", 0);//CRQ371841-WCAG Changes-added
            $("#overlay").attr("tabindex", -1);//CRQ371841-WCAG Changes-added
            $("#skiplink").attr("tabindex", -1).attr('aria-hidden', 'true');//CRQ371841-WCAG Changes-added
            $("#site").attr("tabindex", -1).attr('aria-hidden', 'true');//CRQ371841-WCAG Changes-added
            $("#disclaimer .calltoaction a").attr('tabindex', '0').focus(); //CRQ371841-WCAG Changes-added focus
            //$("#dialog-title").focus(function () {
            //    $("#dialog-title").attr('style', 'outline-style:thin;border-color:black');
            //});
            //$("#disclaimer").removeAttr('tabindex').attr('role','document');
            $("#disclaimer .calltoaction a").attr("role", "button").attr("aria-label", "continue");
            $("#disclaimer .calltoaction a").unbind('click').click(function () {
                $("#modalHolder").animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
                $("#modalHolder").hide();
                $("#overlay").fadeOut(300);
                var newWindow = window.open(url);
                newWindow.focus();
                return false;
            });
            var inputs = $("#modalHolder").find('select, input, textarea, button, a,p,div').filter(':visible');
            var firstInput = inputs.first();
            var lastInput = inputs.last();
            /*set focus on first input*/
            //firstInput.focus();

            $('#disclaimer .calltoaction a').each(function () {
                var href = String($(this).attr("href"));
                var $defaultSpan = $("<span class='visually-hidden'>External site Opens in new window</span>");
                var $pdfSpan = $("<span class='visually-hidden'>Pdf opens in new window</span>");
                if (href.indexOf(".pdf") > -1) {
                    $(this).append($pdfSpan);
                }
                else { $(this).append($defaultSpan); }


            });

            /*redirect last tab to first input*/
            lastInput.on('keydown', function (e) {
                if ((e.which === 9 && !e.shiftKey)) {
                    e.preventDefault();
                    firstInput.focus();
                }
            });

            /*redirect first shift+tab to last input*/
            firstInput.on('keydown', function (e) {
                if ((e.which === 9 && e.shiftKey)) {
                    e.preventDefault();
                    lastInput.focus();
                }
            });
            var dialogheaderElement = $("#disclaimer h3");
            $(".closeDialog").unbind('click').click(function () {
                $("#modalHolder").hide();
                $("#disclaimer .calltoaction a").attr("href", "#");
                $("#disclaimer").removeAttr("tabindex");//CRQ371841-WCAG Changes-added focus
                $("#overlay").removeAttr("tabindex");//CRQ371841-WCAG Changes-added
                $("#skiplink").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
                $("#site").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
                $("#modalHolder").animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
                $("#overlay").fadeOut(300);
                dialogheaderElement.removeAttr("tabindex");
                element.css('outline', 'none !important')
                  .attr("tabindex", -1)
                  .focus();
                //return false;
            });
            //CRQ371841-WCAG Changes start
            $("#modalHolder").unbind('keypress').keypress(function (evnt) {
                if (evnt.which == 27) {
                    $("#modalHolder").hide();
                    $("#overlay").fadeOut(300);
                    return false;
                }
            });
            //$(".closeDialog").unbind('focusout').focusout(function () {
            //    $("#disclaimer").focus();
            //    return false;
            //});

            document.onkeydown = function (evt) {
                evt = evt || window.event;
                if (evt.keyCode == 27) {
                    $("#disclaimer .calltoaction a").attr("href", "#");
                    $("#disclaimer").removeAttr("tabindex");//CRQ371841-WCAG Changes-added focus
                    $("#overlay").removeAttr("tabindex");//CRQ371841-WCAG Changes-added
                    $("#skiplink").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
                    $("#site").removeAttr("tabindex").removeAttr('aria-hidden');//CRQ371841-WCAG Changes-added
                    $("#modalHolder").animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
                    $("#modalHolder").hide();
                    $("#overlay").fadeOut(300);
                    dialogheaderElement.removeAttr("tabindex");
                    element.css('outline', 'none !important')
                  .attr("tabindex", 0)
                  .focus();
                    return false;
                }
            };

            //CRQ371841-WCAG Changes end       
        }
    });



    /* Popup for provider details */

    $(".detailsView a").click(function (e) {
        e.preventDefault();
        var text = $(this).parents(".providerresult").find(".providerDetailsInfo").html();
        $("#overlay").fadeIn(300);
        api.getContentPane().html(text);
        $("#provDetailsHolder").show();
        $("#provDetailsHolder #provModal").append('<p class="closeModalInfo"><a href="javascript: void(0);" title="close modal" role="button">Close Modal</a></p>');
        setModalPositionDetails();
        var containerHeight = $("#provDetailsHolder").innerHeight();
        var windowHeight = window.innerHeight;

        $("#provDetailsHolder").animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
        api.reinitialise();
        if ($("#provModal .providerDetailsPop .providerServiceLocations").length > 1) {
            $("#provModal .providerDetailsPop .providerServiceLocations").equalHeightsNew();
        }
        if (parseInt(containerHeight + 120) > windowHeight) {
            $("html, body").animate({ scrollTop: 0 }, "slow");
        }

        return false;
    });

    $(".print").click(function () {
        window.print();
    });

    $('.icon-search').click(function () {
        $('#SearchForm').submit();
    });

    /* Start slider */
    function startSlider() {
        $("#pageSlider").flexslider
        ({
            controlsContainer: "#pageSliderNav",
            animation: "slide",
            selector: "#sliderContainer > .figure",
            directionNav: false,
            pauseOnAction: false,
            pauseOnHover: false,
            useCSS: false,
            touch: false,
            start: function (slider) {
                setsliderInfoHeight(slider);
                $('.flex-play').click(function () {
                		//OHHMOChanges
                        $('#pageSlider #pageSliderNav .flex-pauseplay a').append('<img  alt="Pause Carousel" src="../../images/siteFiles/pennsylvania/bgSliderNav.png" >');
                        //OHHMOChanges
                    slider.play();
                });
                $('.flex-pause').click(function () {
                                       //OHHMOChanges
                        if ($(this).attr('class') == "flex-play") {
                            $('#pageSlider #pageSliderNav .flex-pauseplay a').append('<img  alt="Play Carousel" src="../../images/siteFiles/pennsylvania/bgSliderNav.png" >');
                        }
                        else if ($(this).attr('class') == "flex-pause") {
                            $('#pageSlider #pageSliderNav .flex-pauseplay a').append('<img  alt="Pause Carousel" src="../../images/siteFiles/pennsylvania/bgSliderNav.png" >');
                         }
                         //OHHMOChanges
                    slider.pausePlay();
                });
                $('.flex-control-paging a[role = "button"]').click(function () {
                    $('#sliderContainer li[aria-hidden = "true"] .sliderInfo').removeAttr('tabindex');
                    $('.flex-active-slide .sliderInfo').attr('tabindex', '-1').focus();
                });

            },
            mousewheel: false,
            pausePlay: true,
            pauseText: 'Pause Carousel',
            playText: 'Play Carousel'
        });

        $(".flex-control-paging").insertAfter('.flex-pauseplay');//Today
        $("#pageSliderNav").insertAfter('.flex-viewport');//Today

        var slider = 1;
        $('#pageSlider #pageSliderNav .flex-control-paging li').each(function () {
            // $(this).attr("tabindex", "0");
            $(this).find('a').text('Slide ' + slider);
            slider++;
        });
        //OHHMOChanges
        var slider1 = 1;
        $('#pageSlider #pageSliderNav .flex-pauseplay').each(function () {
            // $(this).attr("tabindex", "0");
            $(this).find('a').append('<img  alt="Pause Carousel" src="../../images/siteFiles/pennsylvania/bgSliderNav.png" >');

            slider1++;
        });       
        //OHHMOChanges

        var carCount = 1;
        $('#sliderContainer').attr('role', 'presentation');
        $('#sliderContainer li.figure').each(function (index) {
            if ($(this).attr('class') != 'figure clone') {
                $(this).attr('role', 'presentation');
                $(this).find('h3').before('<span class = "visually-hidden">Slide ' + carCount + "</span>");
                carCount++;
            }
            //$(this).find('h3').attr("id", "Carli" + carCount);
            // $(this).find('.figCaption').attr("aria-labelledby", "Carli" + carCount);
        });
        carCount = carCount - 1;
        $('#pageSlider').prepend('<span class = "visually-hidden">Carousel with ' + carCount + " slides</span>").attr('role', "complementary").attr('aria-label', "Carousel");

    }




    function createMarquee() {
        if (marquee != null) {
            marquee.trigger('update');
        }
        else {
            marquee = $(".marquee").marquee();
        }
    }

    $("#emergencyMessage a").click(function () {
        if (marquee != null) {
            if ($(this).hasClass("marqueePlay")) {
                $(this).toggleClass("marqueePlay");
                $(this).attr("title", "Pause Message");
                marquee.trigger('start');
            }
            else {
                $(this).toggleClass("marqueePlay");
                $(this).attr("title", "Play Message");
                marquee.trigger('stop');
            }
        }
    });

    function setsliderInfoHeight(item) {
        var maxHeight = 0;
        $(".sliderInfo").css("height", "");

        if (menu.children("li").css("display") == "table-cell") {
            $(".sliderInfo").css("height", "");
        }
        else {
            $(".sliderInfo").each(function () {
                if ($(this).innerHeight() > maxHeight) { maxHeight = $(this).innerHeight(); }
            });

            $(".sliderInfo").css("height", parseInt(maxHeight + 30));
        }
    }

    /*Add Ellipses to marquee content*/
    function dotify() {

        if ($("#sliderContainer .figCaption").length > 0) {
            try {
                $("#sliderContainer .figCaption").dotdotdot({
                    /*	The HTML to add as ellipsis. */
                    ellipsis: "...",
                    /*	How to cut off the text/html: 'word'/'letter'/'children' */
                    wrap: "word",
                    /*	jQuery-selector for the element to keep and put after the ellipsis. */
                    after: null,
                    /*	Whether to update the ellipsis: true/'window' */
                    watch: true,
                    /*	Optionally set a max-height, if null, the height will be measured. */
                    height: 80,
                    /*	Deviation for the height-option. */
                    tolerance: 0,
                    /* Callback function that is fired after the ellipsis is added,
                    receives two parameters: isTruncated(boolean), orgContent(string). */
                    callback: function (isTruncated, orgContent) { },
                    lastCharacter:
                    {
                        /*	Remove these characters from the end of the truncated text. */
                        remove: [' ', ',', ';', '.', '!', '?'],
                        /*	Don't add an ellipsis if this array contains 
                        the last character of the truncated text. */
                        noEllipsis: []
                    }
                });
            }
            catch (err) { }
        }
    }

    $(window).load(function () {
        if ($.isFunction($.fn.flexslider)) {
            startSlider();
        }
    });

    if ($.isFunction($.fn.marquee)) {
        createMarquee();
    }

    /* site menu toggle */
    var isShowing = false;
    var toggler = $('#nav-toggle');
    var menu = $('#mainNavigation #main-nav');
    var menuHeight = menu.height();
    var footerToggler = $('.toggle-menu-expand');
    var siteMapNavHolder = $("#siteMapNavHolder");
    //Commented for Wcag Start
    var footerMenu = $("#siteMapNavHolder #siteMapNav li");
    var hiddenFooterMenu = $("#siteMapNavHolder #siteMapNav li").not(".sitemap-header");
    //End
    // var footerMenu = $("#siteMapNavHolder #siteMapNav div");
    var footerMenuContent = $("#siteMapNavHolder #siteMapNav ul ul li");//Modified for Footer collapse
    //  var hiddenFooterMenu = $("#siteMapNavHolder #siteMapNav div ul li").not(".sitemap-header");//Modified for Footer collapse
    toggler.attr("aria-expanded", "false").attr('role', 'button');
    footerToggler.attr("aria-expanded", "false").attr('role', 'button').attr('aria-label', 'sitemapnavigation');;
    $(toggler).click(function (e) {
        //menu.slideToggle();
        if (menu.is(':visible') == false) {
            menu.slideDown('500');
            //  menu.attr("aria-expanded", "true");//Added for wcag menu aria expanded
            toggler.attr("aria-expanded", "true");//Added for wcag menu aria expanded
        }
        else {
            menu.slideUp('500');
            //menu.attr("aria-expanded", "false");//Added for wcag menu aria expanded
            toggler.attr("aria-expanded", "false");//Added for wcag menu aria expanded
        }
        return false;
    });

    $(siteMapNavHolder).on('click', function () {
        if (hiddenFooterMenu.is(':visible') == true) {
            footerMenu.slideDown('500', function () {
                $(footerToggler).text("[-]").attr("aria-expanded", "true");
            });
        }
        else {
            if ($("#topLinks").css("width") == $("#logoSlogan").css("width")) {
                footerMenu.slideUp('500', function () {
                    $(footerToggler).text("[+]").attr("aria-expanded", "false");
                });
            }
            else {
                hiddenFooterMenu.slideUp('500', function () {
                    $(footerToggler).text("[+]").attr("aria-expanded", "false");
                });
            }
        }
    });

    $(footerToggler).on('click', function () {
        if (hiddenFooterMenu.is(':visible') == false) {
            footerMenu.slideDown('500', function () {
                $(footerToggler).text("[-]").attr("aria-expanded", "true");;
                footerMenuContent.css("display", "list-item");////Added for Footer collapse
            });
        }
        else {
            if ($("#topLinks").css("width") == $("#logoSlogan").css("width")) {
                footerMenu.slideUp('500', function () {
                    $(footerToggler).text("[+]").attr("aria-expanded", "false");
                });
            }
            else {
                hiddenFooterMenu.slideUp('500', function () {
                    $(footerToggler).text("[+]").attr("aria-expanded", "false");
                });
            }
        }
        return false;
    });



    function SetInputWidth() {
        $("#mainNavigation #main-nav li").last().removeAttr("style");
        //$windowWidth = parseInt($(window).width() / parseFloat($("body").css("font-size")));
        var containerWidth = $("#mainNavigation").innerWidth();
        var totalWidth = 0;
        $("#mainNavigation #main-nav li").not("li:last").each(function () {
            totalWidth += $(this).outerWidth();
        });

        var calcWidth = (Math.floor(containerWidth - totalWidth)) - 1;


        if (menu.children("li").css("display") == "table-cell") {
            $("#mainNavigation #main-nav li").last().css("width", calcWidth);
            if ($.isFunction(dotify())) {
                dotify();
            }
        }
        else {
            $("#mainNavigation #main-nav li").last().removeAttr("style");
            $("#sliderContainer .figCaption").trigger("destroy");
        }
    }

    function setMaxHeight() {
        $windowWidth = parseInt($(window).width() / parseFloat($("body").css("font-size")));
        $(".boxBg").css("height", "");
        $(".columnContainer").each(function () {
            equalHeight($(this));
        });
        equalHeight($("#centerContent .articleContent"));
    }

    function equalHeight(obj) {
        var heightArray = obj.find("div.boxBg").map(function () {
            return $(this).height();
        }).get();
        var maxHeight = Math.max.apply(Math, heightArray);
        obj.find("div.boxBg").height(parseInt(maxHeight + 42));
    }

    setMaxHeight();
    $(window).load(function () {
        SetInputWidth();
    });

    setTableCellHeight();

    function setTableCellHeight() {
        $('.table').each(function () {
            equalizeTableElementHeight(this);
        });
    }

    function equalizeTableElementHeight($table) {
        if ($(".table-cell").length > 0) {
            var $tableCells = $('.table-cell', $table);
            var $tableElements = $('.table-element', $tableCells);
            $tableElements.removeAttr("style");
            $(".table-header", $tableCells).removeAttr("style");
            if ($(".table").css("display") == "table") {
                $(".table-header", $tableCells).setAllToMaxHeight();
                $tableElements.each(function (i) {
                    $('.table-element:eq(' + i + ')', $tableCells).setAllToMaxHeight();
                });
            }
        }
        else {
            var $tableCells = $('.table-cell', $table);
            var $tableElements = $('.table-element', $tableCells);

            $(".table-header", $tableCells).css("height", "");
            $tableElements.css("height", "");
            $(".table-element", ".table-Data").each(function () {
                if ($(this).children().length == 0 || $(this).html() == '') {
                    $(this).hide();
                }
            });
        }
        if ($(".table-cell-no-header").length > 0) {
            $(".table-cell-wrapper").removeAttr("style");
            if ($(".table").css("display") == "table") {
                $(".table-cell-wrapper", ".table-no-header").each(function (i) {
                    $(".table-cell-wrapper", ".table-no-header:eq(" + i + ")").setAllToMaxHeight();
                });
            }
            else {
                $(".table-cell-wrapper").css("height", "");
                $(".table-cell-wrapper", ".table-cell-no-header").each(function () {
                    if ($(this).children().length == 0 || $(this).html() == '') {
                        $(this).hide();
                    }
                });
            }
        }
    }


    var moreInfoHolder = $('<div/>', { id: 'moreInfoHolder' });

    $(window).resize(function () {
        isShowing = false;
        $(footerToggler).text("[+]");
        footerMenu.css("display", "");
        if (!$("#SearchTerm").is(":focus") || menu.children("li").css("display") == "table-cell") {
            menu.css("display", "");
        }
        SetInputWidth();
        setsliderInfoHeight();
        setMaxHeight();
        setTableCellHeight();
        if ($.isFunction($.fn.marquee)) {
            createMarquee();
        }
        if (moreInfoHolder.length > 0 && moreInfoHolder.css("display") == "block") {
            setModalPosition();
        }
        if ($("#provDetailsHolder").length > 0 && $("#provDetailsHolder").css("display") == "block") {
            setModalPositionDetails();
        }
    });

    $('body').jqTextResize({ 'smallerButton': '.functions li:first', 'largerButton': '.functions li:last' });

    window.onload = function () {
        $(".accordion").accordion({ collapsible: true, active: false, heightStyle: "content" });
        $('.accordion').prepend("<span class='visually-hidden'>This is an accordion control.The folowings tab will be activated by enter or space bar.</span>");
        //$('.accordion .ui-accordion-header').attr('tabindex', 0);
        ////add plus icon to the accordin
        $('.accordion').find('div.header.bold').append("<span class='plus' aria-hidden='true'></span>");
        $('.accordion').find('div.header.bold').each(function (index) {
            $(this).attr('id', index).attr('role', 'heading').attr('aria-level', 4);
        });

        //$('.accordion').find('dd.accordion-content').attr('role', 'tabpanel').attr('aria-hidden', 'true');
        //var accdtCount = 1;
        //$('.accordion').each(function (index) {
        //    $(this).find('dt.accordion-header').each(function (index) {
        //        $(this).attr('aria-controls', "accDt" + accdtCount);
        //        $(this).next('dd').attr('id', "accDt" + accdtCount);
        //        accdtCount++;
        //    });
        //});

        //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
        $('.accordion-header').click(function () {
            var id = $(this).find('.header').attr('id');
            var iconPlusExists = $('#' + id).find('span.plus').length > 0 ? true : false;
            $(".accordion .accordion-header").find('div.header.bold').find('span').remove();
            $(".accordion .accordion-header").find('div.header.bold').append("<span class='plus' aria-hidden='true'></span>");
            $('.accordion-header').removeClass('active').attr('aria-expanded', 'false');
            $('.accordion-content').not(':animated').hide();
            if (iconPlusExists == false) {

                $('#' + id).find('span').remove();
                $('#' + id).first().append("<span class='plus' aria-hidden='true'></span>");
                $('#' + id).parent('.accordion-header').removeClass('active');
            }
            else if (iconPlusExists == true) {
                $('#' + id).find('span').remove();
                $('#' + id).append("<span class='minus' aria-hidden='true'></span>");
                $('#' + id).parent('.accordion-header').addClass('active').attr('aria-expanded', 'true');
                // $(this).next('dd').attr('tabindex', '0');
                $(this).next('dd').find('.paragraph p a').attr('title', '');
                $(this).next('dd').attr('style', 'display:block;');
            }
        });

        ////CRQ371841-WCAG - ACCORDION BUTTON ACTION (ON Enter key stroke DO THE FOLLOWING)
        $('.accordion-header').on('keyup', function (event) {
            if (event.which == 13 || event.which == 32) {
                var id = $(this).find('.header').attr('id');
                var iconPlusExists = $('#' + id).find('span.plus').length > 0 ? true : false;
                $(".accordion .accordion-header").find('div.header.bold').find('span').remove();
                $(".accordion .accordion-header").find('div.header.bold').append("<span class='plus' aria-hidden='true'></span>");
                $('.accordion-header').removeClass('active').attr('aria-expanded', 'false');;
                $('.accordion-content').not(':animated').hide();
                if (iconPlusExists == false) {

                    $('#' + id).find('span').remove();
                    $('#' + id).first().append("<span class='plus' aria-hidden='true'></span>");
                    $(this).removeClass('active');
                }
                else if (iconPlusExists == true) {

                    $('#' + id).find('span').remove();
                    $('#' + id).append("<span class='minus' aria-hidden='true'></span>");
                    $(this).addClass('active').attr('aria-expanded', 'true');;
                    $(this).next('dd').find('.paragraph p a').attr('title', '');
                    $(this).next('dd').attr('style', 'display:block;');
                }

            }
        });

        $('.accordion-header').hover(function () {
            $(this).toggleClass("hover");
        }, function () {
            $(this).toggleClass("hover");
        });

    };


    $(".moreInfo").click(function () {
        moreinfoParent = $(this);//WCAG-OH
        var fullHref = $(this).attr("href");
        var href = fullHref.split("#");
        if (href.length > 1) {
            var moreInfo = $('<div/>', { id: 'moreInfo' });
            moreInfoHolder.append(moreInfo);
            moreInfoHolder.css("top", "-600");
            moreInfoHolder.attr({"role":"alertdialog"}); //WCAG-OH
            $("#moreInfoContainer").append(moreInfoHolder);
            moreInfo.load(href[0] + " #" + href[1], function (responseText, textStatus, XMLHttpRequest) {
                if (textStatus == 'error') {
                    $(this).html('<p>There was an error making the AJAX request</p>');
                }
                else {
                    $("#overlay").fadeIn(300);
                    moreInfoHolder.show();
                    moreInfo.attr("tabindex", "-1").focus();//WCAG-OH
                    moreInfo.append('<p class="closeModalInfo"><a tabindex="0" href="javascript: void(0);" title="close modal" role="button">Close Modal</a></p>');
                    setModalPosition();
                    var containerHeight = $("#moreInfoHolder").innerHeight();
                    var windowHeight = window.innerHeight;
                    moreInfoHolder.animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
                    if (parseInt(containerHeight + 120) > windowHeight) {
                        $("html, body").animate({ scrollTop: 0 }, "slow");
                    }

                    var inputs = $("#moreInfoHolder").find('select, input, textarea, button, a,p,div').filter(':visible');
                    var firstInput = inputs.first();
                    var lastInput = inputs.last();

                    /*redirect last tab to first input*/
                    lastInput.on('keydown', function (e) {
                        if ((e.which === 9 && !e.shiftKey)) {
                            e.preventDefault();
                            firstInput.focus();
                        }
                    });

                    /*redirect first shift+tab to last input*/
                    firstInput.on('keydown', function (e) {
                        if ((e.which === 9 && e.shiftKey)) {
                            e.preventDefault();
                            lastInput.focus();
                        }
                    });

                }
            });
        }
        return false;
    });


    /*$(".popup-mmic").click(function(e)
	{
        e.preventDefault();
		var url = $(this).attr("href");
		$("#overlay").fadeIn(300);
		var moreInfo = $('<div/>', { id: 'moreInfo' });
		moreInfoHolder.append(moreInfo);
		moreInfoHolder.css("top", "-600");
        $("#moreInfoContainer").append(moreInfoHolder);
		var html = '<h3 class="header">Notice</h3>';
		html += '<div class="paragraph">If you are looking for a medical provider, please contact your medical health plan</div>';
		html += '<p class="calltoaction ribbon ribbon-right-main" role="button"><a title="Continue" href="' + url + '">Continue</a></p>';
		html += '<p class="closeModalInfo"><a href="javascript: void(0);" title="close modal" role="button">Close Modal</a></p>';
		moreInfo.html(html);
		$("#moreInfoHolder").show();
		setModalPosition();
		var containerHeight = $("#moreInfoHolder").innerHeight();
		var windowHeight = window.innerHeight;
		moreInfoHolder.animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
		if (parseInt(containerHeight + 120) > windowHeight) 
		{
			$("html, body").animate({ scrollTop: 0 }, "slow");
		}
		return false;
	});
	
	$(".popup-mma").click(function(e)
	{
        e.preventDefault();
		var url = $(this).attr("href");
		$("#overlay").fadeIn(300);
		var moreInfo = $('<div/>', { id: 'moreInfo' });
		moreInfoHolder.append(moreInfo);
		moreInfoHolder.css("top", "-600");
        $("#moreInfoContainer").append(moreInfoHolder);
		var html = '<h3 class="header">Notice</h3>';
		html += '<div class="paragraph">Before proceeding, please make certain that your health insurance i.d. card specifies MMIC as your health plan provider.</div>';
		html += '<p class="calltoaction ribbon ribbon-right-main" role="button"><a title="Continue" href="' + url + '">Continue</a></p>';
		html += '<p class="closeModalInfo"><a href="javascript: void(0);" title="close modal" role="button">Close Modal</a></p>';
		moreInfo.html(html);
		$("#moreInfoHolder").show();
		setModalPosition();
		var containerHeight = $("#moreInfoHolder").innerHeight();
		var windowHeight = window.innerHeight;
		moreInfoHolder.animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
		if (parseInt(containerHeight + 120) > windowHeight) 
		{
			$("html, body").animate({ scrollTop: 0 }, "slow");
		}
		return false;
	});*/

    function setModalPosition() {
        var containerHeight = $("#moreInfoHolder").innerHeight();
        var windowHeight = window.innerHeight;
        if (parseInt(containerHeight + 120) > windowHeight) {
            $("#moreInfoHolder").css("position", "absolute");
        }
        else {
            $("#moreInfoHolder").css("position", "");
        }
    }

    function setModalPositionDetails() {
        var containerHeight = $("#provDetailsHolder").innerHeight();
        var windowHeight = window.innerHeight;
        if (parseInt(containerHeight + 120) > windowHeight) {
            $("#provDetailsHolder").css("position", "absolute");
        }
        else {
            $("#provDetailsHolder").css("position", "");
        }
    }

    var provInfoDetailsHolder = $('<div/>', { id: 'provInfoDetailsHolder' });

    $("#provDetailsHolder").on("click", ".moreInfoDetails", function (e) {
        e.preventDefault();
        var fullHref = $(this).attr("href");
        var href = fullHref.split("#");
        if (href.length > 1) {
            var provInfoDetailsMoreInfo = $('<div/>', { id: 'provInfoDetailsMoreInfo' });
            provInfoDetailsHolder.append(provInfoDetailsMoreInfo);
            $("#provModal").append(provInfoDetailsHolder);
            provInfoDetailsMoreInfo.load(href[0] + " #" + href[1], function () {
                $(".scrollPane").animate({ opacity: 0.25 }, { duration: 450, easing: 'easeOutSine' });
                provInfoDetailsHolder.show();
                provInfoDetailsMoreInfo.append('<p class="closeModalDetailsInfo"><a href="javascript: void(0);" title="close modal" role="button"><< Back</a></p>');
                //provInfoDetailsHolder.animate({ top: 120 }, { duration: 450, easing: 'easeOutSine' });
            });
        }
        return false;
    });

    $("#moreInfoContainer").on("click", ".closeModalInfo a", function () {
        moreInfoHolder = $("#moreInfoHolder");

        $("#moreInfoHolder #moreinfo").removeAttr("tabindex");//WCAG-OH
        moreInfoHolder.animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
        moreInfoHolder.empty().remove();
        $("#overlay").fadeOut(300);
        moreinfoParent.css('outline', 'none !important')
                  .attr("tabindex", 0)
                  .focus();//WCAG-OH
    });


    $("#provDetailsHolder").on("click", ".closeModalInfo a", function () {
        $("#provDetailsHolder").animate({ top: -600 }, { duration: 150, easing: 'easeOutSine' });
        //$("#provDetailsHolder #provModal .scrollPane #scrollPaneText").html('');
        $("#provDetailsHolder #provModal .closeModalInfo").remove();
        $(".scrollPane").css("opacity", "");
        $("#provDetailsHolder").hide();
        provInfoDetailsHolder.empty().remove();
        $("#overlay").fadeOut(300);
    });

    $(window).scroll(function () {
        if ($(this).scrollTop() != 0) {
            $('.back-to-top').fadeIn();
        }
        else {
            $('.back-to-top').fadeOut();
        }
    });

    $('.back-to-top').click(function () {
        $('body,html').animate({ scrollTop: 0 }, 800);
    });

  $(document).ready(function () {
      $('ul.tabs li').click(function () {
          var tab_id = $(this).attr('data-tab');
                //$('ul.tabs li').removeClass('current');
          //$('.tab-content').removeClass('current');
          $(this).parent().find('li.current').removeClass('current');
          $(this).parent().parent().find('div.current').removeClass('current');

          $(this).addClass('current');
          $('#' + tab_id).addClass('current');
      })

  })

    $('.cd-filter-block h4').on('click', function () {
      $(this).find("a.FiltersColorAndFont").attr('aria-expanded', $(this).find("a.FiltersColorAndFont").attr('aria-expanded') === 'true' ? 'false' : 'true');
      $(this).toggleClass('closed').siblings('.cd-filter-content').slideToggle(300);
  })
  
  $('.cd-filter-block h4').on('click', function () {
      $(this).find("a.FiltersColorAndFont").attr('aria-expanded', $(this).find("a.FiltersColorAndFont").attr('aria-expanded') === 'true' ? 'false' : 'true');
      $(this).toggleClass('closed').siblings('div').find('.cd-filter-content').slideToggle(300);
  })

  //Mobile Accordion start
  $('.accordion-content-mobile').not(':animated').hide();
  $('.accordion-content-mobile:first').show();
  $('.accordion-header-mobile:first').addClass('active');
  var hash = window.location.hash;
  var thash = hash.substring(hash.lastIndexOf('#') + 1, hash.length);
  if (thash != "" && $(".accordion").length != 0) {
      var $$ = $("[rel=" + thash + "]");
      //$('.accordion-header-mobile').removeClass('active');
      //$('.accordion-content-mobile').slideUp('normal');
      //debugger;
      if ($$.next().is(':hidden') == true) {
          $$.addClass('active');
          $$.next().slideDown('normal', function () {
              $('body,html').animate({ scrollTop: $$.position().top }, 800);
          });
      }
  }



  //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
  $('.accordion-header-mobile').click(function () {
      //$('.accordion-header-mobile').removeClass('active');
      //$('.accordion-content-mobile').slideUp('normal');

      $(this).addClass('active');
      $(this).next().slideDown('normal', function () {
          $('body,html').animate({ scrollTop: $(this).position().top }, 800);

      });


  });

  $('.accordion-header-mobile').hover(function () {
      $(this).toggleClass("hover");
  }, function () {
      $(this).toggleClass("hover");
  });



  //Mobile Accordion End


function LazyLoadImages(divSource)
{
	$('.'+divSource).children('img').attr('src',$('.'+divSource).children('img').attr('Text')); 
}

  //Mobile Accordion Detail Start
  $(function () {
      //Ã‚  Accordion Panels
      $(".accordiondetail").show();
      $(".pane").hide();
      //setTimeout("$('.accordiondetail div').slideToggle('slow');", 10);
      $('.accordiondetail header').click(function () {

          //$(this).next(".pane").slideToggle("slow").siblings(".pane:visible").slideUp("slow");
          //$(this).toggleClass("current");
          //$(this).siblings("header").removeClass("current");
          var hiden = $(this).next(".pane:visible");
          var hiden1 = $(this).find("img");
        //10/02/18 - Google map static image modified
	//$(this).next(".pane").find(".google-service-maps").children('img').attr('src',$(this).next(".pane").find(".google-service-maps").children('img').attr('Text'));
        var gmaps = $(this).next(".pane");
          gmaps .find(".google-service-maps").each(function () {
              $(this).children('img').attr('src',$(this).children('img').attr('Text'));
          });
          $(".pane").hide();
          $(".arwexpand").removeClass("rotated");

          //WCAG - Mercy ViewDetails Tab
          var prev_ViewDetail = $('.tabs').filter(function () {
              return $(this).css('background-color').toLowerCase().indexOf('rgb(255, 255, 255)') > -1
          })

          prev_ViewDetail.css("background-color", "rgb(255, 255, 255)").css("background-color", "rgb(0, 0, 0)");

          if (hiden.length == 0) {
              $(this).next(".pane").slideToggle("slow").siblings(".pane:visible").slideUp("slow");
              $(this).find("img").addClass("rotated");
              $(this).find("a").attr('aria-expanded', true);
              $(this).next('.pane').children().children().css("background-color", "rgb(255, 255, 255)"); //WCAG - Mercy ViewDetails Tab
          }
          else {
              $(this).find("img").removeClass("rotated");
              $(this).find("a").attr('aria-expanded', false);
          }

          //WCAG - Mercy ViewDetails Tab
          var curr_ViewDetail = $('.tabs').filter(function () {
              return $(this).css('background-color').toLowerCase().indexOf('rgb(255, 255, 255)') > -1
          })

          ViewDetails_Access(curr_ViewDetail)
      });
  });

  $(function () {
      $('.accordiondetail1').click(function () {
          //$(this).closest(".accordiondetail").find(".view-moredetails").text("VIEW DETAILS");
          $(this).closest(".accordiondetail").find("#View").text("VIEW DETAILS");
          $(this).closest(".pane").hide();
      });
  });

  //Mobile Accordion Detail End
  $(window).scroll(function () {
      if ($(window).scrollTop() >= 450) {
          $('.divTableheader').addClass('fixed-header');
      }
      else {
          $('.divTableheader').removeClass('fixed-header');
      }
  });

 
    $("#btnclear").click(function () {     
            $("select").each(function () {
                $(this).val($("option", this).eq(8).val());
            });
	$("#ASAMLevel").each(function () {
                $(this).val($("option", this).eq(0).val());
            });
            //$('select').selectBox('refresh');
            $(".inputHolder").removeClass("parent-validation-error");
            $("select").removeAttr('aria-invalid');
            $("textarea").removeAttr('aria-invalid');
            $("input").removeAttr('aria-invalid');
            $('.field-validation-error').find('span').remove();  
            $('#errorContainer ul li').remove(); //WCAG-OH
            $('#errorContainer').removeAttr("tabindex"); //WCAG-OH
            $('#errorContainer').hide();
          // $("#ddlMultiselect").multiSelect( 'refresh' );
           // $('#Specilatydropdown').multiselect("deselectAll", false).multiselect("refresh");
	    $("#Specilatydropdown option:selected").removeAttr("selected");
            $('#Specilatydropdown').multiselect("refresh");
            $('#Specialtydropdown').val("");
            $('#SpecialtyList').val("");
           // $("#Specilatydropdown option:selected").prop("selected", false);
        // $("#Specilatydropdown").multiSelect("clearSelection");btn-default
            //$("#Specilatydropdown").multiSelect('reset');
      
   			if($('#ddlOpioid1').length > 0) {
                $("#ddlOpioid1 option:selected").removeAttr("selected");
                $('#ddlOpioid1').multipleselect("refresh");
                $('#ddlOpioid').val("");
            }
    });

 $("#btnclearTXDSNP").click(function () {     
            $("select").each(function () {
                $(this).val($("option", this).eq(8).val());
            });
	$("#ASAMLevel").each(function () {
                $(this).val($("option", this).eq(0).val());
            });
           // $('select').selectBox('refresh');
            $(".inputHolder").removeClass("parent-validation-error");
            $("select").removeAttr('aria-invalid');
            $("textarea").removeAttr('aria-invalid');
            $("input").removeAttr('aria-invalid');
            $('.field-validation-error').find('span').remove();  
            $('#errorContainer ul li').remove(); //WCAG-OH
            $('#errorContainer').removeAttr("tabindex"); //WCAG-OH
            $('#errorContainer').hide();
          // $("#ddlMultiselect").multiSelect( 'refresh' );
           // $('#Specilatydropdown').multiselect("deselectAll", false).multiselect("refresh");
          
	    $("#Specilatydropdown option:selected").removeAttr("selected");
            $('#Specilatydropdown').multiselect("refresh");
            $('#Specialtydropdown').val("");
            $('#SpecialtyList').val("");
           // $("#Specilatydropdown option:selected").prop("selected", false);
        // $("#Specilatydropdown").multiSelect("clearSelection");btn-default
            //$("#Specilatydropdown").multiSelect('reset');
    });
  $("#chkhide").click(function () {
            $("#divcity").show();
            $("#divzip").hide();
            $("#chkdisplay").removeAttr('checked');
            $(".Textbox-zip").val('');
    });

    $("#chkdisplay").click(function () {
            $("#divcity").hide();
            $("#divzip").show();
            $("#chkhide").removeAttr('checked');
            $("#city").val('');
            $("#county").val('');
    });

    function LoadWheel() {   
            var IsMobileValue = '@(ViewContext.Controller.ViewBag.IsMobile)';    
       if(IsMobileValue != 'No')
            {
           //document.getElementById('divLoading1').style.visibility = 'visible'
           $("#divLoading p img").attr('alt', 'Loading'); //WCAG - add to announce screen reader
           document.getElementById('divLoading').style.visibility = 'visible'
         
            }
    }


     $('#btnsearch').click(function () {
        $('.error_show').hide();
        var hasError = false;
        var searchReg = /^[a-zA-Z- ,]+$/;
        var zipReg = /^[0-9,a-zA-Z]+$/;
        var selectVal = $('#DropList').val();
        var cityVal = $('#city').val();
        var countyVal = $('#county').val();
        var zipVal = $('.Textbox-zip').val();
        var nameVal = $('#Provname').val();
        var zipVal = $('.Textbox-zip').val();
        //var specialtyvar = $('#ddlspecialty').val();
        var specialtyvar = $('#Specialtydropdown').val();

        if (!searchReg.test(cityVal) && cityVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
                hasError = true;
            $('#city').attr("aria-invalid","true");
        } else if (!searchReg.test(countyVal) && countyVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
               hasError = true;
               $('#county').attr("aria-invalid", "true");
        }
        else if (!zipReg.test(zipVal) && zipVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (selectVal == "--Please Select--") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
            hasError = true;
           
        }
            else if (cityVal == "" && countyVal == "" && zipVal.length >1 && zipVal.length < 5) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
            hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')   
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if ((nameVal == "" && specialtyvar == "" ) || nameVal.indexOf("%") > -1) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal.length > 5 ) {
                $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
                hasError = true;
            $('#Zip').attr("aria-invalid", "true");
            }
        else if (nameVal.length < 2 && specialtyvar == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter a valid Provider Name/Hospital Name</span></li>')
            hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
   
        if (hasError == true)
        {
            $('#errorContainer').show();
            $("#errorContainer").attr("tabindex", "-1");//WCAG-OH
            $("#errorContainer").focus();//WCAG-OH
            return false;
          
        }
        else
        {
           $('#errorContainer').hide();
            LoadWheel();
        }
    });

 $('#btnsearchTXDSNP').click(function () {
        $('.error_show').hide();
        var hasError = false;
        var searchReg = /^[a-zA-Z- ,]+$/;
        var zipReg = /^[0-9,a-zA-Z]+$/;
        var selectVal = $('#DistanceDropList').val();
        var cityVal = $('#city').val();
        var countyVal = $('#county').val();
        var zipVal = $('.Textbox-zip').val();
        var nameVal = $('#Provname').val();
        var zipVal = $('.Textbox-zip').val();
        //var specialtyvar = $('#ddlspecialty').val();
        var specialtyvar = $('#Specialtydropdown').val();

        if (!searchReg.test(cityVal) && cityVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
                hasError = true;
            $('#city').attr("aria-invalid","true");
        } else if (!searchReg.test(countyVal) && countyVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
               hasError = true;
               $('#county').attr("aria-invalid", "true");
        }
        else if (!zipReg.test(zipVal) && zipVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (selectVal == "--Please Select--") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
            hasError = true;
           
        }
            else if (cityVal == "" && countyVal == "" && zipVal.length >1 && zipVal.length < 5) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
            hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')   
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if ((nameVal == "" && specialtyvar == "" ) || nameVal.indexOf("%") > -1) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal.length > 5 ) {
                $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
                hasError = true;
            $('#Zip').attr("aria-invalid", "true");
            }
        else if (nameVal.length < 2 && specialtyvar == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter a valid Provider Name/Hospital Name</span></li>')
            hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
   
        if (hasError == true)
        {
            $('#errorContainer').show();
            $("#errorContainer").attr("tabindex", "-1");//WCAG-OH
            $("#errorContainer").focus();//WCAG-OH
            return false;
          
        }
        else
        {
           $('#errorContainer').hide();
            LoadWheel();
        }
    });
  //TexasTele
 $('#btnsearchtexas').click(function () {
         $('.error_show').hide();
         var hasError = false;
         var searchReg = /^[a-zA-Z- ]+$/;
         var zipReg = /^[0-9]+$/;
         var selectVal = $('#DropList').val();
         var cityVal = $('#city').val();
         var countyVal = $('#county').val();
         var zipVal = $('.Textbox-zip').val();
         var nameVal = $('#Provname').val();
         var zipVal = $('.Textbox-zip').val();
		 var chkTele =   document.getElementById("chkTelemedicine").checked;
	
         //var specialtyvar = $('#ddlspecialty').val();
         var specialtyvar = $('#Specialtydropdown').val();
                                var provAddressVal = $('#ProvAddress').val();
                                var validProvAddress = true;

    //Provider Address Validation base on length
                                  if (provAddVal != "") {
                                  var provAddVal = provAddressVal.split(",");
                                  var provNamVal = provAddressVal.split("-");
                                  if(provAddVal.length !=4 && provNamVal.length !=2)
                                                  validProvAddress=false;
                                }else{validProvAddress=true;}
         if (!searchReg.test(cityVal) && cityVal != "") {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
            // $("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
             hasError = true;
             $('#city').attr("aria-invalid", "true");
         } else if (!searchReg.test(countyVal) && countyVal != "") {
             //$("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#county').attr("aria-invalid", "true");
         }
         else if (!zipReg.test(zipVal) && zipVal != "") {
             // $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Zip').attr("aria-invalid", "true");
         }
         else if (selectVal == "--Please Select--") {
             // $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;

         }
         else if (cityVal == "" && countyVal == "" && zipVal.length > 1 && zipVal.length < 5) {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
            // $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             hasError = true;
             $('#Zip').attr("aria-invalid", "true");
         }
         else if (cityVal == "" && countyVal == "" && zipVal == "") {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
            // $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             hasError = true;
             $('#Zip').attr("aria-invalid", "true");
         }      
         else if (cityVal == "" && countyVal == "" && zipVal.length > 5) {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
            // $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             hasError = true;
             $('#Zip').attr("aria-invalid", "true");
         } 
		 //Ignore Validation for Specialty and  Provider if check box for telemedicine is selected
		
		 if (nameVal == "" && specialtyvar == "" && provAddressVal =="" && hasError == false) {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
            // $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
         }else if ((nameVal.length < 2 && specialtyvar == "" && validProvAddress == false) || nameVal.indexOf("%") > -1) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter a valid Provider Address from the suggested addresses</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
         }
         else if ((nameVal.length < 2 && specialtyvar == "" && validProvAddress == false) || nameVal.indexOf("%") > -1) {
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
             $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
         }
   		if(chkTele ==true)
		{
           hasError = false;
		}

         if (hasError == true) {
             $('#errorContainer').show();
             $("#errorContainer").attr("tabindex", "-1");//WCAG-OH
             $("#errorContainer").focus();//WCAG-OH
             return false;

         }
         else {
             $('#errorContainer').hide();
             LoadWheel();
         }
     });
  
  	 $('#btnMercysearch').click(function () {
        $('.error_show').hide();
        var hasError = false;
        var searchReg = /^[a-zA-Z- ,]+$/;
        var zipReg = /^[0-9,a-zA-Z]+$/;
        var selectVal = $('#PlanDropList').val();
        var cityVal = $('#city').val();
        var countyVal = $('#county').val();
        var zipVal = $('.Textbox-zip').val();
        var nameVal = $('#Provname').val();
        var zipVal = $('.Textbox-zip').val();
        //var specialtyvar = $('#ddlspecialty').val();
        var specialtyvar = $('#Specialtydropdown').val();

        if (!searchReg.test(cityVal) && cityVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
                hasError = true;
            $('#city').attr("aria-invalid","true");
        } else if (!searchReg.test(countyVal) && countyVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
               hasError = true;
               $('#county').attr("aria-invalid", "true");
        }
        else if (!zipReg.test(zipVal) && zipVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (selectVal == "--Please Select--") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
            hasError = true;
           
        }
            else if (cityVal == "" && countyVal == "" && zipVal.length >1 && zipVal.length < 5) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
            hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')   
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if ((nameVal == "" && specialtyvar == "" ) || nameVal.indexOf("%") > -1) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty</span></li>')
             hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal.length > 5 ) {
                $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
                hasError = true;
            $('#Zip').attr("aria-invalid", "true");
            }
        else if (nameVal.length < 2 && specialtyvar == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter a valid Provider Name/Hospital Name</span></li>')
            hasError = true;
             $('#Provname').attr("aria-invalid", "true");
        }
   
        if (hasError == true)
        {
            $('#errorContainer').show();
            $("#errorContainer").attr("tabindex", "-1");//WCAG-OH
            $("#errorContainer").focus();//WCAG-OH
            return false;
          
        }
        else
        {
           $('#errorContainer').hide();
            LoadWheel();
        }
    });

	$("#PlanDropList").css({ "border-color": "#ccc", "height": "29px", "border-width": "thin"});
		$("#DistanceDropList").css({ "border-color": "#ccc", "height": "29px", "border-width": "thin"});
$('#btnsearchKansas').click(function () {
        $('.error_show').hide();
        var hasError = false;
        var searchReg = /^[a-zA-Z- ,]+$/;
        var zipReg = /^[0-9,a-zA-Z]+$/;
        var selectVal = $('#DropList').val();
        var cityVal = $('#city').val();
        var countyVal = $('#county').val();
        var zipVal = $('.Textbox-zip').val();
        var nameVal = $('#Provname').val();
        var zipVal = $('.Textbox-zip').val();
        //var specialtyvar = $('#ddlspecialty').val();
        var specialtyvar = $('#Specialtydropdown').val();
		var specializeExpVal = $('#ddlOpioid').val();

        if (!searchReg.test(cityVal) && cityVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
                hasError = true;
            $('#city').attr("aria-invalid", "true");
      

        } else if (!searchReg.test(countyVal) && countyVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
               hasError = true;
               $('#county').attr("aria-invalid", "true");
        }
        else if (!zipReg.test(zipVal) && zipVal != "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (selectVal == "--Please Select--") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
            hasError = true;
           
        }
            else if (cityVal == "" && countyVal == "" && zipVal.length >1 && zipVal.length < 5) {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
            hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal == "") {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code,City or County</span></li>')   
               hasError = true;
            $('#Zip').attr("aria-invalid", "true");
        }
        else if (specializeExpVal == "" && specialtyvar == "" && nameVal=="")  {
            $("#errorContainer ul").append('<li><span class="error_show" id="errorName">Select a Specialty OR Specialized Expertise OR Provider Name/Hospital Name</span></li>')
             hasError = true;
             $('#ddlOpioid').attr("aria-invalid", "true");
        }
        else if (cityVal == "" && countyVal == "" && zipVal.length > 5 ) {
                $("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
                hasError = true;
            $('#Zip').attr("aria-invalid", "true");
            }
       
   
        if (hasError == true)
        {
            $('#errorContainer').show();
            $("#errorContainer").attr("tabindex", "-1");//WCAG-OH
            $("#errorContainer").focus();//WCAG-OH
            return false;
          
        }
        else
        {
           $('#errorContainer').hide();
            LoadWheel();
        }
});

    //4/25/2019
    //WCAG - Provider Search Results View Details TABs keyboard access -Start
    function ViewDetails_Access(curr_ViewDetail) {
        curr_ViewDetail.children().keydown(tabListKeyPress).click(tabListClick);
    }


    var tabListKeyPress = function (event) {
        if (event.which === 37 || event.which === 38 ||
            (event.which === 33 && event.ctrlKey)) { //left/up/ctrl+pageup
            var prevItem = $(event.currentTarget).prev("li");
            if (prevItem.length > 0) {
                focusTab(prevItem);
                event.preventDefault();
            } else {
                //go to the last one
                var lastItem = $(event.currentTarget).siblings("li").last();
                focusTab(lastItem);
                event.preventDefault();
            }
        } else if (event.which === 39 || event.which === 40 ||
            (event.which === 34 && event.ctrlKey)) { //right/down/ctrl+pagedown
            var nextItem = $(event.currentTarget).next("li");
            if (nextItem.length > 0) {
                focusTab(nextItem);
                event.preventDefault();
            } else {
                //go to the first one
                var firstItem = $(event.currentTarget).siblings("li").first();
                focusTab(firstItem);
                event.preventDefault();
            }

        }
    }

    var tabListClick = function (event) {
        focusTab($(event.currentTarget));
    }

    var focusTab = function (newTab) {
        // Identify existing focus tab and: 1) Unset aria-selected, 2) set tabindex=-1, 3) replace
        // active class with inactive on both the tab and the panel, 4) set aria-hidden on panel

        var curr = $('.tabs').filter(function () {
            return $(this).css('background-color').toLowerCase().indexOf('rgb(255, 255, 255)') > -1
        });
        var activeTab = curr.children('li.current');

        activeTab
            //.addClass("")
            .removeClass("current")
            .attr("aria-selected", "false")
            .attr("tabindex", "-1");

        $("#" + activeTab.attr("aria-controls"))
           // .addClass("current")
            .removeClass("current")
           // .removeClass("")
            .attr("aria-hidden", "true");

        // For newly focused tab: 1) Set aria-selected, 2) set tabindex=0, 3) replace inactive class
        // with active on both tab and panel, 4) unset aria-hidden on panel

        newTab
            .addClass("current")
           // .removeClass("")
            .attr("aria-selected", "true")
            .attr("tabindex", "0");

        $("#" + newTab.attr("aria-controls"))
            .addClass("current")
            //.removeClass("")
            .attr("aria-hidden", "false");

        newTab.focus();
    }


    //4/25/2019
    //WCAG - Provider Search Results View Details TABs keyboard access -End
    $('#btnsearchCA').click(function () {
        $('.error_show').hide();
        var hasError = false;
        var searchReg = /^[a-zA-Z- ,]+$/;
        var zipReg = /^[0-9,a-zA-Z]+$/;
        var selectVal = $('#PlanDropdownList').val();
        var cityVal = $('#city').val();
        var countyVal = $('#county').val();
        var zipVal = $('#Textbox-zip').val();
        var nameVal = $('#Provname').val();
        //var zipVal = $('.Textbox-zip').val();
        var npiVal = $('#NPILicense').val() === undefined ? '' : $('#NPILicense').val();
        var specialtyvar = $('#Specialtydropdown').val();
      	var checkTelehealth = ($('input[name="chkTelemedicine"]').length > 0) ? $('input[name="chkTelemedicine"]').is(':checked') : false;

        if (selectVal == "--Please Select--") {
            if ($('#PlanDropdownList').data() != null && ($('#PlanDropdownList').data('id') == "illinicareplan" || $('#PlanDropdownList').data('id') == "texasplan"|| $('#PlanDropdownList').data('id') == "virginiaplan")) {
                $("#errorContainer ul").append('<li><span class="error_show" id="error-PlanDropdownList">Select Your Plan</span></li>');
            } else {
                $("#errorContainer ul").append('<li><span class="error_show" id="error-PlanDropdownList">Select Your County</span></li>')
            }
            hasError = true;
            $('#city').removeAttr("aria-invalid");
            $('#city').removeAttr("aria-describedby");
            $('#county').removeAttr("aria-invalid");
            $('#county').removeAttr("aria-describedby");
            $('#Zip').removeAttr("aria-invalid");
            $('#Zip').removeAttr("aria-describedby");
            $('#Provname').removeAttr("aria-describedby");
            $('#NPILicense').removeAttr("aria-describedby");
            $('#Specilatydropdown').removeAttr("aria-describedby");
            $('#Provname').removeAttr("aria-invalid");
            $('#NPILicense').removeAttr("aria-invalid");
            $('#PlanDropdownList').attr("aria-describedby", "error-PlanDropdownList");
                        

        } else if (!checkTelehealth) {
            if (cityVal == "" && countyVal == "" && zipVal == "") {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-Textbox-zip">Enter a ZIP code, City or County</span></li>')
              hasError = true;

              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#Textbox-zip').attr("aria-invalid", "true");
              $('#Textbox-zip').attr("aria-describedby", "error-Textbox-zip");
              $('#city').attr("aria-describedby", "error-Textbox-zip");
              $('#county').attr("aria-describedby", "error-Textbox-zip");
              $('#city').attr("aria-invalid", "true");
              $('#county').attr("aria-invalid", "true");

          } else if (!searchReg.test(cityVal) && cityVal != "") {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-city">Enter a valid City</span></li>')
              hasError = true;
              $('#city').removeAttr("aria-invalid");
              $('#city').removeAttr("aria-describedby");
              $('#county').removeAttr("aria-invalid");
              $('#county').removeAttr("aria-describedby");
              $('#Zip').removeAttr("aria-invalid");
              $('#Zip').removeAttr("aria-describedby");
              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#city').attr("aria-invalid", "true");
              $('#city').attr("aria-describedby", "error-city");


          } else if (!searchReg.test(countyVal) && countyVal != "") {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-county">Enter a valid County</span></li>')
              hasError = true;
              $('#city').removeAttr("aria-invalid");
              $('#city').removeAttr("aria-describedby");
              $('#county').removeAttr("aria-invalid");
              $('#county').removeAttr("aria-describedby");
              $('#Zip').removeAttr("aria-invalid");
              $('#Zip').removeAttr("aria-describedby");
              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#county').attr("aria-invalid", "true");
              $('#county').attr("aria-describedby", "error-county");


          } else if (!zipReg.test(zipVal) && zipVal != "" && zipVal.length > 1 && zipVal.length < 5) {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-Textbox-zip">Enter a valid ZIP code</span></li>')
              hasError = true;
              $('#city').removeAttr("aria-invalid");
              $('#city').removeAttr("aria-describedby");
              $('#county').removeAttr("aria-invalid");
              $('#county').removeAttr("aria-describedby");
              $('#Zip').removeAttr("aria-invalid");
              $('#Zip').removeAttr("aria-describedby");
              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#Textbox-zip').attr("aria-invalid", "true");
              $('#Textbox-zip').attr("aria-describedby", "error-Textbox-zip");


          } else if ((nameVal == "" && specialtyvar == "" && (npiVal == "" || npiVal == undefined)) || nameVal.indexOf("%") > -1) {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-Provname">Enter Provider/Facility Name or Select a Specialty</span></li>')
              hasError = true;
              $('#city').removeAttr("aria-invalid");
              $('#city').removeAttr("aria-describedby");
              $('#county').removeAttr("aria-invalid");
              $('#county').removeAttr("aria-describedby");
              $('#Zip').removeAttr("aria-invalid");
              $('#Zip').removeAttr("aria-describedby");
              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#Provname').attr("aria-invalid", "true");
              $('#Provname').attr("aria-describedby", "error-Provname");
              $('#NPILicense').attr("aria-invalid", "true");
              $('#NPILicense').attr("aria-describedby", "error-Provname");
              $('#Specilatydropdown').attr("aria-describedby", "error-Provname");

          } else if (nameVal.length < 2 && specialtyvar == "" && npiVal == "") {
              $("#errorContainer ul").append('<li><span class="error_show" id="error-Provname">Enter a valid Provider/Facility Name</span></li>')
              hasError = true;
              $('#city').removeAttr("aria-invalid");
              $('#city').removeAttr("aria-describedby");
              $('#county').removeAttr("aria-invalid");
              $('#county').removeAttr("aria-describedby");
              $('#Zip').removeAttr("aria-invalid");
              $('#Zip').removeAttr("aria-describedby");
              $('#PlanDropdownList').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-describedby");
              $('#NPILicense').removeAttr("aria-describedby");
              $('#Specilatydropdown').removeAttr("aria-describedby");
              $('#Provname').removeAttr("aria-invalid");
              $('#NPILicense').removeAttr("aria-invalid");
              $('#Provname').attr("aria-invalid", "true");
              $('#Provname').attr("aria-describedby", "error-Provname");

          }

          if (npiVal != "") {
              var regex = /^[0-9a-zA-Z\_]+$/
              var valid = regex.test(npiVal);
              if (valid == false) {
                  $("#errorContainer ul").append('<li><span class="error_show" id="error-NPILicense">Please enter a valid NPI/State License</span></li>')
                  hasError = true;
                  $('#city').removeAttr("aria-invalid");
                  $('#city').removeAttr("aria-describedby");
                  $('#county').removeAttr("aria-invalid");
                  $('#county').removeAttr("aria-describedby");
                  $('#Zip').removeAttr("aria-invalid");
                  $('#Zip').removeAttr("aria-describedby");
                  $('#PlanDropdownList').removeAttr("aria-describedby");
                  $('#Provname').removeAttr("aria-describedby");
                  $('#NPILicense').removeAttr("aria-describedby");
                  $('#Specilatydropdown').removeAttr("aria-describedby");
                  $('#Provname').removeAttr("aria-invalid");
                  $('#NPILicense').removeAttr("aria-invalid");
                  $('#NPILicense').attr("aria-invalid", "true");
                  $('#NPILicense').attr("aria-describedby", "error-NPILicense");

              }
          }
        }

        $('button.multiselect-clear-filter').trigger('click');
        if (hasError == true) {
            $('#errorContainer').show();
            $("#errorContainer").attr("tabindex", "-1");
            $("#errorContainer").focus();
            return false;
        }
        else {
            $('#errorContainer').hide();
            LoadWheel();
        }

        /*if (selectVal == "--Please Select--") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Select Your Plan</span></li>')
            hasError = true;
            $('#PlanDropdownList').addClass('findprovider-form-error');
            $('label[for="PlanDropdownList"]').addClass('findprovider-form-error');
            $('#error-PlanDropdownList').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Select Your County</span>');
            $('#PlanDropdownList').focus();
        } else {
            hasError = false;
            $('#PlanDropdownList').removeClass('findprovider-form-error');
            $('label[for="PlanDropdownList"]').removeClass('findprovider-form-error');
            $('#error-PlanDropdownList').empty();
        }

        if (cityVal == "" && countyVal == "" && zipVal == "") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a ZIP code, City or County</span></li>');
            hasError = true;
            $('#Textbox-zip').attr("aria-invalid", "true");
            $('#Textbox-zip').addClass('findprovider-form-error');
            $('label[for="Textbox-zip"]').addClass('findprovider-form-error');
            $('#error-Textbox-zip').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a ZIP Code</span>');
            $('#Textbox-zip').focus();

            $('#city').addClass('findprovider-form-error');
            $('label[for="city"]').addClass('findprovider-form-error');
            $('#error-city').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a City or County</span>');

            $('#county').addClass('findprovider-form-error');
            $('label[for="county"]').addClass('findprovider-form-error');
            $('#city').focus();
        }

        if (zipVal != "") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorZip">Enter a valid ZIP code</span></li>')
            if (!zipReg.test(zipVal) && zipVal.length > 1 && zipVal.length < 5) {
                hasError = true;
                $('#Textbox-zip').attr("aria-invalid", "true");
                $('#Textbox-zip').addClass('findprovider-form-error');
                $('label[for="Textbox-zip"]').addClass('findprovider-form-error');
                $('#error-Textbox-zip').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a valid ZIP code</span>');
                $('#Textbox-zip').focus();
            } else {
                hasError = false;
                $('#Textbox-zip').removeAttr("aria-invalid");
                $('#Textbox-zip').removeClass('findprovider-form-error');
                $('label[for="Textbox-zip"]').removeClass('findprovider-form-error');
                $('#error-Textbox-zip').empty();
            }   
        }

        if (cityVal != "") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorCity">Enter a valid City</span></li>')
            if (!searchReg.test(cityVal)) {
                hasError = true;
                $('#city').attr("aria-invalid", "true");
                $('#city').addClass('findprovider-form-error');
                $('label[for="city"]').addClass('findprovider-form-error');
                $('#error-city').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a valid City</span>');
                $('#city').focus();
            } else {
                hasError = false;
                $('#city').removeAttr("aria-invalid");
                $('#city').removeClass('findprovider-form-error');
                $('label[for="city"]').removeClass('findprovider-form-error');
                $('#error-city').empty();
            }
        }

        if (countyVal != "") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorCounty">Enter a valid County</span></li>')
            if (!searchReg.test(countyVal)) {
                hasError = true;
                $('#county').attr("aria-invalid", "true");
                $('#county').addClass('findprovider-form-error');
                $('label[for="county"]').addClass('findprovider-form-error');
                $('#error-county').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a valid County</span>');
                $('#county').focus();
            } else {
                hasError = false;
                $('#county').removeAttr("aria-invalid");
                $('#county').removeClass('findprovider-form-error');
                $('label[for="county"]').removeClass('findprovider-form-error');
                $('#error-county').empty();
            }
        }

        if ((nameVal == "" && specialtyvar == "" && npiVal == "") || nameVal.indexOf("%") > -1) {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter Provider Name/Hospital Name or Select a Specialty or NPI/State License</span></li>')
            hasError = true;
            $('#Provname').attr("aria-invalid", "true");
            $('#Provname').addClass('findprovider-form-error');
            $('label[for="Provname"]').addClass('findprovider-form-error');
            $('#error-Provname').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter Provider Name/Hospital Name or Select a Specialty or NPI/State License</span>');
            $('#Provname').focus();
        }

        if (nameVal != "") {
            //$("#errorContainer ul").append('<li><span class="error_show" id="errorName">Enter a valid Provider Name/Hospital Name</span></li>')
            if (nameVal.length < 2 && specialtyvar == "" && npiVal == "") {
                hasError = true;
                $('#Provname').attr("aria-invalid", "true");
                $('#Provname').addClass('findprovider-form-error');
                $('label[for="Provname"]').addClass('findprovider-form-error');
                $('#error-Provname').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Enter a valid Provider Name/Hospital Name</span>');
                $('#Provname').focus();
            } else {
                hasError = false;
                $('#Provname').removeAttr("aria-invalid");
                $('#Provname').removeClass('findprovider-form-error');
                $('label[for="Provname"]').removeClass('findprovider-form-error');
                $('#error-Provname').empty();
            }
        }

        if (npiVal != "") {
		    var regex = /^[0-9a-zA-Z\_]+$/
		    var valid = regex.test(npiVal);
		    if(valid== false) {
		        //$("#errorContainer ul").append('<li><span class="error_show" id="errorName">Please enter a valid NPI/State License</span></li>')
                hasError = true;
                $('#NPILicense').addClass('findprovider-form-error');
                $('label[for="NPILicense"]').addClass('findprovider-form-error');
                $('#error-NPILicense').html('<span class="glyphicon">&#xe209;</span>&nbsp;<span class="error_show">Please enter a valid NPI/State License</span>');
                $('#NPILicense').focus();
		    }           
        }
		
		$('button.multiselect-clear-filter').trigger('click');
        if (hasError == true) {
            //$('#errorContainer').show();
            //$("#errorContainer").attr("tabindex", "-1");
            //$("#errorContainer").focus();
            //$("#Textbox-zip").focus();
            return false;
        }
        else {
           //$('#errorContainer').hide();
            LoadWheel();
        }*/
    });
});
