ArticleAvailability =
{
    dataTable : new Array(),
    linkShowAvailable: null,
    linkCloseAvailable: null,
    dataTableIterator: 0,
    addDataTable : function(i_WarehouseName, i_WarehouseId, i_Balance)
    {
        this.dataTable[this.dataTableIterator] = new Array();
        this.dataTable[this.dataTableIterator]['warehouse_name'] = i_WarehouseName;
        this.dataTable[this.dataTableIterator]['warehouse_id'] = i_WarehouseId;
        this.dataTable[this.dataTableIterator]['balance'] = i_Balance;

        ++this.dataTableIterator;
    },
    switchLink:function(i_Switch)
    {
        linkTo = document.getElementById('article_availability_link');
        switch (i_Switch)
        {
            case 0:
                linkTo.innerHTML = this.linkCloseAvailable;
            break;
            case 1:
                linkTo.innerHTML = this.linkShowAvailable;
            break;
        }
    },
    generateTableRows: function()
    {


        tableRef = document.getElementById('warehouse_stock_table');

        block = 0;

        j = 2;


        /* bylo  i in this.dataTable ale nie dzialalo pod IE 7.0) */
        for ( i=0; i<this.dataTable.length; i++ )
        {

            newRow   = tableRef.insertRow(j++);

            newCell1  = newRow.insertCell(0);
            newCell2  = newRow.insertCell(1);

            newText1  = document.createTextNode(this.dataTable[i]['warehouse_name']+':');
            newText2  = document.createTextNode(this.dataTable[i]['balance']);
            newCell1.appendChild(newText1);
            newCell2.appendChild(newText2);
            newCell1.className = 'warehouse_title';
            newCell2.className = 'warehouse_state';

            /*
             * Ostatni klucz w tablicy zawiera systemowe wartosci ktore sa niewymagane
             * Ponizsza blokada zabiezpiecza przed pobraniem danych z ostatniego klucza
             */

            if ( this.dataTable.length == ++block ) break;
        }
    },
    closeReport: function()
    {
        tableRef = document.getElementById('warehouse_stock_table');

        while ( tableRef.rows[2] )
        {
           tableRef.deleteRow(2);
        }

        this.switchLink(1);

        this.dataTableIterator = 0;
    }
}
