//var console
//if (!console) { console = {debug: function(){}} }

window.addEvent('domready', function(){
        var tbls = $$("table.prod");
        var dscr = $$("div.dscr");
        dscr.each(function(d) {
            d.setOpacity(0)
            d.setStyle('width',1)
        });
        tbls.each(function(tbl) {
            tbl.addEvent("mouseenter", tblOnOver)
            tbl.addEvent("mouseleave", tblOnOut)
        });
        $$("table.prod_row").addEvent("mouseleave", tblsOnOut)
        var cols = $$("td.col").each(function(c) {
            if(c.getFirst()){
                c.addEvent("mouseenter", addClassOver)
                c.addEvent("mouseleave", removeClassOver)
            }else{
                c.setStyle('background', '#FFF')
            }
        });
        $$('table.variant tbody tr').each(function(tr) {
            tr.addEvent("mouseenter", addClassOver)
            tr.addEvent("mouseleave", removeClassOver)
        });
        $$('table.combined tbody tr').each(function(tr) {
            tr.removeEvents("mouseenter")
            tr.removeEvents("mouseleave")
        });
});

function tblOnOver(event) {
    var d0 = this.getElement('div.dscr')
    var b0 = this.getElement('div.bm')
    var bm = this.getParent().getParent().getElements('div.bm')
    bm.each(function(b){
        if(b != b0){
            b.setOpacity(0)
        }
    });
    d0.setOpacity(1)
    d0.effect('width', {duration: 200}).start(d0.getStyle("width").toInt(),150);
    b0.effect('opacity', {duration: 200}).start(b0.getStyle("opacity"),1);
}
function tblOnOut(event) {
    var d = this.getElement('div.dscr')
    d.effect('width', {duration: 200, onComplete: function(){
        d.setOpacity(0)
    }}).start(d.getStyle("width").toInt(),1);
}
function tblsOnOut(event) {
    var bm = this.getElements('div.bm')
    var op
    bm.each(function(b){
        op = b.getStyle('opasity')
        b.effect('opacity', {duration: 200}).start(op,1);
    });
}
function addClassOver(event) {
    this.addClass('over')
}
function removeClassOver(event) {
    this.removeClass('over')
}
