//This one is called when we Ajaxify tabs
//It is optional. It assumes that jquery.js is already loaded
// Moreover, we must call this BEFORE we include tabber.js

function ajxg(page,pars,thediv){

  var html = $.ajax({
  url: page,
  data: pars,
  async: false
   }).responseText;

//In the next 4 lines we'll strip out the outer 'div' that 
//contains the text which we seek. If we don't it creates
//problems by shooting out of the tab right margins
var pos = html.search(/\<div id="wikitext"\>/i)+36;
html = html.substr(pos);
var pos2= html.length-6;
html = html.substr(0,pos2);

//   $.getIfModified(page,pars,function(html){
thediv.innerHTML = 
  '<table style="margin:0px auto; text-align:left;" width="100%" ><tr><td>'+html+'</td></tr></table>';

//} );


}


/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */
//WARNING: If options are given, they MUST be defined prior to the loading of "tabber.js"!!
document.write('<style type="text/css">.tabber{display:none;}<\/style>');



var tabberOptions = {
  'onClick': function(argsObj) {
//Tabber object
    var t = argsObj.tabber;
// Which tab was clicked (0..n)
    var i = argsObj.index;
// The tab content div
    var div = this.tabs[i].div;
    var thatDivId = div.getAttribute("id");
    if (thatDivId == undefined) return true;

// Get the page that needs to be loaded
   var i2 = thatDivId.substr(1); //we've clever. We named one set of DIV as ttb_1, etc and the other tb_1
   //So we need to remove just the first char to get the ID of the DIV that contains the page name

 var element = document.getElementById(i2);

// if element indeed existed it means it was an ajaxified tab
if (element){
   url = element.innerHTML;
//Display a loading message

    div.innerHTML = "<p>Loading...<\/p>";
//Fetch some html depending on which tab was clicked
//use the plain jane text skin so sidebar, etc are not displayed

    var pars = 'skin=text';

    ajxg(url,{skin: "text"},div);
    } else return true;
  // if it was not an ajaxified tab, then we can rest in peace. tabber.js would do the display
  },
  'onLoad': function(argsObj) {
 //Load the first tab
    argsObj.index = 0;
    this.onClick(argsObj);
  }
}


