var WindowBanner = Class.create();

WindowBanner.prototype = {

	initialize: function()
	{
		this.relCatch = 'showBanner';
		this.loadingEffect = new AjaxLoadingEffect({containerId:'banner-cnt-overlay'});
	},
	
	setCatcher: function()
	{
		var aLinks = $$('a[rel="'+this.relCatch+'"]');
		if(aLinks)
		{
			aLinks.each(function(el) { el.onclick = function() { return false } } )
            aLinks.invoke('observe', 'click', this.showWindow.bindAsEventListener(this) );			
		}
	},
	
	showWindow:function(objEvent)
	{
		var A = Event.findElement(objEvent, 'a');
		var href = A.href;
		window.scrollTo(0,0);
		/*this.hideShowBodyScroll('hidden');*/
		
		this.loadingEffect.setLoadingEffect();
           new Ajax.Request(href, {
                'onSuccess':this.successLoading.bind(this)
            });
	},
	
	successLoading: function( responce)
	{
		var bod = document.getElementsByTagName('body')[0];
		/*
		var divCnt = document.createElement('div');
		divCnt.id = 'banner-popup-cnt';
		bod.appendChild(divCnt);
		
		this.loadingEffect.removeLoadingEffect();
		
		divCnt.innerHTML = responce.responseText;
		*/
		new Insertion.Bottom(bod, responce.responseText) 
		return false;
		
	},
	
	closeWindow: function(objElement)
	{	
		Element.remove($('info_api_block'));
		/*this.hideShowBodyScroll('');
	},
	
	hideShowBodyScroll: function( display )
	{
		document.body.style.overflow=display;*/
	}	
	

}

var objWindowBanner = new WindowBanner();
Event.observe(document, 'dom:loaded', objWindowBanner.setCatcher.bindAsEventListener(objWindowBanner) );
