/**
* JQuery Send Plugin
* @author rlamana
*/

jQuery.fn.extend
({
     /**
      * Delivers easily an HTML Form via Ajax and POST method.
      *
      * @param {string} callback A function to be executed whenever the data is loaded successfully.
      * @example A callback function, like in jQuery ajax function:
      *	    function (data, text_status)
      *	    {
      *		// 'data' could be xmlDoc, jsonObj, html, text, etc...
      *		// textStatus can be one of:
      *		//	"timeout"
      *		//	"error"
      *		//	"notmodified"
      *		//	"success"
      *		//	"parsererror"
      *	    }
      *
      *	@param {string} data_type Type of data to be returned to callback function:
      *	    "xml", "html", "script", "json", "jsonp", or "text".
      *	@see jQuery.ajax()
      */
      send: function(callback, data_type)
      {        
         // 'this' should be a form
         $.ajax
         ({
            type:	'post',
            url:	$(this).attr('action'),
            data:	$(this).serialize(),
            success: function(response)
            {
               callback.call(this, response, "success");
            },

            error: function(http_request, text_status, error_thrown)
            {
               callback.call(this, {}, text_status);
            },
            dataType: data_type
         });
      }
   });
