// Initializes User Scripts:
$(document).ready(function() {
  $("#theme").append('<div id="sparkler"><img src="/sparkler.jpg" width="340" height="352" alt="" /></div>');
  $('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:
  $("a.lnkBlank").click(function() {
    window.open($(this).attr("href"), 'window2', '');
    return false;
  });
  
  $("img").each(function() {
    var img = $(this).attr("src");
    if ( img == '' || img == '/' || img.substr(0, 1) == '?' ) $(this).hide();
  });

  pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']', path: ''}, function(html) {
    $("#siteMenu").after('<div id="subNavigation"></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;'
    });
  });
  
  if ( $("#rightColumn").height() > $("#mainColumn").height() ) {
    $("#mainColumn").height($("#rightColumn").height());
  }
});
