DIF = 2;

function ts_incElSize(el)
{
    if (el.currentStyle)
    {
        f_size = el.currentStyle['fontSize'];
    }
    else if(window.getComputedStyle)
    {
        f_size = document.defaultView.getComputedStyle(el,null).getPropertyValue('font-size');
    }

    if(f_size)
    {
        size = parseInt(f_size, 10);

        if(f_size != size)
        {
            if((size + DIF) >= 18)
            {
                new_size = '18px';
            }
            else
            {
                new_size = size + DIF + 'px';
            }

            el.style.fontSize = new_size;
        }
        else
        {
            if((size+1) <= 5)
            {
                el.setAttribute('size', size+1);
            }

        }

    }
}

function ts_decElSize(el)
{
    if (el.currentStyle)
    {
        f_size = el.currentStyle['fontSize'];
    }
    else if(window.getComputedStyle)
    {
        f_size = document.defaultView.getComputedStyle(el,null).getPropertyValue('font-size');
    }

    if(f_size)
    {
        size = parseInt(f_size, 10);

        if(f_size != size)
        {
            if((size - DIF) <= 9)
            {
                new_size = '9px';
            }
            else
            {
                new_size = size - DIF + 'px';
            }

            el.style.fontSize = new_size;
        }
        else
        {
            if((size - 1) >= 1)
            {
                el.setAttribute('size', size - 1);
            }

        }
    }

}

function ts_set(el, type, excptn)
{

if(excptn != null)
{
    if(!isArray(excptn))
    {
        if(isString(excptn))
        {
            excptn = new Array(excptn.split(','));
        }
        else
        {
            excptn = new Array();
        }
    }
}
else
{
    excptn = new Array();
}




if(el.style)
    {
        switch(type)
        {
            case 'inc':

                    ts_incElSize(el);

                    kids = find_childs(el,excptn);

                    for(i in kids)
                    {
                        if(kids[i] && (kids[i].nodeType == 1))
                        {
                            ts_incElSize(kids[i]);
                        }
                    }

                break;

            case 'dec':

                    ts_decElSize(el);

                    kids = find_childs(el, excptn);

                    for(i in kids)
                    {
                        if(kids[i] && (kids[i] != 'undefined') && (kids[i].nodeType == 1))
                        {
                            ts_decElSize(kids[i]);
                        }
                    }

                break;

        }
    }
}

function ts_increase(id, excptn)
{
    el = document.getElementById(id);
    ts_set(el, 'inc', excptn);
}

function ts_decrease(id, excptn)
{
    el = document.getElementById(id);
    ts_set(el, 'dec', excptn);
}


function nodeListToArray(nodelist)
{
    arr = new Array();
    for(j=0; j<nodelist.length; j++)
    {
        arr[j] = nodelist[j];
    }

    return arr;
}

function find_childs(el, exception_class)
{
    kids = new Array();
    tmp = new Array();

    els = el.getElementsByTagName('*');

    for(key in els)
    {
        flag = true;
        if(els[key].className)
        {
            cn = els[key].className.split(' ');
            for(c in cn)
            {
                for(i in exception_class)
                {
                    if(cn[c] == exception_class[i])
                    {
                        flag = false;
                    }
                }
            }
        }

        if(flag)
        {
            kids[key] = els[key];
        }
    }

    return kids;
}

function isArray(v)
{
    return v.constructor == Array;
}

function isString(v)
{
    return typeof(v) == 'string';
}

function get_level_elements(el)
{
    while(el.previousSibling)
    {
        el = el.previousSibling;
    }

    var arr = new Array();
    var i = 0;

    arr[0] = el;

    while(el.nextSibling)
    {
        el = el.nextSibling;

        i++;
        arr[i] = el;
    }

    return arr;
}