
function SctMenu(name, numMenus, selectedIndex) {
    this.name = name;
	this.numMenus = numMenus;
    this.selectedIndex = selectedIndex;
    this.divs = [];
    this.divsOn = [];
    this.relDiv = null;
}

SctMenu.prototype.onLoad = function() {

    this.relDiv = DynAPI.document.all[this.getName() + 'RelDiv'];

    for (var i=0; i<this.numMenus; i++) {
        this.divs[i] = DynAPI.document.all[this.getName() + 'Entrys_' + i + 'OffRel'];
        this.divsOn[i] = DynAPI.document.all[this.getName() + 'Entrys_' + i + 'OnRel'];
	}
    this.onResize();
}

SctMenu.prototype.onResize = function() {
    this.relDiv.updateValues();
    this.reDraw();
}

SctMenu.prototype.reDraw = function() {
    var x = this.relDiv.getX();
    var y = this.relDiv.getY();
    var lay;
    for (var i=0; i<this.numMenus; i++) {
        if (this.selectedIndex == i) {
            lay = this.divsOn[i];
            this.divs[i].setVisible(false);
        } else {
            lay = this.divs[i];
            this.divsOn[i].setVisible(false);
        }
        lay.moveTo(x,y);
        y += lay.getHeight();
        lay.setVisible(true);
    }
}

SctMenu.prototype.select = function() {
	var a=arguments;
    if (this.selectedIndex != a[0]) {
        this.selectedIndex = a[0];
    } else {
        this.selectedIndex = -1;
    }
    this.reDraw();
}

SctMenu.prototype.getName = function() {
    return this.name;
}

