$(document).ready(function(){
      $("#lblSignUpMessage").attr('aria-label','Signup message');
      $("#lblSignUpMessage").css('display','none');
      $("#lblSignUpMessage").text( "Signup message" );
      $(".fa-search").attr('role','Search');
      $(".fa-search").attr('aria-label','Search link');
	  $("#spnRunSiteSearch > i.fa").attr('role','Button');
      $(".genClickable").attr('tabindex','0');
      $(".genClickable").attr('role','button');
      $("#spnRunSiteSearch").attr('role','button');
      $(".fa-chevron-right").attr('role','none');
      
      $('#divToolBarWrp').each(function(){
  		$(this).find('.divToolWrp').attr('role', 'button');
      });
      $('.divNavGroupLink').attr('role', 'button');
      
      $('#customizeCookies').attr('role', 'button');
  
      $('.flex-direction-nav a').each(function(){
  		$(this).attr('role', 'button');
  		$(this).attr('tabindex', '0');
      });
  
      $('.flex-control-nav a').each(function(){
  		$(this).attr('role', 'button');
      });
  
      $(".plannerTable tr th").each(function(){
        var arrowAlt = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
        $(this).find('img').attr("alt", "Arrow " + arrowAlt);
        $(this).attr("scope", "col");
      });
     $('.blogMainThumb h3').each(function(){
        var blogH3Text= $(this).html();
  	$(this).replaceWith( "
"+blogH3Text+"
" );
     });
     $('.blogMainThumb h4').each(function(){
        var blogH4Text= $(this).html();
  	$(this).replaceWith( "
"+blogH4Text+"
" );
     });
      var newsArticle = 0;
        
        $(".homeNewsItem .divNewsMoreLinkWrp a").each(function(){
            newsLinkAlt = this.getAttribute('aria-label');
            $(this).removeAttr('alt');
            var newsLinkAltHead = $(this).closest('.blogMainThumb').find('.h3 span').text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
            if(newsLinkAlt === null){
                // not there            
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            }else if (newsLinkAlt === '') {
                // empty
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            }   
        });
    
        $(".news .blogMainThumb .divNewsMoreLinkWrp a").each(function(){
            newsLinkAlt = this.getAttribute('aria-label');
            var newsLinkAltHead = $(this).closest('.blogMainThumb').find('.h3 span').text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
            if(newsLinkAlt === null){
                // not there            
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            }else if (newsLinkAlt === '') {
                // empty
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "Read " + newsLinkAltHead + " link" );
            }   
       });
        $(".news .blogMainThumb img").each(function(){
            newsImgAlt = this.getAttribute('alt');
            var newsLinkAltHead = $(this).closest('.blogMainThumb').find('.h3 span').text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
           
            if (newsImgAlt === null) {
                // not there
                $(this).attr("alt", "Photo of News " + newsLinkAltHead);
            } else if (newsImgAlt === '') {
                // empty
                $(this).attr("alt", "Photo of News " + newsLinkAltHead);
            } else {        
              // has value
              $(this).attr("alt", "Photo of News " + newsLinkAltHead);
            }
        });
        $(".divMpcItemInnerWrp .divMpcItemDetailLinkWrp a").each(function(){
            eventLabel = this.getAttribute('aria-label');
            var eventHead1 = $(this).closest('.divEventBodyWrp').find('.divMpcItemHeaderRight h2').text();
            if(eventLabel === null){
                // not there            
                $(this).attr("aria-label", "Read event " + eventHead1 + " link" );
            }else if (eventLabel === '') {
                // empty
                $(this).attr("aria-label", "Read event " + eventHead1 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "Read event " + eventHead1 + " link" );
            }   
       });
        
        $("#divNextMeetingWrp a").each(function(){
            meetingLabel = this.getAttribute('aria-label');
            $(this).removeAttr('alt');
            var meetingHead1 = $(this).closest('#divNextMeetingHead').text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
            var meetingHead2 = $(this).closest('#divNextMeetingBody').text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
            
            if(meetingLabel === null){
                // not there            
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " link" );
            }else if (meetingLabel === '') {
                // empty
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " link" );
            }   
        });    
        
        $(".divMeetingBodyInnerWp a").each(function(){
            meetingLabel = this.getAttribute('aria-label');
            $(this).removeAttr('alt');
            var meetingHead1 = $(this).closest('.divMeetingBodyWrp').find('.divMpcItemDayWrp').text();
            var meetingHead2 = $(this).closest('.divMeetingBodyWrp').find('.divMpcItemDateWrp').text();
            var meetingHead3 = $(this).closest('.divMeetingBodyWrp').find('.divMpcItemHeaderRight h2').text();
            
            if(meetingLabel === null){
                // not there            
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " " + meetingHead2 + " link" );
            }else if (meetingLabel === '') {
                // empty
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " " + meetingHead2 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "View " + meetingHead1 + " " + meetingHead2 + " " + meetingHead2 + " link" );
            }   
        });  
        
        $(".councillorMainId ul li .councillorNameTxt a").each(function(){
            councilLabel = this.getAttribute('aria-label');
            var councilHead1 = $(this).text();
            var councilHead2 = $(this).closest('.first').find('.councillorMain h4 em').text();
            
            if(councilLabel === null){
                // not there            
                $(this).attr("aria-label", "View " + councilHead1 + " " + councilHead2 + " link" );
            }else if (councilLabel === '') {
                // empty
                $(this).attr("aria-label", "View " + councilHead1 + " " + councilHead2 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "View " + councilHead1 + " " + councilHead2 + " link" );
            }   
        });  
        
        $(".noticeBoardReport span a").each(function(){
            noticeLabel = this.getAttribute('aria-label');
            var noticeHead1 = $(this).closest('.noticeBoardReport').find('.noticeBoardReportHead').text();            
            if(noticeLabel === null){
                // not there            
                $(this).attr("aria-label", "View notice " + noticeHead1 + " link" );
            }else if (noticeLabel === '') {
                // empty
                $(this).attr("aria-label", "View notice " + noticeHead1 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "View notice " + noticeHead1 + " link" );
            }   
        });  
        
        $(".divPolicyItemWrp a").each(function(){
            policyLabel = this.getAttribute('aria-label');
            var policyHead1 = $(this).closest('.divPolicyItemWrp').find('.style11').text();            
            if(policyLabel === null){
                // not there            
                $(this).attr("aria-label", "View policy " + policyHead1 + " link" );
            }else if (policyLabel === '') {
                // empty
                $(this).attr("aria-label", "View policy " + policyHead1 + " link" );
            } else {      
                // has value
                $(this).attr("aria-label", "View policy " + policyHead1 + " link" );
            }   
        });
        
        $(".divPageGalleryItem img").each(function(){
            localAttrAlt = this.getAttribute('alt');
            var localAttrHead1 = $(this).closest('a').text().trim();            
            if(localAttrAlt === null){
                // not there            
                $(this).attr("alt", "Photo of " + localAttrHead1 );
            }else if (localAttrAlt === '') {
                // empty
                $(this).attr("alt", "Photo of " + localAttrHead1 );
            } else {      
                // has value
                $(this).attr("alt", "Photo of " + localAttrHead1 );
            }   
        });  
    
        
        $(".slides").attr("role", "none");
  		function checkForElement() {
          setTimeout(function() {
            $(".slides li.clone").each(function() {
                $(this).attr("role", "none");
            });
          }, 1500);
        }
        checkForElement();
  		$('h1').attr('role','heading');  
  
  
  		var slideImage = 0;
        $(".slides li img").each(function() {
            slideImgAlt = this.getAttribute('alt');
            if (slideImgAlt === null) {
                // not there
                slideImage++;
                $(this).attr("alt", "Photo of News" + slideImage);
            } else if (slideImgAlt === '') {
                // empty
                slideImage++;
                $(this).attr("alt", "Photo of News" + slideImage);
            } else {        
              // has value
              slideImage++;
              $(this).attr('alt', function( idx, originalSlideImgAlt ){
                return originalSlideImgAlt + ' Photo ' + slideImage
              });
            }
        });
  
  	   var annualAuditReport = 0;
        $(".annualAuditReport li a").each(function() {            
            reportAriaLabel = this.getAttribute('aria-label');
            if (reportAriaLabel === null) {
                // not there
                annualAuditReport++;
                $(this).attr("aria-label", "Report link" + annualAuditReport);
            } else if (reportAriaLabel === '') {
                // empty
                annualAuditReport++;
                $(this).attr("aria-label", "Report link" + annualAuditReport);
            } else {        
              // has value
              annualAuditReport++;
              $(this).attr('aria-label', function( idx, originalReportLabel ){
                return originalReportLabel + ' Link ' + annualAuditReport
              });
            }
        });
       
  
        $("a").each(function(){
            allLinkRole = this.getAttribute('role');
  			if(allLinkRole === null){
                // not there
                $(this).attr('role', 'link');
            }else if (allLinkRole === '') {
                // empty
                $(this).attr('role', 'link');
            } else {      
                // has value                
                $(this).attr('role', 'link');
            }
  
            allLinkAlt = this.getAttribute('aria-label');
            if(allLinkAlt === null){
                // not there
                allLinkText = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
                $(this).attr("aria-label", $.trim(allLinkText) + " link");
                $(this).attr('tabindex', '0');
            }else if (allLinkAlt === '') {
                // empty
                allLinkText = $(this).text().replace(/([-,.€~!@#$%^*()_+=`{}\[\]\|\\:;'<>])+/g, '');
                $(this).attr("aria-label", $.trim(allLinkText) + " link");
                $(this).attr('tabindex', '0');
            } else {      
                // has value
                $(this).attr('aria-label', function( idx, originalLinkTxt ){
                  return originalLinkTxt
                });
                $(this).attr('tabindex', '0');
            }
        });
        
        $(".gdprcookie-intro a").each(function(){
            allLinkAlt = this.getAttribute('aria-label');
            if(allLinkAlt === null){
                // not there
                allLinkText = $(this).text();
                $(this).attr("aria-label", allLinkText + " link");
            }else if (allLinkAlt === '') {
                // empty
                allLinkText = $(this).text();
                $(this).attr("aria-label", allLinkText + " link");
            } else {      
                // has value
                $(this).attr('aria-label', function( idx, originalLinkTxt ){
                  return originalLinkTxt
                });
            }
        });
        
        var allImgLinkTxt = 0;
        $("img").each(function(){
            allImgAlt = this.getAttribute('alt');
            if(allImgAlt === null){
                // not there
                allImgLinkTxt++;
                $(this).attr("alt", "Photo of Image " + allImgLinkTxt);
            }else if (allImgAlt === '') {
                // empty
                allImgLinkTxt++;
                $(this).attr("alt", "Photo of Image " + allImgLinkTxt);
            } else {      
                // has value
                $(this).attr('alt', function( idx, originalImgAltTxt ){
                  return originalImgAltTxt
                });
            }
        });
  
        var noticeImg = 0;
        $(".noticeBoardReport").each(function(){
          noticeImg++;
          $(this).find('img').attr("alt", "Photo of Notice board " + noticeImg);
          $(this).find('p a').attr("title", "Notice board link " + noticeImg);
        });
    
        $(".iconfloatleft a").each(function(){
          var iconListImg = $(this).text();           
          $(this).find('img').attr("alt", "Photo of " + iconListImg);        
        });
  
        var weatherImg = 0;
        $(".weatherWrapper img").each(function(){
          weatherImg++;         
          $(this).attr("alt", "Photo of weather image " + weatherImg);        
        });
  
 
      $('.nav-link').attr('aria-haspopup', 'true');
  	  //$(".bypass-block-link").attr('href', '#divMainContentWrp');
  
      $(".divToolWrp").attr("tabindex", "0");
      $(".divNavGroupLink").attr("tabindex", "0");
      $('#spnRunSiteSearch').attr('tabindex', '0');
      $('.genClickable').attr('tabindex', '0');
      $('figure').attr('role', 'none');
      $('table').attr('role', 'none');
      $('.fa-search').attr('role', 'link');
      $('.fa-chevron-right').attr('role', 'link');
      $('#divNextMeetingHead').attr('role', 'none');
      var allTabIndexEle = 0;
      
      $('a, span, p, div').each(function(){
        allTabIndex = this.getAttribute('tabindex');
        
        if(allTabIndex === null){
            // not there
            
        }else if (allTabIndex === '') {
            // empty
        } else {      
            // has value
            allTabIndexEle++;
            $(this).attr('tabindex', '0');
        }        
      });
      $('[role=button]').attr('tabindex', '0');
     });