//Optional fix for firefox interface bug
function firefoxbug() {
	if (!window.firefox&&!document.all) { 
		window.firefox = document.createElement('iframe');
		firefox.style.display = 'none';
		document.getElementsByTagName('body').item(0).appendChild(firefox);
	}			
}

function firefoxClear() {
	if (window.firefox) {window.firefox.src = 'empty.js'}
}

function remoteCall(URL, param) {
	var head = document.getElementsByTagName('head').item(0);
	if (head) {
		firefoxbug();

		//construct querystring. 
		//	If more than one parameter (beyond URL) is supplied they are considered name/value pairs.
		//	Any odd parameter is considered the value for the 'param' parameter.
		var querystring = '';
		for (var i=1;i < remoteCall.arguments.length; i++) {
			if ((i+1) < remoteCall.arguments.length) {
				querystring += '&' + remoteCall.arguments[i] + '=';
				i++;
			} else {
				querystring += '&param=';
			}
			querystring += escape(remoteCall.arguments[i]);
		}

		//script block to append, append querystring of parameters
		var script = document.createElement('script');
		script.setAttribute('src', URL + '?time=' + new Date().toGMTString() + querystring);
		script.setAttribute('id', 'remote');
				
		//remove prior appended script (will not intefer, remove any javascript or change variables, but stops DOM from bloating)
		var prior = document.getElementById('remote');
		if (prior) {head.removeChild(prior)}
		
		//appending script executes it, the server will return script that calls remoteCallback(), so it's an asynchronous call.
		head.appendChild(script);
	}
}
