I have found this script at:

it is really working nice for my needs, and is quite simple especially for some one that has absolutely no idea about javascript.

The script is actually a tab system when you click in one of the "buttons" the specified tag is opening.

I need just some more functionality: to assign at the selected button a class="selected" in order to style the selected tab differently,

So I really tried some different ways (please don't laugh I am new to this part), but until my copy of "The JavaScript Anthology" is here I have to finalize this

so the javascript is :

function hidestories() {
var divs=document.getElementById('stories').getElementsByTagName('div');
for (j=0; j<divs.length; j++) {
var rE = new RegExp("(^|\\s)" + 'story' + "(\\s|$)");
if (rE.test(divs[j].className)) {

function stories(first) {
var thebuttons=document.getElementById('thebuttons').getElementsByTagName('a');
for (i=0; i<thebuttons.length; i++) {
thebuttons[i].onclick=function() {
var thestory=(this.href).split("#",2)[1];
return false;
if (first) {
var firstone=document.getElementById('stories').firstChild;
if (firstone.nodeType != 1) {firstone = firstone.nextSibling;}
window.onload=function() {

and the html is

<ul id="thebuttons">
<li><a href="#storyA">Story A</a></li>
<li><a href="#storyB">Story B</a></li>
<div id="stories">
<div id="storyA" class="story">
here goes the content of tab a
<div id="storyB" class="story">
here goes the content of tab b

Thanks in advance for your help