KeyBox.AjaxBox = Class.create(KeyBox.Base,
{
	initialize: function(optionsObj)
	{
		this.initKeyBoxBase(optionsObj);
	},
	
	startAjaxCall: function(url, optParamObj, eventA)
	{
		var self = this;
		var container = this.container;
		new Ajax.Request(url,
		{
			method: 'GET',
			parameters: optParamObj,
			onSuccess: function(transport)
			{
				$(container).innerHTML = transport.responseText;
				self.showResult();
			},
			onFailure: function()
			{
				self.removeBox();
			}
		});
	},
	
	showResult: function()
	{
		var container = this.container;
		var base = this.base;
		var centerDims = this.calculateCenterDimensions(container, base);
		$(container).setStyle(
		{
			'top' : centerDims.top+'px',
			'left' : centerDims.left+'px'
		});
		
		this.createCloseBtn();
			
		setTimeout(function()
		{
			new Effect.Opacity(container,
			{
				duration:1.1,
				from: 0.0,
				to: 0.99,
				queue: { position: 'end', scope: 'KeyBoxScope', limit: 2 },
				beforeStart: function()
				{
					$(container).setStyle({'display':'block'});
				}
			});
		}.bind(this),200);
	},
	
	activateBox: function()
	{
		//this.showBaseContainer();
	},
	
	createCloseBtn: function()
	{
		var closeBtn = new Element('a', { 'onclick':'return false;', 'id':'keyboxCloseBtn' });
		closeBtn.innerHTML = 'X';
		$(closeBtn).observe('click', function()
		{
			this.removeBox();
		}.bind(this));
		$(this.container).appendChild(closeBtn);
	}
});
Event.observe(window, 'load', function()
{
	var keybox = new KeyBox.AjaxBox();
	if($('showMoreInfo'))
	{
		Element.observe('showMoreInfo', 'click', function()
		{
			var catId = this.getAttribute('rel');
			keybox.startAjaxCall('/index.php',
			{
				'c_' : 'CategoryContentGUI',
				'm_' : 'writeCategoryAjax',
				'cid' : catId
			});
			keybox.activateBox();				
		});
	}
});