// javascript file

var xmlHttp;

var json = {
	
	url : '',
	response : null,
	call_back_function : null,
	data_method : true,
	
	call_back : function ( cbf ) { this.call_back_function = cbf; },
	make_connection : function(){
		xmlHttp = null;
		this.response = null;
		try{ // Firefox, Opera 8.0+, Safari
			xmlHttp = new XMLHttpRequest();
		} catch (e) { // Internet Explorer
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		if ( xmlHttp == null ) { alert ('Browser does not support HTTP Request'); return false; }
		if (this.url.search(/\?/) == -1 ) { this.url += '?RAND=' + Math.random(9999); }
		if (this.url.search(/\?/) != -1 ) { this.url += '&RANDOMISE=' + Math.random(9999); }
		xmlHttp.onreadystatechange = json.stateChanged;
		xmlHttp.open("GET",this.url,true);
		xmlHttp.send(null);
		return true;
	},

	stateChanged : function() { 
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete' ){ 
			if (typeof json.call_back_function == 'function' ) {
				if ( xmlHttp.responseText == -1 ) {  json.call_back_function ( '' ); }
				if ( json.data_method == false ) { json.call_back_function ( xmlHttp.responseText ); }
				else {
					var tmb = eval( ("(" + xmlHttp.responseText+ ");") );
					json.call_back_function ( tmb );
				}
			}
		}
	}
}