(function(){
cfpf={
	browser: undefined,
	flashID: undefined,
	flash: undefined,
	
	getBrowserType: function()
	{
		var agent = navigator.userAgent;
		var agentStr = 'unknown';
		if( agent.indexOf( 'MSIE' ) > -1 ){ agentStr = 'IE'; }
		if( agent.indexOf( 'Firefox' ) > -1 ){ agentStr = 'Firefox'; } 
		if( agent.indexOf( 'Opera' ) > -1 ){ agentStr = 'Opera'; }
		if( agent.indexOf( 'Safari' ) > -1 ){ agentStr = 'Safari'; } 
		if( agent.indexOf( 'Chrome' ) > -1 ){ agentStr = 'Chrome'; }
		return agentStr;
	},
	
	getFlash: function( id )
	{
		return ( cfpf.browser == 'IE' ? window[ id ] : document[ id ] );
	},
	
	onWindowBlur: function()
	{
		if( cfpf.flash.onWindowBlur )
			cfpf.flash.onWindowBlur();
	},
	
	onWindowFocus: function()
	{
		if( cfpf.flash.onWindowFocus )
			cfpf.flash.onWindowFocus();
	},
	
	setFocus: function()
	{
		window.focus();
	},
	
	wheel: function( event )
	{
		if( !event )
			event = window.event;
	
		if( event.preventDefault )
			event.preventDefault();
		
		event.returnValue = false;
	},
	
	stealWheel: function()
	{
		if( window.addEventListener )
			window.addEventListener( 'DOMMouseScroll', cfpf.wheel, false );
		
		window.onmousewheel = document.onmousewheel = cfpf.wheel;
	},
	
	unstealWheel: function()
	{
		if( window.removeEventListener )
			window.removeEventListener( 'DOMMouseScroll', cfpf.wheel, false );

		window.onmousewheel = document.onmousewheel = null;
	},
	
	beforeUnloadHandler: function( event )
	{
		try
		{
			if( cfpf.flash.onBrowserUnload )
				cfpf.flash.onBrowserUnload();
		}
		catch( event )
		{
			//
		}
		finally
		{
			//alert( 'Window or Tab closed.' );
		}
	},
	
	addBeforeUnloadListener: function()
	{
		window.onbeforeunload = document.onbeforeunload = cfpf.beforeUnloadHandler;
	},
	
	removeBeforeUnloadListener: function()
	{
		window.onbeforeunload = document.onbeforeunload = null;
	},
	
	constructor: function()
	{
		cfpf.browser = cfpf.getBrowserType();
		cfpf.flash = cfpf.getFlash( cfpf.flashID );
		
		if( cfpf.flash != undefined )
		{
			window.onfocus = cfpf.onWindowFocus;
			window.onblur  = cfpf.onWindowBlur;
		}
	},
	
	init: function( id )
	{
		cfpf.flashID = id;
		window.onload  = cfpf.constructor;
	}
}
})();

