// ===============================================================
// CBkort version 2.x, copyright Carl Bro GIS&IT, 2006
// ===============================================================
// $Archive: /Products/CBKort2/development/2.3/standard_patch_02/wwwroot/js/standard/leftbar.js $ 
// $Date: 23-11-07 9:54 $
// $Revision: 3 $ 
// $Author: Kpo $
// =============================================================== 


function LeftBar()
{
    this.items = new Array();
    this.items[0] = {id:'themeselector'};
    this.top = null;
    this.left = null;
    this.width = null;
    this.defaultheigth = null;
    this.maxheigth = null;
    this.currentheigth = null;
    this.defaultok = false;
}

LeftBar.prototype.setDefault = function()
{
    if(!this.defaultok)
    {
        var e = getElement('leftbar');
        this.top = e.style.top;
        this.left = e.style.left;
        this.width = e.style.width;
        this.maxheigth = e.style.height;
        this.defaultheigth = getElement(this.items[0].id).style.height;
        this.currentheigth = getElement(this.items[0].id).style.height;
        this.defaultok = true;
        
        this.lastid = null;
        this.currentid = null;
    }
}

LeftBar.prototype.setHeight = function(height)
{
    if(!this.defaultok)
        this.setDefault();

    if(!height)
    {
        if(getElement(this.items[0].id).style.height == this.defaultheigth)
            height = this.maxheigth;
        else
            height = this.defaultheigth;
    }

    for(var i=0;i<this.items.length;i++)
    {
        getElement(this.items[i].id).style.height = height;
    }
    this.currentheigth = height;
}

LeftBar.prototype.addItem = function(id)
{
    if(!this.defaultok)
        this.setDefault();

    this.items[this.items.length] = {id:id};
    var e = getElement(id);
    e.style.top = this.top;
    e.style.left = this.left;
    e.style.width = this.width;
    e.style.height = this.currentheigth;
}

LeftBar.prototype.showItem = function(id)
{
    this.lastid = this.currentid;
    this.currentid = id;
    for(var i=0;i<this.items.length;i++)
    {
        var e = getElement(this.items[i].id);
        if(this.items[i].id==id)
            showBlock(e);
        else
            hideBlock(e);
    }
}

LeftBar.prototype.showLastItem = function()
{
    this.showItem(this.lastid);
}

LeftBar.prototype.setToCurrentHeigth = function()
{
    for(var i=0;i<this.items.length;i++)
        getElement(this.items[i].id).style.height = this.currentheigth;
}

var leftBar = new LeftBar();