// 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;
    });

    pixelsilk.renderSkin('[' + '[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: ' »'
        });
    });

    $(".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();
    }
  
});
/*
$(window).load(function() {
  if ( $("#sectionBackgroundImage img").attr("src") != '' && $("#sectionBackgroundImage img").attr("src") != '/' ) {
    $("#contentInner").css("background-image", $("#sectionBackgroundImage img").attr("src"));
  }
});
*/

function faqToggle(id) {
  $("dl#faq dd#" + id).slideToggle("normal");
}