
/**
 * Image Tab Menu System
 * Author: Brett Reid brett@activeice.co.za
 * © Copyright 2006 Active Ice - http://activeice.co.za
 * This script may be used freely under the GNU Public Licence
 * as long as this notice remains intact.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * Last Updated: 7 July 2006
 *
 * @constructor
 *
 * @params subnav:array, spacer:string, tab_id:integer
 */
function AI_TabMenu(subnav_array, spacer, tab_id) {
	this.subnav = subnav_array;
	this.subnav_spacer = spacer;
	this.active_tab = tab_id;
	this.tabOn(tab_id);
}

 /**
 * Do rollover state of tab
 *
 * @params tabID
 */
AI_TabMenu.prototype.tabOn = function(tabID) {
	
	this.hideAll();
	
	var tabObj = ( document.getElementById( 'tab-' + tabID ) ) ?  document.getElementById( 'tab-' + tabID ) : null;
	var tabSubNav = ( document.getElementById('subnav') ) ? document.getElementById('subnav') : null;
	
	if ( tabID != 8 ) {
		if ( tabObj && tabObj.src.indexOf("_o") == -1 ) {
			var tmp_array = tabObj.src.split("images/");
			var new_src = "images/" + tmp_array[1].replace(".gif", "") + "_o.gif";
			tabObj.src = new_src;
		}
	}
	
	if ( tabSubNav )
		tabSubNav.innerHTML = '<p>' + this.subnav[tabID - 1] + '</p>';
	
}

 /**
 * Change tab to off state
 *
 * @params tabID
 */
AI_TabMenu.prototype.tabOff = function(tabID) {
	
	var tabObj = ( document.getElementById( 'tab-' + tabID ) ) ?  document.getElementById( 'tab-' + tabID ) : null;
	
	if ( tabObj && tabObj.src.indexOf("_o") != -1 ) {
		var tmp_array = tabObj.src.split("images/");
		var new_src = "images/" + tmp_array[1].replace("_o", "");
		tabObj.src = new_src;
	}
}

 /**
 * Hide all tabs
 *
 * @params none
 */
AI_TabMenu.prototype.hideAll = function() {
	
	for ( var i = 0; i < (this.subnav.length - 1) ; i++ ) {
		if ( this.active_tab != (i+1) )
			this.tabOff(i+1);
	}
}

 /**
 * Show specific subnav only
 *
 * @params none
 */
AI_TabMenu.prototype.showSubNavOnly = function(tabID) {
	
	var tabSubNav = ( document.getElementById('subnav') ) ? document.getElementById('subnav') : null;
	this.hideAll();
	for ( var i = 0; i < (this.subnav.length - 1) ; i++ ) {
		if ( i == tabID )
			tabSubNav.innerHTML = '<p>' + this.subnav[tabID - 1] + '</p>';
	}
}

 /**
 * Start countdown to return to active tab
 *
 * @params none
 *
AI_TabMenu.prototype.startTimer = function() {
	this.timer = setTimeout("backToActive()", 3000);
}
*/


