// Initializes User Scripts:
$(document).ready(function() {
  
     // Selects text in Search Box when focused:
    $('input[type=text].clearText').each(function() {
        var txtSearchText = $(this).val();
        $(this).focus(function() {
            if ($(this).val() == txtSearchText) {
                $(this).val('');
            }
        });
        $(this).blur(function() {
            if ($(this).val() == '') {
                $(this).val(txtSearchText);
            }
        });
     });

  // Opens up links in new window.
  $('.lnkBlank').click(function() {
    window.open($(this).attr('href'), 'newWindow', '');
    return false;
  });

 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: 1,
      containerElement: "#theme",
      menuElement: "ul",
      rightArrow: " »"   
    });
   
  $('#topMenu li:has(ul)').hover(function(){
    $(this).addClass('over')
    
    },function(){
    $(this).removeClass('over')
      
      });
  
  });
  
       
      if ( $('.example2 p img').attr("src") == '' || $('.example2 p img').attr("src") == '/' || $('.example2 p img').attr("src") == '?w=150') {
       $('.example2').hide() } 
         
         $('.listItemImage').each(function(){
         if ( $(this).attr("src") == '' || $(this).attr("src") == '/' || $(this).attr("src") == '?w=150') {
       $(this).parent('.portfolioList2').hide() } 
         });
         
      if ( $('.ArticleSection_ListBriefDescription img').attr("src") == '' || $('.ArticleSection_ListBriefDescription img').attr("src") == '/' || $('.ArticleSection_ListBriefDescription img').attr("src") == '?w=150') {
       $('.itemFullDescription').css('width' , 'auto').css('min-height' , '0px') 
         $('.ArticleSection_ListBriefDescription img').hide() }
  

  // Init: Pixelsilk jQuery Modal for Video Links:
  $('a.videoLink').pixelsilkModal({
    contentType: 'iframe',
    fadeInSpeed: 300,
    fadeOutSpeed: 300,
    closeButtonHTML: '',
    modalWidth: 530,
    modalHeight: 330,
    keepInView: false
  });
         
});
