// Initialize the Scripts for this site.
var searchBox = $('#search');
$(document).ready(function() {
  
  if ( document.URL.indexOf('EditListItem.aspx') > -1 ) $("body#page").css('overflow', 'auto');
    
    // Opens up links in new window.
    $("a[id!='onlineBanking']").each(function() {
      $(this).click(function() {
        if ( $(this).hasClass('lnkBlank') ) {
          alert('SVBT is not endorsing or guaranteeing the products, information, or recommendations provided by linked sites. SVBT is not liable for any failure of products or services advertised on those sites. Each third-party site may have a privacy policy different than SVBT. The linked third-party Web site may provide less security than the SVBT site.');
          window.open($(this).attr('href'), 'newWindow', '');
          return false;
        } else {
          var link = $(this).attr('href');
          if ( link.indexOf('southvalleybank.com') == -1 && link.indexOf('southvalleybank.net') == -1 && link.indexOf('https://online.homevalleybank.com') == -1 && (link.substr(0, 7) == 'http://' || link.substr(0, 8) == 'https://') ) {
              return confirm('SVBT is not endorsing or guaranteeing the products, information, or recommendations provided by linked sites. SVBT is not liable for any failure of products or services advertised on those sites. Each third-party site may have a privacy policy different than SVBT. The linked third-party Web site may provide less security than the SVBT site.');
          }
        }
      });
    });
  
    // Select the text in the search box:
    $('input.txtSearch').focus(function() {
        $(this).select();
    });
    
    // Hides list item images if no src is defined:
    $('img.listItemImage').each(function() {
        //if ($(this).attr('src') == '' || $(this).attr('src') == '?w=150') {
        //    $(this).hide();
        //}
      var img = $(this).attr("src");
      if ( typeof(img) == 'undefined' || img == '' || img == '/' || img.substr(0, 1) == '?' || img.substr(0, 2) == '/?' ) $(this).hide();
    });
    
    $('.staffInfoItem span.text').each(function() {
        if ($(this).html() == '') {
            $(this).parent().hide();
        }
    });
    
    searchBox.width(0);
    searchBox.height(0);
    /* Search Box */
    $('#openSearch').toggle(function() {
      searchBox.show();
      searchBox.animate({'width':'220px','height':'35px'}, 250);
      searchBox.find('input[type=text]').focus();
    }, function() {
      searchBox.animate({'width':'0','height':'0'}, 500, function() {
        $(this).hide();
      });
      searchBox.find('input[type=text]').blur();
    });
    
    // IE6 Detector plugin:
    $('body').ieDetector();
    
});

$(window).load(function() {
    resizeWindow();
    $(window).resize(function() {
        resizeWindow();
    });
    if ( $.browser.mozilla ) resizeWindow();
});

