
document.observe("dom:loaded",function() {
    onResize();
    var obj2 = $('lastSeenC');
    if(obj2){
        obj2.setStyle({'display':'block'});
        obj2.observe('mouseover',function(event) {
            event.stop();
            $('lastSeen').setStyle({'display':'block'});
        });
        obj2.observe('mouseout',function(event) {
            event.stop();
            $('lastSeen').setStyle({'display':'none'});
        });
    }
    window.onresize = onResize;
    
    new itumaText();
});

function onResize() {
    var obj = $('lastSeenAnchor');
    var obj2 = $('lastSeenC');
    if(obj && obj2) {
        var pos = obj.cumulativeOffset();
        obj2.setStyle({'top':pos.top+'px','left':pos.left+'px'});
    }
}

function lx_menu(id,level) {
    if (ppActiveMenu[level] == id) {
        $('mainMenuIcon'+id.substr(1)).src = "/images/navArrowC_0.png";
        new claMenu($('menu_'+id),"out");
        ppActiveMenu[level] = "";
        return;
    }
    $('mainMenuIcon'+id.substr(1)).src = "/images/navArrowCOpen_0.png";
    new claMenu($('menu_'+id),"in");
    ppActiveMenu[level] = id;
}



var claMenu = Class.create({
    _method : null,
    _obj : null,
    _value : 0,
    _target : 0,
    _step : 0,
    _orig : 0,
    initialize : function(_obj,_method) {
        this._obj = _obj;
        this._method = _method;
        
        if (this._method == "in") {
            this._target = this._obj.getHeight();
            this._step = this._target / 6;
            if (this._step < 20)
                this._step = 20;
            this._value = 0;
            this._obj.setStyle({'height':'1px','overflow':'hidden'});
            this._obj.setStyle({'display':'block'});
        } else {
            this._orig = this._obj.getHeight();
            this._target = 0;
            this._step = -this._orig / 6;
            if (Math.abs(this._step) < 20)
                this._step = -20;
            this._value = this._orig;
            this._obj.setStyle({'overflow':'hidden'});
            this._obj.setStyle({'display':'block'});
        }

        new PeriodicalExecuter(this.slider.bindAsEventListener(this), 0); 
    },
    slider : function(pe) {
        pe.stop();
        this._value += this._step;
        if (this._value > this._target && this._method == "in") {
            this._value = this._target;
        }
        if (this._value < this._target && this._method == "out") {
            this._value = this._target;
        }
        this._obj.setStyle({'height':this._value+'px'});
        if (this._value != this._target)
            new PeriodicalExecuter(this.slider.bindAsEventListener(this), 0.11);
        else {
            if (this._method == "out") {
                this._obj.setStyle({'display':'none'});
                this._obj.setStyle({'height':this._orig+'px'});
                this._obj.setStyle({'height':''});
            }
            if (this._method == "in") {
                this._obj.setStyle({'height':''});
            }
            //delete this;
        }
    }
});

function styleChangeCursor(idElement) {
    $obj_element = document.getElementById(idElement);
    if($obj_element.style.cursor == 'pointer') {
        $obj_element.style.cursor = '';
    } else {
        $obj_element.style.cursor = 'pointer';
    }
}

var itumaText = Class.create({
    initialize : function() {
        var items = $$('body')[0].adjacent('.productpreview_text');
        if (items.length == 0)
            return;
        items.each(function(item) {
            var maxH = item.getHeight();
            var myH = item.down(0).getHeight();
            if (myH > maxH) {
                item.down(3).setStyle({'display':'block'});
            }
        });
    }
});
