function Ajax(echoFunction, responseType){//version 1.1.0
this.request=null;
this.response=null;
this.callingMethod='';
this.responseType=(typeof(responseType)=='string' && responseType.toLowerCase()=='responsexml ')?
	'responseXML':'responseText';
this.echoFunction=echoFunction||null;

/********* M E T H O D *********/
this.initialize=function(){
this.response=null;
this.callingMethod='';
if(!this.request){
	if(window['XMLHttpRequest']){/*IE7, Mozillas*/ try{this.request=new XMLHttpRequest();}catch(e){this.request=null;}; }
	else if(window['ActiveXObject']){/*IE<IE7*/
	var ajaxMSversions=[
		/*'Msxml2.DOMDocument.5.0', 'Msxml2.DOMDocument.4.0', 'Msxml2.DOMDocument.3.0', 'MSXML2.DOMDocument',*/ 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'
	];
		for(var v=0; v<ajaxMSversions.length; v++){
			try{this.request=new ActiveXObject(ajaxMSversions[v]); return this.request;}catch(e){this.request=null;};
		}
	}
	else if(window['createRequest']){ try{this.request=window.createRequest();}catch(e){this.request=null;}; }
	else{alert('XMLHTTP not enabled. Impossible to proceed.');}
};
return this.request;
}

/********* M E T H O D *********/
this.noOtherIntervals=function(mode){
if(window['notesIM']){
	if(window['notes_callerIsIM']){return false;};
	if(mode){ if(!window['notesIM']['notesTheTimer']){notesSetInterval();}; }
	else{clearInterval(window['notesIM']['notesTheTimer']); window['notesIM']['notesTheTimer']=null;};
};
}

/********* M E T H O D *********/
this.get=this.send=function(address, query, echoFunction, responseType){
if(!address || !this.initialize()){return false;};
this.callingMethod='GET';
this.responseType=responseType||this.responseType;
query=query||'';
query=query.replace(/\?/, '');
//query=unescape(query);
this.request.open('GET', (address+'?'+query), true);
this.request.setRequestHeader('Content-Type', 'text/xml');
if(typeof(echoFunction)!="function"){this.request.onreadystatechange=this.echo(this);/*currying*/}
else{this.request.onreadystatechange=echoFunction;};
this.noOtherIntervals(0);
this.request.send(null);
}

/********* M E T H O D *********/
this.post=function(address, send, echoFunction, responseType){
if(!address || !this.initialize()){return false;};
this.callingMethod='POST';
this.responseType=responseType||this.responseType;
send=send||'';
//send=send.replace(/%/g, '#37#');
//send=send.replace(/\+/g, '#43#');
//send=unescape(send);
this.request.open('POST', address, true);
this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
if(typeof(echoFunction)!="function"){this.request.onreadystatechange=this.echo(this);/*currying*/}
else{this.request.onreadystatechange=echoFunction;};
this.noOtherIntervals(0);
this.request.send(send);
}

/********* M E T H O D *********/
this.head=function(address, send, echoFunction){
if(!address || !this.initialize()){return false;};
this.callingMethod='HEAD';
send=send||'';
this.request.open('HEAD', address, true);
this.request.setRequestHeader('Content-Type', 'text/xml');
if(typeof(echoFunction)!="function"){this.request.onreadystatechange=this.echo(this);/*currying*/}
else{this.request.onreadystatechange=echoFunction;};
this.noOtherIntervals(0);
this.request.send((send||null));
}

/********* M E T H O D *********/
this.error=function(statusError){
if(statusError){
this.response=(this.request && this.request.status)? 'Ajax Error: '+this.request.status+': '+this.request.statusText: 'Ajax Error: Requested document may be temporarily unavailable';
	if(12156 - this.request.status.toString()>=0 && this.request.status.toString() - 12001>=0){
	return this.response;
	}
	else{
	alert(this.response);
	};
return this.response;
}
else{return false;};
}

/********* M E T H O D *********/
this.echo=function(ajaxInstance){
return function(){//currying
	if(ajaxInstance.request.readyState==4 || ajaxInstance.request.readyState=='complete'){
	ajaxInstance.noOtherIntervals(1);
		if(ajaxInstance.request.status==200 || ajaxInstance.request.status==100){
		ajaxInstance.response=
		(ajaxInstance.callingMethod=='GET' || ajaxInstance.callingMethod=='POST')?ajaxInstance.request[ajaxInstance.responseType]:
		(ajaxInstance.callingMethod=='HEAD')?ajaxInstance.request.getAllResponseHeaders():false;
			if(typeof(ajaxInstance.echoFunction)=="function"){
			return ajaxInstance.echoFunction(ajaxInstance.response);
			};/*no function passed as parameter: a default behaviour:*/
		return ajaxInstance.response;/*response is STORED in the instance.response property, ready for further manipulation*/
		}
		else{return ajaxInstance.error(1);};
	}
	else{return ajaxInstance.error(0);};
}//currying over
}

this.trueSpans=[];
/********* M E T H O D *********/
this.afterWords=function(){}/*you can redefine it*/

/********* M E T H O D *********/
this.spans=function(ajaxInstance){/*Ajax RESPONSE*/
return function(){//currying
	if(ajaxInstance.request.readyState==4 || ajaxInstance.request.readyState=='complete'){
		if(ajaxInstance.request.status==200 || ajaxInstance.request.status==100){
			if(!ajaxInstance.request.responseText){return '';};
		ajaxInstance.response=ajaxInstance.request.responseText.split('||');
		ajaxInstance.response.pop();
			for(var s=0; s<ajaxInstance.trueSpans.length; s++){
				if(!ajaxInstance.trueSpans[s].childNodes.length){
				ajaxInstance.trueSpans[s].appendChild( document.createTextNode('') );
				};
				if(typeof(ajaxInstance.response[s])!="undefined"){
				var firstChar=ajaxInstance.trueSpans[s].childNodes[0].nodeValue.substring(0,1);
				ajaxInstance.trueSpans[s].childNodes[0].nodeValue=
				('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(firstChar)>=0)?
				ajaxInstance.response[s]: ajaxInstance.response[s].toLowerCase();
				};
			}
		ajaxInstance.afterWords();
		if(typeof window['footersLastWords']=="function"){footersLastWords();}
		}
		else{return ajaxInstance.error(1);};
	}
	else{return ajaxInstance.error(0);};
}//currying over
}

this.lastInvokedLanguage='';

/********* M E T H O D *********/
this.words=this.word=function(language, regexp, file){/*Ajax REQUEST: onClick="ajax.words('inglese');"*/
regexp=regexp||/^_\d+$/;// /^[cs]_\d+$/
file=file||'ajax_words.php';
this.lastInvokedLanguage=language;
this.trueSpans=[];
language=language||'';
language=language.toLowerCase();
var spans=document.getElementsByTagName('SPAN');
var spansToString='data=';
for(var s=0; s<spans.length; s++){
var matches=spans[s].className.match(regexp);/*identifies words by className, NOT id, because IDs are unique, BUT words in the document may be REPEATED*/
	if(matches && matches[0].indexOf('_0')<0/*a phony classname x_0 is available for Dhtml purposes*/){
	spansToString+=matches[0];
	this.trueSpans[++this.trueSpans.length-1]=spans[s];
	};
}
spansToString+="&language="+language+"";
if(document.getElementById('token')){spansToString+="&token="+document.getElementById('token').value;};
if(document.getElementById('javascript')){spansToString+="&javascript="+document.getElementById('javascript').value;};
this.get('_php_/'+file, spansToString, this.spans(this));//currying
}

/*class ends - developed by:	http://www.unitedscripters.com/	*/}

var ajax=new Ajax();
var ajaxWords=new Ajax();
