function explode( delimiter, string, limit ) {

    var emptyArray = { 0: '' };

    // third argument is not required
    if ( arguments.length < 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }

    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }

    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }

    if ( delimiter === true ) {
        delimiter = '1';
    }

    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function str_replace(search, replace, subject) {
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;

    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };

    return sa ? s : s[0];
}


function Round(val,precision)
{
    return parseFloat(parseFloat(val).toFixed(precision));
}

function Get_Elem(el)
{
    return document.getElementById(el);
}

function Get_Content_Width()
{
    return Get_Elem('content_block').offsetWidth;
}

function Display_Table_Blocks()
{
    b_width   = 290;
    t_width   = Get_Content_Width()-100;
    c_width   = 0;
    after_txt = "<div style='clear:both;'>&nbsp;</div>";

    if (t_width>0)
    {
        c_width = Round(t_width/b_width,0);
    }

    j=0;
    for (i=0; i<=10000; i++)
    {
        var elem = Get_Elem('categoria_'+i);
        if (elem)
        {
            j++;
            if (j%c_width==0) $j('#categoria_'+i).after(after_txt);
        }
    }
}
