/**
 * Modded animate() for jQuery
 * ---------------------------
 * Allows you to specify additional easing functions on
 * a per-property basis, E.g.
 *    $().animate({
 *       left: 200,
 *       top: [200, 'easeOutBounce']
 *    });
 * ---------------------------
 * @author James Padolsey
 * @info 
 */

jQuery.fn.animate = (function(_anim){
    
    var jQEasing = jQuery.easing;
    
    return function(prop, duration, easing, callback) {
        
        var props = {}, optall, i, hasEaser = false;
        
        for ( i in prop ) {
            if ( jQuery.isArray(prop[i]) ) {
                hasEaser = true;
                props[i] = prop[i][1];
                prop[i] = prop[i][0];
            }
        }
        
        opt = jQuery.speed(duration, easing, callback);
        
        if (hasEaser) {
        
            opt.step = (function(_step){
                return function(now, fx) {
                    var end = fx.end, easeFn;
                    if ( easeFn = props[fx.prop] ) {
                        fx.now = jQEasing[easeFn]( now/end, now, 0, end, end );
                    }
                    _step && _step.call( fx.elem, fx.now, fx );
                };
            })(opt.step);
            
        }
        
        opt.complete = opt.old || callback || jQuery.isFunction(easing) && easing;
        
        return _anim.call( this, prop, opt );
        
    };
    
})(jQuery.fn.animate);
