var ajax = function(url,callback){ 
	this.xmlHttp = this.createHttpRequest(); 
	if(!this.check_made_xmlHttp()){return false;} 
	this.sendRequest(url,callback); 
} 

ajax.prototype.createHttpRequest= function(){ 
	if(window.ActiveXObject){ 
		try { 
			return new ActiveXObject("Msxml2.XMLHTTP") ; 
		} catch (e) { 
			try { 
				return new ActiveXObject("Microsoft.XMLHTTP") ; 
			} catch (e2) { 
				return null ; 
			} 
		} 
	}
	else if(window.XMLHttpRequest){ 
		 return new XMLHttpRequest() ; 
	}
	else { 
		return null ; 
	} 
}

ajax.prototype.sendRequest= function(url,callback){ 
	var xmlHttp = this.xmlHttp; 
	var connect_page_try=0;

	try {
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
	catch(e) {
		connect_page_try++;
		if(connect_page_try<3) {
			alert('서버와의 통신에 실패하였습니다. 재시도 합니다. try : #' + connect_page_try);			
		}
		else {
			alert('서버와의 통신에 실패하였습니다.');
			//location.href="/";
			return false;
		}
	}

    xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4&&xmlHttp.status == 200) {
			callback(xmlHttp);
		}
	}
}

ajax.prototype.check_made_xmlHttp= function(){ 
	if(!this.xmlHttp) return false; 
	else return true; 
}

ajax.prototype.debug= function(){ 
	alert(this.xmlHttp.responseText);
}
