
jQuery.preloadImages = function() {
  for (var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$(document).ready(function() {
  $('#mainnav img').each( function(i) {

    //hide all but first
    var src = $(this).attr('src');
    if (! src.match(/_active\.png/)) {
      var hrc = src.replace(/\.png/g, "_active.png");
      $.preloadImages(hrc);
      $(this).hover(
        function () {
          //alert(hrc);
          $(this).attr('src', hrc);
        }, 
        function () {
          $(this).attr('src', src);
        }
      );
    }

  });
});

function popup(id) {

  if ( $('#' + id).is(':hidden') )
    {
      $('.popupdiv').hide();
      $('#' + id).show().addClass('popupdiv');
    }
  else
    {
      $('#' + id).hide();
    }
 }


jQuery().ajaxStart(function() {
    $('#loader').show();
}).ajaxStop(function() {
    $('#loader').hide();
});


function load_product(id) {
  if (id>0) {
    $.ajax({

      url: "/cgi-bin/load_product.pl",
      data: "id=" + id,

      success: function(msg){

	  $("#desc").html(msg).show();
	
      }
   });

  }
}

