//-----------------------------------------------------------------------------
// Copyright (c)2005-2007, Summerleaze Computer Services
// $Revision: 1.1 $
//-----------------------------------------------------------------------------

//
//	General AJAX functions...
//

function newAJAX() {
	var obj = false;
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest) {
		try {
			obj = new XMLHttpRequest();
		} 
		catch(e) {
			alert(e.description);
			obj = false;
		}
	} 
	// branch for IE/Windows ActiveX version
	else if(window.ActiveXObject) {
		try {
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) {
				alert(e.description);
				obj = false;
			}
		}
	}
	return obj;
}

function updateSelect(el, script) {
	var xmlhttp = newAJAX();
	if (xmlhttp) {
		if (debug == 1) 		
			document.getElementById('debug').innerHTML += script + '<br />';

		xmlhttp.open('GET', script, false);
		xmlhttp.send('');

		var options = xmlhttp.responseText.split(/;/);

		el.options.length = 0;
		for(var i=0; i<options.length; i++) {
			var option = options[i].split(/,/);

			el.options[i] = new Option(option[1], option[0]);
		}
	}
}	

function updateDate(el) {
	var xmlhttp = newAJAX();
	if (xmlhttp) {
		var script = '/ajax_getDate.php?&date=' + el.value.replace(/\s/g, '+');
		
		if (debug == 1) 		
			document.getElementById('debug').innerHTML += script + '<br />';

		xmlhttp.open('GET', script, false);
		xmlhttp.send('');

		el.value = xmlhttp.responseText;
	}
}

