
MM_CColours = {
   cc: []
  ,el: null
  ,fx: null
  
  ,init: function()
  {
    this.el = new Element('div');
    this.fx = new Fx.Morph(this.el, {duration: 250});
    
    this.el.setStyles({
       opacity: 0
      ,top: 0
      ,left: 0
      ,height: 0
      ,width: 0
      ,position: 'absolute'
      ,border: '1px solid #999999'
      ,background: '#ffffff'
      ,overflow: 'hidden'
    });
    document.getElement('body').adopt(this.el);
    this.cc = document.getElements('img.leather_hover');
    this.cc.addEvent('mouseenter', function()
    {
      var imgSrc = this.src.replace(/w40\.h40\.croph/, 'w200.h137.croph');
      //'/media/Image/Generate/Modelle/Zubehoer/' + getCType().ucFirst() + '/' + this.name + '.w200.jpg';
      MM_CColours.displayInit(imgSrc, this);
    });
    this.cc.addEvent('mouseleave', function()
    {
      MM_CColours.el.setStyles({
         opacity: 0
        ,top: 0
        ,left: 0
        ,height: 0
        ,width: 0
      });
    });
  }
  
  ,actImg: ''
  ,actOrigin: null
  
  ,placeAtOrigin: function()
  {
    var coords = this.actOrigin.getCoordinates();
    
    this.el.setStyles({
       left: coords.left + 20
      ,top: coords.top - 147
      ,width: 200
      ,height: 137
    });
  }
  
  ,displayInit: function(img, origin)
  {
    this.actImg = img;
    this.actOrigin = origin;
    
    this.placeAtOrigin();

    new Asset.images([img], {
      onComplete: function()
      {
        var theImg = new Element('img', {src: this.img});
        MM_CColours.el.empty();
        MM_CColours.el.adopt(theImg);
        MM_CColours.fx.start({
           opacity: 1
          ,left: parseInt(MM_CColours.el.getStyle('left')) - 20
        });
      }.bind({img: img, origin: origin})
    });
  }
};
MM_CTypes = [];
function getCType()
{
  var e = MM_CTypes.length;
  for (var i = 0; i < e; i ++)
  {
    if (MM_CTypes[i].checked)
    {
      return MM_CTypes[i].get('value');
    }
  }
  
  return '';
}




window.addEvent('domready', function()
{
  MM_CTypes = document.getElements('input.img_select');
  MM_CColours.init();
});
