$(document).ready(function(z){
	$('a[href*="dev.pgworks.com"]').each(function(){
    	console.log( $(this).attr('href') );
    });
	$('a[href$="/residential/"]', '#breadcrumbs').closest('li').hide();
    $('.sidebar', '#main > .container > .row').each(function(i,itm){
      var $this = $(this), $aside = $('aside', $this);
      if ($aside.get(0)){
        if ($aside.children().length == 0 && $.trim($aside.text()).length == 0){
          console.log('we have an empty sidebar');
          $this.hide();
          $('.main', '#main > .container > .row').removeClass('col-md-push-4');
        }
      }
    });
    
    get_share_href();
    $('#whatsnewslider').on('slid.bs.carousel', function () {get_share_href();});
});

function get_share_href(){
 	  var $current = $('.item.active', '#whatsnewslider');
      if ($current){
      	var $href = $current.find('a').attr('href');
        //console.log($href);
        set_share_href($href);
      }
}

function set_share_href( $in ){
	$('#whatsnew-fb').attr('href', $('#whatsnew-fb').attr('data-temp') + encodeURIComponent($in) );
    $('#whatsnew-tw').attr('href', $('#whatsnew-tw').attr('data-temp') + encodeURIComponent($in) );
    $('#whatsnew-tw').attr('data-url', $in );
    $('#whatsnew-mail').attr('href', $('#whatsnew-mail').attr('data-temp') + encodeURIComponent($in) );
}

var gaClickCount = 1;
function gaTrack( $cat, $action, $label) {
	// ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue]
	ga('send', 'event', $cat, $action, $label, gaClickCount);
    console.log('tracked');
	gaClickCount++;
}

$(document).on('click', '#MoreWaystoPay', function(e){
	gaTrack('More Ways to Pay', 'clicked', window.location.href);
    console.log('clicked');
    return true;
});