/**
 *
 * tNav
 *
 * Version 1
 *
 * @author Monty Dickerson 
 * @date 2008-10-06
 * @package none
 *
 *		Evolved from original undocumented code used by Layout Developers at Infinity Pro Sports,
 *	this code is for processing change of content pane, requested by user clicking on a tab image,
 *	which involves changing the tab images (to reflect on/off appearance) and changing the content
 *	pane which is on display.
 */

function tabClick(tNav,tabName) {

	function changeTabs() {
		for (var t = 0; t < tabNames.length; t++) {
			var status = 'off_'						
			if (tabNames[t]===tabName) { 
				status = 'on_';			//filename begins with on_  for selected img
				tNav.tab[tabNames[t]].on = true;
				tNav.on[setName] = tabNames[t];
			} else {
				tNav.tab[tabNames[t]].on = false;
			}//if
//			console.log('tabNames[' + t + '] = ' + tabNames[t] + ' ... status is ' + status);
//			console.log('img src= '+tNav.base.imgUrl + status + tNav.tab[tabNames[t]].filename);
			document.getElementById(tNav.base.idTab+tabNames[t]).src = tNav.base.imgUrl + status + tNav.tab[tabNames[t]].filename;
		}//endfor
	}

	function changeStage() {
		function getStage(location) {
			xmlhttp.abort();
			loadXMLHttpObject();
			xmlhttp.open("GET",location,false);
			xmlhttp.send(null);
			return xmlhttp.responseText;
		}//function
		var stageId = tNav.base.idStage + setName;
//		console.log('changeStage stageId= '+stageId);
		document.getElementById(stageId).innerHTML = getStage(tNav.base.ajaxUrl + tNav.tab[tabName].contentpane);
		//Run scripts in contentpane of the new stage, unaltered code
		dcontents = document.getElementById(stageId);
		if (dcontents) {
			var cp_d = dcontents.getElementsByTagName('script');
			for (var cp_x = 0; cp_x < cp_d.length; cp_x++) {
				with (window) {
					eval(cp_d[cp_x].text);
				}//endwith
			}//for
		}//if
	}//function

	var setName	 = tNav.tab[tabName].set;
//	console.log('setName= '+setName);
	var tabNames = tNav.set[setName];
//	console.log('tabNames= '+tabNames);

	changeTabs();
	changeStage();

}//endfunction

//////////////////////////////////////////////////////////////////////
