/* menu / hints */
function setEffectDone(eff) {
	eff.element.addClassName('-hint-effect-done');
	if (eff.element.hasClassName('-hint-delayed')) {
		Effect.BlindUp(eff.element);
		eff.element.removeClassName('-hint-delayed');
	}
}
var Hint = Class.create({
	initialize: function(msg, hdl, opts) {
		this.hint = new Element('div', {style: 'display: none', className: 'hint'});
		this.hint.innerHTML = msg; // for prefomatted messages
		if (Prototype.Browser.IE) {
			var frm = new Element('iframe', {scrolling: 'no', frameBorder: 0, className: 'hint-frame'}); // IE6.0- fixing
			frm.setStyle({height: this.hint.getHeight()+'px'});
			this.hint.appendChild(frm);
		}
		this.handler = $(hdl);
		this.handler.parentNode.appendChild(this.hint);
		this.handler.observe('mouseover', this.show.bindAsEventListener(this));
		this.handler.observe('mouseout', this.hide.bindAsEventListener(this));
		this.opts = {fliph: false};
		Object.extend(this.opts, opts);
	},
	show: function() {
		if ($(this.hint).visible()) {
			this.hint.removeClassName('-hint-delayed');
			return;
		}
		this.hint.removeClassName('-hint-effect-done');
		var pos = Element.cumulativeOffset(this.handler);
		var hdlSize = Element.getDimensions(this.handler);
		var hintSize = Element.getDimensions(this.hint);
		var viewport = document.viewport.getDimensions();
		var offset = document.viewport.getScrollOffsets();
		var left = pos.left + hdlSize.width + 4;
		if (this.opts.fliph || left+hintSize.width > viewport.width+offset.left) {
			left = pos.left - hintSize.width - 4;
		}
		var top = pos.top;
		if (top+hintSize.height > viewport.height+offset.top) {
			top = pos.top - hintSize.height + hdlSize.height;
		}
		this.hint.setStyle({left: left+'px', top: top+'px'});
		Effect.BlindDown(this.hint, {afterFinish: setEffectDone});
	},
	hide: function() {
		if (!$(this.hint).visible()) {
			return;
		}
		if (!this.hint.hasClassName('-hint-effect-done')) {
			this.hint.addClassName('-hint-delayed');
			return;
		}
		Effect.BlindUp(this.hint);
	}
});
/* banner */
var Banner = Class.create({
	initialize: function(el, min, max, duration) {
		this.element = $(el);
		this.min = (min == null)?0.3:min;
		this.max = (max == null)?1:max;
		this.duration = (duration == null)?0.5:duration;
		this.element.observe('mouseover', this.show.bindAsEventListener(this));
		this.element.observe('mouseout', this.hide.bindAsEventListener(this));
		this.hide();
	},
	show: function() {
		new Effect.Opacity(this.element, {duration: this.duration, from: this.min, to: this.max});
	},
	hide: function() {
		new Effect.Opacity(this.element, {duration: this.duration, from: this.max, to: this.min});
	}
});
