var VFCatalog = new Class
({
	autoResize: false,
	
	__catalogs: [],
	__catalogContainer: null,
	__catalogObject: null,
	
	initialize: function()
	{
	},

	init: function()
	{
		this.__catalogContainer = new Element('div', {'class': 'vfCatalog hide'}).inject(document.body);
	},
	
	addCatalog: function(options)
	{
		var catalogId = this.__catalogs.length;
		
		this.__catalogs.push(options);
		
		if (options.link)
			options.link.addEvent('click', this.show.bind(this, [catalogId]));

		return catalogId;
	},
	
	show: function(catalogId)
	{
		this.__catalogContainer.removeClass('hide');

		if (this.autoResize)
		{
			var documentSize = document.getSize();
			this.__catalogContainer.setStyles
			({
				'width': documentSize.x,
				'height': documentSize.y - 5
			});
		}
		
		this.__catalogObject = new Swiff
		(
			'wsip.swf', 
			{
			    'width': '100%',
			    'height': '100%',
			    'container': this.__catalogContainer,
			    'params': 
			    {
			        'wMode': null,
			        'bgcolor': '#ffffff'
			    },
			    'vars': 
			    {
			        'catalog_xml': this.__catalogs[catalogId].xml || ''
			    }
			}
		);
	},
	
	hide: function()
	{
		this.__catalogContainer.addClass('hide');
		this.__catalogContainer.empty();
	}
});

var vfCatalog = new VFCatalog();

function vfCatalogClose()
{
	window.close();
}

window.addEvent
(
	'domready',
	function()
	{
		vfCatalog.init();
		var catalogId = vfCatalog.addCatalog
		({
			'xml': './Ciekawa_Fizyka.xml'
		});
		vfCatalog.show(catalogId);
	}
);
