/**
 * callback must be the string name of the function
 */

var jObject = Class.create({
	initialize: function(url, callback) {
		this.url = url || "http://mnyp1cgidev1/JSON";
		callback = callback || "alert";
		this.data = new Array({"key": "callback", "value":callback});
	},

	add: function(key, value) { this.data.push({"key" : key, "value" : value}); },

	dump: function() {
		var sb = "jObject Dump:\n";
		this.data.each(function(s, index) { sb = sb + "\t" + s.key + " => " + s.value + "\n"; });
		sb = sb + "URL: " + this.url + "\n";
		return sb;
	},

	call: function() {
		var call = this.url + "?";
		this.data.each(function(s, index) {
			if(!call.endsWith('?')) { call = call + "&"; }
			call = call + s.key + "=" + s.value;
		});
		
		if($('JSON')) { $('JSON').remove(); }
		$$('head')[0].appendChild(new Element('script', {'id': 'JSON','type': 'text/javascript','src': call}));
	}
});

