var xmlHttp

	var oPopup=window.createPopup();

	function nullReturn() {
		return false;
	}
	function ajaxSysReq() {
		var variable = "http://msdn2.microsoft.com/en-us/library/bb470452.aspx";
		open(variable,"sysreq");
		return;
	}
	
	function dxplainAlgorithm() {
		var text = "DXplain's knowledge base is comprised of over 2300 disease profiles.  Each disease profile contains from 10 to over 100 clinical findings, with an average of 53 findings per disease.  As an example, the disease profile of pneumococcal pneumonia would contain, among many others, the findings cough, fever, rales, pleuritic chest pain and elevated neutrophil count.";
		text += "<P>Each finding has two attributes relating it to the disease: one attribute describes how frequently the finding is seen in the disease, and the other expresses how strongly the finding suggests that disease. Each finding also has a disease-independent attribute that conveys the importance of the finding (malaise is less important than hemoptysis). The degree of support for a particular disease is related to the entry of case findings that are both important and suggestive of the particular disease.  Common diseases are given extra weight. Support for a given disease will be lowered if findings commonly seen in the disease are stated to be absent. ";
		text += "DXplain uses this information to generate an ordered list of diagnoses associated with some or all of a given set of findings. ";
		var variable = "displayTextbox.asp?command=why&whytext=" + text;
		open(variable,"algorithm_area","width=600,height=310");
		return;
	}
	function dxplainAlgorithm_popup() {
		var text = "DXplain's knowledge base is comprised of over 2300 disease profiles.  Each disease profile contains from 10 to over 100 clinical findings, with an average of 53 findings per disease.  As an example, the disease profile of pneumococcal pneumonia would contain, among many others, the findings cough, fever, rales, pleuritic chest pain and elevated neutrophil count.";
		text += "<P>Each finding has two attributes relating it to the disease: one attribute describes how frequently the finding is seen in the disease, and the other expresses how strongly the finding suggests that disease. Each finding also has a disease-independent attribute that conveys the importance of the finding (malaise is less important than hemoptysis). The degree of support for a particular disease is related to the entry of case findings that are both important and suggestive of the particular disease.  Common diseases are given extra weight. Support for a given disease will be lowered if findings commonly seen in the disease are stated to be absent. ";
		text += "DXplain uses this information to generate an ordered list of diagnoses associated with some or all of a given set of findings. ";
		var pbody=oPopup.document.body;
		pbody.style.backgroundColor="#FFFFC8";
		pbody.style.border="solid gray 2px";
		pbody.style.fontFamily="arial";
		pbody.style.fontWeight="bold";
		pbody.style.fontSize="13px";
		pbody.style.color="#23238E";
		pbody.style.margin="10px";
		pbody.style.cursor="arrow";
		pbody.innerHTML = text + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
		oPopup.show(240,100,600,310,document.body);
	}
	function privacyNotice(str) {
		var text = "<P><h3>Privacy Statement --  DXplain®</h3>\n";
		text += "<B>DXplain uses an individual’s email address as a user ID for the system’s usage and problem logs. The reasons we want email addresses are that they provide a unique identifier for our logging; they allow users to save a case in DXplain’s logs; and most importantly, they allow us to respond to user questions, critiques and suggestions left for the DXplain developers through our online Feedback function.\n";
		text += "<P>Our policy is that never, under any circumstances, do we publish or provide these email addresses to anyone. DXplain was developed by and is owned by the Laboratory of Computer Science, Massachusetts General Hospital (LCS,MGH).  All members of  LCS/MGH sign a strict confidentiality policy.\n";
		text += "<P>If you have any questions or need additional information, please send a message to:  ";
		text += "<i>dxplain\@mgh.harvard.edu</i>";
		var variable = "displayTextbox.asp?command=why&whytext=" + text;
		open(variable,"why_area","width=600,height=330");
		return;
	}
	function privacyNotice_popup(str) {
		var text = "<P><h3>Privacy Statement --  DXplain®</h3>\n";
		text += "<B>DXplain uses an individual’s email address as a user ID for the system’s usage and problem logs. The reasons we want email addresses are that they provide a unique identifier for our logging; they allow users to save a case in DXplain’s logs; and most importantly, they allow us to respond to user questions, critiques and suggestions left for the DXplain developers through our online Feedback function.\n";
		text += "<P>Our policy is that never, under any circumstances, do we publish or provide these email addresses to anyone. DXplain was developed by and is owned by the Laboratory of Computer Science, Massachusetts General Hospital (LCS,MGH).  All members of  LCS/MGH sign a strict confidentiality policy.\n";
		text += "<P>If you have any questions or need additional information, please send a message to:  ";
		text += "<i>dxplain\@mgh.harvard.edu</i>";
		var pbody=oPopup.document.body;
		pbody.style.backgroundColor="#FFFFC8";
		pbody.style.border="solid gray 2px";
		pbody.style.fontFamily="arial";
		pbody.style.fontWeight="bold";
		pbody.style.fontSize="13px";
		pbody.style.color="#23238E";
		pbody.style.margin="10px";
		pbody.style.cursor="arrow";
		pbody.innerHTML = text + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
		oPopup.show(240,100,600,330,document.body);
	}
	function why(whytext) {
		var variable = "displayTextbox.asp?command=why&whytext=" + whytext;
		open(variable,"why_area","width=600,height=120");
	}
	function why_popup(whytext) {
		var pbody=oPopup.document.body;
		pbody.style.backgroundColor="#FFFFC8";
		pbody.style.border="solid gray 2px";
		pbody.style.fontFamily="arial";
		pbody.style.fontWeight="bold";
		pbody.style.fontSize="13px";
		pbody.style.color="#23238E";
		pbody.style.margin="10px";
		pbody.style.cursor="arrow";
		pbody.innerHTML = whytext + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
		oPopup.show(250,240,500,110,document.body);
	}
	function why_close()  {
		alert ( "whyclose" );
	}
	function ghelp(cmd) {
		if ( cmd == 'askquestion' ) {
			var variable = "displayTextbox.asp?command=" + cmd;
			open(variable,"hint_area","width=600,height=370");
		} else if ( cmd == 'casefindings' ) {
			var variable = "displayTextbox.asp?command=" + cmd;
			open(variable,"hint_area","width=420,height=190");
		} else if ( cmd == 'age' ) {
			var variable = "displayTextbox.asp?command=" + cmd;
			open(variable,"hint_area","width=600,height=240");
		}
	}
	function ghelp_popup(cmd) {
		if ( cmd == "askquestion" ) {
			var text="<P><b><h3>Findings Present?</h3><P>Based on the findings you enter, DXplain generates a list of diseases that may explain these findings. The Findings Present? function is useful when you are not sure which additional data are considered important.  DXplain presents suggestions as to which additional information would be most useful in refining the disease list. <P>In this interrogative mode, DXplain asks you about the presence or absence of clinical manifestations that will make the leading diseases under consideration more or less likely. You may select 'Y' if finding present, 'N' if finding absent or 'Unk' if unknown.<P>If the question icon is clicked, DXplain will display a brief explanation of why the finding is considered useful.";
			var pbody=oPopup.document.body;
			pbody.style.backgroundColor="#FFFFC8";
			pbody.style.border="solid gray 2px";
			pbody.style.fontFamily="arial";
			pbody.style.fontWeight="bold";
			pbody.style.fontSize="13px";
			pbody.style.color="#23238E";
			pbody.style.margin="10px";
			pbody.innerHTML = text + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
			oPopup.show(200,45,560,300,document.body);
		} else if ( cmd == "casefindings" ) {
			var text="<P><b><h3>Case Findings</h3>";
			text += "<P> &nbsp; &nbsp; <img border=0 SRC=\"" + graphic + "/close-x-inactive.gif\" WIDTH=12 HEIGHT=12 VALIGN=\"Middle\">";
			text += " &nbsp; Remove finding from case findings list";
			text += "<BR> &nbsp; &nbsp; <img border=\"0\" SRC=\"" + graphic + "/absent-minus-inactive.gif\" WIDTH=12 HEIGHT=12 VALIGN=\"Middle\">";
			text += " &nbsp; Convert to absence of finding";
			text += "<BR> &nbsp; &nbsp; <img border=\"0\" SRC=\"" + graphic + "/present-+-inactive.gif\" WIDTH=12 HEIGHT=12 VALIGN=\"Middle\">";
			text += " &nbsp; Convert to presence of finding";
			text += "<BR> &nbsp; &nbsp; <img border=\"0\" SRC=\"" + graphic + "/focus-f-inactive.gif\" WIDTH=12 HEIGHT=12 VALIGN=\"Middle\">";
			text += " &nbsp; Activate focus on finding";
			text += "<BR> &nbsp; &nbsp; <img border=\"0\" SRC=\"" + graphic + "/focus-f-active.gif\" WIDTH=12 HEIGHT=12 VALIGN=\"Middle\">\n";
			text += " &nbsp; Remove focus from finding";
					
			var pbody=oPopup.document.body;
			pbody.style.backgroundColor="#FFFFC8";
			pbody.style.border="solid gray 2px";
			pbody.style.fontFamily="arial";
			pbody.style.fontWeight="bold";
			pbody.style.fontSize="13px";
			pbody.style.color="#23238E";
			pbody.style.margin="10px";
			pbody.innerHTML = text + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
			oPopup.show(240,310,420,190,document.body);
		}
	}
	function publications(str) {
		var text = "<P><h3>Pertinent Articles about DXplain</h3>\n";
		text += "<OL>\n";
		text += "<LI>\n";
		text += "Barnett GO, Cimino JJ, Hupp JA, Hoffer EP.  DXplain - an evolving diagnostic decision-support system.  JAMA.  1987; 258:67-74.\n";
		text += "<LI>\n";
		text += "Berner ES, Webster, GD, Shugermann AA, et al.  Performance of four computer-based diagnostic systems.   N Engl J Med.  1994;330:1792-6.\n";
		text += "<LI>\n";
		text += "Berner ES, Jackson JR, Algina J.  Relationships among performance scores of four diagnostic decision support systems.   J Am Med Inform Assoc. 1996;3(3):208-15.\n";
		text += "<LI>\n";
		text += "Barnett GO, Famiglietti KT, Kim RJ, Hoffer EP, Feldman MJ.  DXplain on the Internet.  Proceedings of the 1998 AMIA Annual Fall Symposium, 1998 Nov 7-11, Orlando, FL.  607-611.\n";
		text += "</OL>\n";
		text += "<P>\n";
 		var pbody=oPopup.document.body;
		pbody.style.backgroundColor="#FFFFC8";
		pbody.style.border="solid gray 2px";
		pbody.style.fontFamily="arial";
		pbody.style.fontWeight="bold";
		pbody.style.fontSize="13px";
		pbody.style.color="#23238E";
		pbody.style.margin="10px";
		pbody.style.cursor="arrow";
		if ( 1 == 1 )  {
			pbody.innerHTML = text + "<P><button tabindex=\"-1\" onclick=\"parent.oPopup.hide();\" style=\"border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc \">Close Window</button>\n";
		} else {
			text += "<P> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
			text += "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
			text += "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
			text += "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
			text += "<font face=\"arial\" fontSize=\"13px\" color=\"maroon\" onclick=\"parent.oPopup.hide();\" style=\"border-top:2px solid maroon; background:#FFFFC8 \">ť close ť</font>\n";
			pbody.innerHTML = text;
		}
		oPopup.show(168,87,650,230,document.body);
	}

function publications_pubmed(uid) {
	nwidth = 1000;
	nheight = 800;
	var variable = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=Pubmed&dopt=Abstract&list_uids=" + uid;
	open(variable, "pub_ref", "top=0,left=0,toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=2,resizable=yes,copyhistory=0,width=1000,height=800");
 }



	function ltrim(str) {
    	return str.replace(/^[ ]+/, '');
	}
	function rtrim(str) {
    	return str.replace(/[ ]+$/, '');
	}
	function trim(str) {
    	return ltrim(rtrim(str));
	}
 	function replace(string,text,by) {
	    var strLength = string.length, txtLength = text.length;
    	if ((strLength == 0) || (txtLength == 0)) return string;

	    var i = string.indexOf(text);
    	if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;

		var newstr = string.substring(0,i) + by;

	    if (i+txtLength < strLength)
    	    newstr += replace(string.substring(i+txtLength,strLength),text,by);

	    return newstr;
	}
	function rstrip(lstr,delimiter) {
		if (lstr != "") {
			var strlen, cptr, lpflag, chk
			strlen = lstr.length;
			cptr = strlen;
			lpflag=true;
		do {
			chk=lstr.charAt(cptr-1)
			if (chk != delimiter) {
				lpflag = false }
			else {
				if (cptr == 0) {
					lpflag = false }
				else {
					cptr-- }}}
		while (lpflag == true)
		if (cptr < strlen) {
			lstr = lstr.substring(0,cptr) }}
		return lstr
	}
	function mumps_replace(str,piece1,piece2)  {
		var s1,s2;
		s1 = str.split(piece1);
		s2 = s1.join(piece2);
		return(s2);
	}
	function mumps_piece(str,piece,start,end)  {
		var s1,s2,newArray;
		s1 = str.split(piece);
		if ( end < 1 )  {
			end = start;
		}
		newArray = s1.slice(start-1,end);
		s2 = newArray.join(piece);
		return(s2);
	}
	function createPostStringTextbookFinding(findingStr, variableStr, functionFinding, commandStr) {
		v_age = document.main_form.a_age.value;
		v_gender = document.main_form.a_gender.value;
		v_duration = document.main_form.a_duration.value;
		var url="q="+findingStr;
		url=url+"&sid="+Math.random();
		url=url+"&session="+ document.main_form.session.value;
		url=url+"&login="+ document.main_form.login.value;
		url=url+"&userid="+ document.main_form.userid.value;
		url=url+"&background="+ document.main_form.background.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&finding=" + findingStr;
		url=url+"&autoLookup=" + document.main_form.autoLookup.value;
		url=url+"&command="+ commandStr;
		url=url+"&ajax=yes";
		url = mumps_replace(url," ","+");
		return url;
	}
	function createPostStringTextbookDisease(diseaseStr, variableStr, functionFinding, commandStr) {
		v_age = document.main_form.a_age.value;
		v_gender = document.main_form.a_gender.value;
		v_duration = document.main_form.a_duration.value;
		var url="q="+diseaseStr;
		url=url+"&sid="+Math.random();
		url=url+"&session="+ document.main_form.session.value;
		url=url+"&login="+ document.main_form.login.value;
		url=url+"&userid="+ document.main_form.userid.value;
		url=url+"&background="+ document.main_form.background.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&disease=" + diseaseStr;
		url=url+"&termnumlist=" + document.main_form.termnumlist.value;
		url=url+"&autoLookup=" + document.main_form.autoLookup.value;
		url=url+"&command="+ commandStr;
		url=url+"&ajax=yes";
		url = mumps_replace(url," ","+");
		return url;
	}
	function createPostStringCaseEntry(findingStr, variableStr, functionFinding) {
		v_age = document.main_form.c_age.value;
		v_gender = document.main_form.c_gender.value;
		v_duration = document.main_form.c_duration.value;
		var url="q="+findingStr;
		url=url+"&sid="+Math.random();
		url=url+"&session="+ document.main_form.a_session.value;
		url=url+"&login="+ document.main_form.a_login.value;
		url=url+"&userid="+ document.main_form.a_userid.value;
		url=url+"&background="+ document.main_form.a_background.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&finding=" + findingStr;
		var fnumber = document.getElementById("a_findingNum").value;
		url=url+"&findingNum=" + fnumber;
		for ( i=0; i<fnumber; i++) {
			url=url+"&finding" + i + "="+document.getElementById("a_finding" + i).value;
		}
		url=url+"&command="+ document.main_form.a_command.value;
		url=url+"&termnumlist=" + document.main_form.a_termnumlist.value;
		url=url+"&ftextlist=" + document.main_form.a_ftextlist.value;
		url=url+"&quserasked=" + document.main_form.a_quserasked.value;
		url=url+"&focusfinding=" + document.main_form.a_focusfinding.value;
		url=url+"&functionFinding=" + functionFinding;
		url=url+"&a_message=" + document.main_form.a_message.value;
		url=url+"&ajax=yes";
		url = mumps_replace(url," ","+");
		return url;
	}
	function createPostStringProcessPair(findingStr, variableStr, functionFinding) {
		var v_age = new String("");
		var v_gender = new String("");
		var v_duration = new String("");
		for ( i=0; i<document.main_form.a_age.length; i++) {
			if ( document.main_form.a_age.options[i].selected )
				v_age = document.main_form.a_age.options[i].value;
		}
		for ( i=0; i<document.main_form.a_gender.length; i++) {
			if ( document.main_form.a_gender.options[i].selected )
				v_gender = document.main_form.a_gender.options[i].value;
		}
		for ( i=0; i<document.main_form.a_duration.length; i++) {
			if ( document.main_form.a_duration.options[i].selected )
				v_duration = document.main_form.a_duration.options[i].value;
		}
		var url="q="+findingStr;

		url=url+"&sid="+Math.random();
		url=url+"&login="+ document.main_form.a_login.value;
		url=url+"&session="+ document.main_form.a_session.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&finding=" + findingStr;
		var fnumber = document.getElementById("findingNum").value;
		url=url+"&findingNum=" + fnumber;
		for ( i=0; i<fnumber; i++) {
			url=url+"&finding" + i + "="+document.getElementById("finding" + i).value;
		}
		url=url+"&command="+ document.main_form.a_command.value;
		url=url+"&termnumlist=" + document.main_form.a_termnumlist.value;
		url=url+"&ftextlist=" + document.main_form.a_ftextlist.value;
		url=url+"&quserasked=" + document.main_form.a_quserasked.value;
		url=url+"&focusfinding=" + document.main_form.a_focusfinding.value;
		url=url+"&functionFinding=" + functionFinding;
		url=url+"&ajax=yes";
		url = mumps_replace(url," ","+");
		return url;
	}
	function createPostString(findingStr, variableStr, functionFinding, noFinding) {
		var v_age = new String("");
		var v_gender = new String("");
		var v_duration = new String("");
		for ( i=0; i<document.main_form.a_age.length; i++) {
			if ( document.main_form.a_age.options[i].selected )
				v_age = document.main_form.a_age.options[i].value;
		}
		for ( i=0; i<document.main_form.a_gender.length; i++) {
			if ( document.main_form.a_gender.options[i].selected )
				v_gender = document.main_form.a_gender.options[i].value;
		}
		for ( i=0; i<document.main_form.a_duration.length; i++) {
			if ( document.main_form.a_duration.options[i].selected )
				v_duration = document.main_form.a_duration.options[i].value;
		}
		var url="q="+findingStr;
		url=url+"&sid="+Math.random();
		url=url+"&session="+ document.main_form.a_session.value;
		url=url+"&login="+ document.main_form.a_login.value;
		url=url+"&userid="+ document.main_form.a_userid.value;
		url=url+"&background="+ document.main_form.background.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&finding=" + findingStr;
		if ( document.main_form.command.value == "newcase" ) {
			url=url+"&findingNum=0";
			url=url+"&command="+ document.main_form.command.value;
			url=url+"&termnumlist=" + document.main_form.termnumlist.value;
			url=url+"&ftextlist=" + document.main_form.ftextlist.value;
			url=url+"&quserasked=" + document.main_form.quserasked.value;
			url=url+"&quserlist=" + document.main_form.quserlist.value;
			url=url+"&focusfinding=" + document.main_form.focusfinding.value;
		} else {
			var fnumber = document.getElementById("findingNum").value;
			url=url+"&findingNum=" + fnumber;
			for ( i=0; i<fnumber; i++) {
				url=url+"&finding" + i + "="+document.getElementById("finding" + i).value;
			}
			url=url+"&command="+ document.main_form.command.value;
			url=url+"&termnumlist=" + document.main_form.termnumlist.value;
			url=url+"&ftextlist=" + document.main_form.ftextlist.value;
			url=url+"&quserasked=" + document.main_form.quserasked.value;
			url=url+"&quserlist=" + document.main_form.quserlist.value;
			var qnumber = document.getElementById("qusernum").value;
			url=url+"&qusernum=" + qnumber;
			url=url+"&functionFinding=" + functionFinding;
			url=url+"&focusfinding=" + document.main_form.focusfinding.value;
			if ( qnumber > 0 ) {
				for ( i=0; i<qnumber; i++) {
					url=url+"&quser" + i + "="+document.getElementById("quser" + i).value;
					url=url+"&qufinding" + i + "="+document.getElementById("qufinding" + i).value;
				}
			}
			if ( variableStr != '' ) {
				url=url+"&"+variableStr
			}
			url=url+"&ajax=yes";
		}
		url += "&nofinding=" + noFinding;
		url = mumps_replace(url," ","+");
		return url;
	}

function newCase() {
	if ( programCode == "m" ) {
		if ( confirm ("Terminate case and return to Case Menu.") ) {
			document.main_form.command.value = 'newcase';
			document.main_form.submit();
		}
	} else {
		if ( confirm ("Delete findings list and start a new case.") ) {
			document.main_form.command.value = 'newcase';
			document.main_form.submit();
		}
	}
	return;
}	

function newCaseOnLoad(str)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="command=newcase";
	url=url+"&login=" + document.main_form.a_login.value;
	url=url+"&userid="+ document.main_form.a_userid.value;
	url=url+"&session="+ document.main_form.a_session.value;
	url=url+"&background="+ document.main_form.a_background.value;	
	var url2="newCase.asp";
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedNewCase;
	xmlHttp.send(params);
}

function stateChangedNewCase() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function stateChangedDisplayDemographics() {
	if (xmlHttp2.readyState==4) {
		document.getElementById("txtBox2").innerHTML=xmlHttp2.responseText;
		goNext = 1;
	}
}
function caseEntryIRF(str)
{
	return;
}


function caseEntry_ReturnTextBook() {
	document.main_form.command.value = 'caseEntryTextBook';
	document.main_form.submit();
}
function caseEntry_Return() {
	document.main_form.command.value = 'caseEntry';
	document.main_form.submit();
}
	
function caseEntryOnLoad(str)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringCaseEntry(str,"","");
	var url2="caseEntry.asp";
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedCaseEntry;
	xmlHttp.send(params);
}

function stateChangedCaseEntry() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}

function processPair(str)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringProcessPair(str,"","");

	var url2="caseEntry.asp";
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedProcessPair;
	xmlHttp.send(params);
}
function stateChangedProcessPair() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function askQuestion(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "askQuestion";
	document.main_form.submit();
	return;
}
function removeFinding(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "removeFinding";
	document.main_form.submit();
	return;
}
function stateChangedRemoveFinding() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function focusFinding(str)
{
	if ( programCode == "k" || (programCode == "m") ) {
		alert ( "This function is unavailable for this demo.");
		return;
	}
	var stFinding = str;
	if ( (str.substr(0,3) == "NO ") || (str.substr(0,3) == "NO+") ) {
		alert ( "You cannot focus on an absent finding.");
		return;
	}
	document.main_form.finding.value = str;
	document.main_form.command.value = "focusFinding";
	document.main_form.submit();
	return;
}

function unFocusFinding(str)
{
	if ( programCode == "k" || (programCode == "m") ) {
		alert ( "This function is unavailable for this demo.");
		return;
	}
	document.main_form.finding.value = str;
	document.main_form.command.value = "unFocusFinding";
	document.main_form.submit();
	return;
}

function stateChangedFocusFinding() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}

function changeDemographic(dfinding, type)
{
	var typeStr;
	var ret_Array = new Array;
	var fnumber = Number(document.main_form.findingNum.value);
	if ( fnumber < 1 && ( type > 0) ) {
		return;
	}
	if ( type == 0 ) {
		document.main_form.command.value = "updateScoreAge";
	} else if ( type == 1 ) {
		document.main_form.command.value = "updateScoreGender";
	} else {
		document.main_form.command.value = "updateScoreDuration";
	}
	document.main_form.finding.value = dfinding;
	document.main_form.submit();
	return;
}

function stateChangedChangeDemographic() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function addNotermFinding(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "addNotermFinding";
	document.main_form.submit();
	return;
}
function addHierarchyFinding(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "addHierarchyFinding";
	document.main_form.submit();
	return;
}
function AF(str)
{
	if ( document.main_form.noFindingCheckbox.checked ) {
		document.main_form.nofinding.value = "NO";
	} else {
		document.main_form.nofinding.value = "";
	}
	document.main_form.finding.value = str;
	document.main_form.command.value = "addFinding";
	document.main_form.submit();
	return;
}
function switchNOFinding(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "switchNOFinding";
	document.main_form.submit();
	return;
}

function GetXmlHttpObject2()  {
  var xmlHttp;
  try
    {
	// Firefox, Opera 8.0+, Safari    
	xmlHttp=new XMLHttpRequest();
	}
  catch (e)
    {    
	// Internet Explorer
	try
      {      
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
    catch (e)
      {
	  try
        {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
      catch (e)
        {        
		//alert("Your browser does not support AJAX!");        
		//return false;
		return null;
		}
	 }
  }
  return xmlHttp;
} 
	
function GetXmlHttpObject()  {
	var xmlHttp=null;

	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
  	} catch (e) {
		// Internet Explorer
		//	if (typeof(XMLHttpRequest) == "undefined") {
	    try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.6.0");
		} catch(e) {
		    try { 
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
			} catch(e) {
			    try { 
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				} catch(e) {
					try { 
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
					} catch(e) {
					    return null;
					}
				}
			}
		}
	}
	return xmlHttp;
}
function evidenceDisease(str)
{ 
	document.main_form.disease.value = str;
	document.main_form.command.value = "evidenceDisease";
	document.main_form.submit();
	return;
}
function diseaseDescription(str)
{ 
	document.main_form.disease.value = str;
	document.main_form.command.value = "diseaseDescription";
	document.main_form.submit();
	return;
}
function findingDescription(str)
{
	document.main_form.finding.value = str;
	document.main_form.command.value = "findingDescription";
	document.main_form.submit();
	return;
}
function findingAddnInfo(str)
{
	var login = document.main_form.login.value;
	var v_userid = document.main_form.userid.value;
	var v_session = document.main_form.session.value;
	var variable = programName + "?command=findingAddnInfo&finding=" + str;
	variable += "&login=" + login + "&userid=" + v_userid + "&session=" + v_session;
	open(variable,"findingaddninfo_area","scrollbars=yes,resizable=yes,width=800,height=600");
	return;
}
function diseaseCompare(str)
{ 
	document.main_form.finding.value = str;
	document.main_form.command.value = "dxCompare";
	document.main_form.submit();
	return;
}
function display_dxcompare(comvalue,text)
{
	if ( comvalue == 'display_dxcompare' ) {
		flag = 0;
		if ( document.main_form.diseaseSelect.checked ) {
			flag = flag + 1;
		} else {
			for ( i=0; i<document.main_form.diseaseSelect.length; i++) {
				if ( document.main_form.diseaseSelect[i].checked ) {
					flag = flag + 1;
				}
			}
		}
		if ( flag <2 || flag > 4 ) {
			alert ( 'You must select 2 to 4 diseases to compare.' )
			return;
		}

	} else if ( comvalue == 'help_dxcompare' )  {
		var variable = programName + "?command=help_dxcompare&text=" + text;
		open(variable,"compare_area","width=500,height=300");
		return;
	}
	document.main_form.command.value = 'display_dxcompare';
	document.main_form.submit();
}
function processFinding(finding)
{
	if ( finding.length != 3 ) {
		return;
	}
	document.main_form.findingTBox.value = finding;
	document.main_form.command.value = "processfindingpair";
	document.main_form.action = urlAlias + "/dxp.dxlink2.asp";
	document.main_form.submit();
}

	function pause(numSeconds)
	{
	    var now, goalTime;
	    now = new Date();
	    goalTime = now.getTime() + 1000*numSeconds;

	    while (now.getTime() < goalTime) {
       		now = new Date();
		}
	}

function processTextBookSubmit()
{
	var topFinding;
	var topFindingHierarchy;
	try {
		topFindingHierarchy = document.getElementById("topFindingHierarchy").value;
	} catch (e) {
		topFindingHierarchy = String("");
	}
	if ( topFindingHierarchy != "" ) {
		if ( document.main_form.dfInfoRadiobutton[0].checked ) {
			findingDescriptionTextbookHierarchy(topFindingHierarchy);
		} else {
			DL(topFindingHierarchy);
		}
		return false;
	}
	if ( document.main_form.dfInfoRadiobutton[0].checked ) {
		var url = "command=cachelookuptbfinding";
	} else {
		var url = "command=cachelookuptbdisease";
	}
	try {
		topFinding = document.getElementById("topFinding").value;
	} catch (e) {
		topFinding = "";
	}
	if ( topFinding == "" ) {
		return false;
	} else {
		document.main_form.autolookupinputname.value = "";
		if ( document.main_form.dfInfoRadiobutton[0].checked ) {
			FL(topFinding);
		} else {
			DL(topFinding);
		}
		return false;
	}
	return false;
}
function processSubmit()
{
	var topFinding;
	var topFindingHierarchy;
	
	if ( document.main_form.noFindingCheckbox.checked ) {
		document.main_form.nofinding.value = "NO";
	} else {
		document.main_form.nofinding.value = "";
	}
	
	try {
		topFindingHierarchy = document.getElementById("topFindingHierarchy").value;
	} catch (e) {
		topFindingHierarchy = String("");
	}
	if ( topFindingHierarchy != "" ) {
		document.main_form.finding.value = topFindingHierarchy;
		document.main_form.command.value = "addHierarchyFinding";
		return true;
	}
	try {
		topFinding = document.getElementById("topFinding").value;
	} catch (e) {
		topFinding = String("");
	}
	if ( topFinding == "" ) {
		return false;
	} else {
		document.main_form.finding.value = topFinding;
		document.main_form.command.value = "addFinding";
		return true;
	}
	return false;
}
function trapSubmit()
{
	return false;
}
function processLogin()
{
	document.main_form.command.value = 'loginprocess';
	document.main_form.submit();
	return;
}
function verify_password(str)
{
	document.main_form.command.value = "loginprocess";
	document.main_form.submit();
	return;
}
function checkLogin(a,b,c)
{
	if ( a == '1' ) {
		if ( document.main_form.background.value == '' || (document.main_form.background.value == null) )  {
			flag = 0;
			if ( document.main_form.background.length == 12 ) {
				for ( i=1; i<document.main_form.background.length; i++) {
					if ( document.main_form.background.options[i].selected) {
						flag = 1;
					}
				}
			} else {
				for ( i=0; i<document.main_form.background.length; i++) {
					if ( document.main_form.background.options[i].selected) {
						flag = 1;
						}
				}
			}
			if ( flag == 0 ) {
				alert ('Please select a Professional Status.');
				return;
			}
		} else {
			if ( document.main_form.background.value == 'Click on arrow to the right for listing.' ) {
				alert ('Please select a Professional Status.');
				return;
			}
		}
	}
	if ( b == '1' ) {
		if ( document.main_form.userid.value == '' ) {
			alert ('Please enter a valid email address.');
			return;	
		}
		if ( !validateEmail(document.main_form.userid.value,true,true) ) {
			return;
		}
	}
	if ( c == '1' ) {
		if ( document.main_form.instname.value == '' ) {
			alert ('Please enter your Institution/Organization Name.');
			return;
		}
	}
	document.main_form.command.value = 'checklogin';
	document.main_form.submit();
}
function saveCase2()
{
	alert ( 'This function is currently unavailable.' );
	return;
}
function retrieveCase2()
{
	alert ( 'This function is currently unavailable.' );
	return;
}
function saveCase(str)
{
	if ( programCode == "k" || (programCode == "m") ) {
		alert ( "This function is unavailable for this demo.");
		return;
	}
	if ( confirm ("Saving Current Case.  A previously saved case will be overwritten.") ) {
		document.main_form.command.value = 'saveCase';
		document.main_form.submit();
	}
	return;
}
function retrieveCase(str)
{
	if ( programCode == "k" || (programCode == "m") ) {
		alert ( "This function is unavailable for this demo.");
		return;
	}
	document.main_form.command.value = 'retrieveCase';
	document.main_form.submit();
}
function process_zget(cmd, casename) {
	if ( cmd == 'z_deletecase' ) {
		if ( !confirm('Are you sure you want to delete this case?  Click <OK> to Delete or <Cancel>.') ) {
			return;
		}
	}
	if ( (cmd == 'z_retrievecase') || (cmd == 'z_deletecase') || (cmd == 'x_z_retrievecase') || (cmd == 'x_z_deletecase')) {
		document.main_form.z_casename.value = casename;
		document.main_form.command.value = cmd;
		document.main_form.submit();
		return;
	}
}
function saveCaseFunctions(cmd, casename)
{
	if ( programCode == "k" || (programCode == "m") ) {
		alert ( "This function is unavailable for this demo.");
		return;
	}
	if ( cmd == "displaySaveCase" ) {
		document.main_form.command.value = 'displaySaveCase';
		document.main_form.submit();
		return;
	} else if ( cmd == "retrieveCaseMenu" ) {
		document.main_form.command.value = 'retrieveCaseMenu';
		document.main_form.submit();
		return;
	} else if ( cmd == "z_savecase" ) {
		document.main_form.command.value = cmd;
		document.main_form.submit();
		return;
	}
	if ( cmd == 'x_z_deletecase' ) {
		alert ( "This function is unavailable.  Send msg to RJK.");
		return;
	}
	if ( cmd == 'z_deletecase' || (cmd == 'x_z_deletecase') ) {
		if ( !confirm('Are you sure you want to delete this case?  Click <OK> to Delete or <Cancel>.') ) {
			return;
		}
	}
	if ( (cmd == 'z_retrievecase') || (cmd == 'z_deletecase') || (cmd == 'x_z_retrievecase') || (cmd == 'x_z_deletecase')) {
		document.main_form.z_casename.value = casename;
		document.main_form.command.value = cmd;
		document.main_form.submit();
		return;
	}
}
function printFormat()
{
	document.main_form.command.value = 'printformat';
	document.main_form.submit();
}
function xfunctions(str)
{
	document.main_form.command.value = 'xfunctions';
	document.main_form.submit();
}
function stateChangedSaveCase() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function log_question4(str)
{
	document.main_form.command.value = "log_question4";
	document.main_form.submit();
	return;
}
function bypass_question4(str)
{
	document.main_form.command.value = "bypass_question4";
	document.main_form.submit();
	return;
}
function select_democase(dcase)
{
	document.main_form.democase.value = dcase;
	document.main_form.command.value = "process_demo";
	document.main_form.submit();
	return;
}
function textBook(dfStr)
{
	document.main_form.command.value = "textbook" + dfStr;
	document.main_form.submit();
	return;
}
function help()
{
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	v_where = document.main_form.where.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;
	var nwidth=850;
	var nheight=580;
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=help" + "&where=" + v_where;
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration;
	open(variable,"help_area","scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
	alert ( 'This function is currently unavailable.' );
	return;
}
function feedback()
{
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;
	var nwidth=850;
	var nheight=400;
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=comment";
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration;
	open(variable,"feedback_area","scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function feedbackFrontend()
{
	v_login = document.main_form.login.value;
	v_session = document.main_form.session.value;
	var nwidth=850;
	var nheight=400;
	var variable = "http://" + url_machine + urlAlias + "/" + programName + "?login=" + v_login + "&userid=&session=" + v_session + "&background=&termnumlist=&command=comment";
	variable += "&a_age=&a_gender=&a_duration=";
	open(variable,"feedback_area","scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function sendFeedback()
{
	return;
	document.main_form.command.value = 'savecomment';
	document.main_form.submit();
}
function exit(str)
{
	if ( confirm ("Do you wish to EXIT DXplain.") ) {
		document.main_form.command.value = 'exit';
		document.main_form.submit();
	}
}

function searchMerckMedicus(searchString) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;
	
	var nwidth=screen.width-200;
	var nheight=screen.height-200;
	searchString = searchString.replace(/\^/g,"'");
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=merckmedicussearch";
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration + "&searchString=" + searchString;
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function searchDynaMed(sid,searchString) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;

	var nwidth=screen.width-200;
	var nheight=screen.height-200;
	searchString = searchString.replace(/\^/g,"'");
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=dynamedsearch";
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration + "&searchString=" + searchString;
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function searchUpToDate(searchString)	{
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;
	var nwidth=screen.width-200;
	var nheight=screen.height-200;
	searchString = searchString.replace(/\^/g,"'");
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=uptodatesearch";
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration + "&searchString=" + searchString;
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function searchGoogle(searchString)	{
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_termnumlist = document.main_form.termnumlist.value;
	bgplus = document.main_form.background.value;
	v_age = document.main_form.a_age.value;
	v_gender = document.main_form.a_gender.value;
	v_duration = document.main_form.a_duration.value;
	var nwidth=screen.width-200;
	var nheight=screen.height-200;
	searchString = searchString.replace(/\^/g,"'");
	var variable = programName + "?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&background=" + bgplus + "&termnumlist=" + v_termnumlist + "&command=googlesearch";
	variable += "&a_age=" + v_age + "&a_gender=" + v_gender + "&a_duration=" + v_duration + "&searchString=" + searchString;
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	return;
}
function searchGoogle2(searchString)
{
	urlStr = "http://www.google.com/webhp?hl=en&";
	urlStr2 = "+site%3Aintelihealth.com+OR+site%3Ahealth.harvard.edu+OR+site%3Amayoclinic.com+OR+site%3Ahopkinsmedicine.org+OR+site%3Awww.nlm.nih.gov+OR+site%3AeMedicine.com+OR+site%3Aclevelandclinic.org/health+OR+site%3AWebMD.com+OR+site%3Awww.CDC.gov+OR+site%3Ahealthfinder.gov/library+OR+site%3Awww.merck.com/mmpe/&FORM=MSNH";
	searchString = searchString.replace(/\^/g,"'");
	urlStr += "q=" + searchString;
	var variable = urlStr + urlStr2;
	var nwidth=screen.width-200;
	var nheight=screen.height-200;
	newwindow=open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes,width=" + nwidth + ",height=" + nheight + "");
	if (window.focus) {newwindow.focus()}
	return;
}
function processFindingFunction(finding)
{
	var cmd = new String("");
	for ( i=0; i<document.main_form.functionFinding.length; i++) {
		if ( document.main_form.functionFinding[i].checked) {
			cmd = document.main_form.functionFinding[i].value;
		}
	}
	if ( cmd == "I" ) {
		if ( finding.substr(0,3) == "NO " || (finding.substr(0,3) == "NO+" ) ) {
			finding = finding.substr(3);
		}
		findingDescription( finding );
	} else if ( cmd == "R" ) {
		removeFinding( finding );
	} else if ( cmd == "F" ) {
		if ( finding.substr(0,3) == "NO " || (finding.substr(0,3) == "NO+" ) ) {
			alert ( "You cannot focus on an absent finding.");
			return;
		}	
		focusFinding ( finding );
	}
	return;
}
function addFindingEvidence(str)	{
	var found = Number(0);
	if ( document.main_form.findingSelectEx.checked ) {
		found++;
	} else {
		for ( i=0; i<document.main_form.findingSelectEx.length; i++) {
			if ( document.main_form.findingSelectEx[i].checked ) {
				found++;
			}
		}
	}
	if ( found == 0 )  {
		alert ('Please check finding(s) you wish to add and then click on the Submit selected finding(s) button.');
		return;
	}
	document.main_form.command.value = 'addfindingevidence';
	document.main_form.submit();
}
function evidenceDiseaseTextbook(str) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookDisease(str,"","I","textbookEvidenceDisease");
	var url2 = programName;
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedEvidenceDiseaseTextbook;
	xmlHttp.send(params);
}
function stateChangedEvidenceDiseaseTextbook() {
	if (xmlHttp.readyState==4)  {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function diseaseInformationTextbook(str) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookDisease(str,"","I","textbookDiseaseInformation");
	var url2 = programName;
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedDiseaseInformationTextbook;
	xmlHttp.send(params);
}
function stateChangedDiseaseInformationTextbook() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function findingDescriptionTextbook(str)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookFinding(str,"","I","textbookDDx");
	var url2 = programName;
	var params = url;
	xmlHttp.open("POST", url2, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = stateChangedFindingDescriptionTextbook;
	xmlHttp.send(params);
}
function stateChangedFindingDescriptionTextbook() {
	if (xmlHttp.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttp.responseText;
	}
}
function findingDescriptionTextbookHierarchy(str)
{
	xmlHttpFDTH=GetXmlHttpObject();
	if (xmlHttpFDTH==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookFinding(str,"","I","textbookDDxHierarchy");
	var url2 = programName;
	var params = url;
	xmlHttpFDTH.open("POST", url2, true);
	xmlHttpFDTH.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpFDTH.onreadystatechange = stateChangedFindingDescriptionTextbookHierarchy;
	xmlHttpFDTH.send(params);
}
function stateChangedFindingDescriptionTextbookHierarchy() {
	if (xmlHttpFDTH.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttpFDTH.responseText;
	}
}
function FL(str)
{
	document.main_form.autolookupinputname.value = "";
	document.main_form.autolookupinputname.focus();
	xmlHttpFL=GetXmlHttpObject();
	if (xmlHttpFL==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookFinding(str,"","I","textbookDDxLookup");
	var url2 = programName;
	var params = url;
	xmlHttpFL.open("POST", url2, true);
	xmlHttpFL.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpFL.onreadystatechange = stateChangedFindingDescriptionLookup;
	xmlHttpFL.send(params);
	return;
}
function stateChangedFindingDescriptionLookup() {
	if (xmlHttpFL.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttpFL.responseText;
	}
}
function DL(str)
{
	document.main_form.autolookupinputname.value = "";
	document.main_form.autolookupinputname.focus();
	xmlHttpDL=GetXmlHttpObject();
	if (xmlHttpDL==null)  {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = createPostStringTextbookDisease(str,"","I","textbookEvidenceDiseaseLookup");
	var url2 = programName;
	var params = url;
	xmlHttpDL.open("POST", url2, true);
	xmlHttpDL.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpDL.onreadystatechange = stateChangedEvidenceDiseaseLookup;
	xmlHttpDL.send(params);
	return;
}
function stateChangedEvidenceDiseaseLookup() {
	if (xmlHttpDL.readyState==4) {
		document.getElementById("txtBox1").innerHTML=xmlHttpDL.responseText;
	}
}
function textBookOnLoad(str)
{
	return;
	alert ( "onload textBookOnLoad" );
}
function newpage() {
	document.main_form.command.value = "newpage";
	document.main_form.submit();
	return;
}
function signin2(cmd) {
	v_login = document.main_form.login.value;
	v_session = document.main_form.session.value;
	
	if ( v_login.indexOf("webmerckmd") == 0 ) {
		if ( cmd == "gotoMerckMedicus" ) {
			document.main_form.action = "https://www.merckmedicus.com/pp/us/hcp/dxplain.jsp?sessionID=" + v_session + "\";\n";
			document.main_form.submit();
			return;
		}
	}
	if ( cmd == "signin" ) {
		document.main_form.command.value = "disclaimer";
		document.main_form.submit();
	} else {
		document.main_form.command.value = cmd;
		document.main_form.submit();
	}
	return;
}
function qtour2() {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	var variable = "http://" + url_machine + urlAlias + "/" + programName + "?command=qtour&login=" + v_login + "&userid=" + v_userid + "&session=" + v_session;
	open(variable, "Assessment", "top=0,left=0,toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=2,resizable=yes,copyhistory=0,width=1024,height=788");
}
function FAQ2() {
	document.main_form.command.value = "faq";
	document.main_form.submit();
	return;
}
function licenseInfo2(str) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	var variable = "http://" + url_machine + urlAlias + "/" + programName + "?command=licenseinfo&login=" + v_login + "&userid=&session=" + v_session;
	open(variable, "Assessment", "top=0,left=0,toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=2,resizable=yes,copyhistory=0,width=1024,height=768");
}
function publications2(str) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	nwidth = 780;
	nheight = 530;
	var variable = "http://" + url_machine + urlAlias + "/" + programName + "?command=pub_display&login=" + v_login + "&userid=&session=" + v_session;
	open(variable, "publications", "top=0,left=0,toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=2,resizable=yes,copyhistory=0,width=" + nwidth + ",height=" + nheight);
}
function process_link(theForm, url, disease) {
	var variable = programName + "?command=otherlinks&url=" + url + "&disease=" + disease;
	open(variable,"_blank","resizable=yes");
}
function process(theForm, uid, disease) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	var variable = "http://" + url_machine + "/dxp/pubmed/pubmed.asp?login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&command=pubmed&uid=" + uid + "&disease=" + disease + "&pubmed=";
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,resizable=yes");
}
function pubmedStrategy(strategy) {
	v_login = document.main_form.login.value;
	v_userid = document.main_form.userid.value;
	v_session = document.main_form.session.value;
	v_disease = document.main_form.disease.value;
	var variable = "http://" + url_machine + "/dxp/pubmed/pubmed.asp?command=searchstrategy&strategy=" + strategy + "&login=" + v_login + "&userid=" + v_userid + "&session=" + v_session + "&disease=" + v_disease;
	open(variable,"_blank","menubar=yes,toolbar=yes,location=yes,titlebar=yes,status=yes,resizable=yes");
}
function switchAjaxLookup() {
		document.main_form.command.value = 'switchajaxlookup';
		document.main_form.submit();
}
	function cacheAddFindingLookup(str)
	{ 
		str = str.replace(/\s+/g,' ');
		var strLen = str.length;
		if ( str != rtrim(str) )
			return;
			
		str = str.replace(/ /g,"+");
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)  {
			alert ("Your browser does not support AJAX!");
			return;
		}
		document.getElementById("autolookupimage").style.display="none";
		document.getElementById("autolookupwaitimage").style.display="inline";
		var url = "command=cachelookupaddfinding&lookupstring=" + str;
		login = document.getElementById("login").value;
		userid = document.getElementById("userid").value;
		url += "&login=" + login + "&userid=" + userid;
		var url2 = "autoLookuptools.asp";
		var params = url;
		xmlHttp.open("POST", url2, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = stateChangedCacheFindingLookup;
		xmlHttp.send(params);
	}
	function cacheTextbookFindingLookup(str)
	{
		str = str.replace(/\s+/g,' ');
		str = trim(str);
		var strLen = str.length;
		if ( strLen < 2 )	{
			document.getElementById("txtBoxLookup").innerHTML="";
			return;
		}
		if ( strLen == 1 )
			return;

		str = str.replace(/ /g,"+");
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)  {
			alert ("Your browser does not support AJAX!");
			return;
		}
		document.getElementById("autolookupimage").style.display="none";
		document.getElementById("autolookupwaitimage").style.display="inline";
		if ( document.main_form.dfInfoRadiobutton[0].checked ) {
			var url = "command=cachelookuptbfinding";
		} else {
			var url = "command=cachelookuptbdisease";
		}
		url += "&lookupstring=" + str;
		url=url+"&autoLookup=" + document.main_form.autoLookup.value;
		login = document.getElementById("login").value;
		userid = document.getElementById("userid").value;
		url += "&login=" + login + "&userid=" + userid;
		var url2 = "autoLookuptools.asp";
		var params = url;
		xmlHttp.open("POST", url2, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = stateChangedCacheFindingLookup;
		xmlHttp.send(params);
	}
	function stateChangedCacheFindingLookup() {
		if (xmlHttp.readyState==4) {
			document.getElementById("txtBoxLookup").innerHTML=xmlHttp.responseText;
			document.getElementById("autolookupimage").style.display="inline";
			document.getElementById("autolookupwaitimage").style.display="none";
		}
	}
	function createPostStringCacheTextbookFindingLookup(findingStr, variableStr, functionFinding, commandStr) {
		v_age = document.main_form.a_age.value;
		v_gender = document.main_form.a_gender.value;
		v_duration = document.main_form.a_duration.value;
		var url="q="+findingStr;
		url=url+"&sid="+Math.random();
		url=url+"&session="+ document.main_form.session.value;
		url=url+"&login="+ document.main_form.login.value;
		url=url+"&userid="+ document.main_form.userid.value;
		url=url+"&background="+ document.main_form.background.value;
		url=url+"&age=" + v_age;
		url=url+"&gender=" + v_gender;
		url=url+"&duration=" + v_duration;
		url=url+"&finding=" + findingStr;
		url=url+"&command="+ commandStr;
		url=url+"&ajax=yes";
		url = mumps_replace(url," ","+");
		return url;
	}
	function noFindingChecked()  {
		document.main_form.autolookupinputname.focus();
	}
	function process_guide(guide)  {
		document.main_form.guide.value = guide;
		document.main_form.command.value = 'selectfinding';
		document.main_form.submit();
	}
	function process_guide2(comvalue, gcase)  {
		if ( gcase == 2 ) {
			var guidetext = new Array;
			var numgtext = 6;
			if ( comvalue == 'previous' ) {
				document.main_form.guide.value--;
			} else {
				document.main_form.guide.value++;
			}
			if ( document.main_form.guide.value > numgtext ) {
				document.main_form.guide.value = 1;
			} else if ( document.main_form.guide.value < 1 ) {
				document.main_form.guide.value = numgtext;
			}
			guidetext[1] = "1)  If you were seeing a male patient with these findings, your differential diagnosis would include acute appendicitis, viral gastroenteritis, mesenteric lymphadenitis and perhaps inflammatory bowel disease (specifically regional enteritis) near the top. Since this patient is female, you must also consider acute pelvic inflammatory disease (PID) and other pelvic/ovarian diseases. The limited presenting symptoms do not clearly point to any one of these to the exclusion of others, as seen on DXplain's list of diseases.  Note that abdominal pain, right lower quadrant is highlighted and that the Focus icon is active.  In this demonstration, only diseases containing that term will be displayed.";
			guidetext[2] = "2)  As a first step, add the finding 'adnexal tenderness' in the Finding Lookup box.  Note that as you type the first few letters, the complete term will appear, and you click on it to enter it. You will now see Pelvic Inflammatory Disease move up to the top of the list of Common Diseases, with ++ indicating strong support.  Other pelvic/ovarian diseases also move up.  Acute appendicitis is still high on the list.";
			guidetext[3] = "3)  To see how the differential could have gone in a different direction, remove adnexal tenderness from the term list by clicking on the <img border=0 SRC=\"graphic/close-x-active.gif\" width=\"12\" height=\"12\" valign=\"bottom\" alt=\"X\"> icon next to that term.  Add Anorexia via the Finding lookup box.  Note that the gyn disorders move down in likelihood.";
			guidetext[4] = "4)  Finally, using the Finding Lookup box, add 'watery diarrhea' and 'contacts with similar symptoms.'  While appendicitis is still high on the list, as it must always be considered in patients with RLQ pain, viral gastroenteritis also shows up with a + indicating strong support.  To see why, click on that disease in the disease list.";
			guidetext[5] = "5)  You may also wish to try the Dx Comparison function to see how important findings differentiate one from another.  First click the 'DX Comparison' button.  You will then have the opportunity to select from 2-4 diseases for comparison.";
			guidetext[6] = "6)  You have completed this tutorial case, now feel free to experiment with DXplain.<br>You may click on the 'Case Menu' button above the Case Findings window to return to Case Menu page and try another tutorial.</b>";
		} else if ( gcase == 4 ) {
			var guidetext = new Array;
			var numgtext = 10;
			if ( comvalue == 'previous' ) {
				document.main_form.guide.value--;
			} else {
				document.main_form.guide.value++;
			}
			if ( document.main_form.guide.value > numgtext ) {
				document.main_form.guide.value = 1;
			} else if ( document.main_form.guide.value < 1 ) {
				document.main_form.guide.value = numgtext;
			}
			guidetext[1] = "1)  In this case we have an adolescent with fatigue, cervical adenopathy and fever. The broad categories of infection and neoplasia are suggested, and ENT involvement is likely. In this DEMO version of DXplain, you will not be able to remove these ‘start-up’ findings. Also, the focus feature is turned on for ‘cervical adenopathy’. Therefore, no matter what other findings are entered,  no disease will appear on DXplain’s list unless that disease is known to include ‘cervical adenopathy’.";
			guidetext[2] = "2)  Note that infectious mononucleosis is at the top of the 'COMMON Diseases' list. As an exercise, in the 'Finding Lookup' box on the left side of the screen below,  enter now  the findings 'sore throat' (be sure to Press ENTER to keep original selection when prompted) and then 'tonsillar exudate'. Note that you can type just the first several letters, and when you see the term in view via the 'autocomplete' function, you may then just click on the term.";
			guidetext[3] = "3)  Note how Tonsillitis and Strep throat are now 'suggested diseases' (as indicated by the +), and Mono is strongly supported (as indicated by ++), whereas other causes of lymphadenopathy such as lymphoma or head and neck cancer remain on the list, but unsupported. Next enter into the 'Finding Lookup' box  the finding 'heterophile antibody positive' followed by 'atypical lymphocytes increased'. This gives much further weight to Mono, which is still strongly supported (++).";
			guidetext[4] = "4)  To illustrate further how the DXplain program weighs clinical data, remove the four findings you just entered by clicking on the <img border=0 SRC=\"graphic/close-x-active.gif\" width=\"12\" height=\"12\" valign=\"bottom\" alt=\"X\"> (left-most) icon to the left of each of the top four findings in the  Case Findings window in the center of the screen. ";

			guidetext[5] = "5)  Now click the 'No' checkbox next to the Finding Lookup textbox, and enter 'Heterophile'. DXplain appropriately suggests 'Heterophile Antibody positive'. Select this and the finding 'NO Heterophile Antibody positive' will be added to the Case Findings window. Mono has now dropped down on the list as the absence of a positive heterophile makes mononucleosis much less likely. Since the heterophile can be falsely negative, however, especially early on in the disease, Mono is not excluded.";
			guidetext[6] = "6)  Now enter 'atypical lymphocytes increased' into the Finding Lookup box. Note that Mono now appears higher up on the list.";
			guidetext[7] = "7)  Now please remove (by clicking on the <img border=0 SRC=\"graphic/close-x-active.gif\" width=\"12\" height=\"12\" valign=\"bottom\" alt=\"X\"> icon)  this ‘atypical lymphocytes increased’ finding so that the only additional finding, other than the start-up findings, is No Heterophile Antibody positive. Enter the finding 'Lymph node fixed' . Notice how the diseases 'Hodgkins disease' and 'Head and neck cancer, unknown site' now rise much higher on the list.";
			guidetext[8] = "8)  Finally, enter the finding 'weight loss severe' and then 'night sweats,' into the Finding Lookup box.  This puts both pulmonary TB and Hodgkins lymphoma at the top of the 'Common' disease list both with a (+) sign indicating there is sufficient information for these to be 'suggested' diseases.";
			guidetext[9] = "9)  Try entering some of your own findings now, or choose from those suggested by DXplain in the 'OPTIONAL-Are these findings present?' section below the Case Findings Window. Clicking on the blue '?' to the right of DXplain's suggested findings will explain how each finding might influence whether a disease is supported. Also, select any disease on the list by clicking it. This will show you what findings in the case support that particular disease. ";
			guidetext[10] = "10)  You have completed this tutorial case, now feel free to experiment with DXplain. ";
			guidetext[10] += "You may click on the 'Case Menu' button above the Case Findings window to return to Case Menu page and try another tutorial. ";
		}
		var newtext = "<b>Guide to Tutorial Case:" + " &nbsp; &nbsp; [ " + document.main_form.guide.value + " / " + numgtext + " ] </b><br>" + guidetext[document.main_form.guide.value];
		guideScript.innerHTML = newtext;
		if ( document.main_form.guide.value == 1 ) {
			linktext1 = "";
		} else if ( document.main_form.guide.value > 1 ) {
			linktext1 = "<- Previous";
		}
		if ( document.main_form.guide.value == numgtext ) {
			linktext2 = "Beginning ->";
		} else {
			linktext2 = "Next ->";
		}
		guideButton1.innerHTML = linktext1;
		guideButton2.innerHTML = linktext2;
	}
	
	
	

