// Initializes User Scripts:

if (jQuery.jquery == '1.3.2') {
    jQuery.noConflict(true);
}

$(document).ready(function() {
    
    // Selects  text  in Search Box when focused:
     $('input.txtSearch').each(function() {
        var txtSearchText  = $(this).val();
        $(this).focus(function() {
            if ($(this).val() == txtSearchText) {
                $(this).val('');
            }
        });
        $(this).blur(function() {
              if ($(this).val() == '') {
                $(this).val(txtSearchText);
            }
        });
    });
    
    // Hides list item images if no src is defined:
    $('img.listItemImage').each(function() {
        if ($(this).attr('src') == '' || $(this).attr('src') == '?w=150') {
            $(this).hide();
        }
    });
    
    $('.staffInfoItem span.text').each(function() {
        if ($(this).html() == '') {
            $(this).parent().hide();
        }
    });
    
    // Load  the  slideshow if slides exist.
    if ($("#slideShow a").size() > 1) {
        $("#slideShow").cycle({
              timeout:    8000
        });
    }
    
    // Ability to let links pop up in new window / tab:
    if ( $(".lnkBlank").length ) {
      $(".lnkBlank").click(function() {
        window.open($(this).attr('href'), 'window2', '');
        return false;
      });
    }
    pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']', path: ''}, function(html) {
        $("body").append('<div id="subNavigation"></div>');
        $("#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: 175,
          containerElement: "#wrapper",
          menuElement: "ul",
          rightArrow: '&nbsp;»'
        });
    });
    // Left secondary menu
    $('#leftmain ul').navMenu({
      menuWidth: 207,
      containerElement: "#wrapper",
      menuElement: "ul",
      rightArrow: '&nbsp;»'
    });
    
});
