function AJAX(serverURL, className, callBack)
{
	this.serverURL = serverURL;
	this.callBack = callBack;
	this.className = className;
	this.htmlHead = document.getElementsByTagName('HEAD').item(0);
}

AJAX.prototype = {

	counter: 0,

	arguments: [],

	stringify: function (v) {
		var a = [];

		function e(s) {
			a[a.length] = s;
		}

		function g(x) {
			var c, i, l, v;

			switch (typeof x) {
			case 'object':
				if (x) {
					if (x instanceof Array) {
						e('[');
						l = a.length;
						for (i = 0; i < x.length; i += 1) {
							v = x[i];
							if (typeof v != 'undefined' &&
									typeof v != 'function') {
								if (l < a.length) {
									e(',');
								}
								g(v);
							}
						}
						e(']');
						return;
					} else if (typeof x.valueOf == 'function') {
						e('{');
						l = a.length;
						for (i in x) {
							v = x[i];
							if (typeof v != 'undefined' &&
									typeof v != 'function' &&
									(!v || typeof v != 'object' ||
										typeof v.valueOf == 'function')) {
								if (l < a.length) {
									e(',');
								}
								g(i);
								e(':');
								g(v);
							}
						}
						return e('}');
					}
				}
				e('null');
				return;
			case 'number':
				e(isFinite(x) ? +x : 'null');
				return;
			case 'string':
				l = x.length;
				e('"');
				for (i = 0; i < l; i += 1) {
					c = x.charAt(i);
					if (c >= ' ') {
						if (c == '\\' || c == '"') {
							e('\\');
						}
						e(c);
					} else {
						switch (c) {
						case '\b':
							e('\\b');
							break;
						case '\f':
							e('\\f');
							break;
						case '\n':
							e('\\n');
							break;
						case '\r':
							e('\\r');
							break;
						case '\t':
							e('\\t');
							break;
						default:
							c = c.charCodeAt();
							e('\\u00' + Math.floor(c / 16).toString(16) +
								(c % 16).toString(16));
						}
					}
				}
				e('"');
				return;
			case 'boolean':
				e(String(x));
				return;
			default:
				e('null');
				return;
			}
		}
		g(v);
		return a.join('');
	},

	doCall: function(method, arguments) {
		this.arguments = [];
		for (var i = 0; i < arguments.length; i++) {
			this.arguments[this.arguments.length] = arguments[i];
		}

		var affid = '10225'; // id for this site 
		var advid = '1754';
		var url = this.serverURL + '?class=' + this.className + '&method=' + method + '&arguments=' + encodeURI(this.stringify(this.arguments) + '&callback=' + this.callBack + '&affiliateid=' + affid + '&advid=' + advid) + '&timestamp=' + (new Date()).getTime();

		var script = document.createElement('SCRIPT');
		script.setAttribute('type', 'text/javascript');
		script.setAttribute('charset', 'utf-8');
		script.setAttribute('src', url);
		script.setAttribute('id', '_ajax_' + this.counter);
		this.htmlHead.appendChild(script);
	}
}
