// 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") == '/' || $(this).attr("src").substr(0, 1) == '?' ) {
      $(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
    });
  }
  
  // Footer Links - pop up in new window / tab:
  $('a.lnkBlank').click(function() {
    window.open($(this).attr("href"), 'window2', '');
    return false;
  });
  
  pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']', path: ''}, function(html) {
    $("body").append('<div  id="subNavigation" style="display:none;"></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: "#retainer",
      menuElement: "ul",
      rightArrow: '&nbsp;»'
    });
    $("#Menu>li:has(ul)>a").prepend('<span  class="menu-sub-indicator">&nbsp;»</span>');
  });
});
