function ClassAjax( url, method, display ) {
	
	this.ajax;
	this.url = url;
	this.method = method;
	this.display = display;
	this.encode = "utf-8";
	this.params = new Array();
	this.responseText;
	this.function_name;
	this.mutipart = false;
	this.error;
	
	this.hexChars = "0123456789ABCDEF";

	this.dec2Hex = function ( Dec ) {
		var a = Dec % 16;
		var b = (Dec - a)/16;
		var hex = "" + this.hexChars.charAt(b) + this.hexChars.charAt(a);
		return hex;
	}
	
	this.thai = function( s ) {
		var s2 = '';
		for ( var i = 0 ; i < s.length ; i++ ) {
			if( s.charCodeAt(i) > 3423 ) {
				var n = s.charCodeAt(i)-3424;
				s2 += '%'+this.dec2Hex(n);
			} else s2 += s.charAt(i);
		}
		return s2;
	}

	//Create Ajax Object
	try {
		// Firefox, Opera 8.0+, Safari
		this.ajax = new XMLHttpRequest();
	} catch ( e ) {
		// Internet Explorer
		try {
			this.ajax = new ActiveXObject( "Msxml2.XMLHTTP" );
		} catch ( e ) {
			try {
				this.ajax = new ActiveXObject( "Microsoft.XMLHTTP" );
			} catch ( e ) {
				this.error("Ajax object not set.");
			}
		}
	}
	
	this.addParam = function( nameVar, value ) {
		this.params.push( nameVar+"="+encodeURIComponent(value) );
		//this.params.push( nameVar+"="+encodeURI(value) );
		//this.params.push( nameVar+"="+escape(value) );
		//this.params.push( encodeURIComponent(nameVar)+"="+this.thai(value) );
	}
	
	this.createParameters = function() {
		var q = "";
		if ( this.params.length > 0 ) {
			for ( i = 0 ; i < this.params.length ; i++ ) {
				q += this.params[i]+"&";
			}
			q = q.substr(0, q.length-1);
		}
		return q;
	}
	
	//Send data
	this.send = function() {
		if ( self.ajax == null ) {
			this.error("Ajax object not set.");
			return;
		}
		var tempurl = this.url;
		if ( this.method == null ) this.method = "GET";
		var querystring = this.createParameters();
		if ( this.method.toLowerCase() == "get" ) {
			tempurl += "?"+querystring;
		}
		this.ajax.onreadystatechange = this.stateChange;
		this.ajax.open( this.method, tempurl, true );
		if ( this.method.toLowerCase() == "post" ) {
			var content = "";
			if ( this.mutipart ) content = "multipart/form-data;";
			else content = "application/x-www-form-urlencoded;";
			this.ajax.setRequestHeader("Content-Type", content+"charset="+this.encode);
			this.ajax.send(querystring);
		} else {
			this.ajax.send(null);
		}
	}
	
	//Check state change and retrieve data.
	var self = this;
	this.stateChange = function() {
		if ( self.ajax != null ) {
			if ( self.ajax.readyState == 4 || self.ajax.readyState == "complete" ) { 
				if ( self.ajax.status == 200 ) {
					self.responseText = self.ajax.responseText;
					if ( self.function_name != null ) {
						var temp = self.function_name;
						if ( temp.substring( temp.length-1, temp.length ) != ")" ) self.function_name = temp+"()";
						eval( self.function_name );
					}
					else if ( self.display != null ) document.getElementById(self.display).innerHTML = self.responseText;
				} else self.error( self.statusText );
			} //else document.getElementById(self.display).innerHTML = "Loading...";
		} else self.error("Ajax object not set.");
	}
	
	this.error = function( msg ) {
		document.getElementById(self.display).innerHTML = msg;
	}
	
}