
// remote scripting library
// (c) copyright 2005 modernmethod, inc


var rsl_debug_mode = false;



function rsl_debug(text) {

	if(rsl_debug_mode) alert('RSD: ' + text)

} // end function




function rsl_init_object() {

	rsl_debug('rsl_init_object() called.')


	var A;

	try {

		A = new ActiveXObject('Msxml2.XMLHTTP');

	} catch (e) {

		try {

			A = new ActiveXObject('Microsoft.XMLHTTP');

		} catch (oc) {

			A = null;

		}

	}


	if(!A && typeof XMLHttpRequest != 'undefined') A = new XMLHttpRequest();

	if (!A) rsl_debug('Could not create connection object.');


	return A;


} // end function



		
function rsl_call(url, callback) {


	var x;

	x = rsl_init_object();
	x.open('GET', url, true);


	x.onreadystatechange = function() {

		if (x.readyState != 4) 
			return;

		rsl_debug('Received ' + x.responseText);
			
		var status;
		var data;

		status = x.responseText.charAt(0);
		data = x.responseText.substring(2);

		if (status == '-') {

			// do nothing!

		} else {

			callback(data);

		}

	} // end function

	x.send(null);

	rsl_debug('rsl_call url = ' + url);
	rsl_debug('rsl_call: waiting..');
	delete x;


} // end function



