var Tip = Class.create({
	initialize: function(container, tooltip) {
		this.container = $(container);
		this.tooltip   = $(tooltip);
		this.element   = this.container.select('em')[0];
		this.setup();
	},
	setup: function() {
		if(this.element)this.element.observe("mouseover", this.show.bindAsEventListener(this));
	},
	show: function(event) {		
		this.tooltip.style.display = 'block';
		this.listener = this.hide.bindAsEventListener(this);
		Event.observe(document, "click", this.listener);
		Event.observe(this.tooltip, "click", function() {
			this.wait = true; }.bind(this));		
		// event.stop();
	},
	hide: function(event) {
		if (this.wait) return;
		this.container.undoPositioned();
		Event.stopObserving(document, "click", this.listener);
		this.tooltip.style.display = 'none';
		// if (event) event.stop();
	}
});



    document.observe("dom:loaded", function(){
        new Accordion("accordion");
        new Tip('magazine-article', 'tool-tip');
    });


