

                if (typeof(WebToolKit) == 'undefined') {
	                var WebToolKit = {};
                };

                WebToolKit.utf8 = {

	                encode : function (string) {
		                string = string.replace(/\r\n/g,'\n');
		                var utftext = '';

		                for (var n = 0; n < string.length; n++) {
			                var c = string.charCodeAt(n);
			                if (c < 128) {
				                utftext += String.fromCharCode(c);
			                }
			                else if((c > 127) && (c < 2048)) {
				                utftext += String.fromCharCode((c >> 6) | 192);
				                utftext += String.fromCharCode((c & 63) | 128);
			                }
			                else {
				                utftext += String.fromCharCode((c >> 12) | 224);
				                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				                utftext += String.fromCharCode((c & 63) | 128);
			                }
		                }

		                return utftext;
	                },

	                decode : function (utftext) {
		                var string = '';
		                var i = 0;
		                var c = c1 = c2 = 0;
		                while ( i < utftext.length ) {
			                c = utftext.charCodeAt(i);
			                if (c < 128) {
				                string += String.fromCharCode(c);
				                i++;
			                }
			                else if((c > 191) && (c < 224)) {
				                c2 = utftext.charCodeAt(i+1);
				                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				                i += 2;
			                }
			                else {
				                c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
				                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				                i += 3;
			                }
		                }
		                return string;
	                }

                };

                if (typeof(String.prototype.utf8encode) == 'undefined') {
	                String.prototype.utf8encode = function () {
		                return WebToolKit.utf8.encode(this);
	                };
                };

                if (typeof(String.prototype.utf8decode) == 'undefined') {
	                String.prototype.utf8decode = function () {
		                return WebToolKit.utf8.decode(this);
	                };
                };

                WebToolKit.base64 = {

	                keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',

	                encode : function (input) {
		                var output = '';
		                var chr1, chr2, chr3;
		                var enc1, enc2, enc3, enc4;
		                var i = 0;

		                if (typeof(String.prototype.utf8encode) !== 'undefined') {
			                input = input.utf8encode();
		                }

		                do {
			                chr1 = input.charCodeAt(i++);
			                chr2 = input.charCodeAt(i++);
			                chr3 = input.charCodeAt(i++);

			                enc1 = chr1 >> 2;
			                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			                enc4 = chr3 & 63;

			                if (isNaN(chr2)) {
				                enc3 = enc4 = 64;
			                } else if (isNaN(chr3)) {
				                enc4 = 64;
			                }

			                output = output + this.keyStr.charAt(enc1) + this.keyStr.charAt(enc2) +
			                this.keyStr.charAt(enc3) + this.keyStr.charAt(enc4);
		                } while (i < input.length);

		                return output;
	                },

	                decode : function (input) {
		                var output = '';
		                var chr1, chr2, chr3;
		                var enc1, enc2, enc3, enc4;
		                var i = 0;

		                input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');

		                do {
			                enc1 = this.keyStr.indexOf(input.charAt(i++));
			                enc2 = this.keyStr.indexOf(input.charAt(i++));
			                enc3 = this.keyStr.indexOf(input.charAt(i++));
			                enc4 = this.keyStr.indexOf(input.charAt(i++));

			                chr1 = (enc1 << 2) | (enc2 >> 4);
			                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			                chr3 = ((enc3 & 3) << 6) | enc4;

			                output = output + String.fromCharCode(chr1);

			                if (enc3 != 64) {
				                output = output + String.fromCharCode(chr2);
			                }
			                if (enc4 != 64) {
				                output = output + String.fromCharCode(chr3);
			                }
		                } while (i < input.length);

		                if (typeof(String.prototype.utf8decode) !== 'undefined') {
			                return output.utf8decode();
		                } else {
			                return output;
		                }
	                }

                };

                if (typeof(String.prototype.base64encode) == 'undefined') {
	                String.prototype.base64encode = function () {
		                return WebToolKit.base64.encode(this);
	                };
                };

                if (typeof(String.prototype.base64decode) == 'undefined') {
	                String.prototype.base64decode = function () {
		                return WebToolKit.base64.decode(this);
	                };
                };

				var __sampleCrypt = new Object();
				__sampleCrypt.encrypt = function(data)
					{
						return WebToolKit.base64.encode(data);
					}
				__sampleCrypt.decrypt = function(data)
					{
						return WebToolKit.base64.decode(data);
					}

				AjaxPro.cryptProvider = __sampleCrypt;

				
AjaxPro.key = "38.103.63.17";

// NameValueCollectionConverter
addNamespace("Ajax.Web");

Ajax.Web.NameValueCollection = function() {
	this.__type = "System.Collections.Specialized.NameValueCollection";
	this.add = function(key, value) {
		if(this[key] == null)
			this[key] = value;
	}
	this.getKeys = function() {
		var keys = [];
		for(key in this)
			if(typeof this[key] != "function")
				keys.push(key);
		return keys;
	}
	this.getValue = function(key) {
		return this[key];
	}
	this.toJSON = function() {
		var o = this;
		o.toJSON = null;
		delete o.toJSON;
		return AjaxPro.toJSON(o);
	}
}

// DataSetConverter
addNamespace("Ajax.Web");

Ajax.Web.DataSet = function(t) {
	this.__type = "System.Data.DataSet,System.Data";
	this.Tables = [];
	this.addTable = function(t) {
		this.Tables.push(t);
	}
	if(t != null) {
		for(var i=0; i<t.length; i++) {
			this.addTable(t[i]);
		}
	}
}

// DataTableConverter
addNamespace("Ajax.Web");

Ajax.Web.DataTable = function(c, r) {
	this.__type = "System.Data.DataTable,System.Data";
	this.Columns = [];
	this.Rows = [];
	this.addColumn = function(name, type) {
		this.Columns.push({Name:name,__type:type});
	}
	this.toJSON = function() {
		var dt = {};
		dt.Columns = [];
		for(var i=0; i<this.Columns.length; i++)
			dt.Columns.push([this.Columns[i].Name, this.Columns[i].__type]);
		dt.Rows = [];
		for(var i=0; i<this.Rows.length; i++) {
			var row = [];
			for(var j=0; j<this.Columns.length; j++)
				row.push(this.Rows[i][this.Columns[j].Name]);
			dt.Rows.push(row);
		}
		return AjaxPro.toJSON(dt);
	}
	this.addRow = function(row) {
		this.Rows.push(row);
	}
	if(c != null) {
		for(var i=0; i<c.length; i++)
			this.addColumn(c[i][0], c[i][1]);
	}
	if(r != null) {
		for(var i=0; i<r.length; i++) {
			var row = {};
			for(var c=0; c<this.Columns.length && c<r[i].length; c++)
				row[this.Columns[c].Name] = r[i][c];
			this.addRow(row);
		}
	}
}

// ProfileBaseConverter
addNamespace("Ajax.Web");

Ajax.Web.Profile = function() {
	this.toJSON = function() {
		throw "Ajax.Web.Profile cannot be converted to JSON format.";
	}
	this.setProperty_callback = function(res) {
	}
	this.setProperty = function(name, object) {
		this[name] = object;
		AjaxPro.Services.Profile.SetProfile({name:o}, this.setProperty_callback.bind(this));
	}
}

// IDictionaryConverter
addNamespace("Ajax.Web");

Ajax.Web.Dictionary = function(type, kT, vT, items) {
	this.__type = type;
	this.kT = kT;
	this.vT = vT;
	this.keys = [];
	this.values = [];
	this.add = function(k, v) {
		this.keys.push(k);
		this.values.push(v);
		return this.values.length -1;
	}
	if(items != null && !isNaN(items.length)) {
		for(var i=0; i<items.length; i++)
			this.add(items[i][0], items[i][1]);
	}
	this.containsKey = function(key) {
		for(var i=0; i<this.keys.length; i++)
			if(this.keys[i] == key) return true;
		return false;
	}
	this.getValue = function(key) {
		for(var i=0; i<this.keys.length && i<this.values.length; i++)
			if(this.keys[i] == key) return this.values[i];
		return null;
	}
	this.toJSON = function() {
		return AjaxPro.toJSON({__type:this.__type,kT:this.kT,vT:this.vT,keys:this.keys,values:this.values});
	}
}

