/**************************************
* 2009/11/20 ÀÌÇö¼®
*
* jQuery ±â¹Ý ¿Å±â±â ÀÛ¾÷ #1
* - json.js ÆÄÀÏ È£È¯
* - Ajax Class È£È¯
*
* ÀÇÁ¸¼º
* - jquery-1.3.2.js
* - jquery.json.js
**************************************/

Array.prototype.toJSONString = function() {
	return jQuery.toJSON(this);
}

Boolean.prototype.toJSONString = function() {
	return jQuery.toJSON(this);
}

Date.prototype.toJSONString = function() {
	return jQuery.toJSON(this);
}

Number.prototype.toJSONString = function () {
	return jQuery.toJSON(this);
};

String.prototype.toJSONString = function() {
	return jQuery.toJSON(this);
};

String.prototype.parseJSON = function() {
	return jQuery.evalJSON(this);
};

var Ajax = {
	Request:function(url, opt){
		// Passing Properties
		var _url = String(url);
		var _async = opt.asynchronous == null ? "true" : opt.asynchronous;
		var _type = opt.method == null ? "GET" : opt.method.toUpperCase();
		var _contentType = opt.contentType == null ? "application/x-www-form-urlencoded" : opt.contentType;

		// Passing Events
		var _events = {};
		jQuery.each(["beforeSend", "success", "error", "complete"], function(s) {
			var eventName;
			var curName = String(this);
			switch (curName) {
				case "beforeSend":
					eventName = "onLoading";
					break;
				case "success":
					eventName = "onSuccess";
					break;
				case "error":
					eventName = "onFailure";
					break;
				case "complete":
					eventName = "onComplete";
					break
			}

			_events[curName] = function(res){
				var obj = { responseText:res };
				if (opt[eventName] != null) opt[eventName](obj);
			}
		});


		// Execute jQuery Ajax
		jQuery.ajax({
			url:_url,
			type:_type,
			async:_async,
			contentType:_contentType,
			processData:false,
			global:false,
			dataType:"text",
			beforeSend:_events.beforeSend,
			success:_events.success,
			error:_events.error,
			complete:_events.complete
		});
	}
};