var Tab={cur:0};

function initab( classname ) {
  var tabs = [], divs = [], texts = [], f, g, h, i = 0, j = 0, k, o,
  d = document, a = d.getElementsByTagName('h3'),  b = d.createElement('div'),
  c = d.createElement('a'),
  n = function(h) { while((h = h.nextSibling)) {
    if( /div/i.test( h.tagName ) || '' ) { return h; }   return null; }  },
  y = function() { return false; },  z=function(e) { e = e || window.event || {};
var t;
if( e.keyCode===37 &&    ( ( t = this.previousSibling ) || ( t = this.parentNode.lastChild ) )    || e.keyCode===39 &&    ( ( t = this.nextSibling ) || ( t = this.parentNode.firstChild ) ) )
{
if( /a/i.test( t.tagName ) ) { t.focus();
e.returnValue = false; }     return false;   }  };
c.className = 'tab0'; c.hideFocus = true;
while( i < a.length ) { h = a[i];
if( new RegExp( '\\b' + classname + '\\b' ).test( h.className ) &&    ( g = n(h) ) ) {     k = h.firstChild && h.firstChild.nodeValue;
o = c.cloneNode(true); o.href = '?' + ( j + 1 );
o.appendChild( d.createTextNode( k || c || 'Tab' ) );
o.onfocus = new Function( 'return doTab(' + j + ')' );
o.onclick = y;
o.onkeydown = z;
g.className = 'slab0';
h.className = 'slab0';
b.appendChild(o);
tabs[j] = o;
divs[j] = g;
texts[j] = k;
if(!f) { f = h; } j++;   }   i++; } f.parentNode.insertBefore( b, f );
Tab.tabs = tabs;
Tab.divs = divs;
Tab.texts = texts;
i = 0; if( window.location.search ) {  j = parseInt( window.location.search.substring(1) ) - 1;
if( tabs[j] ) { i = j; } } doTab(i);
}

function doTab(i) {  Tab.tabs[Tab.cur].className = 'tab0';
Tab.divs[Tab.cur].className = 'slab0';
Tab.cur=i;
Tab.tabs[i].className = 'tab1';
Tab.divs[i].className = 'slab1';
return false;
}
