(function($) {
    var window = this, undefined, _cvv = window.cvv, _$$ = window.$$, cvv = window.cvv = window.$$ = function(selector, context) {
        return new cvv.fn.init(selector, context);
    };

    function camelCase(name) {
        if (!name || name.length <= 0)
            throw new Error('camelCase error: invalid parameter	of name');

        return name.charAt(0).toLowerCase() + name.substring(1);
    }

    function pascalCase(name) {
        if (!name || name.length <= 0)
            throw new Error('pascalCase	error: invalid parameter of name');

        return name.charAt(0).toUpperCase() + name.substring(1);
    }

    cvv.fn = cvv.prototype = {
        init: function(selector, context) {
            return this;
        },
        version: "0.0.1"
    };

    cvv.fn.init.prototype = cvv.fn;

    cvv.extend = cvv.fn.extend = function() {
        var target = arguments[0] ||
        {}, i = 1, length = arguments.length, deep = false, options;

        if (typeof target === "boolean") {
            deep = target;
            target = arguments[1] ||
            {};
            i = 2;
        }

        if (typeof target !== "object" && !$.isFunction(target))
            target = {};

        if (length == i) {
            target = this;
            --i;
        }

        for (; i < length; i++)
            if ((options = arguments[i]) != null)
            for (var name in options) {
            var src = target[name], copy = options[name];

            if (target === copy)
                continue;

            if (deep && copy && typeof copy === "object" && !copy.nodeType)
                target[name] = cvv.extend(deep, src || (copy.length != null ? [] : {}), copy);
            else
                if (copy !== undefined)
                target[name] = copy;

        }

        return target;
    };

    cvv.extend({
        noConflict: function(deep) {
            ///	<summary>
            ///		Reset $$ to it's original value
            ///	</summary>
            ///	<param name="deep" type="Boolean">
            ///		if true reset the cvv to it's original value
            ///	</param>
            ///	<returns type="cvv" />
            window.$$ = _$$;

            if (deep)
                window.cvv = _cvv;

            return cvv;
        },

        stringify: function(value) {
            ///	<summary>
            ///		Convert JSON Object to JSON String.
            ///	</summary>
            ///	<param name="value" type="Object">
            ///		The JSON Object to Convert.
            ///	</param>
            ///	<returns type="String" />
            return JSON.stringify(value);
        },
        parse: function(text) {
            ///	<summary>
            ///		Convert JSON String to JSON Object.
            ///	</summary>
            ///	<param name="text" type="String">
            ///		The JSON Object to Convert.
            ///	</param>
            ///	<returns type="Object" />
            return JSON.parse(text);
        },
        all: function(element, className, context) {
            ///	<summary>
            ///		select or unselect all check boxes
            ///	</summary>
            ///	<param name="element" type="Element">
            ///		The action element.
            ///	</param>
            ///	<param name="className" type="String">
            ///		The class name of element
            ///	</param>
            ///	<param name="context" type="Selecter">
            ///		The context of selecter.
            ///	</param>
            ///	<returns type="cvv" />
            if (element.checked) {
                $("input:enabled." + className, context).attr('checked', 'checked');
            }
            else {
                $("input:enabled." + className, context).attr('checked', '');
            }
            return cvv;
        },
        getModel: function(model, context) {
            ///	<summary>
            ///		Get a model
            ///	</summary>
            ///	<param name="model" type="Element">
            ///		{}
            ///	</param>
            ///	<param name="context" type="Selecter">
            ///		The context of selecter.
            ///	</param>
            ///	<returns type="cvv" />
            if (Object.prototype.toString.apply(model) !== '[object Object]') {
                throw new Error('$$.getModel error:	model must type of [object Object]');
            }
            $("input,select,textarea,button", $(context)).each(function(index, dom) {
                if (this.name) {
                    if (this.type != 'checkbox' || this.type == 'checkbox' && this.checked) {
                        var name = pascalCase(this.name);
                        if (model.hasOwnProperty(name)) {
                            throw new Error('$$.getModel error:	model had own property of \'' + name + '\'');
                        }
                        model[name] = (this.value ? $(this).val() : '');
                    }
                }
            });
            return this;
        },
        config: function(name, value) {
            
        }
    });
})(jQuery);
