jQuery.extend( jQuery.easing,
{
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	}
});

$(document).ready(function() {
    function easingMenu(){
        var easing = 'easeOutBounce';
        var time = 500; 
        var borderH = 9;
        var borderW = 9;
        var baseH = 35;
        var li = $("#menu li");
        var wrap = '<div class="anime"><div class="anime-top"><div class="btl"></div><div class="btc"></div><div class="btr"></div></div><div class="anime-base"></div></div>';
        var href = window.location.href;
        li.each(function(){
	    var item = $(this);
            $(this)
            .append(wrap).find('.btc').width($(this).width()-2*borderW);
            $(this).find('.anime-top').height(borderH);
            $(this).find('.anime-base').height(baseH);
            var link_href = $(this).find('a').attr('href');
	    var rel = $(this).find('a').attr('rel');
	    var relObject = rel.split(' ');
            if ( href.match(link_href) ) {       
		$(this)
		.find('.anime')
		.css({})
		.stop().animate({top:-($(this).height())}, time, easing);
	    } else if( rel != '' && relObject.length > 0  ){
		
		$.each(relObject, function(i){
			if(href.match(relObject[i])){
				item
				.find('.anime')
				.css({})
				.stop().animate({top:-($(item).height())}, time, easing);				
			}
		});
	    }
        })
        .hover(
        function(){
            var link_href = $(this).find('a').attr('href');
            if (! href.match(link_href) )
            $(this)
            .find('.anime')
            .css({})
            .stop().animate({top:-($(this).height())}, time, easing);  
        },
        
        function(){
            var link_href = $(this).find('a').attr('href');
            if ( ! href.match(link_href) )
            $(this)
            .find('.anime')
            .stop()
            .animate({top:0}, time, easing);
        }
        );
    }
    
    easingMenu();
});
