
function historyHandler()
{
	this.addHistory = function( data )
	{
		if ( data && data.length && ( data != "0" ) )
		{
			unFocus.History.Keeper.addHistory( data, false );
		}
	};
	
	this.onHistoryChange = function( data )
	{
		//  IE calls this when back/forward is pressed, then Flash is called to pushDeeplink which is not meant to happen here
		//  because Flash already has the id of "data" it does not seem to have consequences...
		//  Maybe we can catch this in the Olga Flash API by checking the value of "activePageId" before setting it, only fire an event if the value differs
		if (data && data.length && (data != "0")) {
			pushDeeplink(data);
		}
	};
	
	this.olgaAddHistory = function( data )
	{
		// console.log( "olgaAddHistory data: " + data );
		if ( data && data.length && ( data != "0" ) )
		{
			// TODO Let Flash pass the title or xml request it from back-end
			unFocus.History.Keeper.addHistory( data, true );
			
			// add to statistics tracker
			if (typeof(trackStatistics) == "function") 
				trackStatistics(data);
		}
	};
	
	
	
	unFocus.History.Keeper.addEventListener( 'historyChange', this.onHistoryChange );
	
	this.getCurrentState = function()
	{
	};
};

document.historyHandler = new historyHandler ();

function pushDeeplink( id )
{
	passToFlash( "swfobjId","activePageId", id );
}