


var msie=true;

function onlyNewbrowsers(){
	clearThemAll();
	if(navigator.appName != "Microsoft Internet Explorer"){
		//alert("Apparently you are not using Microsoft Internet Explorer.\nPlease use Microsoft Internet Explorer for this page.")
		
		msie=false;
	}
	//else{
		loadXMLDoc("dontCare", "t13", "dontCare") // this function used to load ontologies and sortedSet
	//}
}


function clearThemAll(){
	//alert(onMenus);
	for(i=1; i<=6; i++){
		var container = document.getElementById("PopupId"+i);
		//container.innerHTML = "";
		container.style.display = "none";
	}
	var container = document.getElementById("SetPopupId");
	//container.innerHTML = "";
	container.style.display = "none";
	var container = document.getElementById("SetPopup2Id");
	//container.innerHTML = "";
	container.style.display = "none";
}


function clearThemAllByClick(){
	if(!onMenus){
		for(i=1; i<=6; i++){
			var container = document.getElementById("PopupId"+i);
			//container.innerHTML = "";
			container.style.display = "none";
		}
		var container = document.getElementById("SetPopupId");
		//container.innerHTML = "";
		container.style.display = "none";
		var container = document.getElementById("SetPopup2Id");
		//container.innerHTML = "";
		container.style.display = "none";
		popup2Appeared=false;
	}
}



function fMouseOverFromHist(e, obj, ttt, container){
	//alert("Ustte obj: "+obj+" - \nttt: "+ttt+" - \ncont: "+container);
	loadXMLDoc(obj, ttt, container);

	if(msie){
		document.getElementById(container).style.pixelLeft = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft + 5;
		document.getElementById(container).style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop + 2;
	}
	else{
		document.getElementById(container).style.top = giveCoordY(e) + 'px';
		document.getElementById(container).style.left = giveCoordX(e) + 5 + 'px';

		//document.getElementById(container).style.top = (e.clientX + document.documentElement.scrollTop  + document.body.scrollTop) + 'px';
		//document.getElementById(container).style.left = newX + popupWidth(document.getElementById("PopupId4")) - 4 + 'px';
	}

	
	//document.getElementById("PopupId3").style.top = newY + 'px';
	//document.getElementById("PopupId2").style.left = newX + document.getElementById("PopupId1").getBoundingClientRect().right - document.getElementById("PopupId1").getBoundingClientRect().left + 6 + 'px';
	//document.getElementById("PopupId3").style.left = newX + popupWidth(document.getElementById("PopupId2")) - 0 + 'px';



	//document.getElementById(container).style.pixelLeft = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft + 5;
	//document.getElementById(container).style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop + 2;
}
  	

var lvlsofar=0;
var onMenus = false;
	

function getMouseX(e) // works on IE6,FF,Moz,Opera7
{ 
  var mousex=0;
		var mousey=0;
	var algor=0;
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
 
  if (e){
  	alert("e.pageX= "+e.pageX+"\ne.clientX= "+e.clientX);

    if (e.pageX){ // this doesn't work on IE6!! (works on FF,Moz,Opera7)
			mousex = e.pageX;
      algor = '[e.pageX]';
      alert("e.pageX= "+e.pageX);
      if (e.clientX) algor += ' [e.clientX] '
    }
    else if (e.clientX){ 
      mousex = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
      algor = '[e.clientX]';
      alert("e.clientX= "+e.clientX);
      
      if (e.pageX) algor += ' [e.pageX] '
    }
  }
  return mousex;
}




function fMouseOver(e, obj, lvl, ttt, container, subj){
	//alert("e: "+event+"\nUstte obj id: "+obj+" - \nttt: "+ttt+"\nlvl: "+lvl+" - \ncont: "+container);
	onMenus=true;
	var conOnce = container;
	var mydivs=document.getElementById("dDivId"+lvl).getElementsByTagName('div');
	for(i=1; i<mydivs.length; i++){
		mydivs[i].className = "cDivCls";
	}  	
	lvl = Number(lvl);
	if(lvl>=lvlsofar){
		lvlsofar=lvl+1;
	}
	if(lvlsofar-lvl>1){	
		for(i=lvl+2; i<=lvlsofar; i++){
			var newId = "PopupId"+i;
			container = document.getElementById(newId);	// yeniId PopupId3 and PopupId4
			//alert("i="+i+"\ncontainer.innerHTML: \n"+container.innerHTML);
			//container.removeChild(container.firstChild);
			container.firstChild.innerHTML = " ";
			//alert("i="+i+"\ncontainer.firstChild.id: "+container.firstChild.id);
			//alert("i="+i+"\ncontainer.firstChild.innerHTML: "+container.firstChild.innerHTML);
			container.style.display = "none"	
			//alert(i);
		}
	}
	//alert("Altta objId: "+obj+" \nttt: "+ttt+" \nlvl: "+lvl+" \ncont: "+container+" ");
	loadXMLDoc(obj, ttt, conOnce, subj);
	if(ttt=="t4"){
		preRel=obj;
	}
	else if(ttt=="t6"){
			preObj=obj;
	}
	document.getElementById(obj).className = "ItemMouseOver";
	if(lvl==4){
		if(msie){
			document.getElementById(container).style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop - 10;
			document.getElementById(container).style.pixelLeft = document.getElementById("PopupId4").getBoundingClientRect().right + Bdy.scrollLeft - 4;
		}
		else{
			//alert("e: "+e+"\nUstte obj id: "+obj+" - \nttt: "+ttt+"\nlvl: "+lvl+" - \ncont: "+container+"  ");
			var newX = findPosX(document.getElementById("PopupId4"));
			document.getElementById(container).style.top = giveCoordY(e) - 10 + 'px';
			document.getElementById(container).style.left = newX + popupWidth(document.getElementById("PopupId4")) - 0 + 'px';
		}
	}
	if(lvl==6){
		//alert("In if(lvl==6): obj= "+obj+" \nttt: "+ttt+" \nlvl: "+lvl+" \ncont: "+container+" ");
		document.getElementById("PopupId6").style.pixelLeft = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft - 200;
		document.getElementById("PopupId6").style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop;
	}
}



var prelvl=0;

function fMouseOut(obj, lvl){
	prelvl = lvl;
	onMenus=false;
}

var preFile=null;
var curFile=null;
var preSubj=null;
var curSubj=null;
var preRel=null;
var curRel=null;
var preObj=null;
var curObj=null;


function filesMouseOver(obj, lvl, ttt, container){
	obj=obj.substring(1);
	//alert("obj= "+obj + "\n lvl= "+ lvl+"\n ttt= "+ttt +"\n container= "+ container);
	preFile=curFile;
	curFile=unescape(obj);
	//alert("preFile= "+preFile+"\ncurFile= "+curFile+"\npreSubj= "+preSubj+"\npreRel= "+preRel+"\npreObj= "+preObj);
	BuildHistory(preFile, curFile, lvl);
	//alert("obj= "+obj);
	loadXMLDoc(obj, ttt, container);
	//document.getElementById(obj).className = "filesItemMouseOver";
	var e = document.createElement('div');
	e.className="eDetailCls";
	e.setAttribute('id', obj);
	//document.getElementById("detailAreaId").innerHTML = "";
	var container = document.getElementById("detailAreaId");
	container.innerHTML="";
	e.appendChild(document.createTextNode("Click "));
	var f = document.createElement('span');
	f.className="xx";
	f.appendChild(document.createTextNode("here"));
	f.setAttribute('id', "fDetId");
	f.onmouseover = new Function("filesHoverMouseOver(\""+escape(f.id)+"\", \'f3\', \'filesId1\');");
	f.onmouseout = new Function("filesHoverMouseOut(\""+escape(f.id)+"\", \'f3\', \'filesId1\');");
	f.onclick = new Function("loadXMLDoc(\""+obj+"\" ,\"t9\" ,\"detailResultId\");");
	e.appendChild(f);
	e.appendChild(document.createTextNode(" to get details of this document"));
	//container.removeChild(container.firstChild);
	container.appendChild(e);
}

   
function filesMouseOut(obj){
	document.getElementById(obj).className = "cFilesCls";
}


function filesHoverMouseOver(ins, fromContId, container){
	//alert(ins);
	ins = unescape(ins);
	document.getElementById(ins).className = "filesItemMouseOver";
	//alert("fromContId= "+fromContId+"\nId= "+ins);
}


function filesHoverMouseOut(ins, ttt, container){
	ins = unescape(ins);
	//alert(ins.substring(0,1));
	if(ins.substring(0,1)=="5"){
		document.getElementById(ins).className = "cDivCls";	// cDivCls for 5. menu.  cFilesCls is for left
	}
	else	
		if(ins.substring(0,1)=="6"){
			document.getElementById(ins).className = "cFilesCls";	// cDivCls for left-most menu that has file names.
	}
	else
		if(ins.substring(0,1)=="7"){
			document.getElementById(ins).className = "cDivCls";	// cDivCls for 5. menu.  cFilesCls is for left
	}
	else
		if(ins.substring(0,1)=="h"){
			document.getElementById(ins).className = "cHistFileName";	// cDivCls for 5. menu.  cFilesCls is for left
	}
	else
		if(ins.substring(0,1)=="f"){
			document.getElementById(ins).className = "xx";	// cDivCls for 5. menu.  cFilesCls is for left
	}
}



function hemensil(e, namedEntity, ttt, container){	//	for Span tags in the abstract
	//alert("namedEntity: "+namedEntity+"\nttt= "+ttt+"\nCont= "+container); 
	if(!popup2Appeared){
		if(ttt=="t2"){
			preSubj=namedEntity;
			loadXMLDoc(namedEntity, ttt, container);	// container is PopupId1 here And ttt is 't2'.
		}
		if(msie){
			document.getElementById(container).style.pixelLeft = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft + 5;
			document.getElementById(container).style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop + 2;
		}
		else{
			document.getElementById(container).style.top = giveCoordY(e) + 'px';
			document.getElementById(container).style.left = giveCoordX(e) + 5 + 'px';
			
			//document.getElementById(container).style.top = (e.clientX + document.documentElement.scrollTop  + document.body.scrollTop) + 'px';
			//document.getElementById(container).style.left = newX + popupWidth(document.getElementById("PopupId4")) - 4 + 'px';
		}
	}
}

   
function BuildMenu(obj){	// this builds the PopudId1 menu.	
	if(!popup2Appeared){
		//alert("popup2Appeared= "+popup2Appeared);
		clearThemAll();
		var items =	obj.getElementsByTagName('item');
		var inss =	obj.getElementsByTagName('ins');
		var d = document.createElement('div');
		d.className="dDivCls";
		d.setAttribute('id', 'dDivId1');
		d.setAttribute('lvl', '1');
		c = document.createElement('div');
		c.className="cHeaderCls";
		c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
		c.appendChild(document.createTextNode("Classes of "+inss[0].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
		d.appendChild(c);
			
		for(i=0; i<items.length; i++){
			c = document.createElement('div');
			c.className="cDivCls";
			c.setAttribute('id', items[i].firstChild.data);
			//alert("build menude forun icinde: "+items[i].id);
			c.appendChild(document.createTextNode(items[i].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
			d.appendChild(c);	
			//alert(items[i].firstChild.data); // returns type names
			//alert(mydivs[i].id);	// returns type names
		}
		var container = document.getElementById("PopupId1");
		container.style.display = "block";
		container.removeChild(container.firstChild);
		container.appendChild(d);
		
		var mydivs=d.getElementsByTagName('div');
		for(i=1; i<mydivs.length; i++){
			//var innerarray=mydivs[i];
			mydivs[i].onmouseover = new Function("fMouseOver(\"event\", \""+mydivs[i].id+"\" ,\"1\" ,\"t3\" ,\"PopupId2\");");	// mydivs[i].nodeValue		firstChild.nodeValue
			//mydivs[i].onmouseover = fMouseOver(event);	// mydivs[i].nodeValue		firstChild.nodeValue
			//displayCursorPosition(event);	
			mydivs[i].onmouseout = new Function("fMouseOut(\""+mydivs[i].id+"\" ,\"1\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		}	
	}
}


var popup2Appeared = false;
   
function FindSubMenu2(obj){	//this builds the PopudId2 menu, that is relations list.
	popup2Appeared = true;
	var inss =	obj.getElementsByTagName('ins');
	var subj = inss[0].firstChild.nodeValue;
	//alert("findMenu2 de subj= "+inss[0].nodeValue);
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dDivCls";
	d.setAttribute('id', 'dDivId2');
	d.setAttribute('lvl', '2');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
	c.appendChild(document.createTextNode("  Relations"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cDivCls";
		c.setAttribute('id', items[i].firstChild.data);
		c.appendChild(document.createTextNode(items[i].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
		d.appendChild(c);
	}
	var container = document.getElementById("PopupId2");
	//alert(container.innerHTML);  // returns "First popup menu"
	//container.innerHTML = d;
	//alert("container.id= "+container.id);
	container.style.display = "block";
	container.removeChild(container.firstChild);
	container.appendChild(d);
	var mydivs=d.getElementsByTagName('div');
	for(i=1; i<mydivs.length; i++){
		mydivs[i].onmouseover = new Function("fMouseOver(\"event\", \""+mydivs[i].id+"\" ,\"2\" ,\"t4\" ,\"PopupId3\" ,\""+inss[0].firstChild.nodeValue+"\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		mydivs[i].onmouseout = new Function("fMouseOut(\""+mydivs[i].id+"\" ,\"2\");");	// mydivs[i].nodeValue		firstChild.nodeValue
	}
	//document.getElementById("PopupId2").style.pixelTop =  document.getElementById("PopupId1").getBoundingClientRect().top + Bdy.scrollTop;
	//document.getElementById("PopupId2").style.pixelLeft = document.getElementById("PopupId1").getBoundingClientRect().right + Bdy.scrollLeft - 4;
	
	var newX = findPosX(document.getElementById("PopupId1"));
	var newY = findPosY(document.getElementById("PopupId1"));
	document.getElementById("PopupId2").style.top = newY + 'px';
	//document.getElementById("PopupId2").style.left = newX + document.getElementById("PopupId1").getBoundingClientRect().right - document.getElementById("PopupId1").getBoundingClientRect().left + 6 + 'px';
	document.getElementById("PopupId2").style.left = newX + popupWidth(document.getElementById("PopupId1")) - 0 + 'px';

} 


function popupWidth(el){
	var w; 
	if (document.getBoxObjectFor) { 
		var bo = document.getBoxObjectFor(el); 
		w = bo.width;
	} 
	else 
		if(el.getBoundingClientRect){
			var rect = el.getBoundingClientRect(); 
			w = rect.right - rect.left;
	} 
	el.w= w;
	//alert("Left: " + x + "\rTop: " + y + "\rWidth: " + w + "\rHeight: " + h);
	return w;
}

function popupHeight(el){
	var h; 
	if (document.getBoxObjectFor){
		var bo = document.getBoxObjectFor(el); 
		h = bo.height;
	} 
	else 
		if(el.getBoundingClientRect){
			var rect = el.getBoundingClientRect(); 
			h = rect.bottom - rect.top;
	} 
	el.h= h;
	//alert("Left: " + x + "\rTop: " + y + "\rWidth: " + w + "\rHeight: " + h);
	return h;
}




function FindSubMenu3(obj)	//this builds the PopudId3 menu, that is obj classes list.
{
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dDivCls";
	d.setAttribute('id', 'dDivId3');
	d.setAttribute('lvl', '3');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
	c.appendChild(document.createTextNode("  Classes"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cDivCls";
		c.setAttribute('id', items[i].firstChild.data);
		c.appendChild(document.createTextNode(items[i].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
		d.appendChild(c);
	}
	var container = document.getElementById("PopupId3");
	//alert("container.innerHTML: "+container.innerHTML);  // returns "First popup menu"
	//alert("id: "+container.id);  // returns "First popup menu"
	//container.innerHTML = d;
	container.style.display = "block";
	container.removeChild(container.firstChild);
	container.appendChild(d);
	var mydivs=d.getElementsByTagName('div');
	for(i=1; i<mydivs.length; i++){
		mydivs[i].onmouseover = new Function("fMouseOver(\"event\", \""+mydivs[i].id+"\" ,\"3\" ,\"t5\" ,\"PopupId4\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		mydivs[i].onmouseout = new Function("fMouseOut(\""+mydivs[i].id+"\" ,\"3\");");	// mydivs[i].nodeValue		firstChild.nodeValue
	}
	//document.getElementById("PopupId3").style.pixelTop =  document.getElementById("PopupId2").getBoundingClientRect().top + Bdy.scrollTop;
	//document.getElementById("PopupId3").style.pixelLeft = document.getElementById("PopupId2").getBoundingClientRect().right + Bdy.scrollLeft - 4;
	var newX = findPosX(document.getElementById("PopupId2"));
	var newY = findPosY(document.getElementById("PopupId2"));
	document.getElementById("PopupId3").style.top = newY + 'px';
	//document.getElementById("PopupId2").style.left = newX + document.getElementById("PopupId1").getBoundingClientRect().right - document.getElementById("PopupId1").getBoundingClientRect().left + 6 + 'px';
	document.getElementById("PopupId3").style.left = newX + popupWidth(document.getElementById("PopupId2")) - 0 + 'px';


} 


function FindSubMenu4(obj){	//this builds the PopudId4 menu, that is obj instances list.
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dDivCls";
	d.setAttribute('id', 'dDivId4');
	d.setAttribute('lvl', '4');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
	c.appendChild(document.createTextNode("  Instances"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cDivCls";
		c.setAttribute('id', items[i].firstChild.data);
		c.setAttribute('lvl', '4');
		c.appendChild(document.createTextNode(items[i].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
		d.appendChild(c);
	}
	var container = document.getElementById("PopupId4");
	//alert(container.innerHTML);  // returns "First popup menu"
	container.style.display = "block";
	container.removeChild(container.firstChild);
	container.appendChild(d);
	var mydivs=d.getElementsByTagName('div');
	for(i=1; i<mydivs.length; i++){
		mydivs[i].onmouseover = new Function("fMouseOver(arguments[0], \""+mydivs[i].id+"\" ,\"4\" ,\"t6\" ,\"PopupId5\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		mydivs[i].onmouseout = new Function("fMouseOut(\""+mydivs[i].id+"\" ,\"4\");");	// mydivs[i].nodeValue		firstChild.nodeValue
	}		
	//document.getElementById("PopupId4").style.pixelTop =  document.getElementById("PopupId3").getBoundingClientRect().top + Bdy.scrollTop;
	//document.getElementById("PopupId4").style.pixelLeft = document.getElementById("PopupId3").getBoundingClientRect().right + Bdy.scrollLeft - 4;
	
	var newX = findPosX(document.getElementById("PopupId3"));
	var newY = findPosY(document.getElementById("PopupId3"));
	document.getElementById("PopupId4").style.top = newY + 'px';
	//document.getElementById("PopupId2").style.left = newX + document.getElementById("PopupId1").getBoundingClientRect().right - document.getElementById("PopupId1").getBoundingClientRect().left + 6 + 'px';
	document.getElementById("PopupId4").style.left = newX + popupWidth(document.getElementById("PopupId3")) - 0 + 'px';


} 



function FindSubMenu5(obj){	// this builds PopupId5, the file names
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dDivCls";
	d.setAttribute('id', 'dDivId5');
	d.setAttribute('lvl', '5');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
	c.appendChild(document.createTextNode("File names"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cDivCls";
		c.setAttribute('id', "5"+items[i].firstChild.data);
		c.setAttribute('lvl', '5');
		var cstr = items[i].firstChild.nodeValue.replace(/_/g," ");
		var cstr = cstr.substring(cstr.indexOf("split")+6);  
		//alert(cstr);
		c.appendChild(document.createTextNode(cstr));  // also .data works instead of nodeValue
		d.appendChild(c);
		c.onclick = new Function("filesMouseOver(\""+escape(c.id)+"\" ,\"5\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseover = new Function("filesHoverMouseOver(\""+escape(c.id)+"\", \'f5\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseout = new Function("filesHoverMouseOut(\""+escape(c.id)+"\", \'f5\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
	}
	var container = document.getElementById("PopupId5");
	//alert(container.innerHTML);  // returns "First popup menu"
	container.style.display = "block";
	container.removeChild(container.firstChild);
	container.appendChild(d);
} 



function FindSubMenu6(obj){ // this gets file names and showed them on search Area (left column)
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dFilesCls";
	d.setAttribute('id', 'dDivId6');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.appendChild(document.createTextNode("File  NNames"));  // also .data works instead of nodeValue
	c.appendChild(document.createTextNode("File Names"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cFilesCls";
		c.setAttribute('id', "6"+items[i].firstChild.data);
		//alert((i+1)+" th item: "+items[i].firstChild.data.replace(/_/g," "));
		var cstr = items[i].firstChild.nodeValue.replace(/_/g," ");
		var cstr = cstr.substring(cstr.indexOf("split")+6);  
		//alert(cstr);
		c.appendChild(document.createTextNode(cstr));  // also .data works instead of nodeValue
		//alert("escape(c.firstChild.nodeValue)\n"+escape(c.id));
		//c.onclick = new Function("filesMouseOver(\""+escape(c.firstChild.nodeValue)+"\" ,\"6\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.onclick = new Function("filesMouseOver(\""+escape(c.id)+"\" ,\"6\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		//c.onmouseout = new Function("filesMouseOut(\""+c.id+"\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseover = new Function("filesHoverMouseOver(\""+escape(c.id)+"\", \'dDivId6\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseout = new Function("filesHoverMouseOut(\""+escape(c.id)+"\", \'f6\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		d.appendChild(c);
	}
	//innerarray.onclick = new Function("filesMouseOver(\""+escape(innerarray.id)+"\" ,\"6\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
	//innerarray.onmouseout = new Function("filesMouseOut(\""+innerarray.id+"\");");	// mydivs[i].nodeValue		firstChild.nodeValue
	var container = document.getElementById("filesId1");
	//alert(container.innerHTML);  // returns "First popup menu"
	//container.removeChild(container.firstChild);
	container.innerHTML="";
	container.appendChild(d);
} // end of function FindSubMenu6


function getPmidReturnAbs(obj){  // this gets file names and showed them on search Area (left column)
	var items =	obj.getElementsByTagName('item');
	//alert("in getPmidReturnAbs item= "+items[0].firstChild.data);
	loadXMLDoc(items[0].firstChild.data, "t1", "textFileArea") 
}


var detailArr=new Array("PMID","OWN","STAT","DA","DCOM","LR","IS","VI","IP","DP","TI","PG");

function GetDet(obj)  // this builds Detail Menu
	{
		var items =	obj.getElementsByTagName('item');
		var d = document.createElement('table');
		//alert("detailArr.length= "+detailArr.length+"\nitems.length"+items.length);
		//alert(detailArr[0]);
		//d.className="dDetCls";
		d.setAttribute('id', 'dDivId8');
		//d.setAttribute('border', '2');
		//var container = document.getElementById("detailAreaId");
		for(i=0; i<items.length; i++)
		{
			c = document.createElement('div');
			//c.className="cDetCls";
			c1 = document.createElement('span');
			//c.setAttribute('id', items[i].firstChild.data);
			c1.className="detHeaderCls";
			c1.appendChild(document.createTextNode(detailArr[i]));  // also .data works instead of nodeValue
			c.appendChild(c1);
			c1 = document.createElement('span');
			c1.className="detContentCls";
			c1.appendChild(document.createTextNode(" = "+items[i].firstChild.nodeValue));  // also .data works instead of nodeValue
			c.appendChild(c1);
			d.appendChild(c);
		}
		//alert(d.tagName);
		//alert(d.childNodes.length);
		var container = document.getElementById("detailAreaId");
		container.style.display = "block";
		//alert(container.id);  // returns "First popup menu"
		container.innerHTML = d.innerHTML;
	}


function removeHist(obj){
	alert("in removeHist id= "+obj);
	//rm = document.getElementById("cHistId");

	//while(rm.firstChild) rm.removeChild(rm.firstChild);


	//rm.removeChild(rm.childNodes[0]);
	
}



function BuildHistory(preFile, curFile, lvl)  // this builds History Menu
{
  clearThemAll();
  //alert("lvl= "+lvl);
  if(preFile!=null){
  	//alert("In buildHistory:\npreFile= "+preFile+"\ncurFile= "+curFile);
		
		//var outerd = document.createElement('div');
		var d = document.createElement('div');
		d.className="dHistCls";
		d.setAttribute('id', "dDivHistId");
		var c = document.createElement('div');
		c.className="cHistCls";
		c.setAttribute('id', 'cId');
/*		c1 = document.createElement('span');
		c1.className="histHeaderCls";
		c1.appendChild(document.createTextNode("X"));  // also .data works instead of nodeValue
		c1.setAttribute('id', "c1Id");
		c1.onclick = new Function("removeHist(\""+c1.parentNode.id+"\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.appendChild(c1);
*/
		
		c1 = document.createElement('span');
		//c.setAttribute('id', items[i].firstChild.data);
		c1.className="histHeaderCls";
		c1.appendChild(document.createTextNode("Previous File Name= "));  // also .data works instead of nodeValue
		c.appendChild(c1);
		c2 = document.createElement('span');
		c2.setAttribute('id', "h"+preFile);
		c2.className="cHistFileName";
		c2.appendChild(document.createTextNode(preFile.substring(preFile.indexOf("split")+6)));  // also .data works instead of nodeValue
		c2.onclick = new Function("filesMouseOver(\""+escape(c2.id)+"\" ,\"7\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		//c2.onclick = new Function("alert(\""+escape(c2.id.substring(1))+"\" ,\"7\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c2.onmouseover = new Function("filesHoverMouseOver(\""+escape(c2.id)+"\", \'histAreaId\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c2.onmouseout = new Function("filesHoverMouseOut(\""+escape(c2.id)+"\", \'f9\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.appendChild(c2);
		d.appendChild(c);
	
		if(lvl=="5"){
			c = document.createElement('div');
			c.className="cHistCls";
				p = document.createElement('pre');
				p.appendChild(document.createTextNode("\t"));  // also .data works instead of nodeValue
				c.appendChild(p);

			c1 = document.createElement('span');
			//c.setAttribute('id', items[i].firstChild.data);
			c1.className="histHeaderCls";
			c1.appendChild(document.createTextNode("MESH term= "));  // also .data works instead of nodeValue
			c.appendChild(c1);
			c2 = document.createElement('span');
			c2.className="cHistValues";
			c2.appendChild(document.createTextNode(preSubj.replace(/_/g," ")));  // also .data works instead of nodeValue
			c.appendChild(c2);

			p = document.createElement('pre');
			p.appendChild(document.createTextNode("  "));  // also .data works instead of nodeValue
			c.appendChild(p);

			c1 = document.createElement('span');
			c1.className="histHeaderCls";
			c1.appendChild(document.createTextNode("--->"));  // also .data works instead of nodeValue
			c.appendChild(c1);

			p = document.createElement('pre');
			p.appendChild(document.createTextNode("  "));  // also .data works instead of nodeValue
			c.appendChild(p);

			c1 = document.createElement('span');
			//c.setAttribute('id', items[i].firstChild.data);
			c1.className="histHeaderCls";
			c1.appendChild(document.createTextNode("Relation= "));  // also .data works instead of nodeValue
			c.appendChild(c1);
			c2 = document.createElement('span');
			c2.className="cHistValues";
			c2.appendChild(document.createTextNode(preRel.replace(/_/g," ")));  // also .data works instead of nodeValue
			c.appendChild(c2);

			p = document.createElement('pre');
			p.appendChild(document.createTextNode("  "));  // also .data works instead of nodeValue
			c.appendChild(p);

			c1 = document.createElement('span');
			c1.className="histHeaderCls";
			c1.appendChild(document.createTextNode("--->"));  // also .data works instead of nodeValue
			c.appendChild(c1);

			p = document.createElement('pre');
			p.appendChild(document.createTextNode("  "));  // also .data works instead of nodeValue
			c.appendChild(p);

			c1 = document.createElement('span');
			c1.className="histHeaderCls";
			c1.appendChild(document.createTextNode("Object= "));  // also .data works instead of nodeValue
			c.appendChild(c1);
			c2 = document.createElement('span');
			c2.className="cHistFileName";
			c2.setAttribute('id', 'cHistObjId');
			//c2.onmouseover = new Function("alert("+c2.id+");");	
			//alert("preObj= "+preObj); loadXMLDoc
			//c2.onmouseover = new Function("loadXMLDoc(\""+preObj+"\", \"t12\", \"PopupId6\");");	
			c2.onmouseover = new Function("fMouseOverFromHist(arguments[0], \""+preObj+"\", \"t12\", \"PopupId6\");");	
			c2.appendChild(document.createTextNode(preObj.replace(/_/g," ")));  // also .data works instead of nodeValue
			c.appendChild(c2);
			d.appendChild(c);
			//outerd.appendChild(d);
		}	
		var container = document.getElementById("histAreaId");
		container.style.display = "block";
		//container.innerHTML="";
		//container.removeChild(container.firstChild);
		//container.appendChild(outerd);
		container.appendChild(d);
		//alert(container.innerHTML);
		 
	}

}


function buildSubMenu5FromHist(obj){	// this builds PopupId5, the file names
	clearThemAll();
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dDivCls";
	//d.setAttribute('id', 'dDivId5');
	//d.setAttribute('lvl', '5');
	c = document.createElement('div');
	c.className="cHeaderCls";
	//c.setAttribute('id', inss[0].firstChild.nodeValue);	// this line causes problem at menu positioning
	c.appendChild(document.createTextNode("File names"));  // also .data works instead of nodeValue
	d.appendChild(c);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cDivCls";
		c.setAttribute('id', "7"+items[i].firstChild.data);
		c.setAttribute('lvl', '6');
		var cstr = items[i].firstChild.nodeValue.replace(/_/g," ");
		var cstr = cstr.substring(cstr.indexOf("split")+6);  
		//alert(cstr);
		c.appendChild(document.createTextNode(cstr));  // also .data works instead of nodeValue
		d.appendChild(c);
		c.onclick = new Function("filesMouseOver(\""+escape(c.id)+"\" ,\"6\" ,\"t1\" ,\"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseover = new Function("filesHoverMouseOver(\""+escape(c.id)+"\", \'f5\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseout = new Function("filesHoverMouseOut(\""+escape(c.id)+"\", \'f5\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
	}
		
	var container = document.getElementById("PopupId6");
	//alert(container.innerHTML);  // returns "First popup menu"
	container.style.display = "block";
	container.removeChild(container.firstChild);
	container.appendChild(d);
} 



function GetSet2(obj){  // this builds Set Popup Menu-2
	setTableExist2 = true;
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dSet2Cls";
	d.setAttribute('id', 'dDivId72');
	//alert(items[0].firstChild.data);
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cSetCls";
		//alert("id= "+items[i].firstChild.data.substring(items[i].firstChild.data.indexOf("--")+3)+"\nsekil= "+items[i].firstChild.data.substring(0, items[i].firstChild.data.indexOf("--")-1));
		c.setAttribute('id', items[i].firstChild.data.substring(items[i].firstChild.data.indexOf("--")+3));
		c.appendChild(document.createTextNode(items[i].firstChild.data.substring(0, items[i].firstChild.data.indexOf("--")-1)));  // also .data works instead of nodeValue
		c.onclick = new Function("ClickFunctionFromGetSet2(\""+escape(c.id)+"\", \"t1\", \"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseover = new Function("SetMouseOver(\""+escape(c.id)+"\");");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseout = new Function("SetMouseOut(\""+escape(c.id)+"\");");	 // mydivs[i].nodeValue		firstChild.nodeValue
		d.appendChild(c);
	}
	var container = document.getElementById("SetPopup2Id");
	container.style.display = "block";
	//alert(container.innerHTML);  // returns "First popup menu"
	//container.innerHTML = d;
	//container.removeChild(container.firstChild);
	container.innerHTML="";
	container.appendChild(d);
	//document.getElementById("SetPopup2Id").style.pixelTop =  document.getElementById("set2AreaId").getBoundingClientRect().top + document.getElementById("set2AreaId").offsetHeight + Bdy.scrollTop;
	//document.getElementById("SetPopup2Id").style.pixelLeft = findPosition(document.getElementById("set2AreaId"));
	//d.childNodes[2].className = "ItemMouseOver";
	var newX = findPosX(document.getElementById("set2AreaId"));
	var newY = findPosY(document.getElementById("set2AreaId"));
	document.getElementById("SetPopup2Id").style.top = newY + 20 + 'px';
	document.getElementById("SetPopup2Id").style.left = newX + 'px';

}


function ClickFunctionFromGetSet2(ins, ttt, container){
	//alert("ins= "+ins+" ttt= "+ttt+" container= "+container);
	document.getElementById("set2AreaId").value=unescape(ins).substring(unescape(ins).indexOf("split")+6);
	//alert("escape(c.id)= "+escape(c.id));
	filesMouseOver('x'+ins, '6', 't1', 'textFileArea'); 
	//loadXMLDoc(ins, ttt, container);
}


function GetSet(obj){  // this builds Set Popup Menu
	setTableExist = true;
	var items =	obj.getElementsByTagName('item');
	var d = document.createElement('div');
	d.className="dSetCls";
	d.setAttribute('id', 'dDivId7');
	//alert(items[0].firstChild.data);
	//document.getElementById("setTextArea").value=items[0].firstChild.data;
	for(i=0; i<items.length; i++){
		c = document.createElement('div');
		c.className="cSetCls";
		c.setAttribute('id', items[i].firstChild.data);
		//alert((i+1)+" th item: "+items[i].firstChild.data.replace(/_/g," "));
		c.appendChild(document.createTextNode(items[i].firstChild.nodeValue.replace(/_/g," ")));  // also .data works instead of nodeValue
		c.onclick = new Function("ClickFunctionFromGetSet(\""+items[i].firstChild.nodeValue+"\", \'t7\', \'filesId1\');");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseover = new Function("SetMouseOver(\""+items[i].firstChild.nodeValue+"\");");	 // mydivs[i].nodeValue		firstChild.nodeValue
		c.onmouseout = new Function("SetMouseOut(\""+items[i].firstChild.nodeValue+"\");");	 // mydivs[i].nodeValue		firstChild.nodeValue
		d.appendChild(c);
	}
	var container = document.getElementById("SetPopupId");
	container.style.display = "block";
	//alert(container.innerHTML);  // returns "First popup menu"
	//container.innerHTML = d;
	//container.removeChild(container.firstChild);
	container.innerHTML="";
	container.appendChild(d);
	//document.getElementById("SetPopupId").style.pixelTop =  document.getElementById("setTextArea").getBoundingClientRect().top + document.getElementById("setTextArea").offsetHeight + Bdy.scrollTop;
	//document.getElementById("SetPopupId").style.pixelLeft = findPosition(document.getElementById("setTextArea"));
	
	var newX = findPosX(document.getElementById("setTextArea"));
	var newY = findPosY(document.getElementById("setTextArea"));
	document.getElementById("SetPopupId").style.top = newY + 20 + 'px';
	document.getElementById("SetPopupId").style.left = newX + 'px';

}



function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}


function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}



function ClickFunctionFromGetSet(ins, ttt, container){
	document.getElementById("setTextArea").value=unescape(ins).replace(/_/g," ");
	loadXMLDoc(ins, ttt, container);
}


function SetMouseOver(ins){
	ins=unescape(ins);
	document.getElementById(ins).className = "ItemMouseOver";
}

function SetMouseOut(ins){
	ins=unescape(ins);
	document.getElementById(ins).className = "cSetCls";
}


function disableEnter() {	// this method disables the enter key to submit while in the textarea.
    return false;
}



var isHL2 = false;  // is HighLighted?
var downArrowIter2 = -1;
var setTableExist2 = false;

function SetAjax2(e, ins, ttt, container){	// for searchById.  ttt is t11 comes from html page. 
	if(ins.length>3){
	
			if( !e ){
				if(window.event){
					e = window.event; 
				}
				else{ 
					return; 
				} 
			}
			if(typeof(e.which) == 'number'){
				e = e.which; 
			} 
			else{
				if(typeof(e.keyCode) == 'number'){
					e = e.keyCode; 
				} 
				else { 
					if(typeof(e.charCode) == 'number'){ 
						e = e.charCode; 
					} 
					else{ 
						return; 
					} 
				} 
			}
	
	
	
		//alert(e);
		if(e=="40" && setTableExist2){
			//isHL = true;
			if(!isHL2){ 
				//alert(setTableExist2);
				downArrowIter2 = -1;
				isHL2 = true;
			}
			if(downArrowIter2<document.getElementById("dDivId72").childNodes.length-1){
				downArrowIter2 +=1;
				//alert("downArrowIter= "+downArrowIter);
				document.getElementById("dDivId72").childNodes[downArrowIter2].className = "ItemMouseOver";
			}
			if(downArrowIter2!="0"){
				//alert("downArrowIter= "+downArrowIter);
				document.getElementById("dDivId72").childNodes[downArrowIter2-1].className = "cSetCls";
			}
		}
		else{
			if(e=="38" && downArrowIter2>"0"){
				isHL2 = true;
				document.getElementById("dDivId72").childNodes[downArrowIter2].className = "cSetCls";
				downArrowIter2 -=1;
				document.getElementById("dDivId72").childNodes[downArrowIter2].className = "ItemMouseOver";
			}
			else{
				if((e>"47" && e<"58") || e=="8"){
					//alert("ins="+ins+" ttt= "+ttt+" cont="+container);
					loadXMLDoc(ins, ttt, container);
					isHL2 = false;
					//if(ins.length>1){	//ins.length>1
						//alert(document.getElementById("dDivId72").childNodes[0].className);
						//alert("selam");
						//alert(document.getElementById("dDivId72").childNodes[0].className);
						
					//}
					//document.getElementById("setTextArea").value=document.getElementById("dDivId72").childNodes[0].id;
					//downArrowIter="-1";
				}
				else{
					if(e=="13" && setTableExist2){
						if(isHL2){
							//c.onclick = new Function("ClickFunctionFromGetSet2(\""+escape(c.id)+"\", \"t1\", \"textFileArea\");");	// mydivs[i].nodeValue		firstChild.nodeValue
							ClickFunctionFromGetSet2(document.getElementById("dDivId72").childNodes[downArrowIter2].id, "t1", "textFileArea");
							//alert("in SetAjax2= "+document.getElementById("dDivId72").childNodes[downArrowIter2].id);
							//loadXMLDoc(document.getElementById("dDivId72").childNodes[downArrowIter2].id, "t1", "textFileArea");	// returns file paths
							var container = document.getElementById("SetPopup2Id");
							//container.removeChild(container.firstChild);
							//container.firstChild.innerHTML = " ";
							container.style.display = "none";
							var buid=document.getElementById("dDivId72").childNodes[downArrowIter2].id;
							//alert(buid.substring(buid.indexOf("split")+6));
							//alert(document.getElementById("dDivId72").childNodes[downArrowIter2].id.substring(0, document.getElementById("dDivId72").childNodes[downArrowIter2].id.indexOf("--")-1) );
							document.getElementById("set2AreaId").value=buid.substring(buid.indexOf("split")+6);
							// .substring(0, items[i].firstChild.data.indexOf("--")-1))
						}
						else{
							//alert(document.getElementById("dDivId72").childNodes[0].id);
							if(ins==document.getElementById("dDivId72").childNodes[0].id){
								loadXMLDoc(ins, "t7", "filesId1");
								var container = document.getElementById("SetPopup2Id");
								//container.removeChild(container.firstChild);
								//container.firstChild.innerHTML = " ";
								container.style.display = "none";
								//document.getElementById("setTextArea").value=document.getElementById("dDivId72").childNodes[downArrowIter].id;
							}
						}
					}
				}
			}
		}
	}
	else{
		var container = document.getElementById("SetPopup2Id");
		//container.firstChild.innerHTML = " ";
		//container.innerHTML = " ";
		container.style.display = "none";
	}
}



var isHL = false;  // is HighLighted?
var downArrowIter = -1;
var setTableExist = false;

function SetAjax(e, ins, ttt, container){	// ttt is t8 coming from keyword search
	if(ins.length>2){
		
		if( !e ){
			if(window.event){
				e = window.event; 
			}
			else{ 
				return; 
			} 
		}
		if(typeof(e.which) == 'number'){
			e = e.which; 
		} 
		else{
			if(typeof(e.keyCode) == 'number'){
				e = e.keyCode; 
			} 
			else { 
				if(typeof(e.charCode) == 'number'){ 
					e = e.charCode; 
				} 
				else{ 
					return; 
				} 
			} 
		}
		//alert('The key pressed has keycode ' + e + ' and is key ' + String.fromCharCode( e ) );
		//alert("e= "+e+"\ne= "+e);
		//alert(ins);
		
		
		if(e=="40" && setTableExist){
			//isHL = true;
			if(!isHL){ 
				//alert(setTableExist);
				downArrowIter = -1;
				isHL = true;
			}
			if(downArrowIter<document.getElementById("dDivId7").childNodes.length-1){
				downArrowIter +=1;
				//alert("downArrowIter= "+downArrowIter);
				document.getElementById("dDivId7").childNodes[downArrowIter].className = "ItemMouseOver";
			}
			if(downArrowIter!="0"){
				//alert("downArrowIter= "+downArrowIter);
				document.getElementById("dDivId7").childNodes[downArrowIter-1].className = "cSetCls";
			}
		}
		else{
			if(e=="38" && downArrowIter>"0"){
				isHL = true;
				document.getElementById("dDivId7").childNodes[downArrowIter].className = "cSetCls";
				downArrowIter -=1;
				document.getElementById("dDivId7").childNodes[downArrowIter].className = "ItemMouseOver";
			}
			else{
				if((e>"64" && e<"123") || e=="8"){
					//alert("ins="+ins+" ttt= "+ttt+" cont="+container);
					loadXMLDoc(ins, ttt, container);	// ttt is t7 coming from keyword search
					isHL = false;
				}
				else{
					if(e=="13" && setTableExist){
						if(isHL){
							loadXMLDoc(document.getElementById("dDivId7").childNodes[downArrowIter].id, "t7", "filesId1");
							var container = document.getElementById("SetPopupId");
							//container.removeChild(container.firstChild);
							//container.firstChild.innerHTML = " ";
							container.style.display = "none";
							document.getElementById("setTextArea").value=document.getElementById("dDivId7").childNodes[downArrowIter].id.replace(/_/g," ");
						}
						else{
							//alert(document.getElementById("dDivId7").childNodes[0].id);
							if(ins==document.getElementById("dDivId7").childNodes[0].id){
								loadXMLDoc(ins, "t7", "filesId1");
								var container = document.getElementById("SetPopupId");
								//container.removeChild(container.firstChild);
								//container.firstChild.innerHTML = " ";
								container.style.display = "none";
								//document.getElementById("setTextArea").value=document.getElementById("dDivId7").childNodes[downArrowIter].id;
							}
						}
					}
				}
			}
		}
	}
	else{
		var container = document.getElementById("SetPopupId");
		//container.firstChild.innerHTML = " ";
		//container.innerHTML = " ";
		container.style.display = "none";
	}
}


function findPosition( oLink ) {
  if( oLink.offsetParent ) {
    for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
      posX += oLink.offsetLeft;
      posY += oLink.offsetTop;
    }
    return posX;
	} else {
    return oLink.x;
  }
}



function giveCoordX(e){
	if(!e){ 
		e = window.event; 
	} 
	if(!e || (typeof(e.pageX) != 'number' && typeof(e.clientX) != 'number')){ 
		return window.alert('Your browser did not pass the required information about the event'); 
	}
	if(typeof(e.pageX) == 'number'){
		var xcoord = e.pageX; 
	} 
	else{
		var xcoord = e.clientX;
		
		if( !(( window.navigator.userAgent.indexOf('Opera')+1) || (window.ScriptEngine && ScriptEngine().indexOf('InScript')+1 && !document.createElement) || window.navigator.vendor == 'KDE')){
			if(document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)){
				xcoord += document.documentElement.scrollLeft;
			} 
			else if(document.body && (document.body.scrollTop || document.body.scrollLeft)){
			xcoord += document.body.scrollLeft;
			}
		}
	}
	return xcoord;
	//window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
}


function giveCoordY(e){ 
	if(!e){ 
		e = window.event; 
	} 
	if(!e || (typeof(e.pageX) != 'number' && typeof(e.clientX) != 'number')){ 
		return window.alert('Your browser did not pass the required information about the event'); 
	}
	if(typeof(e.pageX) == 'number'){
		var ycoord = e.pageY; 
	} 
	else{
		var ycoord = e.clientY;
		
		if( !(( window.navigator.userAgent.indexOf('Opera')+1) || (window.ScriptEngine && ScriptEngine().indexOf('InScript')+1 && !document.createElement) || window.navigator.vendor == 'KDE')){
			if(document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft)){
				ycoord += document.documentElement.scrollTop;
			} 
			else if(document.body && (document.body.scrollTop || document.body.scrollLeft)){
				ycoord += document.body.scrollTop;
			}
		}
	}
	return ycoord;
	//window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
}





var req;
var url;
function loadXMLDoc(ins, ttt, container, subj) 
{
	var param = "username=" + unescape(ins);

	if(ttt == "t1") {
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t1=true"; // param is path, and subj is filename
		//alert("ustte T1 param: "+param);
		//alert("ustte T1 param: "+unescape(ins));
	}
	if(ttt == "t2") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t2=true"; 
		//alert("ustte T2 param: "+param+ "\npopup2Appeared: "+popup2Appeared);	// alerts username=Cronates&t2=true
	}
	if(ttt == "t3") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t3=true"; 
		//alert("ustte T3 param: "+param);	// alerts username=Lipid&t3=true
	}
	if(ttt == "t4") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t4=true&subj=" + subj; 
		//alert("ustte T4 param: "+param);	// alerts username=isa&t4=true&subj=Lipid
	}
	if(ttt == "t5") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t5=true"; 
		//alert("ustte T5 param: "+param);	// alerts username=Hormone&t5=true
	}
	if(ttt == "t6") { 	// this get the instance name from 4th popup menu and returns file paths
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t6=true"; 
		//alert("ustte T6 param: "+param);	// alerts username=17_Ketostroids&t6=true
	}
	if(ttt == "t7") { 				// This gets instance name from left column and returns file paths
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t7=true"; 
		//alert("ustte T7 param: "+param);
	}
	if(ttt == "t8"){					//	this is called from SetAjax function. gets first letters of keyword and returns instance names.
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t8=true"; 
		//alert("ustte T8 param: "+param);
	}
	if(ttt == "t9") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t9=true"; 
		//alert(param);
	}
	if(ttt == "t10") { // This gets Pmid number and returns file paths
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t10=true"; 
		//alert(param);
	}
	if(ttt == "t11") { // This gets Pmid number and returns file paths
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t11=true";
		//alert(param);
	}
	if(ttt == "t12") { 
		uri = "/SemanticBrowser/test.jsp";
		param = param + "&t12=true"; 
		//alert(param);
	}
	if(ttt == "t13") { 
		uri = "/SemanticBrowser/test.jsp";
		param = "t13=true"; 
		//alert(param);
	}


	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } 
        catch(e) {
			req = false;
 		} 
    // branch for IE/Windows ActiveX version
    } 
    else if(window.ActiveXObject) {
       		try {
        		req = new ActiveXObject("Msxml2.XMLHTTP");
      		} 
      		catch(e) {
        		try {
          			req = new ActiveXObject("Microsoft.XMLHTTP");
        		} 
        		catch(e) {
          			req = false;
        		}
			}
    	}
		if(req) {
			req.onreadystatechange = function () { processReqChange(container, ttt); };
		
			req.open("POST", uri, true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            req.send(param);
		}
	}



function processReqChange(container, ttt) {
	if(req.readyState == 4){
		if(req.status == 200){
			
 
 	if (ttt == 't1'){	
 		//alert("en altta js de T1: "+req.responseText); //returns abstract with span tags in it
 		document.getElementById(container).innerHTML = req.responseText;
 		ssx = document.getElementById(container).getElementsByTagName('span');
		for(i=0; i<ssx.length; i++){
			ssx[i].className="cHistFileName";
			ssx[i].onmouseover = new Function("hemensil(arguments[0], this.id, 't2', 'PopupId1');");
		}
 	}	// ttt = t1
 
	if (ttt == 't2'){ 
		//alert("en altta js de: "+req.responseText);
		BuildMenu(req.responseXML);
	}
	if (ttt == 't3'){ 
		//alert("en altta T3 : "+req.responseText);	//this returns relations
		FindSubMenu2(req.responseXML);
	}
	if (ttt == 't4'){ 
		//alert("en altta T4 : "+req.responseText);		//this returns objTypes
		FindSubMenu3(req.responseXML);
	}
	if (ttt == 't5'){ 
		//alert("en altta T5 : "+req.responseText);	//this returns objInstances
		FindSubMenu4(req.responseXML);
	}
	if (ttt == 't6'){ 
		//alert("en altta T6 : "+req.responseText);	//this returns File Names from Lucene
		FindSubMenu5(req.responseXML);
	}
	if (ttt == 't7'){ 
		//alert("en altta T7 : "+req.responseText);	//this returns File Names from Lucene
		FindSubMenu6(req.responseXML);
	}
	if (ttt == 't8'){ 
		//alert("en altta T8 : "+req.responseText);	//gets first letters of keyword and returns instance names.
		GetSet(req.responseXML);
	}
	if (ttt == 't9'){ 
		//alert("en altta T9 : "+req.responseText);	//this returns file abstract from JSP
		GetDet(req.responseXML);
	}
	if (ttt == 't10'){ 
		//alert("en altta T10 : "+req.responseText);	//this returns file abstract from JSP
		getPmidReturnAbs(req.responseXML);
	}
	if (ttt == 't11'){ 
		//alert("en altta T11 : "+req.responseText);	//this returns file names to put into PopupSet2
		GetSet2(req.responseXML);
	}
	if (ttt == 't12'){ 
		//alert("en altta T12 req.responseText= "+req.responseText);	//this returns file abstract from JSP
		buildSubMenu5FromHist(req.responseXML);
		//document.getElementById(container).style.pixelLeft = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft + 5;
		//document.getElementById(container).style.pixelTop =  window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop + 2;
	}
	if (ttt == 't13'){ 
		//alert("en altta T13 : "+req.responseText);	//this returns file names to put into PopupSet2
		//alert("onload");
		
	}



	
	} 
	else 
	{
		alert("There was a problem retrieving the XML data:\n" + req.statusText);
	}
	}
}


