/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
(function($){
    $.fn.jtraymenu=function(opt){
        var o={
            hover:'hover',
            duration:500
        };
        return this.each(function(){
            if(opt){
                $.extend(o,opt);
            }
            var mh=0;
            var $this=$(this);
            var $mnus=$this.children('li');
            var $uls;
            var $pans=$mnus.children('div.pane').css('display','none');
            $pans.each(function(){
                var h=$(this).height();
                mh=mh<h?h:mh;
                $(this).children('ul').css("position","relative").css("top",-h+"px");
                $(this).css("height",h+"px");                 
            });
			$this.find('li').hover(function(){
				  $(this).addClass(o.hover);
				},
			function(){
				  $(this).removeClass(o.hover);
				});
            $mnus.hover(function(e){                 
                var p=$(this).children('div.pane');
                p.css("display","block").css("z-index",11);
                var ul=p.children('ul'); 
                $(ul).stop().animate({
                    top:"0px"
                },Math.ceil((p.height()/mh)*o.duration),"swing");
            },function(e){                                 
                var p=$(this).children('div.pane').css("z-index",10);
                var $ul=p.children('ul');                
                $ul.stop().animate({
                    top:-(p.height())+"px"
                    },Math.ceil((p.height()/mh)*o.duration),function(){                        
                    p.css("display","none");
                });
            }); 
        });  
    };
})(jQuery);
