// JavaScript Document
/*

<script language="javascript" type="text/javascript" >

	// Set up Array
	tab_actions = new Array();
	
	// Tab 1 is an ajax call (sero based)
	i=0;
	tab_actions[i] = new Array();
	tab_actions[i]["ajax"] = new Array();
	tab_actions[i]["ajax"]["url"] = "my_url.php";
	tab_actions[i]["ajax"]["pars"] = "name=val&name=val";
	tab_actions[i]["ajax"]["method"] = "get";
	
	// Tab 2 calls some javascript
	i=2;
	tab_actions[i] = new Array();
	tab_actions[i]["js"] = initialize(); // Google maps
	
</script>

*/

function customTabCick(argsObj){
	
    var t = argsObj.tabber; /* Tabber object */
    var i = argsObj.index; /* Which tab was clicked (0..n) */
    var div = this.tabs[i].div; /* The tab content div */
	
	//alert(i);
	if(!tab_actions[i]) return;
	if(tab_actions[i]["clicked"]) return;
	//alert("made it");
	if(tab_actions[i]["ajax"]){
		//alert("ajax tab");
		/* Display a loading message */
		div.innerHTML = "<p>Loading...<\/p>";
	
		/* Fetch some html depending on which tab was clicked */
		var url = tab_actions[i]["ajax"]["url"];
		var pars = tab_actions[i]["ajax"]["pars"];
		var meth = tab_actions[i]["ajax"]["method"];
		$(div).load(url+"?"+pars)
		// var myAjax = new Ajax.Updater(div, url, {method:meth,parameters:pars});
	}
	else if(tab_actions[i]["js"]){
		//alert("js tab");
		eval(tab_actions[i]["js"]);
	}
	tab_actions[i]["clicked"] = true;
	
}
function customTabLoad(argsObj){
    /* Load the first tab */
    argsObj.index = 0;
    this.onClick(argsObj);
}

var tabberOptions = { 'onClick': customTabCick,'onLoad': customTabLoad } ;
