function ucfirst (str) {
    // Makes a string's first character uppercase  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/ucfirst    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: ucfirst('kevin van zonneveld');
    // *     returns 1: 'Kevin van zonneveld'    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}

MM_CoatChoose = {
   assets: {}
   
  ,elMenuA: null
  ,elMenuB: null
  ,elPane: null
  ,elInfo: null
  ,elTrigger: null
  
  ,onId: null
  
  ,coats: {}
  ,boards: {}
  ,chooseBy: null
  ,chooseById: null
  ,coat: null
  ,menu: null
  
  ,actCoats: null
  
  ,elsMenuATrigger: []
  ,elsMenuBTrigger: []
  
  ,tileW: 130
  ,tileY: 50
  ,tileSh: 15
  ,tileSv: 0
  ,tileT: 12
  ,tileTPadV: 2
  ,tileTPadH: 3
  
  ,tilesX: 3
  ,tilesY: 18
  ,tileSpanY: 3
  
  ,tilesW: 590
  ,tilesH: 270
    
  ,elA: null
  ,elB: null
  
  ,setViewSplitAt: function(menuWidth)
  {
    var panCoord = this.thePanel.getCoordinates();
    console.log('setViewSplitAt(): panCoord: ', panCoord);
    var maxWidth = panCoord.width;
    var paneWidth = maxWidth - menuWidth - 20;
    this.elA.setStyle('width', menuWidth);
    this.elB.setStyle('width', paneWidth);
    
    this.elPane.setStyle('width', paneWidth);
    this.elInfo.setStyle('width', paneWidth);
  }
  
  ,init: function(trigger, panel)
  {
    console.log('MM_CoatChoose.init');
    console.log(arguments);
    var theTrigger = arguments[0] ? arguments[0] : MT_Lightshow.source;
    if (!theTrigger.hasClass('coatChoose') && !theTrigger.hasClass('coatPresenter'))
    {
      console.log('missing class `coatChoose`');
      return;
    }
    var thePanel = arguments[1] ? arguments[1] : MT_Lightshow.theLayer.elementInner;
    this.thePanel = thePanel;
    var menuWidth = 150;    
    var panCoord = thePanel.getCoordinates();
    console.log('panCoord: ', panCoord);
    var maxWidth = panCoord.width;
    var paneWidth = maxWidth - menuWidth - 20;

    var a = new Element('div', {styles: {'float': 'left', width: menuWidth, fontSize: 12}});
    var b = new Element('div', {styles: {'float': 'right', width: paneWidth}});
    var c = new Element('div', {styles: {clear: 'both'}});
    this.elA = a;
    this.elB = b;

    if (paneWidth < 600)
    {
      paneWidth = maxWidth;
      a.setStyles({
         'float': 'none'
        ,width: 'auto'
      });
      b.setStyles({
         'float': 'none'
        ,width: 'auto'
      });
    }
        
    
    thePanel.adopt(a, b, c);
    
    this.elMenuA  = new Element('div', {styles: {marginBottom: 10}});
    this.elMenuB  = new Element('div', {styles: {clear: 'both'}});
    this.elPane   = new Element('div', {styles: {'float': 'left', width: paneWidth, height: 350, overflow: 'hidden'}});
    this.elInfo   = new Element('div', {styles: {'float': 'left', width: paneWidth, paddingTop: 20, height: 180, overflow: 'hidden', fontSize: 12}});
    
    a.adopt(this.elMenuA, this.elMenuB);
    b.adopt(this.elPane, this.elInfo);
    
    this.calcTileSizes();
    
    this.elTrigger  = theTrigger;
    this.onId       = this.elTrigger.get('id');
    
    console.log('this.assets[this.onId]', this.assets[this.onId]);
    if (!this.assets[this.onId])
    {
      window.setTimeout(this.init.bind(this), 200);
      return;
    }
    
    this.coats      = this.assets[this.onId]['coats']       ? this.assets[this.onId].coats            : {};
    this.boards     = this.assets[this.onId]['boards']      ? this.assets[this.onId].boards           : {};
    this.chooseBy   = this.assets[this.onId].lastChooseBy   ? this.assets[this.onId].lastChooseBy     : null;
    this.chooseById = this.assets[this.onId].lastChooseById ? this.assets[this.onId].lastChooseById   : null;
    this.coat       = this.assets[this.onId].lastCoat       ? this.assets[this.onId].lastCoat         : null;
    this.onUId      = this.assets[this.onId].uId            ? this.assets[this.onId].uId              : null;
    this.furnType   = this.assets[this.onId].furnType       ? this.assets[this.onId].furnType         : null;
    this.menu       = this.assets[this.onId].menu           ? this.assets[this.onId].menu             : {};
    this.unClickable  = this.assets[this.onId].unClickable    ? this.assets[this.onId].unClickable          : false;
    this.sampleUid    = this.assets[this.onId].sampleUid      ? this.assets[this.onId].sampleUid            : null;
    this.allowSamples = this.assets[this.onId].allowSamples   ? this.assets[this.onId].allowSamples         : false;
    this.menuAText    = this.assets[this.onId].menuAText      ? this.assets[this.onId].menuAText + '<br />' : '';
    this.changeEvent  = this.assets[this.onId].changeEvent    ? this.assets[this.onId].changeEvent          : '';
    
    this.elMenuA.set('html', this.menuAText + '<div class="inner"></div><div style="clear: both;"></div>');
    
    if (!this.chooseById) { alert('this.chooseById is empty ... PANIC!'); MT_Layer.theBlend.evtClose(); return; }
    this.chooseBoard  = this.chooseBy + this.chooseById;
    
    this.buildMenuA();
    var board = this.buildMenuB(this.chooseBy);
    this.buildPane(board);
  }
  
  ,calcTileSizes: function()
  {
    this.tilesW = parseInt(this.elPane.getStyle('width'));
    this.tilesH = parseInt(this.elPane.getStyle('height'));
    
    this.tileW = Math.floor((this.tilesW - this.tileSh * this.tilesX * 1) / this.tilesX);
    this.tileH = Math.floor((this.tilesH - this.tileSv * this.tilesY * 1) / this.tilesY);
  }
  
  ,buildMenuA: function()
  {
    var parent = this.elMenuA.getElement('.inner');
    parent.empty();
    
    var entries = 0;
    for (k in this.menu)
    {
      entries++;
      var menuItem = this.menu[k];
      var el = new Element('div');
      this.elsMenuATrigger.push(el);
      el.setStyles({
         cursor: 'pointer'
        ,fontWeight: k == this.chooseBy ? 'bold' : 'normal'
        ,'float': 'left'
        ,width: 150
      })
      el.set('text', '>> ' + menuItem.title);
      el.set('id', k);
      
      el.addEvent('click', function()
      {
        var board = MM_CoatChoose.buildMenuB(this.get('id'));
        MM_CoatChoose.elsMenuATrigger.each(function(el){ el.setStyle('font-weight', 'normal'); }); 
        this.setStyle('font-weight', 'bold');
        MM_CoatChoose.buildPane(board);
      })
      
      parent.adopt(el);
    }
    console.log('entries', entries);
    if (1 == entries)
    {
      parent.getParent().set('html', '');
    }
  }
  
  ,buildMenuB: function(key)
  {
    this.elsMenuBTrigger = [];
    var isFloat = this.elMenuB.getParent().getStyle('float');
    this.elMenuB.setStyles({
      border: '1px solid blue'
     ,borderWidth: '0 0px'
     ,overflow: 'auto'
    });
    if ('none' != isFloat)
    {
      this.elMenuB.setStyles({
        height: 570 - (parseInt(this.elMenuA.getStyle('height')) + parseInt(this.elMenuA.getStyle('margin-bottom')))
      });
    }
    else
    {
      this.elMenuB.setStyles({
        marginBottom: 10
      }); 
    }
    
    this.chooseBy = key;
    var parent = this.elMenuB;
    var act = this.chooseBoard;
    parent.empty();
    
    if (!this.menu[key]) return;
    console.log('buildMenuB', this.menu[key]);
    if (this.menu[key].items.types)
    {
      var
        e     = this.menu[key].items.types.length,
        found = false;
      
      for (var t = 0; t < e; t++)
      {
        var type = this.menu[key].items.types[t];
        if (this.menu[key].items[type][act])
        {
          found = true;
          break;
        }
      }
      if (!found)
      {
        for (k in this.menu[key].items[this.menu[key].items.types[0]]) 
        {
          act = k;
          break;
        } 
      }    
    
      for (var t = 0; t < e; t++)
      {
        var type    = this.menu[key].items.types[t];
        var label   = new Element('div');
        var parent2 = new Element('div');
        label.set('text', type);
        label.setStyles({
          fontWeight: 'bold'
          ,clear: 'both'
        });
        parent2.setStyles({
           paddingLeft: 10
          ,marginBottom: 10
        });
        parent.adopt(label);
        parent.adopt(parent2);
         
        for (k in this.menu[key].items[type])
        {
          this.buildPaneB_addItem(this.menu[key].items[type][k], parent2, act, 60);
        }  
      }
    }
    else
    {
      if (!this.menu[key].items[act])
      {
        for (k in this.menu[key].items) 
        {
          act = k;
          break;
        } 
      }
    
    
      for (k in this.menu[key].items)
      {
        this.buildPaneB_addItem(this.menu[key].items[k], parent, act);
      } 
    }
    
    return act;
  }
  
  ,buildPaneB_addItem: function(menuItem, parent, act, width)
  {
    var el = new Element('div');
    var pad = 28;
    width = arguments[3] ? parseInt(arguments[3]) : 150;
    this.elsMenuBTrigger.push(el);
    
    el.setStyles({
       cursor: 'pointer'
      ,fontWeight: k == act ? 'bold' : 'normal'
      ,'float': 'left'
      ,width: width
    })
    
    if (menuItem.image)
    {
      el.setStyles({
         paddingLeft: pad
        ,background: 'url(' + Util.scaleImage(menuItem.image, 'w20.h10.croph') + ') 0 3px no-repeat'
        ,width: width - pad
      })
    }
          
    el.set('text', menuItem.title);
    el.set('id', k);
    
    el.addEvent('click', function()
    {
      MM_CoatChoose.elsMenuBTrigger.each(function(el){ el.setStyle('font-weight', 'normal'); }); 
      this.setStyle('font-weight', 'bold');
      MM_CoatChoose.buildPane(this.get('id'));
    })
    
    parent.adopt(el);
  }

  ,buildPane: function(key)
  {
    console.log('buildPane for: ', key);
    this.elInfo.set('text', '');
    this.elMenuB.setStyle('display', 'block');
    this.chooseBoard  = key;
    this.chooseById   = key.replace(/\D/g, '');
    this.elPane.empty();
    if (!this.boards[key]) return;
    this.actCoats = this.boards[key];

    console.log('buildPane Style: ', this.chooseBy);
    switch (this.chooseBy)
    {
      case 'fw' :
        this.tileSh = 15;
        this.tileSv = 0;
        this.tilesX = 3;
        this.tilesY = 18;
        this.tileSpanY = 3;
        this.buildPane_Fw();
        this.elPane.setStyles({
           overflow: 'hidden'
          ,width: this.tilesW
        })
        break;
      case 'ffw' :
        this.tileSh = 15;
        this.tileSv = 0;
        this.tilesX = 3;
        this.tilesY = 19;
        this.tileSpanY = 3;
        this.buildPane_FFw();
        this.elPane.setStyles({
           overflow: 'hidden'
          ,width: this.tilesW
        })
        break;
      case 'wood' :
        this.tileSh = 15;
        this.tileSv = 0;
        this.buildPane_Wood();
        this.elPane.setStyles({
           overflow: 'hidden'
          ,width: this.tilesW
        })
        break;
      case 'steel' :
        this.tileSh = 15;
        this.tileSv = 0;
        this.buildPane_Steel();
        this.elPane.setStyles({
           overflow: 'hidden'
          ,width: this.tilesW
        })
        break;
      default :
        this.tileSh = 15;
        this.tileSv = 0;
        this.buildPane_Def();
        this.elPane.setStyles({
           overflow: 'auto'
          ,width: this.tilesW
        })
        break;
    }

    window.fireEvent('reInitTips');
  }
  
  ,buildPane_Steel: function()
  {
    this.setViewSplitAt(220);
    this.elInfo.setStyle('width', 220);
    
    this.elPane.setStyle('height', 560);
    this.elMenuB.setStyle('display', 'none');
    this.elA.adopt(this.elInfo);

    this.tilesX     = 3;
    this.tileSpanY  = 6;
    this.calcTileSizes();
  
    
    var e = this.actCoats.length;
    var first = null;
    var active = null;
    for (var i = 0; i < e; i++)
    {
      var coat = this.coats[this.actCoats[i]];
      var tmp = new MC_Coat(coat, this.elPane, 1, this.tileSpanY);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (!active)
    {
      first.element.fireEvent('mouseenter');
    }
    
    
    var poser = new MC_CoatPoser(this.elPane, 3, 10);
    var scale = 'w' + parseInt(poser.element.getStyle('width')) + '.h' + parseInt(poser.element.getStyle('height'));
    poser.element.set('id', 'steel-preview');
    poser.element.setStyles({
       background: 'url(/media/_generate/masscouch/common/fuesse/seria-straight-steel-corners.w590.h220.croph.jpg) top left no-repeat'
      ,'float': 'left'
      ,position: 'relative'
      ,marginRight: this.tileSh
    });
    poser.element.set('html', '&nbsp;');
  }
  
  ,buildPane_Wood: function()
  {
    this.setViewSplitAt(220);
    this.elInfo.setStyle('width', 220);
    this.elInfo.setStyles({
       padding: 0
      ,paddingTop: 110
      ,width: 200
      ,height: 300
    });
    
    this.elPane.setStyle('height', 560);
    this.elMenuB.setStyle('display', 'none');
    this.elA.adopt(this.elInfo);

    this.tilesX = 4;
    this.tilesY = 24;
    this.tileSpanY  = 3;
    this.calcTileSizes();
    
    
    var poser = new MC_CoatPoser(this.elPane, 2, 8);
    var scale = 'w' + parseInt(poser.element.getStyle('width')) + '.h' + parseInt(poser.element.getStyle('height'));
    poser.element.setStyles({
       background: 'url(' + Util.scaleImage(this.getFWInfo('imageMood'), scale) + ') top left no-repeat'
      ,'float': 'left'
      ,position: 'relative'
      ,marginRight: this.tileSh
    });
    poser.element.set('html', '&nbsp;');
  
    
    var e = this.actCoats.length;
    var first = null;
    var active = null;
    for (var i = 0; i < e; i++)
    {
      var coat = this.coats[this.actCoats[i]];
      var tmp = new MC_Coat(coat, this.elPane, 1, this.tileSpanY);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (!active)
    {
      first.element.fireEvent('mouseenter');
    }
  }
  
  ,buildPane_Def: function()
  {
    var e = this.actCoats.length;
    var first = null;
    var active = null;
    for (var i = 0; i < e; i++)
    {
      var coat = this.coats[this.actCoats[i]];
      var tmp = new MC_Coat(coat, this.elPane, 1, this.tileSpanY);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (!active)
    {
      first.element.fireEvent('mouseenter');
    } 
  }
  
  ,tileGrid: []
  ,tileNum: 0
  ,tilesCoated: 0
  
  ,tileWidth: [
     [1]
    ,[{x:2,y:4}]
    ,[{x:2,y:3},{x:2,y:3}]
    ,[{x:2,y:2},{x:2,y:1},{x:2,y:1}]
    ,[{x:2,y:2},{x:2,y:1},{x:2,y:1},{x:2,y:2}]
    ,[{x:2,y:2},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1}]
    ,[{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1}]
    ,[{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:1,y:1},{x:1,y:1}]
    ,[{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1}]
    ,[{x:2,y:1},{x:2,y:1},{x:2,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1}]
    ,[{x:2,y:1},{x:2,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1}]
    ,[{x:2,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1}]
    ,[{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1},{x:1,y:1}]
  ]
  
  ,tileCoords: [
     {x:0,y:0}
    ,{x:1,y:0}
    ,{x:0,y:1}
    ,{x:1,y:1}
    ,{x:0,y:2}
    ,{x:1,y:2}
    ,{x:0,y:3}
    ,{x:1,y:3}
    
    ,{x:3,y:0}
    ,{x:4,y:0}
    ,{x:3,y:1}
    ,{x:4,y:1}
    ,{x:3,y:2}
    ,{x:4,y:2}
    ,{x:3,y:3}
    ,{x:4,y:3}
  ]
  
  ,tileProps: function(x, y)
  {
    var p = {
       id: 0
      ,x: 1
      ,y: 1
      ,w: 1
      ,h: 1
      ,append: null
      ,doFloat: 'left'
      ,doClear: 'none'
    };
    
    var base = 12;
    var have = this.actCoats.length;
    var widths = this.tileWidth[have];
    var coords = this.tileCoords[this.tilesCoated];
    var stdX = 1;
    var xy = widths[this.tileNum];
    p.id = this.tileNum;
    this.tileNum ++;
    p.w = xy.x;
    p.h = xy.y;
    p.x = coords.x;
    p.y = coords.y;
    this.tilesCoated += xy.x * xy.y;
   
    switch (this.tilesCoated)
    {
      case 4 :
        p.append = this.TILE_INFO;
        this.tilesCoated += 2;
        break;
        
      case 10 :
        p.append = this.TILE_MOOD;
        this.tilesCoated += 2;
        break;
        
      case 12 :
        p.append = this.TILE_TAG;
        break;
    }
     
    return p;
  }
  
  ,tiles: null
  
  ,tileDist: [
     []
    ,[]
    ,[]
    ,[]
    ,[   2,                    11, 12,     14]
    ,[1,       5,       9,     11,     13    ]
    ,[   2,    5,       9,     11, 12,     14]
    ,[   2, 4,    6, 8,    10,     12,     14]
    ,[1,    4,    6, 8, 9, 10, 11,     13    ]
    ,[1,    4, 5, 6, 8, 9, 10, 11,     13    ]
    ,[1, 2, 4, 5, 6, 8, 9, 10,     12, 13    ]
    ,[1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13    ]
    ,[1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14]
  ]
  
  ,tileDist2: [
     null
    ,null
    ,null
    ,null
    ,['1,1,1,9', '1,3', '2,3,1,5', '3,1,1,9', '1,10,1,9', '2,10,1,9', '3,10,1,9']
    ,['1,5,1,6', '1,2', '2,9,2,3', '2,1,1,7', '3,1,1,7' , '1,12,1,7', '2,12,1,7', '3,12,1,7']
    ,['1,7,1,5', '1,3', '2,7,1,6', '2,1,1,6', '3,1,1,6' , '3,7,1,6' , '1,13,1,6', '2,13,1,6', '3,13,1,6']
    ,['1,8,1,4', '1,7', '2,7,1,6', '1,1,1,6', '2,1,1,6' , '3,1,1,6' , '3,7,1,6' , '1,13,1,6', '2,13,1,6', '3,13,1,6']
    ,['1,7,1,7', '1,6', '2,7,1,6', '1,1,1,5', '2,1,1,5' , '3,1,1,5' , '3,6,1,4' , '3,10,1,4', '1,14,1,5', '2,14,1,5', '3,14,1,5']
    ,['1,5,1,5', '1,3', '2,6,1,4', '2,1,1,4', '3,1,1,4' , '3,6,1,4' , '1,11,1,4', '2,11,1,4', '3,11,1,4', '1,15,1,4', '2,15,1,4', '3,15,1,4']
    ,['1,6,1,5', '1,6', '2,6,1,4', '1,1,1,4', '2,1,1,4' , '3,1,1,4' , '3,6,1,4' , '1,11,1,4', '2,11,1,4', '3,11,1,4', '1,15,1,4', '2,15,1,4', '3,15,1,4']
    ,['1,6,1,5', '1,5', '2,5,1,6', '1,1,1,4', '2,1,1,4' , '3,1,1,4' , '3,5,1,3' , '3,8,1,3' , '1,11,1,4', '2,11,1,4', '3,11,1,4', '1,15,1,4', '2,15,1,4', '3,15,1,4']
    ,['1,6,1,7', '1,5', '2,6,1,6', '1,1,1,3', '2,1,1,3' , '3,1,1,3' , '3,4,1,3' , '3,7,1,3' , '3,10,1,3' , '1,13,1,3', '2,13,1,3', '3,13,1,3', '1,16,1,3', '2,16,1,3', '3,16,1,3']
    ,['1,6,1,7', '1,5', '2,6,1,4', '1,1,1,3', '2,1,1,3' , '3,1,1,3' , '3,4,1,3' , '3,7,1,3' , '2,10,1,3' , '3,10,1,3' , '1,13,1,3', '2,13,1,3', '3,13,1,3', '1,16,1,3', '2,16,1,3', '3,16,1,3']
    ,['1,4,1,6', '1,5', '2,6,1,4', '1,1,1,3', '2,1,1,3' , '3,1,1,3' , '3,4,1,3' , '3,7,1,3' , '1,10,1,3' , '2,10,1,3' , '3,10,1,3' , '1,13,1,3', '2,13,1,3', '3,13,1,3', '1,16,1,3', '2,16,1,3', '3,16,1,3']
  ]
  
  ,tileDist3: [
     null
    ,['2,2,1,5', '1,2', '1,8,1,6', '2,8,1,6']
    ,['2,2,1,5', '1,2', '1,8,1,6', '2,8,1,6', '2,14,1,6']
    ,['2,2,1,5', '1,2', '1,8,1,6', '2,8,1,4', '2,12,1,4', '2,16,1,4']
    ,['2,2,1,5', '1,2', '1,8,1,6', '2,8,1,3', '2,11,1,3', '2,14,1,3', '2,17,1,3']
    ,['2,2,1,5', '1,2', '1,8,1,6', '2,8,1,2', '2,10,1,2', '2,12,1,2', '2,14,1,2', '2,16,1,2']
  ]
  
  ,parseTilePos: function(tp, tiles)
  {
    var o = {
      x: null
      ,y: null
      ,h: null
      ,w: null
      ,el: null
      ,elIdx: null
    }
    var pos = tp.split(/,/);
    o.x = parseInt(pos[0]);
    o.y = parseInt(pos[1]);
    if (pos[2]) o.w = parseInt(pos[2]);
    if (pos[3]) o.h = parseInt(pos[3]);
    o.elIdx = -3 + (3 * o.y) + -1 + (o.x);
    o.el = tiles[o.elIdx];
    
    return o
  }
  
  ,buildPane_Fw: function()
  {
    this.tileW = Math.floor((this.tilesW) / this.tilesX);
    this.tileH = Math.floor((this.tilesH) / this.tilesY);
    
    var bor = 0;
    var zIndex = 10 + (this.tilesY * this.tilesX);
    for (var y = 0; y < this.tilesY; y++)
    {
      for (var x = 0; x < this.tilesX; x++)
      {
        var cell = new Element('div');
        cell.setStyles({
           width: this.tileW - (2*bor) - this.tileSh
          ,height: this.tileH - (2*bor)
          ,'float': 'left'
          ,border: bor + 'px solid blue'
          ,marginRight: (x == this.tilesX - 1) ? 0 : this.tileSh
          ,position: 'relative'
          ,zIndex: zIndex--
        });
        this.elPane.adopt(cell);
      }
    }
    
    this.tileW = Math.floor((this.tilesW - this.tileSh * this.tilesX * 1) / this.tilesX);
    
    var theTiles = this.elPane.getChildren();
    
    if (!this.tileDist2[this.actCoats.length]) return;
    var tileDist = this.tileDist2[this.actCoats.length];
    var e = tileDist.length;
    var first = null;
    var active = null;
    for (var i = 3; i < e; i ++)
    {
      var tile = this.parseTilePos(tileDist[i], theTiles);
      var coat = this.coats[this.actCoats[i - 3]];
      var tmp = new MC_Coat(coat, tile.el, tile.w, tile.h);
      tmp.element.setStyles({
         zIndex: 5
        ,margin: 0
        ,position: 'absolute'
        ,top: 0
        ,left: 0
        ,zIndex: 5
      });
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (!active)
    {
      first.element.fireEvent('mouseenter');
    }
    
    
    if (this.haveFWInfo('imageMood'))
    {
      var tile = this.parseTilePos(tileDist[0], theTiles);
      var poser = new MC_CoatPoser(tile.el, tile.w, tile.h);
      var scale = 'w' + parseInt(poser.element.getStyle('width')) + '.h' + parseInt(poser.element.getStyle('height'));
      poser.element.setStyles({
         background: 'url(' + Util.scaleImage(this.getFWInfo('imageMood'), scale) + ') center center no-repeat'
        ,'float': 'left'
        ,position: 'absolute'
        ,top: 0
        ,left: 0
        ,zIndex: 5
      });
      poser.element.set('html', '&nbsp;');
    }
    
    if (this.haveFWInfo('desc'))
    {
      var title = this.getFWInfo('tagLine');
      if (title)
      {
        title = '<strong style="display: block; margin-bottom: 2px; font-weight: bold;">' + title + '</strong>';
      }
      var tile = this.parseTilePos(tileDist[2], theTiles);
      var poser = new MC_CoatPoser(tile.el, tile.w, tile.h);
      poser.element.set('html', title + this.getFWInfo('desc').replace(/\n/, '<br />'));
      poser.element.setStyles({
         overflow: 'hidden'
        ,fontSize: 11
        ,textAlign: 'justify'
        ,position: 'absolute'
        ,top: 0
        ,left: 0
        ,zIndex: 5
      });
    }
    
    
    var tile = this.parseTilePos(tileDist[1], theTiles);
    var poser = new MC_CoatPoser(tile.el, 1, 1);
    poser.element.set('html', this.getFWInfo('title'));
    poser.element.setStyles({
       overflow: 'hidden'
      ,fontSize: 15
      ,fontWeight: 'bold'
      ,textAlign: 'justify'
      ,color: '#666666'
      ,position: 'absolute'
      ,top: 0
      ,left: 20
    });
  }
  
  ,buildPane_FFw: function()
  {
    this.setViewSplitAt(220);
    this.elInfo.setStyle('width', 220);
    
    this.elPane.setStyle('height', 560);
    //this.elMenuB.setStyle('display', 'none');
    //this.elA.adopt(this.elInfo);

    //this.tilesX     = 3;
    //this.tileSpanY  = 6;
    this.calcTileSizes();
    
    var bor = 0;
    var zIndex = 10 + (this.tilesY * this.tilesX);
    for (var y = 0; y < this.tilesY; y++)
    {
      for (var x = 0; x < this.tilesX; x++)
      {
        //console.log('create Tile:', x, y);
        var cell = new Element('div');
        cell.setStyles({
           width: this.tileW - (2*bor)
          ,height: this.tileH - (2*bor)
          ,'float': 'left'
          ,border: bor + 'px solid blue'
          ,marginRight: (x == this.tilesX - 1) ? 0 : this.tileSh
          ,position: 'relative'
          ,zIndex: zIndex--
        });
        this.elPane.adopt(cell);
      }
    }
    
    var theTiles = this.elPane.getChildren();
    var first = null;
    var active = null;
    
    if (!this.tileDist3[this.actCoats.length]) return;
    var tileDist = this.tileDist3[this.actCoats.length];
    var e = tileDist.length;
    for (var i = 3; i < e; i ++)
    {
      var tile = this.parseTilePos(tileDist[i], theTiles);
      var coat = this.coats[this.actCoats[i - 3]];
      var tmp = new MC_Coat(coat, tile.el, tile.w, tile.h);
      tmp.element.setStyles({
         zIndex: 5
        ,margin: 0
        ,position: 'absolute'
        ,top: 0
        ,left: 0
        ,zIndex: 5
      });
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (this.haveFWInfo('imageMood'))
    {
      var tile = this.parseTilePos(tileDist[0], theTiles);
      var poser = new MC_CoatPoser(tile.el, tile.w, tile.h);
      var scale = 'w' + parseInt(poser.element.getStyle('width')) + '.h' + parseInt(poser.element.getStyle('height'));
      poser.element.setStyles({
         background: 'url(' + Util.scaleImage(this.getFWInfo('imageMood'), scale) + ') center center no-repeat'
        ,'float': 'left'
        ,position: 'absolute'
        ,top: 0
        ,left: 0
        ,zIndex: 5
      });
      poser.element.set('html', '&nbsp;');
    }
    
    
    var poser = new MC_CoatPoser(theTiles[2], 1, 1);
    poser.element.setStyles({
      fontWeight: 'bold'
    });
    poser.element.set('html', 'Edelstahl');
    
    
    var tile = this.parseTilePos(tileDist[1], theTiles);
    var poser = new MC_CoatPoser(tile.el, 1, 3);
    poser.element.set('html', '<div style="font-weight: bold; font-size: 15px; padding-left: 20px;">' + this.getFWInfo('title') + '</div><div style="margin-top: 10px; padding-left: 20px;">Zur ausgewählten Farbwelt empfehlen wir die passenden Fußoptiken</div>');
    poser.element.setStyles({
       overflow: 'hidden'
      ,textAlign: 'justify'
      ,color: '#666666'
    });
    
    
    var tile = this.parseTilePos(tileDist[2], theTiles);
    var poser = new MC_CoatPoser(tile.el, 1, 10);
    poser.element.adopt(this.elInfo);
    this.elInfo.setStyles({
       padding: 0
      ,width: 'auto'
      ,height: 'auto'
    });
    
    
    
  
    var feet = this.assets[this.onId].boards.steel1;
    var e = feet.length;
    for (var i = 0; i < e; i++)
    {
      var coat = this.coats[feet[i]];
      var tile = this.parseTilePos('3,' + (2 + i * 6) + ',1,6', theTiles);
      var tmp = new MC_Coat(coat, tile.el, 1, 6);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
        active = tmp;
      }
      if (!first)
      {
        first = tmp;
      }
    }
    
    if (!active)
    {
      first.element.fireEvent('mouseenter');
    }
  }
  
  ,buildPane_Fw4: function()
  {
    this.tileW = Math.floor((this.tilesW) / this.tilesX);
    this.tileH = Math.floor((this.tilesH) / this.tilesY);
    
    for (var y = 0; y < this.tilesY; y++)
    {
      for (var x = 0; x < this.tilesX; x++)
      {
        var cell = new Element('div');
        cell.setStyles({
           width: this.tileW
          ,height: this.tileH
          ,'float': 'left'
        });
        this.elPane.adopt(cell);
      }
    }
    
    this.tileW = Math.floor((this.tilesW - this.tileS * this.tilesX * 1) / this.tilesX);
    this.tileH = Math.floor((this.tilesH - this.tileS * this.tilesY * 1) / this.tilesY);
    
    var theTiles = this.elPane.getChildren();
    
    var tileDist = this.tileDist[this.actCoats.length];
    var e = tileDist.length;
    for (var i = 0; i < e; i ++)
    {
      var coat = this.coats[this.actCoats[i]];
      var tmp = new MC_Coat(coat, theTiles[tileDist[i]], 1, 1);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
      }
    }
    
    
    if (this.haveFWInfo('imageMood'))
    {
      var poser = new MC_CoatPoser(theTiles[0], 1, 2);
      var scale = 'w' + parseInt(poser.element.getStyle('width')) + '.h' + parseInt(poser.element.getStyle('height'));
      poser.element.setStyles({
         background: 'url(' + Util.scaleImage(this.getFWInfo('imageMood'), scale) + ') center center no-repeat'
        ,'float': 'left'
      });
      poser.element.set('html', '&nbsp;');
    }
    
    if (this.haveFWInfo('desc'))
    {
      var poser = new MC_CoatPoser(theTiles[7], 1, 1);
      poser.element.set('html', this.getFWInfo('desc').replace(/\n/, '<br />'));
      poser.element.setStyles({
         overflow: 'hidden'
        ,fontSize: 11
        ,textAlign: 'center'
        ,position: 'relative'
        ,top: -10
        ,left: 0
        ,height: parseInt(poser.element.getStyle('height')) + 15
      });
    }
  }
  
  ,buildPane_Fw3: function()
  {
    if (this.haveFWInfo('imageMood'))
    {
      var poser = new MC_CoatPoser(this.elPane, parseInt(this.getFWInfo('imageMoodX')), parseInt(this.getFWInfo('imageMoodY')));
      poser.element.setStyles({
         background: 'url(' + Util.scaleImage(this.getFWInfo('imageMood'), poser.getScale()) + ') center center no-repeat'
        ,'float': 'left'
      });
      poser.element.set('html', '&nbsp;');
    }
    
    
    var e = this.actCoats.length;
    for (var i = 0; i < e; i++)
    {
      if (this.shallPlace('desc', i, e) && this.haveFWInfo('desc'))
      {
        var poser = new MC_CoatPoser(this.elPane, 1, 1);
        poser.element.set('text', this.getFWInfo('desc'));
        poser.element.setStyles({
           'float': 'left'
          ,overflow: 'hidden'
          ,fontSize: 11
        });
      }
      
      if (this.shallPlace('tagLine', i, e) && this.haveFWInfo('tagLine'))
      {
        var poser = new MC_CoatPoser(this.elPane, 1, 1);
        poser.element.set('html', '<div style="padding-top: 20px;">' + this.getFWInfo('tagLine') + '</div>');
        poser.element.setStyles({
           'float': 'left'
          ,overflow: 'hidden'
          ,textAlign: 'center'
        }); 
      }
      
      var coat = this.coats[this.actCoats[i]];
      var tmp = new MC_Coat(coat, this.elPane, 1, 1);
      if (coat.itemId == this.coat) 
      {
        tmp.element.fireEvent('mouseenter');
        tmp.element.fireEvent('mouseleave');
      }
    }
  }
  
  ,shallPlace: function(what, i, e)
  {
    switch (what)
    {
      case 'desc' :
        return 2 == i;
        break;
      case 'tagLine' :
        return 4 == i;
        break;
    }
  }
  
  ,buildPane_Fw2: function()
  {
    this.tiles = [];
    for (var y = 0; y < this.tilesY; y++)
    {
      this.tiles[y] = [];
      for (var x = 0; x < this.tilesX; x++)
      {
        this.tiles[y][x] = {p: null, coat: null};
      }
    }
    
    this.tileGrid = [];
    this.tileNum = 0;
    this.tilesCoated = 0;
    
    var e = this.actCoats.length;
    for (var i = 0; i < e; i++)
    {
      var p = this.tileProps();
      var coat = this.coats[this.actCoats[i]];
      
      this.tiles[p.y][p.x] = {
         p: p
        ,coat: coat
        ,el: null
      };
    }
    
    
      var poser = new MC_CoatPoser(this.elPane, 2, 1);
      poser.element.set('text', this.getFWInfo('desc'));
      poser.element.setStyles({
         'float': p.doFloat
        ,clear: p.doClear
      });
      
      this.tiles[2][0] = {
         p: {w: 2, h: 1}
        ,coat: null
        ,el: poser
      };
      
      
      var poser = new MC_CoatPoser(this.elPane, 2, 1);
      poser.element.set('html', '<div>' + this.getFWInfo('tagLine') + '</div>');
      poser.element.setStyles({
         'float': p.doFloat
        ,clear: p.doClear
      }); 
      poser.element.getFirst().setStyles({
         textAlign: 'center'
        ,fontSize: '1.2em'
        ,paddingTop: 20
      })
      
      this.tiles[1][3] = {
         p: {w: 2, h: 1}
        ,coat: null
        ,el: poser
      };
      
      
      var poser = new MC_CoatPoser(this.elPane, 1, 4);
      poser.element.setStyle('background', (this.haveFWInfo('imageMood') ? 'url(' + this.getFWInfo('imageMood') + ') center center no-repeat' : ''));
      poser.element.set('html', '&nbsp;');
      
      this.tiles[0][2] = {
         p: {w: 1, h: 4}
        ,coat: null
        ,el: poser
      };
    
    var html = '<table cellspacing="0" cellpadding="0">';
    for (var y = 0; y < this.tilesY; y++)
    {
      html += '<tr>';
      for (var x = 0; x < this.tilesX; x++)
      {
        if ((cell = this.tiles[y][x]))
        {
          if (cell.p)
          {
            html += '<td colspan="' + cell.p.w + '" rowspan="' + cell.p.h + '"></td>';
          } 
        } 
      }
      html += '</tr>';
    }
    html += '</table>';
    
    this.elPane.set('html', html);
    
    var tds = this.elPane.getElements('td');
    for (var y = 0; y < this.tilesY; y++)
    {
      for (var x = 0; x < this.tilesX; x++)
      {
        if ((cell = this.tiles[y][x]))
        {
          if (cell.p)
          {
            var td = tds.shift();
            if (cell.el)
            {
              cell.el.inject(td);
            }
            else
            {
              var tmp = new MC_Coat(cell.coat, td, cell.p.w, cell.p.h);
              if (coat.itemId == this.coat) 
              {
                tmp.element.fireEvent('mouseenter');
                tmp.element.fireEvent('mouseleave');
              }
            } 
          }
        } 
      }
    }
  }
  
  ,haveFWInfo: function(key)
  {
    if (!this.menu[this.chooseBy]) return false;
    if (!this.menu[this.chooseBy].items[this.chooseBoard]) return false;
    return this.menu[this.chooseBy].items[this.chooseBoard][key] ? true : false; 
  }
  
  ,getFWInfo: function(key)
  {
    if (!this.menu[this.chooseBy]) return '';
    if (!this.menu[this.chooseBy].items[this.chooseBoard]) return '';
    if ('title' == key) return this.menu[this.chooseBy].items[this.chooseBoard].title;
    return this.menu[this.chooseBy].items[this.chooseBoard][key];
  }
  
  
  ,havePDF: function()
  {
    return this.haveFWInfo('pdf');
  }
  
  ,getPDF: function()
  {
    return this.getFWInfo('pdf');
  }
}

window.addEvent('layerFilled', MM_CoatChoose.init.bind(MM_CoatChoose));









MC_Coat = {
   element: null
  ,coat: null
  
  ,dW: 0
  ,dH: 0
  
  ,getScale: function()
  {
    return 'w' + this.dW + '.h' + this.dH;
  }
  
  ,initialize: function(coat, el, tx, ty)
  {
    this.coat = coat;
    
    var dW = MM_CoatChoose.tileW * tx + ((tx - 1) * MM_CoatChoose.tileSh);
    var dH = MM_CoatChoose.tileH * ty + ((ty - 1) * MM_CoatChoose.tileSv);
    var iB = 0;
    var iW = dW - (2 * (iB + 0));
    var iH = dH - MM_CoatChoose.tileH;
    var tW = dW - (2 * (iB + MM_CoatChoose.tileTPadH));
    
    var hW = 320 * 1.4;
    var hH = 240 * 1.2;
    
    this.dW = dW;
    this.dH = dH;
    
    this.element = new Element('div');
    this.element.setStyles({
       width: dW
      ,height: dH
      ,'float': 'left'
      ,border: '0px solid #eeeeee'
      ,margin: MM_CoatChoose.tileS
      ,margin: '0 ' + MM_CoatChoose.tileSh + 'px ' + MM_CoatChoose.tileSv + 'px 0'
      ,background: 'white'
      ,color: 'black'
      ,fontSize: MM_CoatChoose.tileT - 3
    });
    
    if (this.coat.itemId == MM_CoatChoose.coat)
    {
      this.element.setStyles({
         color: 'white'
        ,background: '#444444'
      });
    }
    
    this.element.set('html', 
    '<div style="width: ' + iW + 'px; height: ' + iH + 'px; border: ' + iB + 'px solid black;' +
    'background: url(' + Util.scaleImage(coat.image, 'w' + iW + '.h' + iH + '.croph') + ') no-repeat center center;' + 
    '"></div>' +
    '<div style="width: ' + tW + 'px;' +
    ' margin: ' + MM_CoatChoose.tileTPadV + 'px ' + MM_CoatChoose.tileTPadH + 'px;' +
    ' white-space: nowrap; overflow: hidden; position: relative;">' + coat.display +
    ((1 == this.coat.muster_vorhanden && MM_CoatChoose.allowSamples) ? '<div style="position: absolute; top: 0; right: 0; z-index: 22000;"><input type="checkbox" /></div>' : '') +
    '</div>'
    );
    
    this.inject(el); 
    
    this.element.getFirst().store('tip:avoid', $('coatChoose-b2'));
    this.element.getFirst().setProperty('title',
      '<div style="padding: 5px 0;"><div style="width: ' + hW + 'px; height: ' + hH + 'px;' +
      'background: url(' + Util.scaleImage(coat.image, 'w' + hW + '.h' + hH + '.croph') + ') no-repeat center center;' + 
      '"></div></div>' +
      '' 
    );
    this.element.getFirst().addClass('tip');
    
    if ((el = this.element.getElement('input')))
    {
      el.addEvent('click', this.evtSample.bind(this));
      el.checked = this.coat.sampleChecked; 
    }
    
    if (this.coat.clickable && !MM_CoatChoose.unClickable)
    {
      this.element.getFirst().setStyle('cursor', 'pointer');
      this.element.getFirst().addEvent('click', this.evtClick.bind(this));
    }
    else if (!this.coat.clickable)
    {
      this.element.getFirst().setProperty('title', 
        '<div style="padding-top: 5px; font-weight: bold;">' + this.coat.tipTop + '</div>'
        + this.element.getFirst().getProperty('title') +
        '<div style="padding-bottom: 5px; font-weight: bold; text-align: right;">' + this.coat.tipBot + '</div>'
        );
    }
    
    this.element.addEvents({
       mouseenter: this.evtEnter.bind(this)
      ,mouseleave: this.evtLeave.bind(this)
    })
  }
  
  ,evtSample: function()
  {
    this.coat.sampleChecked = !this.coat.sampleChecked;
    new Request ({url: '/plugs/cart/moebel_cart_controller.php',
      method: 'post',
      data: {
         muster_id: this.coat.itemId
        ,muster_art: this.coat.mc_bezuege_art
        ,materialmuster_auswahl: 1
        ,moebel_uid: MM_CoatChoose.sampleUid
      },
      onComplete: getCartInnerHtml
    }).send();
  }
    
  ,evtClick: function()
  {
    try
    {
      Cart.update([
         {name: MM_CoatChoose.onId, value: this.coat.itemId}
        ,{name: 'chooseBy'        , value: MM_CoatChoose.chooseBy}
        ,{name: 'chooseById'      , value: MM_CoatChoose.chooseById}
      ]);
    }
    catch (e)
    {
      var name = MM_CoatChoose.onId.split(/__/).shift();
      data = {
         chooseBy   : MM_CoatChoose.chooseBy
        ,chooseById : MM_CoatChoose.chooseById
        ,moebel_uid : MM_CoatChoose.onUId
      };
      switch (MM_CoatChoose.furnType)
      {
        case 'kissen' :
          data['kissen_change_value'] = 1;
          data['what']                = name;
          data['value']               = this.coat.itemId;
          break;
        case 'pwuerfel' :
          data['polsterwuerfel_change_value'] = 1;
          data['what']                = name;
          data['value']               = this.coat.itemId;
          break;
        default :
          data[name] = this.coat.itemId;
          break;
      }
      
      
      new Request ({url: '/plugs/cart/moebel_cart_controller.php',
        method: 'post',
        data: data,
        onComplete: getCartInnerHtml
      }).send();
    }

    
    MM_CoatChoose.assets[MM_CoatChoose.onId].lastChooseBy   = MM_CoatChoose.chooseBy;
    MM_CoatChoose.assets[MM_CoatChoose.onId].lastChooseById = MM_CoatChoose.chooseById;
    MM_CoatChoose.assets[MM_CoatChoose.onId].lastCoat       = this.coat.itemId;
    MM_CoatChoose.coat = this.coat.itemId;
    
    this.setTriggerImgUrl(MM_CoatChoose.elTrigger.getElement('.coatChoose-img'));
    MM_CoatChoose.elTrigger.getElement('.coatChoose-title').set('text', ucfirst(this.coat.mc_bezuege_art) + ', ' + this.coat.display);
    MT_Lightshow.hide();
    window.fireEvent(MM_CoatChoose.changeEvent, this.coat);
    return;
  }
  
  ,setTriggerImgUrl: function(el)
  {
    if ('metall' == this.coat.mc_fuesse_material)
    {
      var feet = /\/([\w-]+)\./.exec(this.coat.image)[1];
      var url = el.getStyle('background-image');
      console.log('url', url);
      url = url.replace(/\/[\w-]+\./, '/' +feet+'.');
      console.log('url', url);
      el.setStyle('background-image', url);
      return;
    }
    else if (this.coat.mc_holzarten_id)
    {
      var url = el.getStyle('background-image');
      console.log('url', url);
      url = url.replace(/\/[\w-]+\./, '/wooden.');
      console.log('url', url);
      el.setStyle('background-image', url);
      return;
    }  
    
    switch (MM_CoatChoose.chooseBy)
    {
      case 'wood' :
        //http://akt.masscouch.masstisch.lan/media/_generate/masscouch/common/couches/delgano/pufa/d004/skids.w62.c474x346x151x73.jpg
        var url = el.getStyle('background-image');
        url = url.replace(/\/[\w-]+\./, '/wooden.');
        el.setStyle('background-image', url);
        break;
      case 'steel' :
        ///media/_generate/masscouch/common/couches/delgano/pufa/d004/skids.w62.c474x346x151x73.jpg
        
        var url = el.getStyle('background-image');
        url = url.replace(/\/[\w-]+\./, '/wooden.');
        el.setStyle('background-image', url);
        break;
      default :
        el.setStyle('background-image', 'url(' + Util.scaleImage(this.coat.mc_bezuege_arten_image_preview, 'w' + parseInt(MM_CoatChoose.elTrigger.getStyle('width'))) + ')');
        break;
    }
  }
  
  ,evtEnter: function()
  {
    this.oldBackground  = this.element.getStyle('background');
    this.oldColor       = this.element.getStyle('color');
    this.element.setStyle('background', '#eeeeee');
    this.element.setStyle('color', '#000000');
    
    'steel-preview'
    
    var fullWidth = parseInt(MM_CoatChoose.elInfo.getStyle('width'));
    var html = '';
    var pflegehinweise = '';
    
    html += '<h3 style="margin: 0 0 5px 0;">' + (this.coat.display.split(/,/).shift()) + '</h3>';
    
    var tmp1 = ['waschen'         , 'bleichen'        , 'buegeln'       , 'reinigung'         , 'trocknen'];
    var tmp2 = ['waschen_erlaubt' , 'bleichen_erlaubt', 'buegeln_stufe' , 'reinigung_erlaubt' , 'trocknen_erlaubt'];
    var e = tmp1.length;
    var pflegehinweise = '';
    var tmp = '';
    for (var i = 0; i < e; i ++)
    {
      var k = tmp2[i];
      if (this.coat[k] && -1 < this.coat[k])
      {
        tmp += '<img src="/media/masscouch/common/waschsymbole/' + tmp1[i] + '_' + this.coat[k] + '.jpg" />';
      }
    }
    if (tmp)
    {
      pflegehinweise += '<br /><br />' + tmp; 
    }
    
    if (this.coat.pflegehinweise)
    {
      pflegehinweise += '<br /><br />' + this.coat.pflegehinweise;
    }
    
    
    if (this.coat.beschreibung)
    {
      html += '<div style="float: left; width: ' + Math.floor(fullWidth * 1) + 'px; font-size: 11px;">';
      html += '<b>Kurzprofil</b><br /><br />';
      html += this.coat.beschreibung.replace(/\n/g, '<br />');
      html += '</div>';
    }
    
    if (this.coat.produktinformation)
    {
      html += '<div style="float: left; width: ' + Math.floor(fullWidth * 0.4) + 'px; font-size: 11px;">';
      html += '<b>Produktinformation</b><br /><br />';
      html += this.coat.produktinformation.replace(/\n/g, '<br />');
      html += '</div>';
    }
    
    if (this.coat.zusammensetzung)
    {
      html += '<div style="float: left; width: ' + Math.floor(fullWidth * 0.3) + 'px; font-size: 11px;">';
      html += '<b>Zusammensetzung</b><br /><br />';
      html += this.coat.zusammensetzung.replace(/\n/g, '<br />');
      html += '</div>';
    }
    
    var html_pflege = [];
    
    if (MM_CoatChoose.havePDF())
    {
      var tmp = '';
      tmp += '<a'; 
      tmp += ' style="line-height: 20px;';
      tmp += 'background:transparent url(/media/Image/Icons/mime/application-pdf.gif) no-repeat scroll left center;';
      tmp += 'padding:0 0 0 20px;"';
      tmp += ' href="' + MM_CoatChoose.getPDF() + '"';
      tmp += ' target="_blank"';
      tmp += '>';
      tmp += 'Katalog herunterladen';
      tmp += '</a>';
      
      html_pflege.push(tmp);
    }
    
    if (pflegehinweise)
    {
      html_pflege.push('<b>Pflege</b>' + pflegehinweise);
    }
    
    if (0 < html_pflege.length)
    {
      var tmp = [];
      html += '<div style="float: right; width: ' + Math.floor(fullWidth * 0.3) + 'px;  font-size: 11px;">';
      html += html_pflege.join('<br /><br />');
      html += '</div>'; 
    }
    
    MM_CoatChoose.elInfo.set('html', html);
  }
  
  ,evtLeave: function()
  {
    this.element.setStyle('background', this.oldBackground);
    this.element.setStyle('color', this.oldColor);
  }
  
  ,inject: function(el)
  {
    el.adopt(this.element);
  }
};
MC_Coat = new Class(MC_Coat);





MC_CoatPoser = {
   element: null
  ,coat: null
  
  ,dW: 0
  ,dH: 0
  
  ,getScale: function()
  {
    return 'w' + this.dW + '.h' + this.dH;
  }
  
  ,initialize: function(el, tx, ty)
  
  {

    var dW = MM_CoatChoose.tileW * tx + ((tx - 1) * MM_CoatChoose.tileSh);
    var dH = MM_CoatChoose.tileH * ty + ((ty - 1) * MM_CoatChoose.tileSv);
    var iB = 0;
    var iW = dW - (2 * (iB + 0));
    var iH = dH - MM_CoatChoose.tileT - (2 * MM_CoatChoose.tileTPadV);
    var tW = dW - (2 * (iB + MM_CoatChoose.tileTPadH));
    
    this.dW = dW;
    this.dH = dH;
    
    this.element = new Element('div');
    this.element.setStyles({
       width: dW
      ,height: dH
      ,margin: '0 ' + MM_CoatChoose.tileS + 'px ' + MM_CoatChoose.tileS + 'px 0'
    });
    
    this.inject(el);
  }
  
  
  
  ,inject: function(el)
  {
    el.adopt(this.element);
  }
};
MC_CoatPoser = new Class(MC_CoatPoser);
