$(function() {

if ($('#nav-current').attr('src') != undefined) {
  var current = $('#nav-current'),
      src = current.attr('src'),
      newsrc = src.substr(0, src.lastIndexOf('.png')) + '_over.png';

  current.attr('src', newsrc);
}

$('#nav > li a').mouseover(function() {
  $(this).attr('class', 'hover');
}).mouseout(function() {
  $(this).attr('class', '');
});

$('#nav > li').mouseover(function() {
  
  var img = $(this).children('img')[0],
      src = img.getAttribute('src');
  if (img.getAttribute('id') != 'nav-current') {
    if (src.search('_over.png') == -1)
      var filename = src.substr(0, src.lastIndexOf('.png'))+'_over.png';
    else 
      var filename = src;
    img.setAttribute('src', filename);
  }
  $(this).attr('class', 'hover');

}).mouseout(function() {

  var img = $(this).children('img')[0],
      src = img.getAttribute('src');
  if (img.getAttribute('id') != 'nav-current') {
    if (src.search('_over.png') == -1)
      var filename = src;
    else 
      var filename = src.substr(0, src.lastIndexOf('_over.png'))+'.png';
    img.setAttribute('src', filename);
  }
  $(this).attr('class', 'nohover');

});

$('a.popup').click(function() {
  window.open($(this).attr('href'));
  return false;
});

});
