if (!jQuery.expr[':']['input'])
jQuery.extend(jQuery.expr[':'], {input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)" }); jQuery.fn.ajaxSubmit = function(options) { options = jQuery.extend({ target: null, url: this.attr('action') || '', method: this.attr('method') || 'GET', before: null, after: null, dataType: null, semantic: false
}, options || {}); var a = this.formToArray(options.semantic); if (options.before && options.before(a, this) === false) return; var q = jQuery.param(a); var get = (options.method && options.method.toUpperCase() == 'GET'); if (get)
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; if (!options.dataType && options.target)
jQuery(options.target).load(options.url, get ? null : a, options.after); else
jQuery.ajax({ url: options.url, success: options.after, type: options.method, dataType: options.dataType, data: get ? null : q
}); return this;}; jQuery.fn.ajaxForm = function(options) { return this.each(function() { jQuery("input:submit,input:image", this).click(function(ev) { this.form.clk = this; if (ev.offsetX != undefined) { this.form.clk_x = ev.offsetX; this.form.clk_y = ev.offsetY;} else if (typeof jQuery.fn.offset == 'function') { var offset = $(this).offset(); this.form.clk_x = ev.pageX - offset.left; this.form.clk_y = ev.pageY - offset.top;} else { this.form.clk_x = ev.pageX - this.offsetLeft; this.form.clk_y = ev.pageY - this.offsetTop;}
})
}).submit(function(e) { jQuery(this).ajaxSubmit(options); return false;});}; jQuery.fn.formToArray = function(semantic) { var a = []; var q = semantic ? ':input' : 'input,textarea,select,button'; jQuery(q, this).each(function() { var n = this.name; var t = this.type; if ( !n || this.disabled || t == 'reset' || (t == 'checkbox' || t == 'radio') && !this.checked || (t == 'submit' || t == 'image' || t == 'button') && this.form && this.form.clk != this || this.tagName.toLowerCase() == 'select' && this.selectedIndex == -1)
return; if (t == 'image' && this.form.clk_x != undefined)
return a.push( {name: n+'_x', value: this.form.clk_x}, {name: n+'_y', value: this.form.clk_y} ); if (t == 'select-multiple') { for(var i=0; i < this.options.length; i++)
if (this.options[i].selected)
a.push({name: n, value: this.options[i].value}); return;}
a.push({name: n, value: this.value});}); return a;}; jQuery.fn.formSerialize = function(semantic) { return jQuery.param(this.formToArray(semantic));}; 