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

  pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']', path: ''}, function(html) {
    $("#navigation").after('<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: 1,
      containerElement: "#container",
      menuElement: "ul",
      rightArrow: ' »'
    });
  });
  
  $("#updateNameBox").focus(function(){
    if($(this).val() == "Your Name") $(this).val("");
    if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
      $(this).css("background-color","#fff").css("color","#000");
    }
  }).blur(function(){
    if($(this).val() == "") $(this).val("Your Name");
    if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
      $(this).css("background-color","#918466").css("color","#E3DED1");
    }
  });
  $("#updateEmailBox").focus(function(){
    if($(this).val() == "Your Email Address") $(this).val("");
    if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
      $(this).css("background-color","#fff").css("color","#000");
    }
  }).blur(function(){
    if($(this).val() == "") $(this).val("Your Email Address");
    if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
      $(this).css("background-color","#918466").css("color","#E3DED1");
    }
  });
  
  $(".listItem .listItemImage").each(function() {
    if ( $(this).attr("src") == '' || $(this).attr("src") == '/' || $(this).attr("src") == '?w=150' ) {
      $(this).hide();
    }
  });
  $("img").each(function(){
    if($(this).attr("src") == '') $(this).hide();
  });
});
