Omni =
{
	parent: null,

	init : function(options)
	{
		this.parent = options.parent;
		return this;
	},

	/*
	 * Sets the UserName in the main Screen. Welcome [userName}
	 */
	setUseName: function(userName, adminAccess, _sessionId, omnilocationMode)
	{
		if(omnilocationMode == null)
		{
			omnilocationMode = 'omni';
		}
		this.parent.$('userNameSpan').set('text', userName);
		loggedUser = userName;

		this.initializeGEViews(omnilocationMode);

		//setMapsViews();
		//overMapWindow();
		if(adminAccess == 'true')
		{
			this.parent.$('adminLink').setStyle('visibility', 'visible');
		}
		sessionId = _sessionId;
	},

	/*
	 * Sets the right Frames for use with GE Plugin View
	 */
	initializeGEViews: function(omnilocationMode)
	{
		this.parent.MochaUI.asetPanelContent();

		if (omnilocationMode == 'ec09')
		{
			this.parent.MochaUI.updateContent({'element':  this.parent.$('gePanel'),'loadMethod': 'iframe', 'url':'./controller?action=showMapPanel'});
			this.parent.MochaUI.updateContent({'element':  this.parent.$('overMapPanel'),'loadMethod': 'iframe', 'url':'./controller?action=showOverMapEC09'});
		}
		else if (omnilocationMode == 'lcoe')
		{
			this.parent.MochaUI.updateContent({'element':  this.parent.$('gePanel'), 'loadMethod': 'iframe', 'url':'./controller?action=showPage&page=lcoe'});
		}
		else
		{
			this.parent.MochaUI.updateContent({'element':  this.parent.$('gePanel'), 'loadMethod': 'iframe', 'url':'./controller?action=showPage&page=gePanel'});
		}

		if (omnilocationMode == 'omni' || omnilocationMode == 'mobileworker')
		{
			this.parent.MochaUI.updateContent({'element':  this.parent.$('overMapPanel'),'loadMethod': 'iframe', 'url':'./controller?action=showOverMap'});
		}

		if (omnilocationMode != 'lcoe')
		{
			this.parent.MochaUI.updateContent({'element':  this.parent.$('assetMenuPanel'),'loadMethod': 'xhr', 'url':'./controller?action=showPage&page=assetPanelFooter'});
		}

		if (omnilocationMode == 'ec09' || omnilocationMode == 'rollcall' || omnilocationMode == 'demo')
		{
			this.stopRefresh();
			this.hidePanel('assetMenuPanel');
			this.parent.liveRefresh = this.parent.MochaUI.showLiveTracking.periodical(this.parent.refreshInterval);
		}

		//$('kmlPlacemarkDataPanel_header').setStyle('display', 'none');
		//$('kmlPlacemarkDataPanel_collapseToggle').fireEvent('click');
	},

	stopRefresh: function()
	{
		this.parent.$clear(this.parent.liveRefresh);
	},

	showMainTaskPanel: function()
	{
		//$('panelid').hasClass('expanded') will return true or false.
		//$('panelid').hasClass('collapsed') will return true or false.
		if(this.parent.$('mainTaskPanel').hasClass('collapsed'))
		{
			this.parent.$('mainTaskPanel_collapseToggle').fireEvent('click');
		}
	},

	hideAssetMenuPanel: function()
	{
		if(this.parent.$('assetMenuPanel').hasClass('expanded'))
		{
			this.parent.$('assetMenuPanel_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	showAssetMenuPanel: function()
	{
		if(this.parent.$('assetMenuPanel').hasClass('collapsed'))
		{
			this.parent.$('assetMenuPanel_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	hideLeftBottomPanel: function()
	{
		if(this.parent.$('leftBottomPanel').hasClass('expanded'))
		{
			this.parent.$('leftBottomPanel_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	showLeftBottomPanel: function()
	{
		if(this.parent.$('leftBottomPanel').hasClass('collapsed'))
		{
			this.parent.$('leftBottomPanel_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	hidePanel: function(panelName)
	{
		if(this.parent.$(panelName).hasClass('expanded'))
		{
			this.parent.$(panelName + '_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	showPanel: function(panelName)
	{
		if(this.parent.$(panelName).hasClass('collapsed'))
		{
			this.parent.$(panelName + '_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
	},

	toglePanel: function(panelName)
	{
		if(this.parent.$(panelName).hasClass('collapsed'))
		{
			this.parent.$(panelName + '_collapseToggle').fireEvent('click');
			//$('kmlPlacemarkDataPanel_header').setStyle('display', 'block');
		}
		else if(this.parent.$(panelName).hasClass('expanded'))
		{
			this.parent.$(panelName + '_collapseToggle').fireEvent('click');
		}
	},

	closeWindow: function(windowName)
	{
		if(this.parent.$(windowName))
		{
			this.parent.MochaUI.closeWindow(this.parent.$(windowName));
		}
	}
}
