
NRT.namespace("Utility.History");
NRT.Utility.History = function()
{
	var _initialized = false;
	var _delegatedNavigationFunction = null;

	//attach initialization handler
	if (Sys.Application === 'undefined')
	{
		alert('Please add a history-enabled script manager to this page.');
		return;
	}

	return {

		/******************************************************************************************************************
		*									P U B L I C   M E T H O D S
		*******************************************************************************************************************/
		/*==================================================================================
		Method		: addHistoryPoint
		Summary		: Calls through to the Sys.Application.addHistoryPoint method.
		Author		: Karl Beyer
		Create Date	: 02/05/2007
		====================================================================================*/
		addHistoryPoint: function(key, stateObject)
		{
			try
			{
				//user passed in a string instead of a state object
				//so let's create one for them
				var state = {
					'state': 'state',
					'value': Sys.Serialization.JavaScriptSerializer.serialize(stateObject)
				};
				Sys.Application.addHistoryPoint(state);
			}
			catch (err)
			{
				_oErrorHandler.Error('NRT.History.addHistoryPoint', _oErrorHandler.ERRORTYPE_JS, err);
				return;
			}
		},
		/******************************************************************************************************************
		*									P U B L I C   M E T H O D S
		*******************************************************************************************************************/
		/*==================================================================================
		Method		: addOnNavigationHandler
		Summary		: Adds the delegate function to handle the Sys.Application.onNavigate event.
		Author		: Karl Beyer
		Create Date	: 02/05/2007
		Remarks     : The delegated function should have the following parameter signature: sender, e
		====================================================================================*/
		addOnNavigationHandler: function(delegatedFunction)
		{
			Sys.Application.add_navigate(delegatedFunction);
		},
		/*==================================================================================
		Method		: addClickable
		Summary		: Calls through to the Sys.Application.addHistoryPoint method.
		Author		: Karl Beyer
		Create Date	: 02/05/2007
		Remarks     : The delegated function should have the following parameter signature: sender, e
		====================================================================================*/
		addClickable: function(sourceElement, delegatedFunction)
		{
			if (sourceElement !== 'undefined' && delegatedFunction !== 'undefined')
				$addHandler(sourceElement, "click", "");
		},
		/*==================================================================================
		Method		: getCurrentLocation
		Summary		: We should most likely not need this function any longer
		====================================================================================*/
		getCurrentLocation: function()
		{
			return window.location;
		},
		/*==================================================================================
		Method		: initialize
		Summary		: This empty function simply acts much like an interface stub.
		====================================================================================*/
		initialize: function()
		{
			return;
		}

	};

} ();



