function dir(obj)
{
	var res = obj + "\n";
	for (attr in obj)
		res += attr + " = " + obj[attr] + "\n"
	return res;
}
var ShowBox = new Class({
	Implements: [Options],
	options: {
	    destinationOverlayOpacity: 0.6,
	    allowManualClose: true,
		duration: 500
	},
	initialize: function(element, overlay, options)
	{
	    this.setOptions(options);
	    this.element = $(element);
	    this.overlay = $(overlay);
	    if (this.options.allowManualClose)
			this.overlay.addEvent("click", this.hide.bind(this));
	    this.targetCoords = this.element.getCoordinates();
	    this.fx = {
			overlayAnimation: new Fx.Tween(this.overlay,
										   {property: "opacity",
										   duration: this.options.duration
											}),
			elementAnimation: new Fx.Tween(this.element,
										   {property: "opacity",
										   duration: this.options.duration
											})
	    }
	},
	show: function(c_url)
	{
	    var popup = this.element
		popup.set('text', "");
	    var myAJAXRequest = new Request.HTML({
		    url: c_url,
		    onSuccess: function(html) {
				popup.set('text', '');
				popup.adopt(html);
		    },
		    onFailure: function() {
				//ПОТОМ УБРАТЬ!
				//popup.innerHTML = '<img src="/media/pic/error.png" />';
				ShowBox.hide();
		    }
		});
	    myAJAXRequest.get(popup);

	    this.setPosition();
		this.element.setStyle("display", "block");
		this.overlay.setStyle("display", "block");
	    this.fx.overlayAnimation.start(0, this.options.destinationOverlayOpacity);
	    this.fx.elementAnimation.start(0, 1);
	},
	remove_elements: function()
	{
		this.element.setStyle("display", "none");
		this.overlay.setStyle("display", "none");
	},
	hide: function()
	{
	    this.fx.overlayAnimation.start(this.options.destinationOverlayOpacity, 0);
	    this.fx.elementAnimation.start(1, 0);
		this.remove_elements.delay(this.options.duration, this);
	},
	setPosition: function()
	{
	    this.element.setStyles({
		    "top": ((document.body.clientHeight / 6) ),
		    "marginLeft": -(this.targetCoords.width / 2)
	 });
	    this.overlay.setStyles({
		    "top": 0,
		    "height": (window.getSize().y*3)
		    });
	}
    })