/* Copyright (c) 2005 by Michael Hanselmann

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
*/
function TabSwitchInit(opts, sel) {
    var d = document;
    if(!d.getElementById) return;

    var init = null;
    for(var i = 2; i < opts.length; i++) {
        var link = d.getElementById(opts[i][1]);
        if(link) {
            link.onclick = _TabClick;
            link._tabs = opts;
            if(!init || sel == opts[i][0] || isFinite(sel) && (i - 2) == sel) init = link;
        }
    }
    if(init) init.onclick();
}

function _TabClick() {
    var d = document;
    if(!d.getElementById) return;

    var opts = this._tabs;
    var minh = opts[1];

    var sel = (opts[0]?d.getElementById(opts[0]):null);

    for(var i = 2; i < opts.length; i++) {
        var div = d.getElementById(opts[i][0]);
        var link = d.getElementById(opts[i][1]);

        if(!div || !link) continue;

        if(this == link) {
            div.style.display = '';
            link.className = 'active';
            if(minh) {
                div.style.minHeight = minh;
                if(d.all) div.style.height = minh; // IE-Fix
            }
            if(sel) sel.value = div.id;
        }else{
            div.style.display = 'none';
            link.className = '';
        }
    }

    return false;
}