function index_interface(_url) {
with(this){
var COBJ = this;
this.core = false;
this.initialized = false;
this.agent = 'index_interface';
this.d_url = _url;
this.d_queue = new Array();
this.d_data = false;
this.d_active = false;
this.call = function(_key){//shorthand fo CC_ref across objects : SCRIPT
	return this.core.reference(_key);
};
this.init = function(_core) {
	if(!this.initialized) {
		this.core = _core;
		this.initialized = true;
	}
};
this.query =function(_agent, _data, _callback) {
	this.d_queue.push(this.create(_agent, _data, _callback));
	cycle();
};
this.create = function(_agent, _query, _callback) {
	var o_query = new Object();
	o_query.agent = _agent;
	o_query.query = _query;
	o_query.callback = _callback;
	return o_query;
};
this.cycle = function() {
	if(!this.d_active&&this.d_queue.length>0) {
		var t_active = this.d_queue.shift();
		this.d_active = t_active;
		$.ajax({
			type: 'POST',
			datatype: 'json',
			url: d_url,
			data: ({
				agent: t_active.agent,
				arguments: t_active.query['data']
			}),
			success: function(myreturn) {
			myreturn = check(myreturn);
				d_active = false;
				if(myreturn) {
					t_active.callback(myreturn);
				}
				cycle();
			}
		});
	}
};
this.check = function(_data) {
	var _alpha = COBJ.trim(_data);
	try{
		var ret = $.parseJSON(_data);
		return ret;
	}catch(error) {
		COBJ.core.debug('SCRIPT EXCEPTION - ERRORCODE: '+error);
		COBJ.core.debug('INPUT STRING:'+_data);
	};
};
this.trim = function(_e) {
	return _e;
};
return this;
}
}
var url = $('input[name=index_interface]').val();
var item = new index_interface(url);
CTRL.register('index_interface', item);

