/* v 0.0.2 */

jQuery.extend({
	param: function( a , pn, d) {
		if (!d)
			d=0;

		var t = typeof(a);
		/* We're at the end of the line so return it. */
		if ((t == 'string' || t == 'number' || t == 'boolean' || t == 'undefined') && pn)
			return pn+'='+encodeURIComponent(a);

		var s = [];
		if ( a.constructor == Array || a.jquery )
			/* Serialize the form elements */
			jQuery.each( a, function(i){
				if (this.name) {
					s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
				} else {
					if (!pn) {
						s.push(jQuery.param(a[i], encodeURIComponent(i),d));
					} else {
						s.push(jQuery.param(a[i], pn+"["+encodeURIComponent(i)+"]",d));
					}
				}
			});
		/* Otherwise, assume that it's an object of key/value pairs */
		else
			for ( var j in a ) {
				d++;
				/* prevent infinite recursion.  max of 10 levels deep. */
				if (d>10)
					break;

				if (!pn)
					/* recurse into siblings. with this as parent. */
					s.push(jQuery.param(a[j], encodeURIComponent(j),d));
				 else
					/* recurse into siblings. */
					s.push(jQuery.param(a[j], pn+"["+encodeURIComponent(j)+"]",d));

			}
		/* Return the resulting serialization */
		return s.join("&").replace(/%20/g, "+");
	}
});


