$.fn.clearForm = function() {
    this.each(function() {
        var type = this.type, tag = this.tagName.toLowerCase();
        if (tag == 'form')
            return $(':input',this).clearForm();
        if (type == 'text' || type == 'password' || tag == 'textarea')
            this.setAttribute('value', '');
        else if (type == 'checkbox' || type == 'radio')
            this.removeAttribute('checked');
        else if (type == 'select-one' || tag == 'select')
            $('option', this).each(function(){
                this.removeAttribute('selected');
            });
    });
};


