window.onload = function()
{
    var tabs = ['tab1', 'tab2', 'tab3', 'tab4'];

    var show = function(active)
    {
        for (var i = 0; i < tabs.length; i++)
        {
            var name = tabs[i];

            document.getElementById('handle-' + name).className = name == active ? 'active' : '';
            document.getElementById('layer-' + name).style.display = name == active ? '' : 'none';

        }
    }

    for (var i = 0; i < tabs.length; i++)
    {
        document.getElementById('handle-' + tabs[i]).onclick = function()
        {
            show(this.id.replace('handle-', ''));

            return false;
        };
    }
}
