var xhrcs = false;


// this function is changed per different ajax functionality, 
// there can be multiple instances of this function all using 2 functions below
// the script referenced takes the parameters and outputs the dynamic content
// the 2 functions below then are generic - they perform the request and output the response

function currencySelect(currency) {

	currencyRequest("/~jackyglass/EMS_new/lib/scripts/ajax.currency.php?currency="+currency);
	
	return false;
	
}



// generic function - no need to alter

function currencyRequest(url) {

	if (window.XMLHttpRequest) {
	
		xhrcs = new XMLHttpRequest();
		
	}else{
	
		if (window.ActiveXObject) {
		
			try {
			
				xhrcs = new ActiveXObject("Microsoft.XMLHTTP");
				
			}
			
			catch (e) { }
		}
		
	}

	if (xhrcs) {
	
		xhrcs.onreadystatechange = showCurrencySelect;
		xhrcs.open("GET", url, true);
		xhrcs.send(null);
		
	}else{
	
		document.getElementById("currency_select").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
		
	}
	
}



// generic function - no need to alter

function showCurrencySelect() {

	if (xhrcs.readyState == 4) {
	
		if (xhrcs.status == 200) {
		
			var outMsg = (xhrcs.responseXML && xhrcs.responseXML.contentType=="text/xml") ? xhrcs.responseXML.getElementsByTagName("choices")[0].textContent : xhrcs.responseText;
			
		}else{
		
			var outMsg = "There was a problem with the request " + xhrcs.status;
			
		}
		
		document.getElementById("currency_select").innerHTML = outMsg;
		
	}
	
}