var Rokmoomenu = new Class(
{
    options: 
    {
        bgiframe: true, hoverClass: 'sfHover', delay: 500, animate: 
        {
            props: ['opacity', 'height'], opts: Class.empty
        }
    }
    , initialize: function(el, options)
    {
        this.setOptions(options); this.element = $(el);
            this.element.getElements('li').each(function(el)
        {
            el.addEvents(
            {
                'mouseover': this.over.bind(this, el), 'mouseout':
                    this.out.bind(this, el)
            }
            )
        }
        , 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)ul.bgiframe(
                {
                    opacity: false
                }
                ); ul.animate(this.options.animate)
            }
            el.getSiblings().each(function(ele)
            {
                /*
                farshid:
                fix for right to left menu
                added for ie, to hide the menus on roll out
                 */
                el.getSiblings().getChildren().each(function(ele)
                {
                    //ele.setStyle('right', 'auto');
					ele.setStyle('right', 5001);
                }
                ); 
                /*
                farshid.
                 */
                ele.removeClass(this.options.hoverClass)
            }
            , this)
        }
    }
    , out: function(el)
    {
        el.sfTimer = (function()
        {
            el.removeClass(this.options.hoverClass); 
            /*
            farshid:
            fix for right to left menu
            added for ie, to hide the menus on roll out
             */
            el.getChildren().each(function(ele)
            {
                //ele.setStyle('right', 'auto');
				ele.setStyle('right', 5001);
            }
            ); 
            /*
            farshid.
             */
            var iframe = el.getElement('iframe'); if (iframe)iframe.remove()
        }
        ).delay(this.options.delay, this)
    }
});
Rokmoomenu.implement(new Options);
Element.extend(
{
    animate: function(obj)
    {
        if (!this.Fx)
        {
            right = 0;
			a = 0;
			this.getParents('ul').each(function(el)
            {
                if (el.id != "horiznav"){
					a += 1;
					if(a < 2){
						right += Math.abs(Math.ceil(el.getStyle('width').split('px')[0]));
					}
				}
            }
            ); this.Fx = this.effects(obj.opts); 
            //if(this.id!="horiznav"){
            this.now = this.getStyles.apply(this, obj.props); 
            //}
            /*
            farshid:
            fix for right to left menu
             */
            this.now['right'] = right;
			
            /*
            farshid.
             */
            this.FxEmpty = {}
            ; for (var i in this.now)this.FxEmpty[i] = 0
        }
        if (obj.props.contains('height') || obj.props.contains('width'))
        {
            this.setStyle('overflow', 'hidden'); this.getParents('ul').each
                (function(el)
            {
                el.setStyle('overflow', 'visible'); 
            }
            )
        }
        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
    }
});