
function ajax(url, callback, config){
    this.xml = new Object;
    
    this.url = url;
    this.callback = callback;
    
    this.config = {
        'method': 'GET',
        'timeout': 0,
        'syn': true
    };
    
	if((config || 0).method) this.config.method = config.method;
	if((config || 0).timeout) this.config.timeout = config.timeout;
	if((config || 0).syn) this.config.syn = config.syn;
	
    this.init = function(){
        if (window.XMLHttpRequest) {
            this.xml = new XMLHttpRequest();
            
            if (this.xml.overrideMimeType) {
                this.xml.overrideMimeType("text/xml");
            }
        }
        else {
            if (window.ActiveXObject) {
                try {
                    this.xml = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                    try {
                        this.xml = new ActiveXObject("Microsoft.XMLHTTP");
                    } 
                    catch (e) {
                    }
                }
            }
        }
    }
    
    this.send = function(){
        var _this = this;
		this.xml.onreadystatechange = function(){
			_this.callback.call(_this.xml);
		}
        
        if (this.config.method.toUpperCase() == 'GET') {
            this.xml.open('GET', this.url, this.config.syn);
            
            try {
                this.xml.send(null);
            } 
            catch (e) {
                alert(e.message);
            }
        }
        else {
            var url = this.url.url;
            var param = this.url.param;
            this.xml.open('POST', url, this.config.syn);
            this.xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            this.xml.send(param);
        }
    }
    
    //constructor
    this.init();
    if (this.url && this.callback) {
        this.send();
    }
}