jQuery.extend = jQuery.fn.extend = function(){
    var deep = false,
          src, copy, options, name, copyIsArray,
          i = 1,  
          length = arguments.length,
          target = arguments[0] || {}

    if( typeof target === "boolean" ){ 
        deep = target
        target = arguments[1] || {}
        i++
    }
    if( typeof target != 'object'){  
        target = {}
    }
    if( i == length){ 
        target = this;
        i--
    }

    for( ; i < length; i++){
        options = arguments[i]
        if( options != null){
            for( name in options){
                src = target[name]  
                copy = options[name]  

                if(target == copy){ 
                    continue;
                }

                if( deep && copy && (  jQuery.isPlainObject(copy) || ( copyIsArray = jQuery.isArray(copy)  )  ) ){  
                    if( copyIsArray ){  
                        copyIsArray = false; 
                        clone = src && jQuery.isArray(src) ? src : [];
                    }else{
                        clone = src && jQuery.isPlainObject(src) ? src : {};
                    }

                    target[ name ] = jQuery.extend( deep, clone, copy );   
                }else if( copy != undefined ){  
                    target[ name ] = copy;
                }
            }
        }
    }
return target

}