
function RDKAjax() {

  var xmlHttp ;

  var xmlHttp_state = new Array('uninitialized', 'loading', 'loaded', 'interactive', 'complete') ;

  this.xml_state ;

  var url = 'http://www.ya.ru/' ;

  var cb_parse_func = '' ;

  this.result ;

  var self ;


  this.init = function() {

	self = this ;

    try {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") ;
    } catch(e) {
    	try {
      	  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") ;
    	} catch(e) {
	  xmlHttp = false ;
    	}
    }

    if (!xmlHttp) {
	xmlHttp = new XMLHttpRequest() ;
    }

    if (!xmlHttp) {
	  alert('Не могу инитиализировать объект!') ;
	  return false ;
    }

  }

  this.send = function(dest_url, cb_func, type, data, sync) {

		//if (this.send.arguments.length == 2)
		if (typeof(sync) == 'undefined')
			sync = true ;

		if (typeof(type) == 'undefined')
			type = "GET" ;

		if (typeof(data) == 'undefined')
			data = null ;


	url = dest_url ;

	if (typeof(cb_func) == 'function')
		cb_parse_func = cb_func ;
	else { alert('error in call_back function!') ; return false ; }

    xmlHttp.open(type, url, sync) ;

    if (type == "POST") {
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;
    }


    if (sync)
    	xmlHttp.onreadystatechange = process_cb ;

    xmlHttp.send(data) ;

	if (!sync)
		process_cb() ;

	this.xml_state = xmlHttp_state[xmlHttp.readyState] ;

  }

  function process_cb() {

	this.xml_state = xmlHttp_state[xmlHttp.readyState] ;

	//alert(this.xml_state) ;

    if (xmlHttp.readyState == 4) {

	//alert(xmlHttp.responseText) ;

	self.result = cb_parse_func(xmlHttp.responseText) ;

//	document.writeln(xmlHttp.responseText) ;

//	document.writeln(xmlHttp.getAllResponseHeaders()) ;

    }

  }

}
