/**
 * This file must be included to support JavaScript Object Notation (JSON). When an instance of the JSON class is created, the request function
 * may be used to post a JSON request. A handlers must be passed as argument.
 * 
 * @version 29-07-2009
 * @author <a href="mailto:r.tennapel@griponservice.nl?SUBJECT=json.js">R. ten Napel, ing.</a>
 **/

/**
 * The class that handles JSON requests. Instantiate this class for JSON support / calls.
 * 
 * @param url				The URL to request.
 * @param handler			The JSON callBack handler function.
 **/
JSON = function(url, handler) {
	this.url = url;
	this.handler = handler;
};

/**
 * Static function that creates a JavaScript object from textual data (in JSON format).
 * 
 * @param data				The JSON textual data to convert to a Javascript object.
 * 
 * @return					A JavaScript object.
 **/
JSON.parse = function(data) {
	return new Function("return " + data)();
};

/**
 * Request JSON data by means of an Ajax call. The retrieved data will be handled by the given callBack function / JSON handler.
 **/
JSON.prototype.request = function() {
	new Ajax(null, this.url, null, null, this.handler).request();
};