// Initializes User Scripts:

$(document).ready(function() {

    // Selects text in Search Box when focused:
    $('input.txtSearch').focus(function() {
        this.select();
    });

    // Footer Links - pop up in new window / tab:
    $('a#smartzLink').click(function() {
        window.open($(this).attr("href"), 'window2', '');
        return false;
    });

    pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']'}, function(html) {
      $('#subNavigation').html(html);
      var sections = $('#subNavigation div');
      var topElements = $('#Menu li:not(.separator)');
      for (z = 0; z < sections.length; z++) {
        var li = topElements[z];
        var lihtml = li.innerHTML;
        li.innerHTML = lihtml + sections[z].innerHTML;
      }
      $('#Menu').navMenu({
        menuWidth: 200,
        containerElement: "#theme",
        containerWidth: 1000,
        menuElement: "ul",
        rightArrow: ' »'
      });
      $('#Menu > li:has(ul) > a').append('<img src="/spacer.gif" class="arrow" width="6" height="6" alt="" />');
      if ( $.browser.msie ) {
        $("a[href='http://www.volunteerconnectnow.org/volunteering/search-opportunities/']").click(function() {
          $(this).attr('href', 'https://volunteer.united-e-way.org/volunteerconnect/volunteer/search.aspx');
          return true;
        });
      }
    });

    $(".articleItemImage").each(function() {
        if ($(this).attr("src") == '' || $(this).attr("src") == '/' || $(this).attr("src") == '?w=150') {
            $(this).hide();
        }
    });
    if ($("#articleImage").attr("src") == '' || $("#articleImage").attr("src") == '/' || $("#articleImage").attr("src") == '?w=240') {
        $("#articleImage").hide();
    }
    if ($("#calendarImage").attr("src") == '' || $("#calendarImage").attr("src") == '/' || $("#calendarImage").attr("src") == '?w=400') {
        $("#calendarImage").hide();
    }

  if ( $("#subHead .inner").height() > 20 ) {
    $("#subHead .inner").css("padding-top", "13px");
  }
  
});
