var xmlhttp;
var previousStr = null;
var previousListname = null;
function browse_list(str,listName,sorting)
  {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	var namepiece = str.split("&");
	var url="list_query.php";
	url=url+"?list="+str+"&sorting="+sorting;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=
	function stateChanged()
  	  {
		document.getElementById("loading_results").innerHTML = "<img src=images/ajax_loader.gif>";
		if (xmlhttp.readyState==4)
		  {
			if (previousStr != null)
			  {
				document.getElementById(previousStr).innerHTML = "<a href=\"#\" name=\""+previousStr+"\" onclick=\"browse_list(this.name,'"+previousListname+"');return false;\">"+previousListname+"</a>"
			  }
			document.getElementById(str).innerHTML = "<a href=\"#\" id=\"chosen\" name=\""+str+"\" onclick=\"browse_list(this.name,'"+listName+"');return false;\">"+listName+"</a>"
			previousStr = str;
			previousListname = listName
			document.getElementById("list_results").innerHTML=xmlhttp.responseText;
			document.getElementById("loading_results").innerHTML = "";

//			document.getElementById(str).innerHTML = "<a href=\"#\" class=\"search\" id=\"chosen\" name="+str+" onclick=\"browse_list(this.name);return false;\">"+namepiece[0]+"</a>";
		  }
	  }
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
  }

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;
  }

function timestamp(orgPk,atlasName,userPk,entrypk)
  {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	var url="list_query.php";
	url=url+"?mode=timestamp&orgpk="+orgPk+"&atlasname="+atlasName+"&userpk="+userPk;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=
	function stateChanged()
  	  {
		document.getElementById("loading_results").innerHTML = "<img src=images/ajax_loader.gif>";
		if (xmlhttp.readyState==4)
		  {
			document.getElementById(entrypk).innerHTML=xmlhttp.responseText;
			document.getElementById("loading_results").innerHTML = "";
		  }
	  }
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
  }
