// CPAINT (Cross-Platform Asynchronous INterface Toolkit) - Version 1.0
// Copyright (c) 2005 Boolean Systems, Inc. - labs.booleansystems.com/cpaint
// Released under the GPL

// This version was modified by Pierre-Luc Soucy for SonicElectronix

function cpaint_get_connection_object()
{
	try {
		cpaint_httpobj_temp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {  
			cpaint_httpobj_temp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (oc) {
			cpaint_httpobj_temp = null;
		} 
	}
	if (!cpaint_httpobj_temp && typeof XMLHttpRequest != 'undefined') 
		cpaint_httpobj_temp = new XMLHttpRequest();
	if (!cpaint_httpobj_temp) alert('[CPAINT Error] Could not create connection object');
	return cpaint_httpobj_temp;
}

function cpaint_call(url, cb_func)
{ 
	if (typeof(cpaint_debug) == 'undefined') cpaint_debug = false;
			
	if (cpaint_debug == true) alert('[CPAINT Debug] Using shared connection object.');
	if (typeof(cpaint_shared_httpobj) == 'undefined') {
		if (cpaint_debug == true) alert('[CPAINT Debug] Getting new shared connection object.');
		cpaint_shared_httpobj = cpaint_get_connection_object();
	}
	cpaint_httpobj = cpaint_shared_httpobj;
	
	if (cpaint_httpobj.readyState != 4) {
		cpaint_httpobj.abort();
	}
		
	cpaint_httpobj.open('GET', url, true);

	cpaint_httpobj.onreadystatechange = function() {
		if (cpaint_httpobj.readyState != 4) {
			return; 
			}
		if (cpaint_debug == true) alert('[CPAINT Debug] ' + cpaint_data);
		cb_func(cpaint_httpobj.responseText); 
	}

	cpaint_httpobj.send(null);
} 				