﻿var imgCache = [];

var NEL =
{
  init : function()
  {
    //home page rollovers
    $('.rollover a').hover(
      function() { $(this).children('p').slideDown(); },
      function() { $(this).children('p').slideUp(); });

    $('a.pu').click(function() { NEL.launchWindow($(this).attr('href')); return false; });
    
    //social media icons
    $('.sm img')
      .each(function()
      {
        NEL.preLoadImage($(this).attr('src'));
        $(this).attr('src', $(this).attr('src').replace('.png', '_bw.png'));
        NEL.preLoadImage($(this).attr('src'));
      });
    $('.sm')
      .hover(function()
      {
        var img = $(this).children('img');
        img.attr('src', img.attr('src').replace('_bw.png', '.png'));
      },
      function()
      {
        var img = $(this).children('img');
        img.attr('src', img.attr('src').replace('.png', '_bw.png'));
      });
  },

  launchWindow: function(url)
  {
     window.open(url, 'sgc_window');
  },
  
  preLoadImage: function(src)
  {
    var img = document.createElement('img');
    img.src = src;
    imgCache.push(img);
  }
}

