//Javascript File
//Navigation Framework

//Reference Pointer to Nav Object
var gaNavPtr;
var gaNavAppPtr;

//**************************************************************************************************
//gaNavigation Object - Inherits AjaxPlugin class
var gaNavigation = Class.create(AjaxPlugin, {
	//Methods
	initialize: function($super, xmlURL, container, bodyDiv) {
		//superclass constructor
		$super();
		//Register Events
		this.register_event_names(['onNavBeginLoad', 'onNavFinishLoad', 'onApplicationChange', 'onBeginWorkflowChange', 'onWorkflowChange','onCompleteWorkflowChange',
			'onTabClick', 'onPageBeginLoad', 'onPageFinishLoad', 'onPageFinishDisplay']);
		//Properties
		this.xmlURL = xmlURL;
		this.container = container;
		this.bodyDiv = bodyDiv;
		this.applications = new Array();
		this.activeApplication = -1;
		this.urlRoot = "";
		this.navXML = "";
		
    		// Include IE-specific styles if nec:
    		if (Prototype.Browser.IE) {
     		 var ie_sheet = $link({ type: "text/css", rel: "stylesheet", href: this.plugins_server_path+"navigation/nav_IE.css" });
     		 document.getElementsByTagName("head")[0].appendChild(ie_sheet);
    		}
	},
	load: function() {
		gaNavPtr = this;
		this.raise_event('onNavBeginLoad', { });
		new Ajax.Request(this.xmlURL, {
			onSuccess: function(transport) {
				var a, b, c;
				var appXML, tmpApp, appName, appTitle, appPath, appHomepage;
				var wfXML, tmpWf, wfName;
				var tabXML, tabName, tabText, tabState, tabURL, isStart, forceReload;
				gaNavPtr.navXML = transport.responseXML.documentElement;
				for(a = 0; a < gaNavPtr.navXML.getElementsByTagName("application").length; a++) {
					gaNavPtr.applications.push(new gaNavApplication(gaNavPtr.navXML.getElementsByTagName("application")[a], a));
					tmpAppName = gaNavPtr.applications[a].name;
					eval("gaNavPtr."+ tmpAppName + " = gaNavPtr.applications[a]");
				}
				gaNavPtr.raise_event('onNavFinishLoad', { });
			},
			onFailure: function(transport) {this.logMsg('AJAX failure:'+transport);}.bind(this),
			onException: function(req, ex) {this.logMsg('AJAX exception '+ex+ ' on '+req.url);}.bind(this)
		});
	},
	loadApplication: function(app) {
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}

		if(typeof(app) == "number") {
			if(this.applications[app]) {
				if(this.activeApplication != app) {
					this.applications[app].load();
				}
			} else {
				this.logMsg(app + ' not found');
			}
		}
	},
	loadWorkflow: function(app, workflow) {
		var cur_wf = this.applications[this.activeApplication].activeWorkflow;
		var cur_tab = this.applications[this.activeApplication].workflows[cur_wf].activeTab;
		var appID, workflowID;

		//Get application array index
		if(typeof(app) == "number") {
			appID = app;
		} else {
			appID = this.getApplicationIndex(app);
		}

		//Get workflow array index
		if(typeof(workflow) == "number") {
			workflowID = workflow;
		} else if(typeof(workflow) == "string") {
			workflowID = this.applications[appID].getWorkflowIndex(workflow);
		}
		this.raise_event('onBeginWorkflowChange', {'app': appID, 'from_workflow': cur_wf, 'to_workflow': workflowID, 'from_tab': cur_tab});

		this.applications[appID].workflows[workflowID].load();
	},
	clearContainer: function() {
		$(this.container).innerHTML = "";
	},
	createPageContentDiv: function(divName) {
		if($(divName) == null) {
			$(gaNavPtr.bodyDiv).appendChild(new Element('div', { 'class': 'mainDivPage', style: 'display: none;', id: divName }));
		}
	},
	displayPage: function(url, divName, forceReload, showPanel) {

		$(this.bodyDiv).childElements().each(function(node) {
			node.setStyle({display: "none"});
		});
		this.raise_event('onPageBeginLoad', {'url': this.urlRoot + url, 'target': divName, 'showPanel': showPanel});
		if(!$(divName) || forceReload == "true" || forceReload == true) {
			if(!$(divName)) {
				this.createPageContentDiv(divName);
			}
			$(divName).setStyle({'display': 'block'});
			//$(divName).innerHTML = '<br /><br /><br /><span style=\"margin-left: auto; margin-right: auto;" align="center"><img src="../shared/images/anim_preloading.gif" width=\"65\" height=\"15\" alt=\"\" /></span>';

			new Ajax.Updater(divName, this.urlRoot + url, {
					evalScripts: true,
					onComplete: function(transport) {
						gaNavPtr.raise_event('onPageFinishLoad', {'url': this.urlRoot + url, 'target': divName});
						gaNavPtr.raise_event('onPageFinishDisplay', {'url': this.urlRoot + url, 'target': divName});
					},
					onFailure: function(transport) {this.logMsg('AJAX failure:'+transport);}.bind(this),
					onException: function(req, ex) {this.logMsg('AJAX exception '+ex+ ' on '+req.url);}.bind(this)
			});
		} else { // If it's already loaded, display it and raise pageFinishDisplay:
			$(divName).setStyle({'display': 'block'});
			gaNavPtr.raise_event('onPageFinishDisplay', {'url': this.urlRoot + url, 'target': divName});
		}
	},
	postToPage: function(url, divName, showPanel, postData) {
		$(this.bodyDiv).childElements().each(function(node) {
			node.setStyle({display: "none"});
		});
		this.raise_event('onPageBeginLoad', {'url': this.urlRoot + url, 'target': divName, 'showPanel': showPanel});
		if(!$(divName)) {
			this.createPageContentDiv(divName);
		}
		new Ajax.Updater(divName, this.urlRoot + url, {
				parameters: postData,
				evalScripts: true,
				onComplete: function(transport) {
					gaNavPtr.raise_event('onPageFinishLoad', {'url': this.urlRoot + url, 'target': divName});
				},
				onFailure: function(transport) {this.logMsg('AJAX failure:'+transport);}.bind(this),
				onException: function(req, ex) {this.logMsg('AJAX exception '+ex+ ' on '+req.url);}.bind(this)
		});
		$(divName).setStyle({'display': "block"});
	},
	getApplicationIndex: function(appName) {
		var a;
		if(appName) {
			for(a = 0; a < this.applications.length; a++) {
				if(this.applications[a].name === appName) {
					return a;
				}
			}
		}
    // otherwise:
		this.logMsg('Nav error - unknown app:'+appName);
		return -1;
	},
	activeApp: function() {
	  return this.applications[this.activeApplication];
	},
	activeWorkflow: function() {
	  return this.activeApp().workflows[this.activeApp().activeWorkflow];
	},
	activeTab: function() {
	  return this.activeWorkflow().tabs[this.activeWorkflow().activeTab];
	},
	tabClick: function(app, workflow, tab) {
		//Convert textual names to array indices
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}
		if(typeof(workflow) != "number") {
			workflow = this.applications[app].getWorkflowIndex(workflow);
		}
		if(typeof(tab) != "number") {
			tab = this.applications[app].workflows[workflow].getTabIndex(tab);
		}
		//Raise onTabClick Event
		this.raise_event('onTabClick', this.applications[app].workflows[workflow].tabs[tab]);

		//Perform the Click
		this.applications[app].workflows[workflow].tabs[tab].click();
	},
	tabClickWithPostData: function(app, workflow, tab, data) {
		//Convert textual names to array indices
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}
		if(typeof(workflow) != "number") {
			workflow = this.applications[app].getWorkflowIndex(workflow);
		}
		if(typeof(tab) != "number") {
			tab = this.applications[app].workflows[workflow].getTabIndex(tab);
		}
		//Raise onTabClick Event
		this.raise_event('onTabClick', this.applications[app].workflows[workflow].tabs[tab]);

		//Perform the Click
		this.applications[app].workflows[workflow].tabs[tab].clickWithPost(data);
	},
	tabActivate: function(app, workflow, tab) {
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}
		if(typeof(workflow) != "number") {
			workflow = this.applications[app].getWorkflowIndex(workflow);
		}
		if(typeof(tab) != "number") {
			tab = this.applications[app].workflows[workflow].getTabIndex(tab);
		}
		this.applications[app].workflows[workflow].tabs[tab].activate();
	},
	tabEnable: function(app, workflow, tab) {
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}
		if(typeof(workflow) != "number") {
			workflow = this.applications[app].getWorkflowIndex(workflow);
		}
		if(typeof(tab) != "number") {
			tab = this.applications[app].workflows[workflow].getTabIndex(tab);
		}
		this.applications[app].workflows[workflow].tabs[tab].enable();
	},
	tabDisable: function(app, workflow, tab) {
		if(typeof(app) != "number") {
			app = this.getApplicationIndex(app);
		}
		if(typeof(workflow) != "number") {
			workflow = this.applications[app].getWorkflowIndex(workflow);
		}
		if(typeof(tab) != "number") {
			tab = this.applications[app].workflows[workflow].getTabIndex(tab);
		}
		this.applications[app].workflows[workflow].tabs[tab].disable();
	},
	isNextEnabled: function() {
		var wfID, currentTabID, nextTabID;
		if(this.activeApplication > -1) {
			wfID = this.applications[this.activeApplication].activeWorkflow;
			currentTabID = this.applications[this.activeApplication].workflows[wfID].activeTab;
			nextTabID = currentTabID + 1;
			if(nextTabID < this.applications[this.activeApplication].workflows[wfID].tabs.length) {
				if(this.applications[this.activeApplication].workflows[wfID].tabs[nextTabID].state == "enabled") {
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	},
	moveNext: function() {
		var wfID, currentTabID, nextTabID;
		if(this.isNextEnabled()) {
			wfID = this.applications[this.activeApplication].activeWorkflow;
			currentTabID = this.applications[this.activeApplication].workflows[wfID].activeTab;
			nextTabID = currentTabID + 1;
			this.applications[this.activeApplication].workflows[wfID].tabs[nextTabID].click();
		}
	},
	prevTabExists: function() {
		var wfID, currentTabID, prevTabID;
		if(this.activeApplication > -1) {
			wfID = this.applications[this.activeApplication].activeWorkflow;
			currentTabID = this.applications[this.activeApplication].workflows[wfID].activeTab;
			prevTabID = currentTabID - 1;
			if(prevTabID >= 0) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	},
	movePrev: function() {
		var wfID, currentTabID;
		if(this.prevTabExists()) {
			wfID = this.applications[this.activeApplication].activeWorkflow;
			currentTabID = this.applications[this.activeApplication].workflows[wfID].activeTab;
			this.applications[this.activeApplication].workflows[wfID].tabs[currentTabID - 1].click();
		}
	},
	application: function(appName) {
		// Returns application object with given name or index
		if(typeof(appName) == "number") {
			return this.applications[Math.floor(appName)];
		} else {
			var appID = this.getApplicationIndex(appName);
			return this.applications[appID];
		}
	},
	app: function(appName) {
		// Returns application object with given name or index
		return this.application(appName);
	},
	submitForm: function(formID, appID, wfID, tabID) {
		// Takes a form with given ID, builds a Hash of the form elements and values, and posts it to the given
		// tab.
		var dataHash =  $H();
		if($(formID) != null) {
			if(gaNavPtr.app(appID).wf(wfID).tab(tabID)) {
				var frm = $(formID);
				for(var a = 0; a < frm.getElements().length; a++) {
					dataHash.set(frm.getElements()[a].name, frm.getElements()[a].value);
				}
				gaNavPtr.app(appID).wf(wfID).tab(tabID).clickWithPost(dataHash);
			}
		}
	}
});

//**************************************************************************************************
//gaNavApplication Object
var gaNavApplication = Class.create({
	//Methods
	initialize: function(appXML, appIndex) {
		//Properties
		try{ this.name = appXML.attributes.getNamedItem("name").nodeValue; } catch (e) { this.name = "";	}
		try{ this.ext_name = appXML.getElementsByTagName("appExternalName")[0].firstChild.nodeValue; } catch (e) { this.ext_name = ""; }
		try{ this.title = appXML.getElementsByTagName("appTitle")[0].firstChild.nodeValue; } catch (e) { this.title = ""; }
		try{ this.path = appXML.getElementsByTagName("appPath")[0].firstChild.nodeValue; } catch (e) { this.path = ""; }
		try{ this.homepage = appXML.getElementsByTagName("appHomepage")[0].firstChild.nodeValue; } catch (e) { this.homepage = ""; }
		this.applicationIndex = appIndex;
		this.activeWorkflow = 0;
		this.JSincludes = new Array();
		this.CSSincludes = new Array();
		this.workflows = new Array();
		this.clickOnLoad = true;
		this.firstLoad = true;

		for(var a = 0; a < appXML.getElementsByTagName("workflow").length; a++) {
			try{ this.workflows.push(new gaNavWorkflow(appXML.getElementsByTagName("workflow")[a], this.name, this.applicationIndex, a)); } catch(e) { }
			tmpWFName = this.workflows[a].name;
			eval("this."+ tmpWFName + " = this.workflows[a]");
		}
		for(a = 0; a < appXML.getElementsByTagName("JavaScriptInclude").length; a++) {
			try{ this.JSincludes.push(appXML.getElementsByTagName("JavaScriptInclude")[a].attributes.getNamedItem("src").nodeValue); } catch(e) { }
		}
		for(a = 0; a < appXML.getElementsByTagName("Stylesheet").length; a++) {
			try{ this.CSSincludes.push(appXML.getElementsByTagName("Stylesheet")[a].attributes.getNamedItem("src").nodeValue); } catch(e) { }
		}
	},
	load: function() {
		this.clickOnLoad = true;
		this._load();
	},
	loadWithoutClick: function() {
		this.clickOnLoad = false;
		this._load();
	},
	_load: function() {
		//Set pointer
		gaNavAppPtr = this;

		//raise onApplicationChange Event
		if(gaNavPtr.activeApplication != this.applicationIndex) {
			gaNavPtr.raise_event('onApplicationChange', { 'appName': this.name });
		}

		//Set Page Title
		$('pageTitle').innerHTML = this.title;

		if (gaNavPtr.debug) {// Add instance config blurb:
			$('pageTitle').innerHTML += '<span id="gaInstanceConfig" />';
			new Ajax.Updater('gaInstanceConfig',gaNavPtr.plugins_server_path+'../../ga/instanceConfig.php?current');
		}

		//Set this application active in the Nav object
		gaNavPtr.activeApplication = this.applicationIndex;

		if(this.firstLoad) {
			for(a = 0; a < this.CSSincludes.length; a++) {
				document.getElementsByTagName("head")[0].appendChild(
					new Element("link", { type: "text/css", rel: "stylesheet", href: this.CSSincludes[a] })
				);
			}
			GA_UTIL.loadJavascript(this.JSincludes, gaNavAppPtr._javascript_loaded);
		} else {
			this.workflows[this.activeWorkflow]._load(this.clickOnLoad);
		}
	},
	_javascript_loaded: function() {
		gaNavAppPtr.firstLoad = false;
		//Load current Active Workflow
		gaNavAppPtr.workflows[gaNavAppPtr.activeWorkflow]._load(gaNavAppPtr.clickOnLoad);
	},
	getWorkflowIndex: function(wfName) {
		var a;
		if(wfName) {
			for(a = 0; a < this.workflows.length; a++) {
				if(this.workflows[a].name === wfName) {
					return a;
				}
			}
		} else {
			return -1;
		}
	},
	enableAll: function(tabname) {
		for(var a = 0; a < this.workflows.length; a++) {
			if (this.workflows[a].tab(tabname))	{
				this.workflows[a].tab(tabname).enable();
			}			
		}
	},
	disableAll: function(tabname) {
		for(var a = 0; a < this.workflows.length; a++) {
			if (this.workflows[a].tab(tabname))	{
				this.workflows[a].tab(tabname).disable();
			}			
		}
	},
	workflow: function(wfName) {
		// Returns workflow object with given name or index
		if(typeof(wfName) == "number") {
			return this.workflows[Math.floor(wfName)];
		} else {
			var wfID = this.getWorkflowIndex(wfName);
			return this.workflows[wfID];
		}
	},
	wf: function(wfName) {
		// Returns workflow object with given name or index
		return this.workflow(wfName);
	}
});

//**************************************************************************************************
//gaNavWorkflow Object
var gaNavWorkflow = Class.create({
	//Methods
	initialize: function(wfXML, appName, appIndex, wfIndex) {
		//Properties
		try{ this.name = wfXML.attributes.getNamedItem("name").nodeValue; } catch(e) { this.name = ""; }
		try{ this.text = wfXML.attributes.getNamedItem("text").nodeValue; } catch(e) { this.text = ""; }
		this.appName = appName;
		this.appIndex = appIndex
		this.workflowIndex = wfIndex;
		this.activeTab = 0;
		this.tabs = new Array();

		for(var a = 0; a < wfXML.getElementsByTagName("tab").length; a++) {
			try{ this.tabs.push(new gaNavTab(wfXML.getElementsByTagName("tab")[a], this.appName, this.appIndex, this.name, this.workflowIndex, a)); } catch(e) { }
			tmpTabName = this.tabs[a].name;
			eval("this."+ tmpTabName + " = this.tabs[a]");
		}
	},
	load: function() {
		this._load(true);
	},
	loadWithoutClick: function() {
		this._load(false);
	},
	_load: function(clickYN) {
		gaNavPtr.raise_event('onWorkflowChange', this);
		gaNavPtr.clearContainer();
		if(gaNavPtr.activeApplication !== this.appIndex) {
			gaNavPtr.activeApplication = this.appIndex;
			gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
			gaNavPtr.applications[this.appIndex].load();
		} else {
			if(gaNavPtr.applications[this.appIndex].activeWorkflow !== this.workflowIndex) {
				gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
				gaNavPtr.applications[this.appIndex].load();
			} else {
				this.tabs.each(function(tab, index) {
					tab.displayMe(gaNavPtr.container);
				});
				if(this.activeTab == 0) {
					if(this.tabs.length > 1) {
						if(this.tabs[0].name == "home" && this.tabs[0].isStart == "true") {
							this.activeTab = 1;
						}
					}
				}
				if(clickYN) {
					this.tabs[this.activeTab].click();
				}
			}
		}
		gaNavPtr.raise_event('onCompleteWorkflowChange', this);
	},
	getTabIndex: function(tabName) {
		var a;
		if(tabName) {
			for(a = 0; a < this.tabs.length; a++) {
				if(this.tabs[a].name === tabName) {
					return a;
				}
			}
		} else {
			return -1;
		}
	},
	tab: function(tabName) {
		// Returns tab object with given name or index
		if(typeof(tabName) == "number") {
			return this.tabs[Math.floor(tabName)];
		} else {
			var tabID = this.getTabIndex(tabName);
			return this.tabs[tabID];
		}
	}
});

//**************************************************************************************************
//gaNavTab Object
var gaNavTab = Class.create({
	//Methods
	initialize: function(tabXML, appName, appIndex, workflowName, workflowIndex, tabIndex) {
		//Properties
		try{ this.name = tabXML.attributes.getNamedItem("name").nodeValue; } catch(e) { this.name = ""; }
		try{ this.text = tabXML.attributes.getNamedItem("text").nodeValue; } catch(e) { this.text = ""; }
		try{ this.state = tabXML.attributes.getNamedItem("state").nodeValue; } catch(e) { this.state = "disabled"; }
		try{ this.isStart = tabXML.attributes.getNamedItem("isStart").nodeValue; } catch(e) { this.isStart = "false"; }
		try{ this.forceReload = tabXML.attributes.getNamedItem("forceReload").nodeValue; } catch(e) { this.forceReload = "false"; }
		try{ this.showPanel = tabXML.attributes.getNamedItem("showPanel").nodeValue; } catch(e) { this.showPanel = "none"; }
		try{ this.url = tabXML.attributes.getNamedItem("url").nodeValue; } catch(e) { this.url = ""; }
		this.tabIndex = tabIndex;
		this.elemID = "nav_" + appName + "_" + workflowName + "_" + this.name;
		this.appName = appName;
		this.appIndex = appIndex;
		this.workflowName = workflowName;
		this.workflowIndex = workflowIndex;
		try{ this.divName = tabXML.attributes.getNamedItem("divName").nodeValue; } catch(e) { 
			this.divName = "content_" + this.appName + "_" + this.url.replace(/[/\\]/g,'_'); 
			var endChar = this.divName.lastIndexOf(".");
			this.divName = this.divName.substring(0, endChar);
		}
	},
	displayMe: function(container) {
		var aIndex = this.appIndex;
		var wIndex = this.workflowIndex;
		var tIndex = this.tabIndex;

		if($(container)) {
			var contElem = $(container);
			var navElem = new Element('div', { id: this.elemID, 'class': 'navContainer', style: 'display: inline;' });

			var navTbl = new Element('table', { cellspacing: '0', cellpadding: '0', border: '0' });
			var navtbody = new Element('tbody');
			var navRow = new Element('tr');

			var leftClass;
			if(this.isStart == "true") {
				leftClass = "Start";
			} else {
				leftClass = "Left";
			}
			navRow.appendChild(new Element('td', { id: 'td_left_' + this.elemID, 'class': 'leftNav ' + this.state + leftClass } ).update('&nbsp;'));
			if(this.isStart == "true" && this.name == "home") {
				var navLink = new Element('a', { id: 'link_' + this.elemID, 'class': 'centerNav', href: 'javascript: gaNavPtr.loadWorkflow(' + aIndex + ', 0);' }).update(this.text.replace(/\s/g,'&nbsp;'));
			} else {
				var navLink = new Element('a', { id: 'link_' + this.elemID, 'class': 'centerNav', href: 'javascript: gaNavPtr.tabClick(' + aIndex + ', ' + wIndex + ', ' + tIndex + ');' }).update(this.text.replace(/\s/g,'&nbsp;'));
			}
			var tdLink = new Element('td', { id: 'td_center_' + this.elemID, 'class': 'centerNav ' + this.state } );
			tdLink.appendChild(navLink);
			navRow.appendChild(tdLink);
			navRow.appendChild(new Element('td', { id: 'td_right_' + this.elemID, 'class': 'rightNav ' + this.state + 'Right' } ).update('&nbsp;'));
			navtbody.appendChild(navRow);
			navTbl.appendChild(navtbody);
			navElem.appendChild(navTbl);
			contElem.appendChild(navElem);
		}
	},
	update: function() {
		if($(this.elemID)) {
			var leftClass;
			if(this.isStart == "true") {
				leftClass = "Start";
			} else {
				leftClass = "Left";
			}
			$('td_left_' + this.elemID).className = 'leftNav ' + this.state + leftClass;
			$('td_center_' + this.elemID).className = 'centerNav ' + this.state;
			$('link_' + this.elemID).innerHTML = this.text;
			$('td_right_' + this.elemID).className = 'rightNav ' + this.state + 'Right';
		}
	},
	enable: function() {
		if($(this.elemID)) {
			this.state = 'enabled';
			this.update();
		}
	},
	disable: function() {
		if($(this.elemID)) {
			this.state = 'disabled';
			this.update();
		}
	},
	activate: function() {
		if($(this.elemID)) {
			this.state = 'active';
			this.update();
			/*
			new Ajax.Request('../shared/ajaxplugins/navigation/session_functions.php', {
				parameters: {
					'function': 'updateCurrentNavPosition',
					navPosition: this.appIndex + ':' + this.workflowIndex + ':' + this.tabIndex
				}
			});
			new Ajax.Request('../shared/ajaxplugins/navigation/session_functions.php', {
				parameters: {
					'function': 'updateViewState',
					navViewState: $(gaNavPtr.bodyDiv).innerHTML
				}
			});
			*/
		}
	},
	click: function() {
		if(this.state != 'disabled') {
			if(gaNavPtr.activeApplication !== this.appIndex) {
				gaNavPtr.activeApplication = this.appIndex;
				gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
				gaNavPtr.applications[this.appIndex].loadWithoutClick();
			} else {
				if(gaNavPtr.applications[this.appIndex].activeWorkflow !== this.workflowIndex) {
					gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].loadWithoutClick();
				} 
			}
			if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab !== this.tabIndex) {
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].loadWithoutClick();
			} 
			gaNavPtr.displayPage(gaNavPtr.applications[this.appIndex].path + this.url, this.divName, this.forceReload, this.showPanel);
			for(var a=0; a < gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs.length; a++) {
				if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].state == "active") {
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].enable();
					break;
				}
			}
			this.activate();
		}
	},
	clickDisabled: function() {
		// Performs a click function even if tab is disabled
		if(gaNavPtr.activeApplication !== this.appIndex) {
			gaNavPtr.activeApplication = this.appIndex;
			gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
			gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
			gaNavPtr.applications[this.appIndex].load();
		} else {
			if(gaNavPtr.applications[this.appIndex].activeWorkflow !== this.workflowIndex) {
				gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].loadWithoutClick();
			} else {
				if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab !== this.tabIndex) {
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].loadWithoutClick();
				}
			}
		}
		gaNavPtr.displayPage(gaNavPtr.applications[this.appIndex].path + this.url, this.divName, this.forceReload, this.showPanel);
		for(var a=0; a < gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs.length; a++) {
			if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].state == "active") {
				if(a != this.tabIndex) {
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].enable();
				}
				break;
			}
		}
		this.activate();
	},
	clickWithPost: function(postData) {
		if(gaNavPtr.activeApplication !== this.appIndex) {
			gaNavPtr.activeApplication = this.appIndex;
			gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
			gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
			gaNavPtr.applications[this.appIndex].loadWithoutClick();
		} else {
			if(gaNavPtr.applications[this.appIndex].activeWorkflow !== this.workflowIndex) {
				gaNavPtr.applications[this.appIndex].activeWorkflow = this.workflowIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
				gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].loadWithoutClick();
			} 
		}
		if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab !== this.tabIndex) {
			gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].activeTab = this.tabIndex;
		} 
		gaNavPtr.postToPage(gaNavPtr.applications[this.appIndex].path + this.url, this.divName, this.showPanel, postData);
		for(var a=0; a < gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs.length; a++) {
			if(gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].state == "active") {
				if(a != this.tabIndex) {
					gaNavPtr.applications[this.appIndex].workflows[this.workflowIndex].tabs[a].enable();
				}
				break;
			}
		}
		this.activate();
	}
});