// -*- coding: utf-8 -*-
// 2006-02-18
// 〈Implementing Tab Menu with JavaScript〉@ http://xahlee.org/js/tabs/a.html

/* Each tab is associated with a file. Each File name (without extension) must be the same as the tab's id. */

// a list of tab id. (file names)
var tabNames= ["a","b","c"];

function setTabColor() {
    // determine the current tab, from file path
    var fPath = document.location.pathname.split('/');
    var currentFile = (fPath[fPath.length-1]).split('.')[0]; // file name without extension

    // go thru all tabs, if match, change tab to red, else silver
    for (var aTab in tabNames) {
        var myObj = document.getElementById(tabNames[aTab]);
        if (tabNames[aTab] == currentFile) { myObj.style.backgroundColor="red";}
        else { myObj.style.backgroundColor="silver";}
    }
}

setTabColor();

