

function jxGetXHO(mimetype) {
	var xmlHttp = null ;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest() ;
		if ( xmlHttp.overrideMimeType ) {
			xmlHttp.overrideMimeType('text/' + mimetype) ;
		}
	} catch (e) { // Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") ;
		} catch (e) { // Internet Explorer
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") ;
		}
	}
	return xmlHttp ;
}



function update_id_after(url, id) {
	xmlHttp = jxGetXHO('html') ;
	if ( xmlHttp == null ) {
		return ;
	}

	xmlHttp.onreadystatechange = function() {
		if ( xmlHttp.readyState == 4 ) {
			if ( xmlHttp.status != 200) {
				return ;
			}
			try {
			document.getElementById(id).innerHTML = xmlHttp.responseText ;
			} catch(e) { } ;
		}
	} ;
	xmlHttp.open("GET", url, true) ;
	xmlHttp.send(null) ;
}

function update_id_after2(url, id) {
	xmlHttp = jxGetXHO('html') ;
	if ( xmlHttp == null ) {
		return ;
	}

	xmlHttp.onreadystatechange = function() {
		if ( xmlHttp.readyState == 4 ) {
			if ( xmlHttp.status != 200) {
				return ;
			}
			try {
			document.getElementById(id).innerHTML = xmlHttp.responseText ;
			} catch(e) { } ;
		}
	} ;
	xmlHttp.open("GET", url, false) ;
	xmlHttp.send(null) ;
}


function runScripts(id) {
	var ScriptFragment = '<script[^>]*>([\\S\\s]*?)<\/script>' ;
	var matchAll = new RegExp(ScriptFragment, 'img');
	var matchOne = new RegExp(ScriptFragment, 'im');
	var element = getElementById(id).innerHTML ;
	return (element.match(matchAll) || []).map(
		function(scriptTag) {
			return (scriptTag.match(matchOne) || ['', ''])[1];
		}
	);
}

function evalScripts(id) {
	return extractScripts(id).map(function(script) { return eval(script) });
}

