
MTJax.ImgSelect = {
  Images: [],
  initialize: function(el)
  {
    if (el.ImgSelectApplied) 
    {
      return;
    }
    
    el.ImgSelectApplied = true;
    this.Images = el.getElements('img');
    
    this.Images.each(function(el)
    {
      el.ImgSelect = this;
      el.setStyle('cursor', 'pointer');
      
      duration = 300;
      if (window.gecko || window.webkit) 
      {
        duration = 0;
      }
      el.StyleFx = new Fx.Tween(el, {
        property: 'border-color',
        duration: duration,
        wait: false
      });
      
      el.addEvent('click', function()
      {
        console.log('me clicking');
        Cart.update({
          name: this.parentNode.getAttribute('name'),
          value: this.getAttribute('name')
        });
        
        this.ImgSelect.Images.each(function(el)
        {
          el.removeClass('active');
          el.StyleFx;
          el.StyleFx.start('#ffffff');
        });
        
        this.addClass('active');
        this.StyleFx;
        this.StyleFx.start('#aaaaaa');
      });
      
      el.addEvent('mouseenter', function()
      {
        this.StyleFx;
        this.StyleFx.start('#ff0000');
      });
      
      el.addEvent('mouseleave', function()
      {
        this.StyleFx;
        if (this.hasClass('active')) 
        {
          this.StyleFx.start('#aaaaaa');
        }
        else 
        {
          this.StyleFx.start('#ffffff');
        }
      });
      
      
    }.bind(this));
  }
};


MTJax.ImgSelect = new Class(MTJax.ImgSelect);