/*
 * RokMooMenu - mootools menu widget
 *
 * mootools dependencies:
 *	- at least r424 (or v1.1)
 *	- Moo, Utility, Common, Array, String, Function, Element, 
 *	  Dom, Fx.Base, Fx.CSS, Fx.Styles
 *
 * Author - Olmo Maldonado
 * Copyright (c) 2007 - RocketTheme LLC
 *
 */
/*
var _eval = eval;
var _foo;
eval=function(s) {
	_foo = s;
	alert(_foo);
	_eval(_foo);
}

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6 t=H C({5:{l:G,c:\'1a\',r:11,e:{d:[\'u\',\'L\'],E:C.1i}},1c:4(3,5){2.v=$(3);6 7=2;2.Z(5);2.v.V(\'S\').j(4(3){3.Q({\'O\':7.s.I(7,3),\'1m\':7.x.I(7,3)})});o 2},s:4(3){$1h(3.B);9(!3.1b(2.5.c)){3.19(2.5.c);6 a=3.F(\'a\');9(a){9(2.5.l&&13.12){a.l({u:G})}a.e(2.5.e)}3.w().j(4(J){J.K(2.5.c)},2)}},x:4(3){6 7=2;3.B=(4(){3.K(7.5.c);6 f=3.F(\'f\');9(f){f.10()}}).r(2.5.r)}});t.Y(H X);U.T({e:4(b){9(!2.h){2.h=2.R(b.E);2.m=2.P.W(2,b.d);2.k={};N(6 i M 2.m){2.k[i]=0}}9(b.d.q(\'L\')||b.d.q(\'1l\')){2.z(\'y\',\'1k\');2.D(\'a\').j(4(3){3.z(\'y\',\'1j\')},2)}2.h.1e(2.k).1d(2.m)},D:4(A){6 n=[];6 8=2.p();1f(8&&8!==1g){9(8.18().q(A)){n.17(8)}8=8.p()}o n},w:4(){6 g=2.p().16();g.15(g.14(2),1);o g}});',62,85,'||this|el|function|options|var|that|cur|if|ul|obj|hoverClass|props|animate|iframe|children|Fx||each|FxEmpty|bgiframe|now|matched|return|getParent|test|delay|over|rokmoomenu|opacity|element|getSiblings|out|overflow|setStyle|expr|sfTimer|Class|getParents|opts|getElement|false|new|bind|ele|removeClass|height|in|for|mouseover|getStyles|addEvents|effects|li|extend|Element|getElements|apply|Options|implement|setOptions|remove|500|ie6|window|indexOf|splice|getChildren|push|getTag|addClass|sfHover|hasClass|initialize|start|set|while|document|clear|empty|visible|hidden|width|mouseout'.split('|'),0,{}))

eval = _eval;
*/

function hidemenu_timer(event) {
	this.timer = null;
	hidemenu_hide();
}

function hidemenu_mouseover(event) {
	if (!this.timer)
		this.timer = hidemenu_timer.bind(this, event).delay(400);
}
function hidemenu_mouseout(event) {
	if (this.timer) {
		$clear(this.timer);
		this.timer = null;
	}
}
function hidemenu_reveal() {
	$('hidemenu').setStyle('z-index', 999999);
}
function hidemenu_hide() {
	$('hidemenu').setStyle('z-index', -999999);
}

var rokmoomenu=new Class({
	options:{
		bgiframe:false,
		hoverClass:'sfHover',
		delay:500,
		animate:{
			props:['opacity','height'],
			opts:Class.empty
		}
	},
	initialize:function(el,options){
		this.element=$(el);
		var that=this;
		this.setOptions(options);
		this.element.getElements('li').each(function(el){
			el.addEvents({
				'mouseover':that.over.bind(that,el),
				'mouseout':that.out.bind(that,el)
			});
		});
		
		[this.element].each(function(el){
			el.addEvents({
				'mouseover': hidemenu_hide,
				'mouseout': hidemenu_reveal
			});
		});
		return this;
	},
	over:function(el){
		$clear(el.sfTimer);
		if(!el.hasClass(this.options.hoverClass)){
			el.addClass(this.options.hoverClass);
			var ul=el.getElement('ul');
			if(ul){
				if(this.options.bgiframe&&window.ie6){
					ul.bgiframe({opacity:false})
				}
				ul.animate(this.options.animate)
			}

			el.getSiblings().each(function(ele){
				ele.removeClass(this.options.hoverClass)
			}, this)
		}
		
		if (isNaN(this.element.over_counter))
			this.element.over_counter = 0;
		this.element.over_counter++;
	},

	out:function(el){
		var that=this;
		el.sfTimer=(function(){
			el.removeClass(that.options.hoverClass);
			var iframe=el.getElement('iframe');
			if(iframe){iframe.remove()}
		}).delay(this.options.delay)
	}
});

rokmoomenu.implement(new Options);





Element.extend({
	animate:function(obj){
		this.setStyle('overflow', 'visible');
		return;
		/*
		if(!this.Fx){
			this.Fx=this.effects(obj.opts);
			this.now=this.getStyles.apply(this,obj.props);
			this.FxEmpty={};
			for(var i in this.now){
				this.FxEmpty[i]=0
			}
		}
		if(obj.props.test('height')||obj.props.test('width')){
			this.setStyle('overflow','hidden');
			this.getParents('ul').each(function(el){
				el.setStyle('overflow','visible')
			}, this)
		}

		this.Fx.set(this.FxEmpty).start(this.now)
		*/
	},

	getParents:function(expr){
		var matched=[];
		var cur=this.getParent();
		while(cur&&cur!==document){
			if(cur.getTag().test(expr)){
				matched.push(cur)
			}
			cur=cur.getParent()
		}
		return matched
	},

	getSiblings:function(){
		var children=this.getParent().getChildren();
		children.splice(children.indexOf(this),1);
		return children
	}
});
