var rollover = {
 images: Object(),
 imagePath: { deere:   '/equipment/new/images/rollovers/deere/',
              hitachi: '/equipment/new/images/rollovers/hitachi/'
 },
 getPath: function($ul) {
  if ($ul.hasClass('deere')) {
   return rollover.imagePath.deere;  
  }
  else if ($ul.hasClass('hitachi')) {
   return rollover.imagePath.hitachi;						
  }
 },
 'select-a-product': '/equipment/new/images/rollovers/select-a-product.jpg'
};

$(document).ready(function(){
 $('.new-equipment .equipment-list a').each(function(i) {
  var $this = $(this),
       imagePath = rollover.getPath($this.parents('ul'));	   
  rollover.images[i] = new Image();
  rollover.images[i].src = imagePath+$.trim($this.text().stripVowelAccent().toLowerCase()).replace(/[^a-z0-9]/g,'-')+'.jpg';
  $this.hover(
   function() { $this.parents('.equipment-list').css({backgroundImage: 'url('+ rollover.images[i].src +')'}); },
   function() { $this.parents('.equipment-list').css({backgroundImage: 'url('+ rollover['select-a-product'] +')'}); }
  );
 });
});

String.prototype.stripVowelAccent = function () {
 return this.replace(/[\xC0-\xC2]/g,'A').replace(/[\xE0-\xE2]/g,'a').replace(/[\xC8-\xCA]/g,'E').replace(/[\xE8-\xEB]/g,'e').replace(/[\xCC-\xCE]/g,'I').replace(/[\xEC-\xEE]/g,'i').replace(/[\xEC-\xEE]/g,'i').replace(/[\xD2-\xD4]/g,'O').replace(/[\xF2-\xF4]/g,'o').replace(/[\xD9-\xDB]/g,'U').replace(/[\xF9-\xFB]/g,'u');
}  


