$(document).ready(function() {
  $('input.txtSearch').focus(function() {
    if ( $(this).val() == 'search' ) {
      $(this).val('');
    }
  });
  $('input.txtSearch').blur(function() {
    if ( $(this).val() == '' ) {
      $(this).val('search');
    }
  });


  // Links - pop up in new window / tab:
  $(".lnkBlank").click(function() {
    window.open($(this).attr("href"), 'window2', '');
    return false;
  });
  
  if ( document.URL.indexOf('EditListItem.aspx') == -1 ) {
    $("img").each(function() {
      var img = $(this).attr("src");
      if ( img == '' || img == '/' || img.substr(0, 1) == '?' || img.substr(0, 2) == '/?' || typeof(img) == 'undefined' ) $(this).hide();
    });
    $("img").error(function() {
      $(this).hide();
    });
  }
  
  pixelsilk2.renderSkin({skin: '[' + '[Menu1Dynamic]' + ']', path: ''}, function(html) {
    $("#siteMenu").after('<div id="subNavigation" style="display: none;"></div>');
    $("#subNavigation").html(html);
    var sections = $("#subNavigation div");
    var topElements = $("#topMenu li:not(.separator)");
    for (z = 0; z < sections.length; z++) {
      var li = topElements[z];
      var lihtml = li.innerHTML;
      li.innerHTML = lihtml + sections[z].innerHTML;
    }
    $("#topMenu").navMenu({
      menuWidth: 250,
      containerElement: "#theme",
      menuElement: "ul",
      rightArrow: ' &raquo;'
    });
    $("#subNavigation").remove();
  });
  
  $('#slideShow').cycle();
});


