
/* jump MENU */

function jumpMENU(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}


/* rewrite HTML */
/* ! prototype.js ! */

function rewriteHTML(id, filename){
	new Ajax.Updater(id, filename, {method:'get'});
}

var popup = {
	base: {
		close: function(){
			if (!this._pop){
				return;
			}
			this._pop.hide();
			this._pop.stopObserving('mouseover', Event.stop)
			this._body.stopObserving('mouseover', this.close.bind(this));
			this._header.stopObserving('mouseover', Event.stop)
		},
		jump: function(base){
			if (!this._pop){
				return;
			}
			this._pop.observe('mouseover', Event.stop);
			this._body.observe('mouseover', this.close.bind(this));
			this._header.observe('mouseover', Event.stop);

			var offset = Position.cumulativeOffset(base);
			this._pop.setStyle({
				display: 'block',
				left   : offset[0] + "px",
				top    : offset[1] + 15 + "px"
			});
		},
		hover: function(target){
			if (this._hover_target){
				this._hover_target.removeClassName('hover');
			}
			this._hover_target = $(target);
			this._hover_target.addClassName('hover');
		}
	},
	_create: function(){
		return this.inject({}, function(result, pair){
			result[pair.key] = wrap(pair.value);
			return result;
		});
		function wrap(f){
			return !(f instanceof Function) ? f : function(){
				if(!this._initialized){
					this._initialized = true;
					this.initialize();
				}
				return f.apply(this, $A(arguments));
			}
		}
	},
	create: function(obj){
		return this._create.call($H(this.base).merge(obj));
	}
};

popup.live = popup.create({
	initialize: function(){
		this._pop = $('popup_jump2recent');
		this._body = $(document.body);
		this._header = $('header');
		this._hover_target = null;
	}
});

popup.other = popup.create({
	initialize: function(){
		this._pop = $('popup_other');
		this._body = $(document.body);
		this._header = $('header');
		this._hover_target = null;
	}
});


