

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

var URLPARAMETERS=getUrlVars();

var CURRENTLANG='english';
if (1) {
	var CL=URLPARAMETERS["language"];
	if (CL!=null && CL.length>0) {
		CL=trim22(CL);
		if (CL.length>0) {
			CURRENTLANG=CL;
		}
	}

						if (CURRENTLANG.indexOf('#')>0) {
							var popo=CURRENTLANG.indexOf('#');
							CURRENTLANG=CURRENTLANG.substring(0,popo);
						}
}


var CURRENTSECTIONC='';
var MULTIROWON='';
var SINGLECOLUMNAUTO='';


				function clearBOX() {
					if (this.value!=null && this.value=='') {
						this.value='';
					}
					if (this.value!=null && this.value=='type another symptom (optional)') {
						this.value='';
					}
				}


				function createCookie(name,value,days) {
				   var expires="";
				    if (days) {
				        var date = new Date();
				        date.setTime(date.getTime()+(days*24*60*60*1000));
				        expires = "; expires="+date.toGMTString();
				    } else {expires = ""; }
				    document.cookie = name+"="+value+expires+"; path=/";
				}

				function readCookie(name) {
				    var nameEQ = name + "=";
				    var ca = document.cookie.split(';');
				    if (ca!=null) {
					    for (var i=0;i < ca.length;i++) {
					        var c = ca[i];
					        while (c.charAt(0)==' ') c = c.substring(1,c.length);
					        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
					    }
				    }
				    return null;
				}

				function eraseCookie(name) {
				    createCookie(name,"",-1);
				}


				function rowMOver(r) {

					if (r.className!='rowHEADER') {
						r.className='rowOver';
					} else {
						//r.style.cursor='hand';
					}
				}

				function rowMOut(r) {

					if (r.className!='rowHEADER') {
						r.className='rowColor';
					}

				}
							
				function toggleD(d) {
					var E=document.getElementById(d);
					var EIMG=document.getElementById('IMG'+d);
					if (E!=null) {
						if (E.style.display=='none') {
							E.style.display='';
							if (EIMG!=null) { 
								EIMG.src='/cms/interface/minus.gif';
							}
						} else {
							E.style.display='none';
							if (EIMG!=null) {
								EIMG.src='/cms/interface/plus.gif';
							}
						}
					}	
					var FIMG=document.getElementById(d+'ARROW');
					if (FIMG!=null) {
						if ((FIMG.src+'').indexOf('chev.png')>=0) {FIMG.src='/chevDOWN.png';}
						else if ((FIMG.src+'').indexOf('chevDOWN.png')>=0) {FIMG.src='/chev.png';}

						if ((FIMG.src+'').indexOf('IP_RARROW.png')>=0) {FIMG.src='/IP_RARROWDOWN.png';}
						else if ((FIMG.src+'').indexOf('IP_RARROWDOWN.png')>=0) {FIMG.src='/IP_RARROW.png';}

					}		
				}

				var openedSelect=new Array(); 

				function openSelect(a) {
					var b=a+'BOX';
					var E=document.getElementById(a);
					var F=document.getElementById(b);
					if (E!=null && F!=null) {

						F.style.display='block';
						openedSelect[openedSelect.length]=a;
					}	
				} 

				


				function closeSelect(a) {
					var b=a+'BOX';
					var E=document.getElementById(a);
					var F=document.getElementById(b);
					if (E!=null && F!=null) {

						F.style.display='none';

					}
				} 

				function closeAllSelects() {
					for (var i=0;i<openedSelect.length;i++) {

						closeSelect(openedSelect[i]);
					}
					openedSelect=new Array();


					for (var x=1;x<=5;x++) {

						var EA='DIVSYM'+x+'VALUE';
						var EN='DIVSYM'+x+'VALUECHOICE';						
						var EE=document.getElementById(EN);
						var EB=document.getElementById(EA);
						if (EB!=null) {

							EB.style.visibility="visible";
						}
						if (EE!=null) {
							EE.style.display="none";
						}

					}
				}

				function setTextValue(r,a) {
					var T=document.getElementById(a+'TEXT');
					var V=document.getElementById(a+'VALUE');
					if (T!=null && V!=null) {
						T.innerHTML=r.innerHTML;

						V.value=r.title;

					}
				}



							var activeCB=0;
							function activeClearButton(n) {
								activeCB=n;
							}
							function clearSym(i) {
								if (i!=activeCB) return;
								if (i!=-1) {
									var SN='DIVSYM'+i+'VALUE';
									//var SNTEXT='DIVSYM'+i+'TEXT';
									var E=document.getElementById(SN);
									//var F=document.getElementById(SNTEXT);
									if (E!=null) {
										//E.selectedIndex=0;
										E.value='';
										//F.innerHTML=' -- SELECT SYMPTOM --';
									}
								}
								if (i!=-1) {

									var SN='SYMPTOMDUR'+i;
									var E=document.getElementById(SN);
									if (E!=null) {
										E.selectedIndex=0;
									}
								}

							}

							function clearSearch() {
								for (var i=1;i<=4;i++) {
									var SN='DIVSYM'+i+'VALUE';
									//var SNTEXT='DIVSYM'+i+'TEXT';
									var E=document.getElementById(SN);
									//var F=document.getElementById(SNTEXT);
									if (E!=null) {
										//E.selectedIndex=0;
										E.value='';
										E.style.backgroundColor='#ffffff';
										//F.innerHTML=' -- SELECT SYMPTOM --';
									}
								}

								for (var i=1;i<=4;i++) {
									var SN='SYMPTOMDUR'+i;
									var E=document.getElementById(SN);
									if (E!=null) {
										E.selectedIndex=0;
									}
								}

							}

							

							function websearchfor(n) {
								var KWTB=document.getElementById("DIVSYM5VALUE");
								var SECE=document.getElementById("section");	
								if (KWTB==null) {
									KWTB=document.getElementById("DIVSYM1VALUE");
									window.location='?issearch=true&section=keyword&keyword='+escape(KWTB.value);

								} else {

						
								if (KWTB!=null && SECE!=null) {
									var txt='';

									for (var i=1;i<=4;i++) {
										var SN='DIVSYM'+i+'VALUE';
										var E=document.getElementById(SN);
										if (E!=null) {
											if (E.value!='') {
												var S=E.value;
												S=trim(S);
												txt+=S+' ';
												E.value='';
											}
										}
									}
									KWTB.value=txt;
									SECE.value="keyword";
									document.forms[0].submit();							
								}
	
								}
							}

							function setRIGHTTYPE(S) {
								var REALT=getMatchType(S);
								REALT=trim(REALT);
								REALT=trim22(REALT);
								//alert(REALT.length);
								if (REALT=='') REALT=CURRENTSECTIONC;
								/*	
								if (REALT=='') {
									REALT='other';

								}
								*/
								if (REALT=='symptom') REALT='';

								if (true || REALT!=CURRENTSECTIONC) {
									//alert(REALT);
									var ES=document.getElementById("section");
									if (ES!=null) {
										ES.value=REALT;
										CURRENTSECTIONC=REALT;
									}

									var EN='DIVSYM1VALUE';
									var EE=document.getElementById(EN);
									if (EE!=null) {
										if ('keyword'==CURRENTSECTIONC) {
											EE.name='keyword';
										} else if ('searchdrug'==CURRENTSECTIONC) {
											EE.name='drug';
										} else if ('searchproc'==CURRENTSECTIONC) {
											EE.name='procedure';
										} else if ('searchdoc'==CURRENTSECTIONC) {
											EE.name='associateddocs';
										//} else if ('other'==CURRENTSECTIONC) {
										//	EE.name='other';
										} else if (''==CURRENTSECTIONC) {
											EE.name='symptom';
										}
									}
								}
							}


							var INVERIFYU=0;
							function verifyUnderstanding() {

								
									if (1) {

										INVERIFYU=1;

										if (1) {
											var SN='DIVSYM1VALUE';
											var E=document.getElementById(SN);
											if (E!=null) {
												if (E.value!='' && E.value!='' && E.value!='type another symptom (optional)') {
													var S=E.value;
													S=trim(S);
													setRIGHTTYPE(S);
												}
											}
										}
									}
								
							}

							function alertMessage(m) {
								var F=document.getElementById('INFOALERTMESSAGEDIV');
								var E=document.getElementById('INFOALERTMESSAGEDIVMESSAGE');
								if (E!=null) {

									E.innerHTML='<span class="fbt mmTXT" style="color: red;">'+m+'</span>';
									showInfoCENTER('ALERTMESSAGEDIV');
								}
							}



							function verify() {

								var g=0;

								if (1==1) {
									var RAA=document.getElementById("realagegiven");
									if (RAA!=null) {
										RAA=RAA.options[RAA.selectedIndex].value;
										RAA*=1;
										if (RAA==0) RAA=29;
										var AGERANGE="18-29";
										if (RAA<=3) {					
											AGERANGE="1-3";
										} else if (RAA<=11) {
											AGERANGE="4-11";
										} else if (RAA<=17) {
											AGERANGE="12-17";
										} else if (RAA<=29) {
											AGERANGE="18-29";
										} else if (RAA<=50) {
											AGERANGE="30-50";
										} else {
											AGERANGE="50+";
										}	
																				
										var BAA=document.getElementById('agerangeselect');
										if (BAA!=null) {
											for (var i=0;i<BAA.options.length;i++) {
												var OO=BAA.options[i];
												if (OO.value==AGERANGE || OO.text==AGERANGE) {
													BAA.selectedIndex=i;
													//alert(AGERANGE+" "+i+" "+BAA.options[BAA.selectedIndex].value);
													break;
												}	
											}
										}

									}
								}

								if (CURRENTSECTIONC=='') {
								if (1==0) {
									var NS=document.getElementsByName("notsymptom");
									if (NS!=null) {
										for (var i=0;i<NS.length;i++) {
											var N=NS[i];
											if (N!=null) N.value='';
										}

									}
								}
								if (1==0) {

									var SN='DIVSYM5VALUE';
									var E=document.getElementById(SN);
									if (E!=null) {
										if (E.value!='') {
											doDiagmatixSearch();
											return true;
										}
									}
								}

				

								if (1) {
									var E=document.getElementById("section");
									if (E!=null) {
										E.value="";
			
									}
								}

								var ww=verifyUnderstanding();
								if (CURRENTSECTIONC!='') return verify();

								if (ww==5) return false;





								if (1==0) {

									var E=document.getElementsByName('gender');
									if (E!=null) {
										var h=0;
										for (var i=0;i<E.length;i++) {
											if (E[i].checked) {
												h=1;
												break;
											}
										}
										if (h==0) {
											alertMessage("Please select a gender");
											g=1;
											return false;
										}								
									}
								}

								if (1==0) {

									var E=document.getElementsByName('agerange');
									if (E!=null) {
										if (E.selectedIndex==0) {
											alertMessage("Please select an age range");
											g=1;
											return false;
										}
									}
								}
								if (1) {
									var SELS=0;
									for (var i=1;i<=4;i++) {
										var SN='DIVSYM'+i+'VALUE';
										var E=document.getElementById(SN);
										if (E!=null) {
											if (E.value=='type another symptom (optional)') {
												E.value='';
											}
											if (E.value=='') {
												SELS=SELS+1;
											}
										}
									}
									if (SELS==4) {
										alertMessage("Please select 1 or more symptoms");
										g=1;
										return false;
									}
								}

								if (1) {
									var PVV=-1;
									for (var i=1;i<=4;i++) {
										var SN='DIVSYM'+i+'VALUE';
										var E=document.getElementById(SN);
										if (E!=null) {
											
											if (E.value!='') {
												var D=document.getElementById('SYMPTOMDUR'+i);
												if (D!=null) {
													if (D.selectedIndex==0) {
														if (PVV==-1) {
															//alertMessage("Please select a duration for all specified symptoms");
															//D.focus();
															//g=1;
															//return false;
														} else {
															D.selectedIndex=PVV;
														}
													} else {
														PVV=D.selectedIndex;
													}
												}
											} else {
												//alert("B");

												var D=document.getElementById('SYMPTOMDUR'+i);
												if (D!=null) {
													if (PVV!=-1) {
														D.selectedIndex=PVV;
													} else {
														D.selectedIndex=0;
													}
												}
												
											}
										}
									}
								}


								} else {
									var SN='DIVSYM1VALUE';
									var E=document.getElementById(SN);
									if (E!=null) {
										var ESS=E.value;
										ESS=trim(ESS);
										ESS=trim22(ESS);
										if (ESS.length>0) {
											setRIGHTTYPE(ESS);
										}
									}
								}

								if (g==0) {
									var SEC=document.getElementById("section");
									if (SEC!=null) {
										SEC.value=CURRENTSECTIONC;
									}
									for (var i=1;i<=4;i++) {
										var SN='DIVSYM'+i+'VALUE';
										var E=document.getElementById(SN);
										if (E!=null) {
											if (E.value=='type another symptom (optional)') {
												E.value='';
											}
										}
									}

									var ADW='';
									//document.forms[0].w.value=ADW;
									document.forms[0].w.value='';



									document.forms[0].submit();
								}

								


								


							}

				var ADWORDSSYM=new Array();
				var ADWORDS=new Array();
				function getADWORD(sy) {
					for (var i=0;i<ADWORDS.length;i++) {
						if (sy==ADWORDSSYM[i]) {
							return ADWORDS[i];
						}
					}
					return '';
				}
				
		var commonsyms=new Array();
		




			
	var currentSub=new Array();


	var matchString	="matchString";
	var matchStringMALE ="matchStringMALE";
	var matchStringFEMALE ="matchStringFEMALE";


	var matchStringCOPY=matchString;
	var matchStringCOPYORIG=matchString;
	var matchStringCOPYMALE=matchStringMALE;
	var matchStringCOPYFEMALE=matchStringFEMALE;



	var matchDoccString	="matchDoccString";
	var matchMedsString	="matchMedsString";
	var matchProcString	="matchProcString";
	var matchDiagString="matchDiagString";


	var matchStringCAT	="matchStringCAT";
	var matchDoccStringCAT	="matchDoccStringCAT";
	var matchMedsStringCAT	="matchMedsStringCAT";
	var matchProcStringCAT	="matchProcStringCAT";
	var matchDiagStringCAT	="matchDiagStringCAT";

	function containsAllWords2(t,w) {
			if (w.indexOf(t)!=-1) {
				return 1;
			}
			var ts=t.split(' ');
			if (ts!=null) {
			for (var i=0;i<ts.length;i++) {
				var TT=ts[i];

				if (TT.length>2) {

					if (w.indexOf(TT)==-1) {
						if (TT.charAt(TT.length-1)=='s') {
							var TTS=TT.substring(0,TT.length-1);
							if (w.indexOf(TTS)==-1) return 0;
						} else {
							return 0;
						}
					}
				}
			} 
			}
			return 1;
					//alert(w+" "+TT);
					//if (ts[i]=='in' || ts[i]=='a' || ts[i]=='the' || ts[i]=='i' ) continue;
				//if (ts[i].length>2 && ts[i]!=' ' && ts[i]!='') 
	}


	function containsAllWords(ts,w,a) {
			for (var i=0;i<ts.length;i++) {
				if (ts[i] && ts[i].length>2) {
					if (w.indexOf(ts[i])==-1) return 0;					
				}
			} 
			return 1;

	}


	function trim(value) {
	   var temp = value;
	   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
	   var obj = / +/g;
	   temp = temp.replace(obj, " ");
	   if (temp == " ") { temp = ""; }
		if (temp.length>0 && temp.charAt(0)==' ') temp=temp.substring(1);
		if (temp.length>0 && temp.charAt(temp.length-1)==' ') temp=temp.substring(0,temp.length-1);
	   return temp;
	}

	function trim22(stringToTrim) {
		if (stringToTrim==undefined || stringToTrim==null) return stringToTrim;
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}

			function ghostingFocus(n,v,c,s) {

				var E=document.getElementById(n);
				if (E!=null) {
					var T=E.value;					
					T=''+T;
					T=trim22(T);
					if (T.length==0) {
						//n.value=v;
					} else if (v==T) {
						E.value='';
						E.className=''+(''+E.className).replace(c,s);


					}
				}
			}
			function changeInputType(n,x) {
				var E=document.getElementById(n);
				if (E!=null) {
					E.type=x;
				}
			}



	function baseSymptoms(found) {
		var f=new Array(found.length);
		for (var x=0;x<found.length;x++) {
			var w=found[x];
			if (w!=null) {
				var ds=w.split('/');
				if (ds!=null) {
				if (ds.length>1) {
					var q=ds[0];
					if (q.charAt(q.length-1)==':') {
						q=q.substring(0,q.length-1);
					}
					f[f.length]=q;
				} else {
					f[f.length]=w;
				}
				}
			}
		}
		return f;
	}

	function injectSyn(t,w,pos,BR) {
		
		//return w;

		//t=trim(t);
	
		var ds=w.split('/');	
		if (ds!=null) {
		if (ds.length>1) {
			var dsQ=w.split('/');

			if (t=='') {
				var q=ds[0];
				q=trim(q);
				if (q.charAt(q.length-1)==':') q=q.substring(0,q.length-1);
				//alert("A: "+q+" : "+w);
				return q;
			}

			for (var i=0;i<ds.length;i++) {
				var q=ds[i];
				q=trim(q);
				ds[i]=q;

				var qc=q;
				if (qc.indexOf("(")!=-1) {
					qc=qc.replace("(","");
					qc=qc.replace(")","");
					dsQ[i]=qc;
				}
			}

			for (var i=0;i<ds.length;i++) {
				var q=ds[i];
				var qc=dsQ[i];
				if (qc.indexOf(t)!=-1) {
					if (i==0 && q.charAt(q.length-1)==':') {
						q=q.substring(0,q.length-1);
						return q;
					}
					return q;

				}
			}

			for (var i=0;i<ds.length;i++) {
				var q=ds[i];	
				var qc=dsQ[i];
				var caw=containsAllWords2(t,qc);
				if (caw==1) {
					if (i==0 && q.charAt(q.length-1)==':') {
						q=q.substring(0,q.length-1);
						//alert("C: "+q+" : "+w);
						return q;
					}
					
					return q;
				}
			}

			//alert("INJECT SYN: "+q);
			var q=ds[0];
			if (q.charAt(q.length-1)==':') q=q.substring(0,q.length-1);
			//alert("D: "+q+" : "+w);
			return q;
		}
		}

		return w;


	}




      function charConversion(intext){
        var intext;
        var outtext = '';
        // loop through the text one character at a time.
        for (var i=0; i<=intext.length; i++) {

		var code = intext.charCodeAt(i);
          	// Setup single char to single char conversions to be made
          	if (code == 8220){code = 34;} //  curly-double quote open
          	if (code == 8221){code = 34;} //  curly-double quote close

	  	if (code == 8217){code = 39;} //  curly-single quote open 
          	if (code == 8216){code = 39;} //  curly-single quote close  
          	if (code == 8211){code = 45;} //  en-dash with -

		// Setup and handle single char to multiple char replacements
		if (code == 8212){ //  em-dash with --
			code = '';
			outtext = outtext+String.fromCharCode(45,45);		
		}		
		if (code == 8482){ //  TM symbol  to (TM)
			code = '';
			outtext = outtext+String.fromCharCode(40,84,77,41);		
		}		
		if (code == 8230){ //  ellipsis  to three-periods
			code = '';
			outtext = outtext+String.fromCharCode(46,46,46);		
		} 
		
		// Handles all single char to single char replacements.
		if (code!=''){	
			//outtext = outtext+String.fromCharCode(code);
			var ttt=''+code;
			if ('NaN'!=ttt) {
				outtext = outtext+'&#'+code+';';
			}
		}
	}
	
	return outtext;

	}



	var TRYCC=0;
	function matchAA() {
		TRYCC++;
		var hreq=HREQQ;
		if (hreq.readyState == 4) {
			if (hreq.status == 200) {
				var R=hreq.responseText;
				R=trim22(R);				
				uAutoCRes(R);
			} else {
				if (TRYCC<3) {
					//setTimeout('matchAA()',100);
				}
			}
		} else {
			if (TRYCC<3) {
				//setTimeout('matchAA()',100);
			}			
		}

	}

	function uAutoCRes(R) {
				var multi=0;
				var DSR=R.split('!');
				HREQQRESALL=new Array();
				//alert(DSR.length);
				for (var g=0;g<DSR.length;g++) {
					R=DSR[g];
					R=trim(R);
					R=trim22(R);

					var rss=R.split('~');
					if (rss.length==2) {	
						var A=rss[0];
						var B=rss[1];
						var X=A.split('|');
						var Y=B.split('|');
						//if (R.length>0) alert(R.length+" "+X.length+" "+Y.length);
						if (X.length==Y.length) {

							var n=new Array(X.length);		
							currentSub=new Array(Y.length);
							var ci=0;
							for (var i=0;i<X.length;i++) {
								if (X[i].length>0) {
									n[ci]=X[i];
									currentSub[ci]=Y[i];
									ci++;
								}
							}

							HREQQRES=n;

							//return n;
							if (DSR.length>1) {
								HREQQRESALL[HREQQRESALL.length]=n;
								//alert(n.length);
							}

						} else {

						}
					}

				}

	}


	var MATCHREQOBJ=null;
	var HREQQTXT='';
	var HREQQ=null;
	var HREQQRES=new Array();
	var HREQQRESALL=new Array();
	var HREQQPREVREQ='';
	var HREQQMSTRING='';
	var HREQQMSTRINGCAT='';
	var PREVQQQTXTREQ='';
	function getMatches(matchString,matchStringCAT,t) {
		//TESTTINEA=(new Date()).getTime();
		var n=new Array(100);		
		currentSub=new Array(100);
		HREQQRES=n;
		HREQQRESALL=new Array(10);
		HREQQTXT=t;
		HREQQMSTRING=matchString;
		HREQQMSTRINGCAT=matchStringCAT;

		if (t==null || trim(t).length<1) return;


		if (matchString==matchStringCAT) matchString='';

		
		
		var gen='';
		if (1) {
			var E=document.getElementsByName('gendersel');
			if (E!=null) {
				var h=0;
				for (var i=0;i<E.length;i++) {
					if (E[i].checked) {
						gen=E[i].value;
						break;
					}
				}
			}
			if (gen=='') {
				var E=document.getElementsByName('gender');
				if (E!=null) {
					var h=0;
					for (var i=0;i<E.length;i++) {
						if (E[i].checked) {
							gen=E[i].value;
							break;
						}
					}
				}
			}
		}

		
		var url='http://autocomplete.medgle.com/ajaxmatch.jsp?matchString='+escape(matchString)+'&matchStringCAT='+escape(matchStringCAT)+'&t='+escape(t)+'&language=english'+'&gender='+escape(gen);



		if (HREQQPREVREQ==url) {
			return;	
		}
		HREQQPREVREQ=url;




		//var rand_no = ''+(10000*Math.random());
		//rand_no=escape(rand_no);
		//url+='&rand='+rand_no;


		url+='&ul=';
		
		//alert(url);
		
		var req = false;
		// branch for native XMLHttpRequest object
		if (MATCHREQOBJ==null) {
			if(window.XMLHttpRequest && !(window.ActiveXObject)) {
			   	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;
					}
				}
			}
			MATCHREQOBJ=req;
		} else {
			req=MATCHREQOBJ;
		}	
		try {
			req.abort();
		} catch (e) {}


		if(req) {	


			/*
			if (matchString=='matchString') {
				HREQQ=req;
				var EEE=getMatchesClient(matchStringClient,t);			
				doMMAATT(EEE);
				return;
			}
			*/

			HREQQ=req;
			//req.onreadystatechange = displayAMatch();
			req.onreadystatechange = displayAMatch;
			//req.open("GET", url, false);
			req.open("GET", url);
			req.send("");			

			TRYCC=0;


		}		

	}

	function doMMAATT(R) {

				R=trim22(R);
				uAutoCRes(R);

				var n=HREQQRES;

				ALLOPS=new Array();

				if (SINGLECOLUMNAUTO!='') {
					if ('symptom'==SINGLECOLUMNAUTO) {

						if (THISS.matchS=='matchDiagString') {

							ALLOPS[0]=new Array();
							ALLOPS[1]=n;
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=new Array();
						} else if (THISS.matchS=='matchMedsString') {
	
							ALLOPS[0]=new Array();
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=n;
							ALLOPS[4]=new Array();
						} else if (THISS.matchS=='matchProcString') {

							ALLOPS[0]=new Array();
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=n;
						} else {
							ALLOPS[0]=n;
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=new Array();
						}

					} else if ('diagnosis'==SINGLECOLUMNAUTO) {

						ALLOPS[0]=new Array();
						ALLOPS[1]=n;
						ALLOPS[2]=new Array();
						ALLOPS[3]=new Array();
						ALLOPS[4]=new Array();


					} else if ('medication'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=new Array();
						ALLOPS[3]=n;
						ALLOPS[4]=new Array();


					} else if ('procedure'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=new Array();
						ALLOPS[3]=new Array();
						ALLOPS[4]=n;


					} else if ('physician'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=n;
						ALLOPS[3]=new Array();
						ALLOPS[4]=new Array();
					}
				} else {
					//ALLOPS=getMatches('matchAll','',txt);
					ALLOPS=n;
				}




				displayMMMM();

				HREQQTXT='';
				HREQQ=null;
				HREQQRES=new Array();
				HREQQRESALL=new Array();
				HREQQPREVREQ='';
				TRYCC=0;

	}


	function displayAMatch() {
		var hreq=HREQQ;
		if (hreq==null) return;
		var matchString=HREQQMSTRING;
		var matchStringCAT=HREQQMSTRINGCAT;

		TRYCC++;
		//var hreq=MATCHREQOBJ;

		if (hreq.readyState == 4) {
			if (hreq.status == 200) {
				TRYCC=10;
				var R=hreq.responseText;
				R=trim22(R);

				uAutoCRes(R);

				var WARNINGT=hreq.getResponseHeader('Warning');
				var n=HREQQRES;
				if (matchString=='matchAll') {
					n=HREQQRESALL;
				}
				

				ALLOPS=new Array();

				//alert(CURTXTTXT+" "+WARNINGT+"\n\n"+R);
				//alert(WARNINGT);
				if (WARNINGT!=null && WARNINGT.length>0 && WARNINGT.indexOf('&')<0 ) {
					if (WARNINGT!=CURTXTTXT) {
						
						displayMMMM();
		
						HREQQTXT='';
						HREQQ=null;
						HREQQRES=new Array();
						HREQQRESALL=new Array();
						HREQQPREVREQ='';
						TRYCC=0;
						return;
					}
				}




				if (SINGLECOLUMNAUTO!='') {
					if ('symptom'==SINGLECOLUMNAUTO) {

						if (THISS.matchS=='matchDiagString') {

							ALLOPS[0]=new Array();
							ALLOPS[1]=n;
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=new Array();
						} else if (THISS.matchS=='matchMedsString') {
	
							ALLOPS[0]=new Array();
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=n;
							ALLOPS[4]=new Array();
						} else if (THISS.matchS=='matchProcString') {

							ALLOPS[0]=new Array();
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=n;
						} else {
							ALLOPS[0]=n;
							ALLOPS[1]=new Array();
							ALLOPS[2]=new Array();
							ALLOPS[3]=new Array();
							ALLOPS[4]=new Array();
						}

					} else if ('diagnosis'==SINGLECOLUMNAUTO) {

						ALLOPS[0]=new Array();
						ALLOPS[1]=n;
						ALLOPS[2]=new Array();
						ALLOPS[3]=new Array();
						ALLOPS[4]=new Array();


					} else if ('medication'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=new Array();
						ALLOPS[3]=n;
						ALLOPS[4]=new Array();


					} else if ('procedure'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=new Array();
						ALLOPS[3]=new Array();
						ALLOPS[4]=n;


					} else if ('physician'==SINGLECOLUMNAUTO) {
						ALLOPS[0]=new Array();
						ALLOPS[1]=new Array();
						ALLOPS[2]=n;
						ALLOPS[3]=new Array();
						ALLOPS[4]=new Array();
					}
				} else {
					//ALLOPS=getMatches('matchAll','',txt);
					ALLOPS=n;
				}




				displayMMMM();

				HREQQTXT='';
				HREQQ=null;
				HREQQRES=new Array();
				HREQQRESALL=new Array();
				HREQQPREVREQ='';
				TRYCC=0;
			}
		} else {
			if (TRYCC<5) {
				setTimeout('displayAMatch()',500);
			}
		}
	}




	function getMatchesGUI(matchString,matchStringCAT,t) {
		//TESTTINEA=(new Date()).getTime();
		var n=new Array(100);		
		currentSub=new Array(100);
		HREQQRES=n;
		HREQQRESALL=new Array(10);
		HREQQTXT=t;
		if (t==null || trim(t).length<1) return;


		if (matchString==matchStringCAT) matchString='';

		

		var gen='';
		if (1) {
			var E=document.getElementsByName('gender');
			if (E!=null) {
				var h=0;
				for (var i=0;i<E.length;i++) {
					if (E[i].checked) {
						gen=E[i].value;
						break;
					}
				}
			}
		}


		var url='http://autocomplete.medgle.com/ajaxmatch.jsp?matchString='+escape(matchString)+'&matchStringCAT='+escape(matchStringCAT)+'&t='+escape(t)+'&language=english'+'&gender='+escape(gen);


		if (HREQQPREVREQ==url) {
			return;	
		}
		HREQQPREVREQ=url;

		//var rand_no = ''+(10000*Math.random());
		//rand_no=escape(rand_no);
		//url+='&rand='+rand_no;


		url+='&ul=';
		
		//alert(url);
		
		var req = false;
		// branch for native XMLHttpRequest object
		if (MATCHREQOBJ==null) {
			if(window.XMLHttpRequest && !(window.ActiveXObject)) {
			   	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;
					}
				}
			}
			MATCHREQOBJ=req;
		} else {
			req=MATCHREQOBJ;
		}	

		if(req) {	
			//req.setRequestHeader("Content-Type","application/x-javascript; charset:ISO-8859-1");  //req.overrideMimeType('text/xml; charset=iso-8859-1'); //req.onreadystatechange = fun;
			req.open("GET", url, false);
			req.send("");			
			HREQQ=req;

			TRYCC=0;
			matchAA();

			n=HREQQRES;
			if (matchString=='matchAll') {
				n=HREQQRESALL;
			}

		}		


		HREQQTXT='';
		HREQQ=null;
		HREQQRES=new Array();
		HREQQRESALL=new Array();
		HREQQPREVREQ='';

		ALLOPS=n;
		return n;
	}





function decodeutf8(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }





	function getMatchType(t) {

		if (t==null || trim(t).length<1) return;

		if (matchString==matchStringCAT) matchString='';

		

		var url='http://autocomplete.medgle.com/ajaxmatch.jsp?task=gettype&t='+escape(t)+'&language=english';
		var rand_no = Math.random();

		//url+='&rand='+rand_no;
		
		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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.overrideMimeType('text/xml; charset=iso-8859-1');  
			//req.onreadystatechange = fun;
			req.open("GET", url, false);
			req.send("");			

			return matchTT(req);
		}		

		return '';
	}


	function matchTT(hreq) {
		if (hreq.readyState == 4) {
			if (hreq.status == 200) {
				var R=hreq.responseText;
				R=trim(R);
				R=trim22(R);
				if (R.length==0) R=''+CURRENTSECTIONC;
				//alert(R+"||"+CURRENTSECTIONC);
				return R;
			} else {

			}
		} else {

		}

	}



	function containsAlreadySimple(ar,v) {
		var ARL=ar.length;
		for (var i=0;i<ARL;i++) {
			if (ar[i]==v) return 1;
		}
		return 0;
	}


	function containsAlready(ar,v) {
		var S=v+'d';
		var T=v+'s';
		for (var i=0;i<ar.length;i++) {

			if (ar[i]==v) return 1;
			if (ar[i]==S) return 1;
			if (ar[i]==T) return 1;

			if ((ar[i]+'d')==v) return 1;
			if ((ar[i]+'s')==v) return 1;

		}
		return 0;
	}


	function containsAlreadySS(ar,v) {
		var S=v+'d';
		var T=v+'s';
		for (var i=0;i<ar.length;i++) {
			if (ar[i]==null) continue;

			if (ar[i]==v) return 1;
			if (ar[i]==S) return 1;
			if (ar[i]==T) return 1;

			if ((ar[i]+'d')==v) return 1;
			if ((ar[i]+'s')==v) return 1;
			if (v.length>10 && ar[i].indexOf(v)!=-1) return 1;

		}
		return 0;
	}


	function showSearchEdit() {
		var E=document.getElementById('searchformarea');
		var F=document.getElementById('searcheditsearch');

		if (E!=null && F!=null) {
			if (E.style.display=='none') {
				E.style.display='';
				F.style.display='none';
			} else {
				E.style.display='none';
				F.style.display='';
			}
		}
	}
	function showWebSearch() {
		window.location='?section=keyword';
	}
	
	var SYMTXTWIDTHSMALL='450px';
	var SYMTXTWIDTHLARGE='780px';
	var AUTOCOMPWIDTHLARGE='930px';
	



	function showDURQ() {

		for (var x=1;x<=4;x++) {
			var EN='DIVSYM'+x+'VALUE';
			var EE=document.getElementById(EN);
			if (EE!=null) {
				if (EE.value.length>=0) {
					var F=document.getElementById('DURADIV'+x);
					if (F!=null) {
						EE.style.width=SYMTXTWIDTHSMALL;//'240px';

						var FN='DIVSYM'+x+'VALUECONTAINER';
						var FE=document.getElementById(FN);
						FE.style.width=SYMTXTWIDTHSMALL;//'240px';


						F.style.display='';
					}
				}
			}
		}

		if (1) {
			var E=document.getElementById('SYMSEARCHPLUSSIGN');
			if (E!=null) E.style.display='';
			var E=document.getElementById('SYMSEARCHGENAGE');
			if (E!=null) E.style.display='';
		}
	}

	function hideDurations() {

		for (var x=2;x<=4;x++) {
			var F=document.getElementById('DURADIV'+x);
			if (F!=null) F.style.display='none';

		}
		if (1) {
			var E=document.getElementById('SYMSEARCHPLUSSIGN');
			if (E!=null) E.style.display='none';
			var E=document.getElementById('SYMSEARCHGENAGE');
			if (E!=null) E.style.display='none';
		}
	}

	function showDurations() {
		for (var x=1;x<=4;x++) {
			var F=document.getElementById('DURADIV'+x);
			if (F!=null) F.style.display='';

		}
	}


	function hideDURQ() {

		if (CURRENTSECTIONC!='' && MULTIROWON!='false') {
			for (var x=4;x>1;x--) {
				var EN='DIVSYM'+x+'VALUE';
				var EE=document.getElementById(EN);
				if (EE!=null) {				
					var q=EE.value;
					q=trim(q);
					if (q.length>0 && q!='type another symptom (optional)') {						
						var FN='DIVSYM1VALUE';
						var FE=document.getElementById(FN);
						if (FE!=null) {
							FE.value=q;
						}
						break;
					}
				}
			}

			if (1) {
				var E=document.getElementById('SYMSEARCHPLUSSIGN');
				if (E!=null) E.style.display='none';
				var E=document.getElementById('SYMSEARCHGENAGE');
				if (E!=null) E.style.display='none';
			}
		}

		for (var x=1;x<=4;x++) {
			
			var EN='DIVSYM'+x+'VALUE';
			var EE=document.getElementById(EN);
			if (EE!=null) {
				if (EE.value.length>0) {
					var F=document.getElementById('DURADIV'+x);
					if (F!=null) {
						EE.style.width=SYMTXTWIDTHLARGE;//'680px';
						var FN='DIVSYM'+x+'VALUECONTAINER';
						var FE=document.getElementById(FN);
						FE.style.width=SYMTXTWIDTHLARGE;//'680px';


						F.style.display='none';
					}
				}
			}
			if (x>1 && MULTIROWON!='false') {
				var EN='DIVSYM'+x+'VALUE';
				var EE=document.getElementById(EN);
				var g=0;
				if (EE!=null) {
					EE.value='';
					var YEN='SYMPTOMROW'+x;
					var YEE=document.getElementById(YEN);
					if (YEE!=null) {
						YEE.style.display='none';
					}
				}
			}
		}



	}
	function showThisSymptomRow(n) {
		var E=document.getElementById('SYMPTOMROWCONTROL'+n);
		var F=document.getElementById('SYMPTOMROWDETT'+n);
		var G=document.getElementById('SYMPTOMROWDETTB'+n);
		if (E!=null && F!=null && G!=null) {
			E.style.display='none';
			F.style.display='';
			G.style.display='';

			var H=document.getElementById('DIVSYM'+n+'VALUE');
			if (H!=null) {
				H.focus();
			}
		}
	}

	function showNextSymptomRow() {

		var FF=document.getElementById("section"); if (FF!=null) FF.value=CURRENTSECTIONC;
		
		

		if (CURRENTSECTIONC=='') {
			if (1) {
				var EN='DIVSYM1VALUE';
				var EE=document.getElementById(EN);
				if (EE!=null) {
					if (EE.value!='' && EE.value!=''  && EE.value!='type another symptom (optional)') {
						showDurations();
						showDURQ();
					}
				}
			}

			for (var x=1;x<=4;x++) {
			var EN='DIVSYM'+x+'VALUE';
			var EE=document.getElementById(EN);
			var g=0;
			if (EE!=null) {
				EE.name='symptom';
				if (EE.value!='' && EE.value!=''  && EE.value!='type another symptom (optional)') {
					if (x==1) g=1;
					var y=x+1;					
					if (y<=4) {
						var YEN='SYMPTOMROW'+y;
						var YEE=document.getElementById(YEN);
						if (YEE!=null) {
							YEE.style.display='';
						}
					}

				}
			}
			}		
			showslide('1');
		} else {


			var EN='DIVSYM1VALUE';
			var EE=document.getElementById(EN);
			if (EE!=null) {
				if ('keyword'==CURRENTSECTIONC) {
					EE.name='keyword';
					showslide('2');
					hideDURQ();
				} else if ('searchdrug'==CURRENTSECTIONC) {
					EE.name='drug';
					showslide('3');
					hideDURQ();
				} else if ('searchproc'==CURRENTSECTIONC) {
					EE.name='procedure';
					showslide('4');
					hideDURQ();
				} else if ('searchdoc'==CURRENTSECTIONC) {
					EE.name='associateddocs';
					showslide('5');
					hideDURQ();

				} else if (''==CURRENTSECTIONC) {
					EE.name='symptom';
					showslide('1');
				}
			}
			

		}

	}



	function showAdvancedSearch() {
		var E=document.getElementById('advancedsearch');
		var F=document.getElementById('ADVLINK');
		if (E!=null && F!=null) {
			if (E.style.display=='none') {
				E.style.display='';
				F.innerHTML='advanced';
			} else {
				E.style.display='none';
				F.innerHTML='advanced';
			}
		}
	}

	function showGraphicalSearch() {

		var E=document.getElementById('GRAPHICALSEARCH');
		if (E!=null ) {
			if (E.style.display=='none') {
				E.style.display='';
			} else {
				E.style.display='none';
			}
		}
		
	}
	

function AutoComplete(aStr, aStrCAT,oText, oDiv, oCont,nMaxSize,iN,addto)
{

	// initialize member variables
	this.matchS=aStr;
	this.matchSCAT=aStrCAT;
	this.oText = oText;
	this.oDiv = oDiv;
	this.oCont = oCont;
	this.activeTDIV=null;
	this.indexName=iN;
	this.nMaxSize = nMaxSize;
	this.usingKeys = 0;
	this.inDIV=0;
	this.addtofield=addto;
	if (this.addtofield==undefined || this.addtofield==null) {
		this.addtofield='false';
	}
	this.SNR=true;
	if (oDiv!=null) {
		if ((''+oDiv.id).indexOf('DTESTVALUE')>=0) {
			this.SNR=false;
		}
	}

	// preprocess the texts for fast access
			
	// attach handlers to the text-box
	if (oText!=null) {
		oText.AutoComplete = this;
		oText.onkeyup = AutoComplete.prototype.onTextChange;
		oText.onkeydown = AutoComplete.prototype.onKD;
		oText.onblur = AutoComplete.prototype.onTextBlur;
		//oCont.on = function() { alert("AA"); } //AutoComplete.prototype.onBMOO;
		oCont.AutoComplete=this;
		oDiv.AutoComplete=this;
		oText.onfocus = AutoComplete.prototype.onTextFocus;
		oText.onclick = AutoComplete.prototype.onClickT;
	}


}

AutoComplete.prototype.onKD = function (oEvent) {
	if (!oEvent) {

		oEvent = window.event;
	}
	if (this.value!=null && this.value=='') {
		this.value='';
	}
	if (this.value!=null && this.value=='type another symptom (optional)') {
		this.value='';
	}
	//alert(oEvent);
	//oEvent.cancelBubble=true;

	switch(oEvent.keyCode) {
        case 38: //up arrow
            //this.previousSuggestion();
			this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV==null) {
				//this.AutoComplete.activeTDIV=this.AutoComplete.oDiv.firstChild;
				this.AutoComplete.activeTDIV=this.AutoComplete.oDiv.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild;
				var OFTOP=this.AutoComplete.activeTDIV.offsetTop;
				this.AutoComplete.oDiv.scrollTop=OFTOP;
			}
			if (this.AutoComplete.activeTDIV && this.AutoComplete.activeTDIV!=null) {
				//alert("D"+this.AutoComplete.activeTDIV.previousSibling+" "+this);
				if (this.AutoComplete.activeTDIV.previousSibling) {
					this.AutoComplete.activeTDIV.className = "AutoCompleteBackground";
					this.AutoComplete.activeTDIV.previousSibling.className = "AutoCompleteHighlight";
					this.AutoComplete.activeTDIV=this.AutoComplete.activeTDIV.previousSibling;
					var OFTOP=this.AutoComplete.activeTDIV.offsetTop;
					this.AutoComplete.oDiv.scrollTop=OFTOP;
				}
		 	}


            break;
        case 37: //left arrow
			this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV && this.AutoComplete.activeTDIV!=null) {
				
				if (this.AutoComplete.activeTDIV.parentNode.parentNode.previousSibling) {
					this.AutoComplete.activeTDIV.className = "AutoCompleteBackground";
					this.AutoComplete.activeTDIV=this.AutoComplete.activeTDIV.parentNode.parentNode.previousSibling.firstChild.firstChild;
					this.AutoComplete.activeTDIV.className = "AutoCompleteHighlight";
				}
			}
            break;
        case 39: //right arrow
			this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV && this.AutoComplete.activeTDIV!=null) {			
				if (this.AutoComplete.activeTDIV.parentNode.parentNode.nextSibling) {
					this.AutoComplete.activeTDIV.className = "AutoCompleteBackground";
					this.AutoComplete.activeTDIV=this.AutoComplete.activeTDIV.parentNode.parentNode.nextSibling.firstChild.firstChild;
					this.AutoComplete.activeTDIV.className = "AutoCompleteHighlight";
				}
			}
            break;
        case 40: //down arrow
            //this.nextSuggestion();
		
			//this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV==null) {
				if (this.AutoComplete.oDiv!=null && this.AutoComplete.oDiv.firstChild!=null) {
					this.AutoComplete.activeTDIV=this.AutoComplete.oDiv.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild;
					this.AutoComplete.activeTDIV.className = "AutoCompleteHighlight";

					var OFTOP=this.AutoComplete.activeTDIV.offsetTop;
					this.AutoComplete.oDiv.scrollTop=OFTOP;
					//document.getElementById('ADDINTINFODIV').innerHTML=''+OFTOP+" "+this.AutoComplete.activeTDIV.scrollHeight+" "+this.AutoComplete.activeTDIV.getAttribute('number')+" ??"+this.AutoComplete.activeTDIV.innerHTML;
				} else {
					
				}
			} else {

				if (this.AutoComplete.activeTDIV && this.AutoComplete.activeTDIV!=null) {
					//alert("D"+this.AutoComplete.activeTDIV.nextSibling+" "+this);
	
					if (this.AutoComplete.activeTDIV.nextSibling) {
						this.AutoComplete.activeTDIV.className = "AutoCompleteBackground";
						this.AutoComplete.activeTDIV.nextSibling.className = "AutoCompleteHighlight";
						this.AutoComplete.activeTDIV=this.AutoComplete.activeTDIV.nextSibling;

						var OFTOP=this.AutoComplete.activeTDIV.offsetTop;
						this.AutoComplete.oDiv.scrollTop=OFTOP;
		
					} else {
					}
			 	} else {
				}
			}

            break;
        case 13: //enter

			this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV!=null) {

				//this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;
				if (false && this.AutoComplete.activeTDIV.title==this.AutoComplete.activeTDIV.title.toUpperCase() && this.AutoComplete.activeTDIV.title.indexOf("#")<0) {
					this.AutoComplete.usingKeys=0;							
					break;
				}


				CURRENTSECTIONC=this.AutoComplete.activeTDIV.getAttribute('alt');	
				if (CURRENTSECTIONC==null || CURRENTSECTIONC==undefined) CURRENTSECTIONC='';
				if (CURRENTSECTIONC=='' || MULTIROWON=='false') {
					if (this.AutoComplete.addtofield=='true') {				
						var CVV=this.AutoComplete.oText.value;
						CVV=CVV.replace(',,',',');
						var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							var CVV=this.AutoComplete.oText.value;
							CVV=CVV.replace(',,',',');
							var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
							CVV+=this.AutoComplete.activeTDIV.innerHTML;
							this.AutoComplete.oText.value=CVV+',';
		
						} else if (CVV.indexOf(this.AutoComplete.activeTDIV.title+',')<0) {
							CVV+=this.AutoComplete.activeTDIV.title;
							this.AutoComplete.oText.value=CVV+',';
						}

						this.AutoComplete.oText.focus();
					} else {
						this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.title;
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;
		
						}
					}
				} else {
					var SN='DIVSYM1VALUE';
					var E=document.getElementById(SN);
					if (E!=null) {
						E.value = this.AutoComplete.activeTDIV.title;
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							E.value = this.AutoComplete.activeTDIV.innerHTML;
						}
					}
					
					for (var i=2;i<=4;i++) {
						var SN='DIVSYM'+i+'VALUE';
						var E=document.getElementById(SN);
						if (E!=null) {
							E.value='';
						}
					}
				}
				CURRENTSECTIONC=this.AutoComplete.activeTDIV.getAttribute('alt');
				if (CURRENTSECTIONC==null || CURRENTSECTIONC==undefined) CURRENTSECTIONC='';
			}


				//this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;

				this.AutoComplete.activeTDIV=null;
				//this.AutoComplete.oDiv.innerHTML = "";
				this.AutoComplete.oDiv.style.display = "none";
				this.AutoComplete.showtextfields();
				//this.AutoComplete.usingKeys=0;

			
			if (MULTIROWON!='false') {
				if (this.AutoComplete!=undefined || this.AutoComplete!=null) {		 
					if (this.AutoComplete!=undefined && this.AutoComplete!=null) {
						if (this.AutoComplete.SNR) showNextSymptomRow();
					}
				}
			}
				
			return false;			
            break;
        case 9: //tab
			this.AutoComplete.usingKeys=1;
			if (this.AutoComplete.activeTDIV!=null) {
				//this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;
				if (false && this.AutoComplete.activeTDIV.title==this.AutoComplete.activeTDIV.title.toUpperCase() && this.AutoComplete.activeTDIV.title.indexOf("#")<0) {
					this.AutoComplete.usingKeys=0;							
					break;
				}
				
				CURRENTSECTIONC=this.AutoComplete.activeTDIV.getAttribute('alt');	
				if (CURRENTSECTIONC==null || CURRENTSECTIONC==undefined) CURRENTSECTIONC='';
				if (CURRENTSECTIONC=='') {		

					if (this.AutoComplete.addtofield=='true') {				
						var CVV=this.AutoComplete.oText.value;
						CVV=CVV.replace(',,',',');
						var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							var CVV=this.AutoComplete.oText.value;
							CVV=CVV.replace(',,',',');
							var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
							CVV+=this.AutoComplete.activeTDIV.innerHTML;
							this.AutoComplete.oText.value=CVV+',';
		
						} else if (CVV.indexOf(this.AutoComplete.activeTDIV.title+',')<0) {
							CVV+=this.AutoComplete.activeTDIV.title;
							this.AutoComplete.oText.value=CVV+',';
						}


						this.AutoComplete.oText.focus();

					} else {
						this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.title;
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;
		
						}
					}
				} else {
					var SN='DIVSYM1VALUE';
					var E=document.getElementById(SN);
					if (E!=null) {
						E.value = this.AutoComplete.activeTDIV.title;
						if (this.AutoComplete.activeTDIV.title.indexOf("#")>=0) {
							E.value = this.AutoComplete.activeTDIV.innerHTML;
						}
					}
					
					for (var i=2;i<=4;i++) {
						var SN='DIVSYM'+i+'VALUE';
						var E=document.getElementById(SN);
						if (E!=null) {
							E.value='';
						}
					}
				}
				CURRENTSECTIONC=this.AutoComplete.activeTDIV.getAttribute('alt');
				if (CURRENTSECTIONC==null || CURRENTSECTIONC==undefined) CURRENTSECTIONC='';

			}



				//this.AutoComplete.oText.value = this.AutoComplete.activeTDIV.innerHTML;
				this.AutoComplete.activeTDIV=null;
				//this.AutoComplete.oDiv.innerHTML = "";
				this.AutoComplete.oDiv.style.display = "none";
				this.AutoComplete.showtextfields();
				//this.AutoComplete.usingKeys=0;

			if (MULTIROWON!='false') {
				if (this.AutoComplete!=undefined && this.AutoComplete!=null) {
					if (this.AutoComplete.SNR) showNextSymptomRow();
				}
			}
				
			//this.AutoComplete.showtextfields();
				


			
            break;

		default:
				this.AutoComplete.usingKeys=0;							
			break;

		
    }



}

AutoComplete.prototype.onClickT = function()
{
	if (this.value!=null && this.value=='') {
		this.value='';
	}

	if (this.value!=null && this.value=='type another symptom (optional)') {
		this.value='';
	}
}


AutoComplete.prototype.onTextBlur = function()
{

	//this.AutoComplete.onblur();
	if (navigator!=undefined) {
		var UA=navigator.userAgent;
		if (UA!=null && UA.indexOf("iPad")<0) {
			//this.AutoComplete.onblur();
		}
	}
	if (this.AutoComplete!=undefined && this.AutoComplete!=null) {
		if (this.AutoComplete.SNR) showNextSymptomRow();
	}
	/*
	var IDD=this.AutoComplete.oText.id
	var COM=document.getElementById(IDD+'COMMENT');
	if (COM!=null) {
		hideDiv(COM.id);
	}
	*/
}

AutoComplete.prototype.onblur = function()
{

	
	//if (this.inDIV==0) {
	//this.oDiv.style.visibility = "hidden";
	this.usingKeys=0;
	this.oDiv.style.display = "none";
	//this.showtextfields();
	//}
	if (this.AutoComplete!=undefined && this.AutoComplete!=null) {
		if (this.AutoComplete.SNR) showNextSymptomRow();
	}

}




AutoComplete.prototype.onBMOV = function()
{
	//this.AutoComplete.inDIV=1;
	this.inDIV=1;

}

AutoComplete.prototype.onBMOO = function()
{
	this.inDIV=0;
	this.usingKeys=0;
	if (this.oDiv.style) this.oDiv.style.display = "none";
	this.showtextfields();

}



AutoComplete.prototype.onFFOO = function()
{
	this.oDiv.style.display = '';
	this.inDIV=1;	
	this.usingKeys=1;
}


							function autocompleteWindowFocus(e) {
								if (e==undefined || e==null) return;
								var c=0;
								var SS='';
								var E=e;
								if (e.srcElement!=undefined) E=e.srcElement; if (E==undefined || E==null) E=e.target;
								var good=0;

								while (c<50) {
									if (E==document) {
										break;
									}
									if (E==window) break;
									if (E.isautocomplete!=undefined && E.isautocomplete!=null && E.isautocomplete=='true') {
										//alert('Y');
										good=1;
									}
			
									if (E.id!=undefined && E.id!=null && (''+E.id).length>0) {
										SS+=E.id+'AA\n';
									}
									c++;
									if (E.parentNode==undefined || E.parentNode==null) { SS+=' '+c+' '; break;}
									E=E.parentNode;									

								}
								//alert(SS);
								if (good==0) {
									//alert('closing');
									closeAUTOCS();
								}
							}

							//document.onclick = aaa;
							if (document.addEventListener) {
								document.addEventListener('click',function (e) {
									var theTarget = e.target;
									if( theTarget && ( e.target.nodeType == 3 || e.target.nodeType == 4 ) ) {
										theTarget = theTarget.parentNode;
									}
									autocompleteWindowFocus(theTarget);
								},false);

								document.addEventListener('onscroll',function (e) {
									var theTarget = e.target;
									if( theTarget && ( e.target.nodeType == 3 || e.target.nodeType == 4 ) ) {
										theTarget = theTarget.parentNode;
									}
									autocompleteWindowFocus(theTarget);
								},false);
							} else if (document.attachEvent) {
								document.attachEvent('click',function (e) {
									var theTarget = e.target;
									if( theTarget && ( e.target.nodeType == 3 || e.target.nodeType == 4 ) ) {
										theTarget = theTarget.parentNode;
									}
									autocompleteWindowFocus(theTarget);
								},false);

								document.attachEvent('onscroll',function (e) {
									var theTarget = e.target;
									if( theTarget && ( e.target.nodeType == 3 || e.target.nodeType == 4 ) ) {
										theTarget = theTarget.parentNode;
									}
									autocompleteWindowFocus(theTarget);
								},false);
							}

							function closeAUTOCS() {
								var EA=document.getElementsByTagName('div');
								if (EA!=null) {
									for (var i=0;i<EA.length;i++) {
										var E=EA[i];
										var idid=''+E.id;
										if (idid.indexOf('VALUECHOICE')>0) {
											hideDiv(E.id);
										}
									}
								}

							}


AutoComplete.prototype.onTextFocus = function()
{
	this.AutoComplete.usingKeys==0;

	var IDD=this.AutoComplete.oText.id
	var COM=document.getElementById(IDD+'COMMENT');
	if (COM!=null) {
		showDiv(COM.id);
	}

}



AutoComplete.prototype.onDivMouseDown = function()
{

	//this.AutoComplete.oText.value = this.innerHTML;

	if (false && this.title==this.title.toUpperCase()  && this.title.indexOf("#")<0 ) {
	} else {

		this.AutoComplete.oDiv.style.display = "none";
		this.AutoComplete.showtextfields();
		this.AutoComplete.usingKeys=0;
		if (this.AutoComplete.addtofield=='true') {	
			if (this.title.indexOf("#")<0) {
				var CVV=this.AutoComplete.oText.value;
				CVV=CVV.replace(',,',',');
				var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
				if (CVV.indexOf(this.title+',')<0) {
					CVV+=this.title;
	
					this.AutoComplete.oText.value=CVV+',';
					this.AutoComplete.oText.focus();
				}
			}

		} else {

			this.AutoComplete.oText.value = this.title;
		}

		if (this.AutoComplete.addtofield=='true') {				
			if (this.title.indexOf("#")>=0) {

				var CVV=this.AutoComplete.oText.value;
				CVV=CVV.replace(',,',',');
				var CVVCP=CVV.lastIndexOf(','); if (CVVCP>0) {CVV=CVV.substring(0,CVVCP)+', ';} else CVV='';
				CVV+=this.innerHTML;
				this.AutoComplete.oText.value=CVV+',';
				this.AutoComplete.oText.focus();
			}
		} else {
			if (this.title.indexOf("#")>=0) {
				this.AutoComplete.oText.value = this.innerHTML;
			}
		}

		CURRENTSECTIONC=this.getAttribute('alt');
		if (CURRENTSECTIONC==null || CURRENTSECTIONC==undefined) CURRENTSECTIONC='';
		if (this.AutoComplete.SNR) showNextSymptomRow();
		if (this.AutoComplete.addtofield=='true') {
			this.AutoComplete.oText.focus();
		}
		//this.AutoComplete.oText.value = this.innerHTML;

	}

}



AutoComplete.prototype.onDivMouseOver = function()
{
	this.AutoComplete.inDIV=1;
	if (this.AutoComplete.usingKeys==0) {
		this.AutoComplete.activeTDIV=this;
		this.className = "AutoCompleteHighlight";
	}
}

AutoComplete.prototype.onDivMouseMove = function()
{

	this.AutoComplete.usingKeys=0;
	
}


AutoComplete.prototype.onDivMouseOut = function()
{
	this.AutoComplete.inDIV=0;
	this.className = "AutoCompleteBackground";
}

AutoComplete.prototype.showtextfields = function() {

		//for (var x=1;x<=4;x++) {
		for (var x=1;x<=5;x++) {

			var EN='DIVSYM'+x+'VALUE';
			var EE=document.getElementById(EN);
			if (EE!=null) {
				EE.style.visibility="visible";
			}

		}

}

function toggleGHOST(e) {
	var E=document.getElementById(e);
	var F=document.getElementById(e+'GHOST');
	if (E!=null && F!=null) {

		if (E.value!='') hideDiv(e+'GHOST');
		else showDiv(e+'GHOST');
	}
}

var LATESTTXT='';
var AUTOCOMPLASTTIME=(new Date()).getTime();
var CURRENTKEYFUN=null;
function helperOnTextChange() {
	if (CURRENTKEYFUN!=null) {
		if (CURRENTKEYFUN.oText!=null) {
			toggleGHOST(CURRENTKEYFUN.oText.id);
		}
		if (1==1) {
			CURRENTKEYFUN.onchange();
			return;
		}


		var txt = CURRENTKEYFUN.oText.value;
		if (txt!='' && txt!='type another symptom (optional)') {
			CURRENTKEYFUN.oText.style.color='#000000';
		} else {
			CURRENTKEYFUN.oText.style.color='#acacac';
		}

		var NOWT=(new Date()).getTime();
		var TDIF=NOWT-AUTOCOMPLASTTIME;
		var LMMM=100;
		

		if (TDIF>LMMM && txt.length>0 && txt==LATESTTXT) {

			CURRENTKEYFUN.onchange();
			AUTOCOMPLASTTIME=(new Date()).getTime();
			return;
		} else {
			if (txt.length>=0 && txt!=LATESTTXT) {
				//LATESTTXT=txt;
				setTimeout('helperOnTextChange()',500);
				return;
			}
		}	
	} 
}

AutoComplete.prototype.onTextChange = function()
{	
	if (this.AutoComplete.oText!=null) {
		toggleGHOST(this.AutoComplete.oText.id);
	}



	var txt = this.AutoComplete.oText.value;
	if (txt!='' && txt!='type another symptom (optional)') {
		this.AutoComplete.oText.style.color='#000000';
	} else {
		//this.AutoComplete.oText.style.color='#acacac';
		this.AutoComplete.oText.style.color='#454545';
		//this.AutoComplete.oText.style.color='#000000';
	}

	var NOWT=(new Date()).getTime();
	var TDIF=NOWT-AUTOCOMPLASTTIME;

	var LMMM=100;
	


	CURRENTKEYFUN=this.AutoComplete;
	CURRENTKEYFUN.onchange();

	AUTOCOMPLASTTIME=(new Date()).getTime();
	return;



}

var TESTTIMEA=(new Date()).getTime();
var TESTTIMEB=(new Date()).getTime();
var AUTOCOMPONLYSHOW='';
var INONCHANGE=0;
var MYONCHANGE=INONCHANGE+0;
var LASTCALL=(new Date()).getTime();
var THISS=null;
var ALLOPS=new Array();
var CURTXTTXT='';

AutoComplete.prototype.onchange = function()
{
	THISS=this;



	if (INONCHANGE<0) INONCHANGE=0;
	THISS.usingKeys=0;
	//if (THISS.usingKeys!=0) return;

	var txt = THISS.oText.value;
	if (txt!='' && txt!='type another symptom (optional)') {
		THISS.oText.style.color='#000000';
	} else {
		THISS.oText.style.color='#acacac';
	}
	txt=txt.toLowerCase();
	if (THISS.addtofield=='true') {				
		var cp=txt.lastIndexOf(',');
		if (cp>0 && (cp+1)<txt.length) {
			txt=txt.substring(cp+1);
		} else if (cp>0 && (cp+1)==txt.length) {
			txt='';
		}
	} 	
	txt=trim(txt);	
	if (false && txt.length<1) {
		THISS.oDiv.innerHTML = "";
		if (THISS.oDiv.style) THISS.oDiv.style.display = "none";
		THISS.showtextfields();
		return;
	}

	var NOWTT=(new Date()).getTime();

	INONCHANGE++;
	//var MYONCHANGE=INONCHANGE+0;
	MYONCHANGE=INONCHANGE+0;
	// count the number of strings that match the text-box value

	//LASTCALL=(new Date()).getTime();

	CURTXTTXT=txt;
	if (CURRENTLANG=='chinesesp') {
		if (matchString.length>0) {
			CURTXTTXT=charConversion(txt);
		}
	}
	//var ALLOPS=new Array();
	ALLOPS=new Array();


	if (SINGLECOLUMNAUTO!='') {
		if ('symptom'==SINGLECOLUMNAUTO) {

			if (THISS.matchS=='matchDiagString') {
				getMatches('matchDiagString','',txt);				
			} else if (THISS.matchS=='matchMedsString') {
				getMatches('matchMedsString','',txt);
			} else if (THISS.matchS=='matchProcString') {
				getMatches('matchProcString','',txt);
			} else {
				getMatches('matchString','',txt);
			}

		} else if ('diagnosis'==SINGLECOLUMNAUTO) {
			getMatches('matchDiagString','',txt);
		} else if ('medication'==SINGLECOLUMNAUTO) {
			getMatches('matchMedsString','',txt);
		} else if ('procedure'==SINGLECOLUMNAUTO) {
			getMatches('matchProcString','',txt);
		} else if ('physician'==SINGLECOLUMNAUTO) {		
			getMatches('matchDoccString','',txt);
		}
	} else {
		getMatches('matchAll','',txt);
	}



	if (ALLOPS == undefined || ALLOPS==null || ALLOPS.length==0) {
		INONCHANGE--;
		//return;
	}

	//displayMMMM();
}
var JUSTDREW='';
function displayMMMM() {

	var txt=CURTXTTXT;

	if (CURRENTLANG=='chinesesp') {
		if (matchString.length>0) {
			CURTXTTXT=charConversion(txt);
		}
	}
	if (JUSTDREW==txt) return;
	//alert(ALLOPS);
	if (ALLOPS.length==5) {
		var aStr=ALLOPS[0];
		var DDStr=ALLOPS[1];
		var DPRStr=ALLOPS[2];
		var DRStr=ALLOPS[3];
		var PRStr=ALLOPS[4];

	}

	//alert(ALLOPS.length);

	//if (LATESTTXT!=txt || INONCHANGE>MYONCHANGE) { INONCHANGE--; return; }

	var RESS=new Array(); var RESSLABEL=new Array(); var RESSECT=new Array(); var RESCOLOR=new Array();
	RESS[RESS.length]=aStr; RESSLABEL[RESSLABEL.length]='SYMPTOMS'; RESSECT[RESSECT.length]=''; RESCOLOR[RESCOLOR.length]='#ffffff';
	RESS[RESS.length]=DDStr; RESSLABEL[RESSLABEL.length]='DIAGNOSES'; RESSECT[RESSECT.length]='keyword'; RESCOLOR[RESCOLOR.length]='#fffafa';
	RESS[RESS.length]=PRStr; RESSLABEL[RESSLABEL.length]='PROCEDURES'; RESSECT[RESSECT.length]='searchproc'; RESCOLOR[RESCOLOR.length]='#fffaff';
	RESS[RESS.length]=DRStr; RESSLABEL[RESSLABEL.length]='DRUGS'; RESSECT[RESSECT.length]='searchdrug'; RESCOLOR[RESCOLOR.length]='#fffffa';
	RESS[RESS.length]=DPRStr; RESSLABEL[RESSLABEL.length]='PHYSICIANS'; RESSECT[RESSECT.length]='searchdoc'; RESCOLOR[RESCOLOR.length]='#fafaff';


	if (SINGLECOLUMNAUTO!='') {
		RESS=new Array(); RESSLABEL=new Array(); RESSECT=new Array();
		if ('symptom'==SINGLECOLUMNAUTO) {
			if (THISS.matchS=='matchDiagString') {
				RESS[RESS.length]=DDStr; RESSLABEL[RESSLABEL.length]='DIAGNOSES'; RESSECT[RESSECT.length]='keyword';

			} else if (THISS.matchS=='matchMedsString') {
				RESS[RESS.length]=DRStr; RESSLABEL[RESSLABEL.length]='DRUGS'; RESSECT[RESSECT.length]='searchdrug';

			} else if (THISS.matchS=='matchProcString') {
				RESS[RESS.length]=PRStr; RESSLABEL[RESSLABEL.length]='PROCEDURES'; RESSECT[RESSECT.length]='searchproc';

			} else {
				RESS[RESS.length]=aStr; RESSLABEL[RESSLABEL.length]='SYMPTOMS'; RESSECT[RESSECT.length]='';
			}

		} else if ('diagnosis'==SINGLECOLUMNAUTO) {
			RESS[RESS.length]=DDStr; RESSLABEL[RESSLABEL.length]='DIAGNOSES'; RESSECT[RESSECT.length]='keyword';

		} else if ('medication'==SINGLECOLUMNAUTO) {
			RESS[RESS.length]=DRStr; RESSLABEL[RESSLABEL.length]='DRUGS'; RESSECT[RESSECT.length]='searchdrug';

		} else if ('procedure'==SINGLECOLUMNAUTO) {
			RESS[RESS.length]=PRStr; RESSLABEL[RESSLABEL.length]='PROCEDURES'; RESSECT[RESSECT.length]='searchproc';

		} else if ('physician'==SINGLECOLUMNAUTO) {
			RESS[RESS.length]=DPRStr; RESSLABEL[RESSLABEL.length]='PHYSICIANS'; RESSECT[RESSECT.length]='searchdoc';
		}
	}

		
	if (aStr==null && DDStr==null && PRStr==null && DRStr==null) {
		THISS.oDiv.innerHTML = "";
		if (THISS.oDiv.style) THISS.oDiv.style.display = "none";
		THISS.showtextfields();
		INONCHANGE--;
		return;
	}


	if (aStr!=null && aStr.length==0 && DDStr!=null && DDStr.length==0 && PRStr!=null && PRStr.length==0 && DRStr!=null && DRStr.length==0) {
		THISS.oDiv.innerHTML = "";
		if (THISS.oDiv.style) THISS.oDiv.style.display = "none";
		THISS.showtextfields();
		INONCHANGE--;

		return;
	}

	
	hideDurations();


	// if a suitable number then show the popup-div
	if (1) {
		// clear the popup-div.
		THISS.oDiv.innerHTML = "";		
		while ( THISS.oDiv.hasChildNodes() )
			THISS.oDiv.removeChild(THISS.oDiv.firstChild);

		//THISS.oDiv.style.width=AUTOCOMPWIDTHLARGE;//'930px';
		if (SINGLECOLUMNAUTO!='') {

			//THISS.oDiv.style.width='260px';
		}

		var TO=document.createElement('table');
		var tbodyObj = document.createElement("TBODY"); TO.appendChild(tbodyObj);
		var trObj = document.createElement("TR"); tbodyObj.appendChild(trObj);


		var WPP='20%';
		var HCC=0;
		for (var p=0;p<RESS.length;p++) {
			aStr=RESS[p];
			if (aStr==null || aStr.length==0 || aStr.length==1) {
				continue;
			}
			HCC++;
		}
		if (HCC>0) {
			WPP=100/HCC;
			WPP=WPP+'%';
		}



		for (var p=0;p<RESS.length;p++) {
			aStr=RESS[p];
			if (aStr==null || aStr.length==0 || aStr.length==1) {
				continue;
			}


			var SECTIONLABEL=RESSLABEL[p];
			var SECTIONTYPE=RESSECT[p];



			var nCount=aStr.length;
	

			var SECTIONTD = document.createElement('td');
			SECTIONTD.style.verticalAlign='top';
			if (p>0) {
				SECTIONTD.style.borderLeft='1px solid #ededed';
				SECTIONTD.style.width=WPP;
			}
			SECTIONTD.style.backgroundColor=RESCOLOR[p];

			var SECTIONDIV = document.createElement('div');

			var SECTIONLABELDIV = document.createElement('div');
			//SECTIONLABELDIV.style.fontFamily='lucida grande, tahoma, verdana, arial, sans-serif';
			SECTIONLABELDIV.className='fbt smTXT';
			SECTIONLABELDIV.style.color='#54747f';
			SECTIONLABELDIV.style.fontSize='11pt';
			
				SECTIONLABELDIV.style.fontSize='12pt';
			
			SECTIONLABELDIV.style.paddingLeft='2px';		
	
			SECTIONLABELDIV.innerHTML=SECTIONLABEL;
			SECTIONDIV.appendChild(SECTIONLABELDIV);



			nCount=aStr.length;
		
	
			//need to sort till 
			var DIRECTMATCHBREAK=-2;

			var FT=txt.charAt(0);
			var ST=txt.charAt(1);

			var SHOWSS=new Array(nCount);
			for (var i=0;i<nCount;i++) {
				SHOWSS[i]=aStr[i];
			}
			nCount=aStr.length;



			var BASEtDiv = document.createElement('div');
			var RPT="<b>"+txt+"</b>";

			var txtRRR=new RegExp(txt,"i");
	
			for (var i = 0; i < nCount; i++ ) {
				if (aStr[i]==null) continue;		
				var tDiv = BASEtDiv.cloneNode(false);//document.createElement('div'); //var tDiv = document.createElement('div');

	
				tDiv.style.fontFamily='"lucida grande", tahoma, verdana, arial, sans-serif';
				tDiv.style.fontSize='10.5pt';	
				
					tDiv.style.fontSize='12pt';	
				
				tDiv.style.paddingLeft='2px';
				tDiv.style.paddingBottom='3px';
				tDiv.style.nowrap='nowrap';
				tDiv.onmousedown = AutoComplete.prototype.onDivMouseDown;
				tDiv.onmouseover = AutoComplete.prototype.onDivMouseOver;
				tDiv.onmouseout = AutoComplete.prototype.onDivMouseOut;
				tDiv.onmousemove = AutoComplete.prototype.onDivMouseMove;
				tDiv.AutoComplete = THISS;


				var SHOW=SHOWSS[i];
				var SHOWBOLD=SHOW;//SHOW.replace(txtRRR,RPT);
		

				tDiv.innerHTML = SHOWBOLD;
				tDiv.title=SHOW;

				tDiv.setAttribute('alt',SECTIONTYPE);
				tDiv.setAttribute('number',i+'');
				if (i==DIRECTMATCHBREAK) {
					tDiv.style.borderBottom='1px solid #aeaeae';
				}
							
				SECTIONDIV.appendChild(tDiv);

			}



			SECTIONTD.appendChild(SECTIONDIV);
			trObj.appendChild(SECTIONTD);


		}

		//if (LATESTTXT!=txt || INONCHANGE>MYONCHANGE) { INONCHANGE--; return; }
		THISS.oDiv.appendChild(TO);


		THISS.oDiv.onmouseover=AutoComplete.prototype.onBMOV;
		THISS.oDiv.onblur=AutoComplete.prototype.onBMOO;
		THISS.oDiv.onfocus=AutoComplete.prototype.onFFOO;
		THISS.oDiv.isautocomplete='true';
		THISS.oDiv.scrollTop=0;
		THISS.activeTDIV=null;
		//need to hide other text fields
		var g=0;
		for (var x=1;x<=5;x++) {
			if (x==THISS.indexName) {
				g=1;
			}			
			if (g==1 && x!=THISS.indexName) {
				var EN='DIVSYM'+x+'VALUE';
				var EE=document.getElementById(EN);
				if (EE!=null) {
					EE.style.visibility="hidden";
				}
			}
		}

		if (THISS.oDiv.style) THISS.oDiv.style.display = "";


	} else {
		THISS.oDiv.innerHTML = "";
		if (THISS.oDiv.style) THISS.oDiv.style.display = "none";
		THISS.showtextfields();
	}

	INONCHANGE--;
	JUSTDREW=txt;
}




function createAutoComplete() {

	
				if (document.getElementById('DIVSYM1VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM1VALUE'), 
						document.getElementById('DIVSYM1VALUECHOICE'), 
						document.getElementById('DIVSYM1VALUECONTAINER'), 
						500,1				
					);
				}
				
				if (document.getElementById('DIVSYM2VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM2VALUE'), 
						document.getElementById('DIVSYM2VALUECHOICE'), 
						document.getElementById('DIVSYM2VALUECONTAINER'), 
						500,2				
					);
				}
				
				if (document.getElementById('DIVSYM3VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM3VALUE'), 
						document.getElementById('DIVSYM3VALUECHOICE'), 
						document.getElementById('DIVSYM3VALUECONTAINER'), 
						500,3				
					);
				}
				
				if (document.getElementById('DIVSYM4VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM4VALUE'), 
						document.getElementById('DIVSYM4VALUECHOICE'), 
						document.getElementById('DIVSYM4VALUECONTAINER'), 
						500,4				
					);
				}
				
				if (document.getElementById('DIVSYM5VALUE')) {

					new AutoComplete(
						matchDiagString,'', 
						document.getElementById('DIVSYM5VALUE'), 
						document.getElementById('DIVSYM5VALUECHOICE'), 
						document.getElementById('DIVSYM5VALUECONTAINER'), 
						500,5				
					);
				}
				
}



function createAutoComplete2() {

	
				if (document.getElementById('DIVSYM1VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM1VALUE'), 
						document.getElementById('DIVSYM1VALUECHOICE'), 
						document.getElementById('DIVSYM1VALUECONTAINER'), 
						500,1,true
					);
				}
				
				if (document.getElementById('DIVSYM2VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM2VALUE'), 
						document.getElementById('DIVSYM2VALUECHOICE'), 
						document.getElementById('DIVSYM2VALUECONTAINER'), 
						500,2,true
					);
				}
				
				if (document.getElementById('DIVSYM3VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM3VALUE'), 
						document.getElementById('DIVSYM3VALUECHOICE'), 
						document.getElementById('DIVSYM3VALUECONTAINER'), 
						500,3,true
					);
				}
				
				if (document.getElementById('DIVSYM4VALUE')) {
					new AutoComplete(
						matchString,'', 
						document.getElementById('DIVSYM4VALUE'), 
						document.getElementById('DIVSYM4VALUECHOICE'), 
						document.getElementById('DIVSYM4VALUECONTAINER'), 
						500,4,true
					);
				}
				
				if (document.getElementById('DIVSYM5VALUE')) {

					new AutoComplete(
						matchDiagString,'', 
						document.getElementById('DIVSYM5VALUE'), 
						document.getElementById('DIVSYM5VALUECHOICE'), 
						document.getElementById('DIVSYM5VALUECONTAINER'), 
						500,5,true			
					);
				}
				
}



function showTESTINFO(n) {
	var E=document.getElementById("TESTINFO");
	if (E!=null) E.innerHTML=n;
}

function sar() {
	document.forms[0].showallresults.value='true';
	document.forms[0].submit();
}

function setEValue(d,v,b) {
	var EE=document.getElementById(d);
	if (EE!=null) {
		if (v!=null) {
			EE.value=v;
		}
		if (b!=null) {
			if ('true'==b) {
				EE.checked=true;
			} else {
				EE.checked=false;
			}
		}
	}
}

function setSYMS(n) {
	if ('male'==n) {
		matchString=matchStringMALE;
		matchStringCOPY=matchStringCOPYMALE;
	} else if ('female'==n) {
		matchString=matchStringFEMALE;
		matchStringCOPY=matchStringCOPYFEMALE;
	} else {
		matchString=matchStringCOPYORIG;
		matchStringCOPY=matchStringCOPYORIG;
		
	}
}

function toggleDISPLAYOFELEMENT(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		if (E.style.display=='none') {
			E.style.display='';
		} else {
			E.style.display='none';
		}
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


function findDim(obj) {

	var CW=''+getStyleO(obj,'width');
	var CH=''+getStyleO(obj,'height');
	
	var OW=obj.offsetWidth;
	var OH=obj.offsetHeight;


	if ('auto'==CH && OH!=null) CH=OH;
	else if ('auto'==CH) CH=50;


	if ('auto'==CW && OW!=null) CW=OW;
	else if ('auto'==CW) CW=50;

	CH=''+CH;
	CW=''+CW;

	//if ('auto'==CH) CH='50';
	//if ('auto'==CW) CW='50';	
	//alert(obj.id+" "+CW+" "+obj.clientWidth+" "+" "+OW+" "+OH);
		
	CH=CH.replace('px','');
	CW=CW.replace('px','');

	return [CW,CH];
}


function toggleDISPLAYOFELEMENTUNDERPARENT(n,pid,tof) {

	var E=document.getElementById(n);	
	var PD=document.getElementById(pid);
	if (E!=null && PD!=null) {
		var pp=findPos(PD);
		E.style.position='absolute';
		E.style.left=pp[0]+'px';	
					
		E.style.top=(pp[1]+tof)+'px';				
	}

	toggleDISPLAYOFELEMENT(n);

}


function toggleDISPLAYOFELEMENTUNDERPARENTAA(n,pid,tof,lo,to) {
	var E=document.getElementById(n);	
	var PD=document.getElementById(pid);	
	if (E!=null && PD!=null) {
		var pp=findPos(PD);
		E.style.position='absolute';
		E.style.left=(pp[0]-lo)+'px';				
		E.style.top=(pp[1]+tof-to)+'px';				
	}

	toggleDISPLAYOFELEMENT(n);

}



function toggleDISPLAYOFELEMENTUNDERPARENTAARR(n,pid,tof,lo,to) {
	toggleDISPLAYOFELEMENT(n);
	var E=document.getElementById(n);	
	var PD=document.getElementById(pid);	
	if (E!=null && PD!=null) {
		var pp=findPos(PD);
		var dd=findDim(E);
		E.style.position='absolute';
		var rr=pp[0]-lo-dd[0];
		E.style.left=(pp[0]-lo-dd[0])+'px';				
		E.style.top=(pp[1]+tof-to)+'px';				
		//alert(E.style.right+"  "+E.style.top);
	}



}



function toggleDISPLAYOFELEMENTSMART(n,pid) {
	toggleDISPLAYOFELEMENT(n);
	var E=document.getElementById(n);	
	var PD=document.getElementById(pid);	
	if (E!=null && PD!=null) {
		var pp=findPos(PD);
		var dd=findDim(E);

		E.style.position='absolute';

		var SH=screen.height;//document.body.parentNode.scrollHeight;;
		var SW=screen.width;//document.body.parentNode.scrollWidth;;
		SH=(typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
		SW=(typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);

		var SCL=document.body.scrollLeft;
		var SCT=document.body.scrollTop;

		var RCX=cX-SCL;
		var RCY=cY-SCT;




		var LR=RCX/SW;
		var TB=RCY/SH;


		if (LR<.5 && TB<.5) {
			E.style.left=(cX+10)+'px';
			E.style.top=(cY+20)+'px';	

		} else if (LR<.5 && TB>=.5) {
			
			E.style.left=(cX+10)+'px';
			E.style.top=(cY-dd[1]-10)+'px';	

		} else if (LR>=.5 && TB<.5) {
			E.style.left=(cX-dd[0]-10)+'px';
			E.style.top=(cY+20)+'px';	

		} else if (LR>=.5 && TB>=.5) {
			E.style.left=(cX-dd[0])+'px';
			E.style.top=(cY-dd[1]+5)+'px';	

		}



		



	}



}


function toggleDISPLAYOFELEMENTUNDERPARENTRIGHT(n,pid,tof) {
	var E=document.getElementById(n);	
	var PD=document.getElementById(pid);	
	if (E!=null && PD!=null) {
		var pp=findPos(PD);
		E.style.right=pp[0]+'px';				
		E.style.top=(pp[1]+tof)+'px';				
		//E.style.display='';
	}
	toggleDISPLAYOFELEMENT(n);

}



	function updateprop(user,dt,coll,id,p,v,bid) {
		var r='/updateprop.jsp?uuu='+escape(user)+'&datatype='+escape(dt)+'&collection='+escape(coll)+'&id='+escape(id)+'&prop='+escape(p)+'&value='+escape(v);
		doAjaxQ(r);
		var E=document.getElementById(bid+'status');
		if (E!=null) {
			E.innerHTML='Updated';
		}

	}


				function hideInfo(n) {
					var E=document.getElementById("INFO"+n);
					if (E!=null) E.style.display='none';
				}


				function hideInfoCENTER(n) {
					LIGHTENPAGE();
					var E=document.getElementById("INFO"+n);
					if (E!=null) E.style.display='none';
				}

				var openInfoBoxs=new Array();

				function showInfo(n) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {

						var NL=cX;
						if (cX>500) {
							NL=cX-500;
						} else {
							NL=cX-30;

						}
						if (NL<20) NL=20;
						if (NL>1000) NL=500;
						
						E.style.left=(NL)+'px';

						E.style.top=(cY+20)+'px';
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
					}
				}



				function hideAllInfo() {
					for (var i=0;i<openInfoBoxs.length;i++) {
						var E=openInfoBoxs[i];
						if (E!=null) {
							E.style.display='none';
						}
					}
					openInfoBoxs=new Array();
				}




				function showInfo2(n) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {

						E.style.left=(20)+'px';
						E.style.top=(cY+5)+'px';
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
					}
				}


				function showInfoWITHPOS(n,e,lr) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {

						var pp=findPos(e);
						var dd=findDim(e);

						var Epp=findPos(E);
						var Edd=findDim(E);

						//alert(pp+" "+dd+" || "+Epp+" "+Edd);

						if ('r'==lr) {
							E.style.left= ((pp[0]+dd[0]*1)-Edd[0]*1)+'px';
							//E.style.top= (pp[1]*1+dd[1]*1)+'px';
							E.style.top= (pp[1]*1+10)+'px';
						} else {
							E.style.left= (pp[0]*1)+'px';
							E.style.top= (pp[1]*1+10)+'px';

						}
						//alert(pp+" "+E.style.left+" "+E.style.top);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
					}
				}

				function showInfoCENTER(n) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						//DARKENPAGE();
						centerOBJ("INFO"+n);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
						scroll(0,0);
					}
				}

				function showInfoCENTERDY(n,fr,jsp) {
					hideAllInfo();					
					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						var FRR=document.getElementById(fr);
						if (FRR!=null) {
							FRR.src=jsp;
						}

						//DARKENPAGE();
						centerOBJ("INFO"+n);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
						scroll(0,0);
					}
				}


				function showInfoBottom(n) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						//DARKENPAGE();
						bottomOBJ("INFO"+n);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
						scroll(0,0);
					}
				}

				function showInfoCENTER2(n,tt) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						//DARKENPAGE();
						centerOBJ2("INFO"+n,tt);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
						scroll(0,0);
					}
				}



				function showInfoCENTER2DY(n,tt,fr,jsp) {
					hideAllInfo();
					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						var FRR=document.getElementById(fr);
						if (FRR!=null) {
							FRR.src=jsp;
						}

						//DARKENPAGE();
						centerOBJ2("INFO"+n,tt);
						E.style.display='';
						openInfoBoxs[openInfoBoxs.length]=E;
						scroll(0,0);
					}
				}

											function showrefi() {
												for (var i=0;i<20;i++) {
													var nn='refi'+i;
													var E=document.getElementById(nn);
													if (E!=null) E.style.display='';
												}
												if (1) {
													var E=document.getElementById('refiSHOW');
													if (E!=null) E.style.display='none';
												}

												if (1) {
													var E=document.getElementById('refiHIDE');
													if (E!=null) E.style.display='';
												}
											}

											function hiderefi() {
												for (var i=2;i<20;i++) {
													var nn='refi'+i;
													var E=document.getElementById(nn);
													if (E!=null) E.style.display='none';
												}
												if (1) {
													var E=document.getElementById('refiSHOW');
													if (E!=null) E.style.display='';
												}

												if (1) {
													var E=document.getElementById('refiHIDE');
													if (E!=null) E.style.display='none';
												}
											}





	function doAjaxQ(url) {

		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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 = processReqChange;
			req.open("GET", url, true);
			req.send("");
		}
	}



	function doAjaxQAS(url) {

		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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 = processReqChange;
			//req.open("GET", url, true);
			//req.send("");

								if (url.length>500) {
									var pp=url.indexOf('?');
									var para=url.substring(pp+1);
									var uuu=url.substring(0,pp);
									//alert(para+"\n\n"+uuu+"\n\n"+ASASTRYURL);
									req.open("POST", uuu, true);
//Send the proper header information along with the request
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", para.length);
req.setRequestHeader("Connection", "close");
									req.send(para);

								} else {
									req.open("GET", url, true);
									req.send(null);
								}

		}
	}





							var isIE = document.all?true:false;

							var cX = 0; var cY = 0;
							function UpdateCursorPosition(e){ 
								if (isIE) {									
									cX = window.event.x+ document.body.scrollLeft; 
									cY = window.event.y+ document.body.scrollTop;
								} else {
									cX = e.pageX; cY = e.pageY;
								}
							}
							function UpdateCursorPositionDocAll(e){ 
								if (isIE) {									
									cX = window.event.x+ document.body.scrollLeft; 
									cY = window.event.y+ document.body.scrollTop;
								} else {
									cX = e.pageX; cY = e.pageY;
								}
								//cX = event.clientX; cY = event.clientY;
							}
							if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
							else { document.onmousemove = UpdateCursorPosition; }

							var activeDIV='';
							var activeDIVSS=new Array();

							function toggleDiv(d) {
								var E=document.getElementById(d);
								if (E!=null) {

									if (E.style.display=='none') {

										E.style.left=(cX-10)+'px';
										E.style.top=(cY-10)+'px';
										E.style.right=(cX+100)+'px';
										E.style.bottom=(cY+200)+'px';

										E.style.display='block';
										activeDIV=d;
										activeDIVSS[activeDIVSS.length]=d;
									} else {
										E.style.display='none';
									}
								}	
							} 

							function hideActiveDiv() {
								hideDiv(activeDIV);
								for (var i=0;i<activeDIVSS.length;i++) {
									hideDiv(activeDIVSS[i]);
								}
							}

							function hideDiv(d) {
								var E=document.getElementById(d);
								if (E!=null) {
										E.style.display='none';

								}	
							} 


							function showDiv(d) {
								var E=document.getElementById(d);
								if (E!=null) {
									E.style.display='';

								}	
							} 


							function showHEAD() {
								var E=document.getElementById('malehead');
								if (E!=null) {
									E.style.display='';
								}
							}
							function hideHEAD() {
								var E=document.getElementById('malehead');
								if (E!=null) {
									E.style.display='none';
								}

							}

							function setNextSymptom(c,v) {
								var done=0;
								for (var i=1;i<=4;i++) {
									var SN='DIVSYM'+i+'VALUE';
									var E=document.getElementById(SN);
									if (E!=null) {
										//alert(i+" "+E.value);
										//if (CURRENTSECTIONC!='' || E.value=='' || E.value=='' || E.value=='type another symptom (optional)') {
										if (E.value=='' || E.value=='' || E.value=='type another symptom (optional)') {

											showThisSymptomRow(i);
											setRIGHTTYPE(v);
											if (SINGLECOLUMNAUTO!='') {
												var PV=E.value+'';
												PV=trim22(PV);
												if (PV.length>0) PV+=', ';
												if (PV.indexOf(v+',')<0) {
													E.value=PV+v;
												}
											} else {
												E.value=v;
											}
											E.style.color='#000000';
											done=1;
										}  else {
											if (SINGLECOLUMNAUTO!='') {
												var PV=E.value+'';
												PV=trim22(PV);
												if (PV.length>0) PV+=', ';
												if (PV.indexOf(v+',')<0) {
													E.value=PV+v;
												}
											}

										}
										/*
										if (false && CURRENTSECTIONC!='') {
											if (i==1 && E.value.length>0) {

												//must be symptom
												E.value=v;
												done=1;
												//alert(i+" "+v+" "+E.value);
												//if (matchStringMALE.indexOf(E.value)<0 && matchStringFEMALE.indexOf(E.value)<0) {
												//}
									
											}
										}
										*/
									}
									if (done==1) break;
								}
								hideActiveDiv();

								showNextSymptomRow();
							}


							function setNextSymptomAndDur(v) {
								var done=0;

								for (var i=1;i<=4;i++) {
									var SN='DIVSYM'+i+'VALUE';
	
									var E=document.getElementById(SN);
									if (E!=null) {

										if (E.value=='' || E.value=='' || E.value=='type another symptom (optional)') {
											if (i>1) {
												showThisSymptomRow(i);
												E.value=v;
												var C=document.getElementById('SYMPTOMDUR'+(i-1));
												var D=document.getElementById('SYMPTOMDUR'+i);
												if (C!=null && D!=null) {
													if (C.selectedIndex!=0) {
														D.selectedIndex=C.selectedIndex;
														E.style.backgroundColor='#efefff';
														done=1;
													}
												}
											}
										}
									}
									if (done==1) break;
								}
								hideActiveDiv();
								showNextSymptomRow();
							}

							function clearNotSymptom(v) {
								for (var i=1;i<=4;i++) {
									var SN='NOTDIVSYM'+i+'VALUE';
	
									var E=document.getElementById(SN);
									if (E!=null) {
										if (E.value==v) {
											E.value='';
											break;
										}
									}
								}
							}

							function setNextNotSymptom(v) {

								var done=0;

								for (var i=1;i<=4;i++) {
									var SN='NOTDIVSYM'+i+'VALUE';
	
									var E=document.getElementById(SN);
									if (E!=null) {
										if (E.value=='') {
											E.value=v;									
											done=1;
										}
									}
									if (done==1) break;
								}
								hideActiveDiv();
							}


							function doDiagmatixSearch() {

							}

											function showSearchEditPictoral() {
												var E=document.getElementById("issearch");
												if (E!=null) {
													E.value=false;
													var F=document.getElementById("section");
													if (F!=null) F.value='';
													document.forms[0].submit();
												}
											}

										
										var NS4=(document.layers) ? true: false;
										function checkLoginEnter(event,ff) {

											var code=0;
	

											if (NS4) {
												code=event.which;
											} else {
												code=event.keyCode;
											}

											if (code==13) {
												
												return fplogin();
												
											}
										}


										function fplogin() {
											var E=document.getElementById('uuname');
											var F=document.getElementById('pppass');
											if (E!=null && F!=null) {
												
												var r='https://www.medgle.com/js.jsp?issearch=true&section=mymedgle&uname='+escape(E.value)+'&pass='+escape(F.value)+'&action=dologin&task=dologin&prevurl=language%3Denglish';
												window.location=r;
											}
										}
										





// this function puts the dark screen over the entire page
function DARKENPAGE()
{
    var page_screen = document.getElementById('page_screen');
    if (page_screen!=null) {
    page_screen.style.height = document.body.parentNode.scrollHeight + 'px';
    page_screen.style.display = 'block';
    }
}

// this function removes the dark screen and the page is light again
function LIGHTENPAGE()
{
    var page_screen = document.getElementById('page_screen');
    if (page_screen!=null) {
    page_screen.style.display = 'none';
    }
}


function centerOBJ(n) {

	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);
		//var CW=window.getComputedStyle(E,"").getPropertyValue("width");
		//var CH=window.getComputedStyle(E,"").getPropertyValue("height");

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");
		
		if ('auto'==CH) CH='500';
		if ('auto'==CW) CW='500';
		
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =document.body.parentNode.scrollHeight+'';
		var PW =document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH/2;
		CW=CW/2;

		PH=PH/2;
		PW=PW/2;

		var L=PW-CW;
		var T=PH-CH;
	
		if (L<0) L=100;
		if (T<0) T=100;
		
		if ((''+T)=='NaN') T='100';
		E.style.left=L+'px';

		E.style.top=T+'px';


		//E.style.left='0px';
		//E.style.top='0px';

		
		//alert(CW+" "+CH+" "+PH+" "+PW+" :: "+L+" "+T);		
	}
	

}




function centerOBJ2(n,tt) {

	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);
		//var CW=window.getComputedStyle(E,"").getPropertyValue("width");
		//var CH=window.getComputedStyle(E,"").getPropertyValue("height");

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");

		if ('auto'==CH) CH=window.innerWidth;//'500';
		if ('auto'==CW) CW=window.innerHeight;//'500';
		CW=''+CW;
		CH=''+CH;
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =''+window.innerHeight; //document.body.parentNode.scrollHeight+'';
		var PW =''+window.innerWidth; //document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH/2;
		CW=CW/2;

		PH=PH/2;
		PW=PW/2;

		//alert(CW+" "+CH+" :: "+PW+" "+PH);		

		var L=PW-CW;
		var T=PH-CH+tt;

		if (L<0) L=10;
		if (T<0) T=30;
		
		E.style.left=L+'px';
		E.style.top=T+'px';
		//E.style.top='70px';
			


		//E.style.left='0px';
		//E.style.top='0px';

		
		//alert(CW+" "+CH+" "+PH+" "+PW+" :: "+L+" "+T);		
	}
	
}



function bottomOBJ(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);
		//var CW=window.getComputedStyle(E,"").getPropertyValue("width");
		//var CH=window.getComputedStyle(E,"").getPropertyValue("height");

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");
		
		if ('auto'==CH) CH='500';
		if ('auto'==CW) CW='500';
		
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =document.body.parentNode.scrollHeight+'';
		var PW =document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH;
		CW=CW/2;

		PH=PH;
		PW=PW/2;

		var L=PW-CW;
		var T=PH-CH;
		
		//alert(PH+"   "+CH+" ::: "+L+" "+T);		


		if (L<0) L=100;
		if (T<0) T=100;

		E.style.left=L+'px';
		E.style.top=T+'px';


		//E.style.left='0px';
		//E.style.top='0px';

		
		//alert(CW+" "+CH+" "+PH+" "+PW+" :: "+L+" "+T);		
	}
	

}






function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


function getStyleO(x,styleProp) {
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}




											function showFILTERROW(base) {
												var i=0;
												for (i=0;i<100;i++) {
													var N=base+i;
													var E=document.getElementById(N);
													if (E!=null) {
														E.style.display='';
													}
												}

												if (1) {
													var E=document.getElementById(base+'show');
													if (E!=null) {
														E.style.display='none';
													}
												}
												if (1) {
													var E=document.getElementById(base+'hide');
													if (E!=null) {
														E.style.display='';
													}
												}
											}

											function hideFILTERROW(base,c) {
												var i=0;
												for (i=0;i<100;i++) {
													if (i<=c) continue;
													var N=base+i;
													var E=document.getElementById(N);
													if (E!=null) {
														E.style.display='none';
													}
												}
												if (1) {
													var E=document.getElementById(base+'show');
													if (E!=null) {
														E.style.display='';
													}
												}
												if (1) {
													var E=document.getElementById(base+'hide');
													if (E!=null) {
														E.style.display='none';
													}
												}
											}



										function modANSearch() {
											if (1) {
												var T=1;
												var X=document.getElementsByName("nnsym");
												if (X!=null && X.length>0) {
													for (var i=0;i<X.length;i++) {
														var A=X[i];
														if (A.checked==true) {
															var Y=A.value;
															var Z='NOTDIVSYM'+T+'VALUE';
															//alert(Z);
															var F=document.getElementById(Z);
															if (F!=null) {
																F.value=Y;
																A.checked=false;
																//alert("NOT "+T+" = "+F.value);
																T++;
															}
														}
														if (T>4) break;
													}
													for (var i=T;i<=4;i++) {
														var F=document.getElementById('NOTDIVSYM'+i+'VALUE');
														if (F!=null) {
															F.value='';
	
														}	
													}
												}

											}

											if (1) {
												var T=1;
												var X=document.getElementsByName("aasym");
												if (X!=null && X.length>0) {
													for (var i=0;i<X.length;i++) {
														var A=X[i];
														if (A.checked==true) {
															var Y=A.value;
															var F=document.getElementById('DIVSYM'+T+'VALUE');
															if (F!=null) {
																F.value=Y;
																//alert(F.value);
																var IDVV=''+A.id;
																if (IDVV.length>0) {
																	A.checked=false;
																}
																//alert("G "+T+" = "+F.value);
																T++;
															}

														}
														if (T>4) break;
													}

													for (var i=T;i<=4;i++) {
														var F=document.getElementById('DIVSYM'+i+'VALUE');
														if (F!=null) {
															F.value='';
	
														}
	
													}
												}

											}

										}



	var HTTPREQUEST=false;
	var FETCHDISPLAY='';
	function fetchurl(url,DE) {
		FETCHDISPLAY=DE;
		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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) {	
			HTTPREQUEST=req;	
			req.onreadystatechange = fetchurlDISP;
			req.open("GET", url, true);
			req.send("");

			var E=document.getElementById(FETCHDISPLAY);
			if (E!=null) {
				var R='<div class="FW" style="padding-top: 100px;"><center><img border="0" src="30-1.gif"></center></div>';
				E.innerHTML=R;
			}

		}
	}

	function fetchurlDISP() {

		if (HTTPREQUEST.readyState == 4) {
			if (HTTPREQUEST.status == 200) {
				var E=document.getElementById(FETCHDISPLAY);

				if (E!=null) {

					if (FETCHDISPLAY.indexOf('MODAL')>=0) {

						var R=HTTPREQUEST.responseText;
						R='<div id="HPROFILEDIVVRR" class="ORANGEBACKCOLOR pdT5 pdB5 pdL5 PDR5  innerbox  smTXT" style="text-align: left;"><div class="FW" style="background-color: #ffffff">'+R+'</div></div>';
						E.innerHTML=R;
					} else {
						var R=HTTPREQUEST.responseText;
						E.innerHTML=R;
					}
				}

			}
		}
	}

												function SDSET() {
													var E=document.getElementById("NRDUR");
													if (E!=undefined && E!=null) {
														var V=E.selectedIndex;
														
														for (var i=1;i<=4;i++) {
															var SN='DIVSYM'+i+'VALUE';
															var F=document.getElementById(SN);
															if (F!=undefined && F!=null) {
																if (F.value!='') {
																	var DSN='SYMPTOMDUR'+i;
																	var G=document.getElementById(DSN);
																	if (G!=null) {
																		G.selectedIndex=V;
																	}
																}
															}
														}
													}
												}


												function SETALLDURA(V) {
													for (var i=1;i<=4;i++) {
														var SN='DIVSYM'+i+'VALUE';
														var F=document.getElementById(SN);
														if (F!=undefined && F!=null) {
															if (F.value!='') {
																var DSN='SYMPTOMDUR'+i;
																var G=document.getElementById(DSN);
																if (G!=null) {
																	G.selectedIndex=V;
																}
															}
														}
													}

												}



		function displayHeightEdit() {
			var D=document.getElementById("EDITHEIGHT");
			D.style.display='';
		}

		function calcHAndClose() {
			var E=document.getElementById("height");
			var F=document.getElementById("heightDISPLAY");

			var cm=document.getElementById("cm").value;
			var feet=document.getElementById("feet").value;
			var inches=document.getElementById("inches").value;


	
			cm=trim(cm);
			feet=trim(feet);
			inches=trim(inches);
		
			if (cm.length==0) {
				feet=parseInt(feet);
				inches=parseInt(inches);

				var X=feet*30.48+inches*2.54;
				X=0.01*parseInt(X*100);

				cm=parseFloat(feet)*12.0 + parseFloat(inches);
				cm*=2.54;
				if ((''+X)=='NaN') { 
					F.innerHTML='';
					E.value='';
				} else {
					var cmcc=''+X;
					if (cmcc.indexOf('.')>0) cmcc=cmcc.substring(0,cmcc.indexOf('.'));

					F.innerHTML=cmcc+"cm&nbsp;&nbsp;("+feet+"'"+inches+'")';
					E.value=X;
				}

			} else {
				cm=0.01*parseInt(cm*100);
				var totalIN=parseFloat(cm)*0.39;
				feet=parseInt(totalIN/12);
				inches=parseInt(totalIN%12);
				if ((''+cm)=='NaN') { 
					F.innerHTML='';
					E.value='';
				} else {
					var cmcc=''+cm;
					if (cmcc.indexOf('.')>0) cmcc=cmcc.substring(0,cmcc.indexOf('.'));

					F.innerHTML=cmcc+"cm&nbsp;&nbsp;("+feet+"'"+inches+'")';
					E.value=cm;
				}
				
			}
			cm=0.01*parseInt(cm*100);
			feet=parseInt(feet);
			inches=parseInt(inches);
			

			var D=document.getElementById("EDITHEIGHT");
			D.style.display='none';

		}


		function displayWeightEdit() {
			var D=document.getElementById("EDITWEIGHT");
			D.style.display='';
		}

		function calcWAndClose() {
			var E=document.getElementById("weight");
			var F=document.getElementById("weightDISPLAY");

			var kg=document.getElementById("kg").value;
			var pounds=document.getElementById("pounds").value;


			kg=trim(kg);
			pounds=trim(pounds);
		
			if (kg.length==0) {
				var X=pounds*0.45359;
				var kgcc=''+X;
				if (kgcc.indexOf('.')>0) kgcc=kgcc.substring(0,kgcc.indexOf('.'));
				F.innerHTML=kgcc+"kg";
				E.value=X;
			} else {
				var kgcc=''+kg;
				if (kgcc.indexOf('.')>0) kgcc=kgcc.substring(0,kgcc.indexOf('.'));
				F.innerHTML=kg+"kg";
				E.value=kg;
			}

			var D=document.getElementById("EDITWEIGHT");
			D.style.display='none';

		}


		function goTOO(u) {
			alert(u);
			//window.location=u;
		}

		function goTOOA(u,a,p) {
			var r=u+'&'+a+'='+escape(p);
			window.location=r;
		}


											function addlife(l) {
												var II='REF'+l;
												var EE=document.getElementById(II);
		
												if (EE!=null) {
													EE.checked=true;
													nsverify();											
												}
											}


											function addsymm(l) {
												var II='SELSYMLINK'+l;
												var EE=document.getElementById(II);
												if (EE!=null) {
													EE.checked=true;
													nsverify();											
												}
											}
								function nsverify() {
									modANSearch();
									verify();
								}
			
		
			function displayTrans(d,m,lg) {
			}
			function displayTransDiv(d,lg) {
			}
		



	function submitRankMove() {
		var d=document.getElementById('rankdd').value;
		var upd=document.getElementById('rankdir').value;
		vote(unescape(d),'symptom',upd,'','','');		
		hideRCD();
	}
	function hideRCD() {
		var R=document.getElementById('RANKCOMMENTDIV');
		if (R!=null) {
			R.style.display='none';
		}
	}
	function urank(upd,t,d) {
		document.getElementById('rankdd').value=d;
		document.getElementById('rankdir').value=upd;		
		document.getElementById('rankcomment').value='';
		toggleDISPLAYOFELEMENTUNDERPARENTAA('RANKCOMMENTDIV',t,0,0,0);		
		var RD=document.getElementById('RANKDIRECTION');
		if (RD!=null) {
			if ('Up'==upd) RD.innerHTML='Suggest move rank of '+unescape(d)+' "UP" for search';
			if ('Down'==upd) RD.innerHTML='Suggest move rank of '+unescape(d)+' "DOWN" for search ';
		}

		//need to construct query to pass for dirvote

	}


								function drawSensitivity(AS,DS,too) {
									  // Create and populate the data table.
									  var data = new google.visualization.DataTable();
									  data.addColumn('string', 'Label');
									  data.addColumn('number', 'Value');
									  data.addRows(2);
									  data.setValue(0, 0, 'Age');
									  data.setValue(0, 1, AS);
									  data.setValue(1, 0, 'Duration');
									  data.setValue(1, 1, DS);

									  var chart = new google.visualization.Gauge(document.getElementById(too));
									  var options = {width: 200, height: 100, redFrom: 90, redTo: 100,yellowFrom:75, yellowTo: 90, minorTicks: 5,axisFontSize: 7};
									  chart.draw(data, options);
								}


var mapTEXTSIZE=["vsmTXT","bsmTXT","smTXT","asmTXT","msTXT","mmTXT","blmTXT","lmTXT"];
function increaseFontSize() {
	for (var j=0;j<mapTEXTSIZE.length;j++) {
		var S=getCSSRule('.'+mapTEXTSIZE[j]);
		if (S!=null) {
			var ss=S.style.fontSize;
			if (ss.indexOf('pt')>0) {
				ss=parseInt(ss.replace('pt',''));
				ss++;
				S.style.fontSize=ss+'pt';
			}
		}
	}


}
function decreaseFontSize() {

	for (var j=0;j<mapTEXTSIZE.length;j++) {
		var S=getCSSRule('.'+mapTEXTSIZE[j]);
		if (S!=null) {
			var ss=S.style.fontSize;
			if (ss.indexOf('pt')>0) {
				ss=parseInt(ss.replace('pt',''));
				ss--;
				S.style.fontSize=ss+'pt';
			}
		}
	}


}



					function highslide(n) {
						var cc=''+n.style.backgroundColor;

						if (n.style.backgroundColor!='#0077aa' && cc!='rgb(37, 143, 173)') {
							n.style.backgroundColor='#29A1C2';
						}
					}

					function unhighslide(n) {
						var cc=''+n.style.backgroundColor;
						if (n.style.backgroundColor!='#0077aa' && cc!='rgb(37, 143, 173)') {
							//n.style.backgroundColor='#ffffff';
							n.style.backgroundColor='transparent';
						}
					}
					
					function showslide(n) {
						
						if (n=='1') {
							if (CURRENTSECTIONC!='') {
								for (var i=1;i<=4;i++) {
									var SN='DIVSYM'+i+'VALUE';
									var E=document.getElementById(SN);
									if (E!=null) {
										E.value='';
									}
								}
							}
							CURRENTSECTIONC='';
						} else if (n=='2') {
							CURRENTSECTIONC='keyword';
							

							var E=document.getElementById('diagguimedgle');
							if (E!=null) E.src="diagimages/diagguimedgle.jpg";

						} else if (n=='3') {
							CURRENTSECTIONC='searchdrug';


							var E=document.getElementById('drugguimedgle');
							if (E!=null) E.src="diagimages/diagguimedgle.jpg";

						} else if (n=='4') {
							CURRENTSECTIONC='searchproc';

							var E=document.getElementById('procguimedgle');
							if (E!=null) E.src="procimages/procguimedgle.jpg";

						} else if (n=='5') {
							CURRENTSECTIONC='searchdoc';

							var E=document.getElementById('docguimedgle');
							if (E!=null) E.src="doccimages/docguimedgle.jpg";


						}

					

						for (var i=1;i<10;i++) {
							var E=document.getElementById('SLIDE'+i);
							if (E!=null) E.style.display='none';

							var F=document.getElementById('SLIDETAB'+i);
							if (F!=null) F.className='opaque';

							var G=document.getElementById('SLIDETD'+i);
							//if (G!=null) G.style.backgroundColor='#ffffff';
							//if (G!=null) G.style.backgroundColor='transparent';
							if (G!=null) G.style.display='none';

							var H=document.getElementById('SLIDETD'+i+'TEXTDIV');
							if (H!=null) H.style.display='none';

							var Y=document.getElementById('SLIDETD'+i+'AAA');
							//if (Y!=null) Y.style.color='#767676';
							if (Y!=null) Y.style.color='#acacac';
							if (Y!=null) Y.style.fontStyle='';
							if (Y!=null) {
								var YI=Y.innerHTML;
								var QE=YI.charCodeAt(0);
								//if (QE==187) { 
								if (QE==8226) {
									YI=YI.substring(1);
									YI=trim22(YI);
								}
								Y.innerHTML=YI;

							}

						}
						var E=document.getElementById('SLIDE'+n);
						if (E!=null) E.style.display='';
						var F=document.getElementById('SLIDETAB'+n);
						if (F!=null) F.className='';	

						var G=document.getElementById('SLIDETD'+n);
						//if (G!=null) G.style.backgroundColor='#a4c4cf';
						if (G!=null) G.style.backgroundColor='#0077aa';
						//if (G!=null) G.style.background='#ff9d00 url(elctrophor3.png) bottom no-repeat';
						//if (G!=null) G.style.background='#005577 url(elctrophor4.png) bottom no-repeat';
						//if (G!=null) G.style.display='';
						if (G!=null) G.style.display='';

						var H=document.getElementById('SLIDETD'+n+'TEXTDIV');
						if (H!=null) H.style.display='';

						var Y=document.getElementById('SLIDETD'+n+'AAA');
						if (Y!=null) Y.style.color='#3366AA';
						//if (Y!=null) Y.style.fontStyle='italic';

							if (Y!=null) {
								var YI=Y.innerHTML;
								//YI="&#187; "+YI;
								//YI="&#8226; "+YI;
								Y.innerHTML=YI;
							}



					}























function getCSSRule(ruleName, deleteFlag) {               // Return requested style obejct
   ruleName=ruleName.toLowerCase();                       // Convert test string to lower case.
   if (document.styleSheets) {                            // If browser can play with stylesheets
      for (var i=0; i<document.styleSheets.length; i++) { // For each stylesheet
         var styleSheet=document.styleSheets[i];          // Get the current Stylesheet
         var ii=0;                                        // Initialize subCounter.
         var cssRule=false;                               // Initialize cssRule. 
         do {                                             // For each rule in stylesheet
            if (styleSheet.cssRules) {                    // Browser uses cssRules?
               cssRule = styleSheet.cssRules[ii];         // Yes --Mozilla Style
            } else {                                      // Browser usses rules?
               cssRule = styleSheet.rules[ii];            // Yes IE style. 
            }                                             // End IE check.
            if (cssRule)  {                               // If we found a rule...
               if (cssRule.selectorText.toLowerCase()==ruleName) { //  match ruleName?
                  if (deleteFlag=='delete') {             // Yes.  Are we deleteing?
                     if (styleSheet.cssRules) {           // Yes, deleting...
                        styleSheet.deleteRule(ii);        // Delete rule, Moz Style
                     } else {                             // Still deleting.
                        styleSheet.removeRule(ii);        // Delete rule IE style.
                     }                                    // End IE check.
                     return true;                         // return true, class deleted.
                  } else {                                // found and not deleting.
                     return cssRule;                      // return the style object.
                  }                                       // End delete Check
               }                                          // End found rule name
            }                                             // end found cssRule
            ii++;                                         // Increment sub-counter
         } while (cssRule)                                // end While loop
      }                                                   // end For loop
   }                                                      // end styleSheet ability check
   return false;                                          // we found NOTHING!
}                                                         // end getCSSRule 

function killCSSRule(ruleName) {                          // Delete a CSS rule   
   return getCSSRule(ruleName,'delete');                  // just call getCSSRule w/delete flag.
}                                                         // end killCSSRule

function addCSSRule(ruleName) {                           // Create a new css rule
   if (document.styleSheets) {                            // Can browser do styleSheets?
      if (!getCSSRule(ruleName)) {                        // if rule doesn't exist...
         if (document.styleSheets[0].addRule) {           // Browser is IE?
            document.styleSheets[0].addRule(ruleName, null,0);      // Yes, add IE style
         } else {                                         // Browser is IE?
            document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style.
         }                                                // End browser check
      }                                                   // End already exist check.
   }                                                      // End browser ability check.
   return getCSSRule(ruleName);                           // return rule we just created.
} 


function clear(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		E.value='';
	}
}


function clearMO(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		var T=E.value;
		var pp=T.lastIndexOf(',');
		if (T.length>1 && pp>0) {
			if (pp=T.length-1) {
				T=T.substring(0,T.length-1);
				T=trim22(T);
			}
			pp=T.lastIndexOf(',');
			if (pp>0 && (pp+1)<T.length) {
				T=T.substring(0,pp+1);
			}
		}
		E.value=T;
	}
}

function toggleDISPLAYOFELEMENT(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		if (E.style.display=='none') {
			E.style.display='';
		} else {
			E.style.display='none';
		}
	}
}

	function setINNER(n,v) {
		var E=document.getElementById(n);
		if (E!=null) {
			E.innerHTML=v;
		}
	}



function getAllFormElements( parent_node ) {
	if( parent_node == undefined ) {
		parent_node = document;
		if (document.getElementById('HMEFORM')!=null) {
			parent_node = document.getElementById('HMEFORM');
		}
	}
	var out = new Array();
	var formInputs = parent_node.getElementsByTagName("input");
	for (var i = 0; i < formInputs.length; i++)
		out.push( formInputs.item(i) );

	formInputs = parent_node.getElementsByTagName("textarea");
	for (var i = 0; i < formInputs.length; i++)
		out.push( formInputs.item(i) );

	formInputs = parent_node.getElementsByTagName("select");
	for (var i = 0; i < formInputs.length; i++)
		out.push( formInputs.item(i) );

	formInputs = parent_node.getElementsByTagName("button");
	for (var i = 0; i < formInputs.length; i++)
		out.push( formInputs.item(i) );
	
	return out;
}


function getDataURL(rp,rv) {
	var parent_node = document;
	if (document.getElementById('HMEFORM')!=null) {
		parent_node = document.getElementById('HMEFORM');
	}

	var URL='';

	var formInputs = parent_node.getElementsByTagName("input");
	for (var i = 0; i < formInputs.length; i++) {
		var E=formInputs.item(i);
		if ((''+E.name).indexOf('query')>=0) continue;
		if (rp!=undefined && rp!=null && E.name==rp) {
			if (URL.length>0) URL+='&';
			URL+=E.name+'='+escape(rv);			
		} else {
			if (E.type=='checkbox') {
				if (E.checked==true) {
					if (URL.length>0) URL+='&';
					URL+=E.name+'='+escape(E.value);
				}
			} else if (E.type=='radio') {
				if (E.checked==true) {
					if (URL.length>0) URL+='&';
					URL+=E.name+'='+escape(E.value);
				}
			} else {
				if (URL.length>0) URL+='&';
				URL+=E.name+'='+escape(E.value);
			}

		}
	}

	formInputs = parent_node.getElementsByTagName("textarea");
	for (var i = 0; i < formInputs.length; i++) {
		var E=formInputs.item(i);
		if ((''+E.name).indexOf('query')>=0) continue;
		if (rp!=undefined && rp!=null && E.name==rp) {
			if (URL.length>0) URL+='&';
			URL+=E.name+'='+escape(rv);			
		} else {
			if (URL.length>0) URL+='&';
			URL+=E.name+'='+escape(E.value);
		}
	}

	formInputs = parent_node.getElementsByTagName("select");
	for (var i = 0; i < formInputs.length; i++) {
		var E=formInputs.item(i);
		if ((''+E.name).indexOf('query')>=0) continue;
		if (rp!=undefined && rp!=null && E.name==rp) {
			if (URL.length>0) URL+='&';
			URL+=E.name+'='+escape(rv);			
		} else {
			if (URL.length>0) URL+='&';
			URL+=E.name+'='+escape(E.options[E.selectedIndex].value);		
		}
	}

	return URL;
}



	var http_req=false;

	function doSearchR(url) {
		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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) {	
			http_req=req;	
			req.onreadystatechange = showSearchR;

								if (url.length>500) {
									var pp=url.indexOf('?');
									var para=url.substring(pp+1);
									var uuu=url.substring(0,pp);
									//alert(para+"\n\n"+uuu+"\n\n"+ASASTRYURL);
									req.open("POST", uuu, true);
//Send the proper header information along with the request
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", para.length);
req.setRequestHeader("Connection", "close");
									req.send(para);

								} else {

			req.open("GET", url, true);
			req.send("");
								}

			/*
			var E=document.getElementById('ANALYTICSINFO');
			if (E!=null) {
				var R='<div class="FW" style="padding-top: 50px;padding-bottom: 50px;"><center><img border="0" src="30-1.gif"></center></div>';
				E.innerHTML=R;


			}
			*/

		}
	}

	function showSearchR() {
		if (http_req.readyState == 4) {
			if (http_req.status == 200) {
				var E=document.getElementById('ANALYTICSINFO');
				if (E!=null) {
					var R=http_req.responseText;
					E.innerHTML=R;

					if (1) {
						var FS=document.getElementById('FITSCORE');
						if (FS!=null) {
							var E=FS.innerHTML;
							var G=document.getElementById('fitscoreval');
							if (G!=null) {
								G.value=E;
							}						
						}
					}

					if (1) {
						var FS=document.getElementById('BMISCORE');
						if (FS!=null) {
							var E=FS.innerHTML;
							var G=document.getElementById('bmival');
							if (G!=null) {
								G.value=E;
							}
						}
					}
					setTimeout('doDaily()',1000);
				}
			}
		}
	}




	var lastS='';
	var currentQ='';
	var currenttt='';
	var prevQQ='';
	function doQ() {
		if (currentQ.length>0) {
			var d=new Date();
			var tt=d.getTime();

			var diff=tt-currenttt;
			if (diff>700 && prevQQ!=currentQ) {
				//alert("D"+diff);
				prevQQ=currentQ;
				doSearchR(currentQ);
			} else {
				setTimeout('doQ()',600);
			}
			last=tt;
			
		}

	}

	function getS() {
		
		var X='hsc.jsp?'+getDataURL();
		//window.open(X);

		var d=new Date();
		var tt=d.getTime();
		if (lastS=='') {
			lastS=tt;
		}
		currentQ=X;
		currenttt=tt;
		setTimeout('doQ()',600);
		//doSearchR(X);
		

	}







	function doSearchQQQ(url,fun) {

		var req = false;
		// branch for native XMLHttpRequest object
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		   	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 = fun;

								if (url.length>500) {
									var pp=url.indexOf('?');
									var para=url.substring(pp+1);
									var uuu=url.substring(0,pp);
									//alert(para+"\n\n"+uuu+"\n\n"+ASASTRYURL);
									req.open("POST", uuu, false);
//Send the proper header information along with the request
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", para.length);
req.setRequestHeader("Connection", "close");
									req.send(para);
			fun(req);
								} else {

			req.open("GET", url, false);
			req.send("");
			fun(req);
								}

		}

		return req;
	}




