var img = new Image();
	img.src = "images/loading.gif";

<!-- function that assemble POST value must be placed here, if placed in separate path/file, browser does not recogize it  -->
function concat(names) {
	<!-- names is an array of form input -->
	var data="rid="+Math.random();
	for (i=0;i<names.length;i++)
		data += "&"+names[i]+"="+encodeURIComponent( document.getElementById(names[i]).value );
	return data;
}

function toggle(id) {
	var expand = document.getElementById(id);
	if (expand.style.display == 'none') {
		expand.style.display = 'block';
	} else {
		expand.style.display = 'none';
	}
}

function geturl(where, file) {

	var http=GetXmlHttpObject();
	if (http==null) {
		document.getElementById(where).innerHTML="Your browser does not support AJAX!";
		return;
	}
	http.open("GET",file+"?rid="+Math.random(),true);
	<!-- also preload image on first page call  -->
	document.getElementById(where).innerHTML="<IMG SRC="+img.src+" class=centered>";
	http.send(null);
	http.onreadystatechange=function() {

		if (http.readyState==4 && http.status == 200) {
			document.getElementById(where).innerHTML=http.responseText;

			<!-- value in href and file sent to this function must be the same  -->
			var anchors = document.getElementsByTagName("a");
			for(var i=0, n=anchors.length; i<n; ++i) {
				if(file==anchors[i].href.substring(anchors[0].href.lastIndexOf('/')+1)) {
					anchors[i].className = "selected";
				} else {
					anchors[i].className = "deselected";
				}
			}

		}
	}
}

function posturl(where, file, data) {
	<!-- data receive from function -->
	var http=GetXmlHttpObject();
	if (http==null) {
		document.getElementById(where).innerHTML="Your browser does not support AJAX!";
		return;
	}
	http.open("POST",file,true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.send(data);

	http.onreadystatechange=function() {

		if (http.readyState==4 && http.status == 200) {
			document.getElementById(where).innerHTML=http.responseText;
		}
	}
}



function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
  	}
	if (window.ActiveXObject) {
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return null;
}

