How To/

//-----------------------------
//-----XMLHttpRequest----------
/*****************************************************

AJAX buzzword :)
This is used for sending http_request 
Remember that cross-domain http_request doesn't work

if you want crossdomain http_request you can
eg. create php script that gets data from remote domain (curl, socket)
and load retrieved data with http_request

//create new object 
request = new XMLObjRequest();

//set response actions
request.http_onResponse = function(responseText){alert('result is' + responseText)}
request.http_onResponseFail = function(){alert('FAILED!')}

//run request. Get data should be part of URL
//post data is send as a second, optional paremeter
request.requestXMLDoc('http://www.mynthon.net' [, 'post_var1=0&post_var2=x']);

*****************************************************/    


  
XMLObjRequest = function(){
	this. http_request = false;
	
	this.http_onResponse = function(t){}
	this.http_onResponseFail = function(){alert('There was a problem with the request.');}
	
	XREQ_Container = function(){
		this.http_onResponse = function(t){};
		this.http_onResponseFail = function(){}
	}
	XREQ_Action = new XREQ_Container();

	this.requestXMLDoc = function(url, data) {
		this.http_request = false;

	  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
	    if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/xml');
	    }
		} else if (window.ActiveXObject) {// IE
	    try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			alert('Cannot create an XMLHTTP instance');
			return false;
		}

		XREQ_Action.http_onResponse = this.http_onResponse;
		XREQ_Action.http_onResponseFail = this.http_onResponseFail;
		
		http_request.onreadystatechange = this.setXMLObj;
		
		var mtd = (data==null ? 'GET' : 'POST');
		http_request.open(mtd, url, true);
		if(mtd == 'POST'){
			http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//head dla posta
			http_request.send(data);
		}else{
			http_request.send(null);
		}
	}
	
	this.setXMLObj = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				resp = http_request.responseText;
				XREQ_Action.http_onResponse(resp);
			} else {
				XREQ_Action.http_onResponse();
			}
	  }
	}
}