function dResizer() {
    this.loadConfig();
}

dResizer.prototype.loadConfig = function() {
    /* Names */
    this.holderId = 'holder';

    this.leftColumnId = 'left_c';
    this.centerColumnId = 'center_c';
    this.rightColumnId = 'right_c';

    this.menuId = 'menu';

    /* Run-time values */
    this.percentageWidth = 0.8;

    this.centerMaxW = 590;
    this.centerMinW = 445;

    this.activeIndex = 0;
}

dResizer.prototype.reset = function(index) {
    if (typeof(index) != 'undefined') {
        this.activeIndex = index;
    }

    this.recount();

    this.holder.style.marginLeft = - Math.ceil(this.holder.offsetWidth / 2) + 'px';

    var Bw = Math.ceil((this.holderWidth * this.percentageWidth) - this.leftColumn.offsetWidth - this.rightColumn.offsetWidth);
    if (Bw > this.centerMaxW) {
        Bw = this.centerMaxW;
    }
    if (Bw < this.centerMinW) {
        Bw = this.centerMinW;
    }

    var Bl = (Math.ceil(Bw / 2) + Math.ceil(this.leftColumn.offsetWidth) - 20);
    //alert(Bw);
    //alert(Bl);

    this.centerColumn.style.width = Bw + 'px';
    this.centerColumn.style.marginLeft =  '-' + Bl + 'px';
    if ($('Scroller-c' + this.activeIndex)) {
        $('Scroller-c' + this.activeIndex).style.width = Bw - 55 + 'px';
        if (animator && (typeof(animator) != 'undefined')) {
            animator.initCenterScroll(this.activeIndex);
        }
    }

    var margin = Math.ceil((this.holderWidth - Bw - this.leftColumn.offsetWidth - this.rightColumn.offsetWidth) / 4);
    //alert(margin);

    this.leftColumn.style.left =  margin + 'px';
    this.rightColumn.style.right =  margin + 'px';

    if (this.menu && (typeof(this.menu) != 'undefined')) {
        this.menu.style.marginLeft = ((margin * 2) + this.holder.offsetLeft + this.leftColumn.offsetWidth) + 'px';
    }
}

dResizer.prototype.recount = function() {
    /* Holder */
    if (!this.holder || (typeof(this.holder) == 'undefined')) {
        this.holder = $(this.holderId);
    }

    //alert('Holder is ' + this.holder + '; Check: ' + (this.holder && (typeof(this.holder) != 'undefined')));

    if (this.holder && (typeof(this.holder) != 'undefined')) {
        this.holderWidth = this.holder.offsetWidth;
        this.holderHeight = this.holder.offsetHeight;
        //alert(this.holderWidth + ' x ' + this.holderHeight);
    } else {
        alert('ACHTUNG! No holder, take window!');
    }
    //alert('Holder width = ' + this.holderWidth);

    /* Columns */
    if (!this.leftColumn || (typeof(this.leftColumn) == 'undefined')) {
        this.leftColumn = $(this.leftColumnId);
    }

    this.centerColumn = $(this.centerColumnId + this.activeIndex);
    this.rightColumn = $(this.rightColumnId + this.activeIndex);

    if (!this.menu || (typeof(this.menu) == 'undefined')) {
        this.menu = $(this.menuId);
    }

    if (this.leftColumn && (typeof(this.leftColumn) != 'undefined') && this.centerColumn && (typeof(this.centerColumn) != 'undefined') && this.rightColumn && (typeof(this.rightColumn) != 'undefined')) {
        //do nothing at now
    } else {
        alert('WARNING! There is some problems with your browser. Please, use Internet Explorer 6.0+ or FireFox 2.0+ or Opera 9+ to see this site correct!');
    }
}

dResizer.prototype.proto = function() {
}

/* ========================================================================== */

var resizer = new dResizer();
var interv;

window.onload = function() {
    resizer.reset();
}

window.onresize = function() {
    resizer.reset();
}