// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// 
// Oorspronkelijke naam :   block positioning
// Opdrachtgever        :   DenK B.V.
// 
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// 
// Bestandsinformatie
// 
// Bestandnaam          :   blocks.js
// Locatie              :   http://www.vansonassurantien.nl/jscripts/
// Gemaakt              :   19-05-2009
// Gewijzigd            :   17-06-2011
// Eigenaar             :   DenK B.V.               - www.denk.biz - info@denk.biz
// Auteur               :   Ruben Hendriks          - hendriks@denk.biz
// Auteur               :   Jean-Piere Duits        - duits@denk.biz
// Versie               :   1.2.0.
// 
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// 
// (C) 2009 DenK Internet Services. Alle rechten voorbehouden. 
// 
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

var yAxis = [0];

function checkBlock(blockId, blockColNr, columnWidth, blockHeight, blockStyle, blockJs)
{
  if (document.getElementById(blockId)) { 
    if((blockColNr + columnWidth) < 5)
    {
        yAxisCoord = yAxis[blockColNr];
        for (counter=blockColNr; counter<(blockColNr + columnWidth); counter++)
        {
            if(yAxis[counter] > yAxisCoord)
            {
                yAxisCoord = yAxis[counter];
            }
        }
        var blockDiv            = document.getElementById(blockId);
        var blockCcDiv          = document.getElementById("blockCC-" + blockId);
        blockDiv.style.top      = yAxisCoord + 'px';
        blockDiv.style.height   = null;
        blockCcDiv.style.height = null;
        var blockDivHeight      = getDivHeight(blockId);
        var blockCcDivHeight    = getDivHeight("blockCC-" + blockId);
        if(blockDivHeight=='')
        {
            blockDivHeight      = '0';
        }
        if(blockCcDivHeight=='')
        {
            blockCcDivHeight    = '0';
        }
        if(blockJs==1)
        {
            blockDiv.style.height   = blockDivHeight + 'px';
            blockCcDiv.style.height = (blockCcDivHeight - blockBorderWidth(blockStyle)) + 'px';
            for (counter=blockColNr; counter < (blockColNr + columnWidth); counter++)
            {
                yAxis[counter] = (yAxisCoord + blockDivHeight) + (20);
            }
        }
        else
        {
            blockDiv.style.height   = blockDivHeight + 'px';
            blockCcDiv.style.height = (blockHeight - blockBorderWidth(blockStyle)) + 'px';
            for (counter=blockColNr; counter < (blockColNr + columnWidth); counter++)
            {
                yAxis[counter] = (yAxisCoord + blockHeight) + (20);
                blockDiv.style.height   = blockHeight + 'px';
            }
        }
    }
    else
    {
        checkBlock(blockId, blockColNr, 4 - blockColNr, blockHeight, blockStyle, blockJs);
    }
  }
}

function getDivHeight(ElementId)
{
    var divHeight = document.getElementById(ElementId).offsetHeight;
    return divHeight;
}

function blockBorderWidth(blockStyle)
{
    var borderWidth = new Array();
    borderWidth[1]  = 1;
    borderWidth[2]  = 0;
    borderWidth[3]  = 1;
    borderWidth[4]  = 1;
    borderWidth[5]  = 1;
    borderWidth[6]  = 0;
    borderWidth[7]  = 1;
    borderWidth[8]  = 0;
    borderWidth[9]  = 1;

    if(blockStyle==undefined)
    {
        return 0;
    }
    else
    {
        return borderWidth[blockStyle];
    }
}


