var theRnd;
 var tizerSz = 12;
tizerArr = new Array(tizerSz);
tizerArr[1] = "commonDrugs.htm";
tizerArr[2] = "survey.htm";
tizerArr[3] = "medIndex.asp";
tizerArr[4] = "writeUs.asp";
tizerArr[5] = "commonDrugs.htm";
tizerArr[6] = "travelGuide.htm";
tizerArr[7] = "immun.htm";
tizerArr[8] = "medCalc.asp";
tizerArr[9] = "medGlossary.asp";
tizerArr[10] = "emergency.htm";
tizerArr[11] = "testIndex.asp";

/*
tizerTxtArr = new Array(tizerSz);
tizerTxtArr[1] = escape("בעיות נפוצות");
tizerTxtArr[2] = escape("מישאלים");
tizerTxtArr[3] = escape("אינדקס התרופות");
tizerTxtArr[4] = escape("כתבו לנו");
tizerTxtArr[5] = escape("בעיות נפוצות");
tizerTxtArr[6] = escape("מדריך לנוסע לחו&quot;ל");
tizerTxtArr[7] = escape("חיסונים");
tizerTxtArr[8] = escape("מחשבונים רפואיים");
tizerTxtArr[9] = escape("מילון מונחים רפואי");
tizerTxtArr[10] = escape("עזרה ראשונה");
tizerTxtArr[11] = escape("בדיקות רפואיות");
*/
theRnd = Math.round(Math.random()*(tizerSz-2)) + 1;

var adsSz = 3;
adsRnd = Math.round(Math.random()*(adsSz-1)) + 1;
//			alert(adsRnd)
//		  alert("from Func " + theRnd + " tizerSz: " + tizerSz)
//   alert(navigator.userAgent)

   var numOnly = /^[0-9]+$/;
   var floatOnly = /^[0-9.]+$/;

/*  Possible Worlds Utilities 
 *
 */

 /* Geting the object by name - try to use getElementsByName, if fail then use eval */

  function PosWor_myGetName(fldStr) {
      if (document.getElementsByName) {
		  theObj = document.getElementsByName(fldStr)[0];
	  } else {
	       theObj   = eval("document." + fldStr);
      }
	  return theObj;
	  
  }




function replaceImg (theField, theImg)
{
   fImage = eval(theField)
   fImage.src = theImg
}

   function loadImages()
   {
       var docu = document;
       var arraySz = 26;
   if (docu.images)
    {
       if (!docu.PW_img) {
 	     docu.PW_img = new Array(arraySz);
 		 for(j=1; j<arraySz; j++) {
            docu.PW_img[j] = new Image;
        } // for
		for (j=1; j<=8; j++)
		{
	        docu.PW_img[j].src = "Images/NewInfomed/p" + (j+9) + "n.gif";
	        docu.PW_img[j+8].src = "Images/NewInfomed/p" + (j+19) + "n.gif";
	        docu.PW_img[j+16].src = "Images/NewInfomed/p" + (j+29) + "n.gif";
     	}  // for loading
		// vitamins
       docu.PW_img[25].src = "Images/NewInfomed/p18n.gif";
       } // !docu.PW_img

   } // if docu.images
  } // loadImages

  function ImgOn (picNum)
{
//	alert(eval(this));
//	alert(theField.name)
   fImage =  PosWor_myGetName("Image" + picNum);
//   fImage.src = theImg + "_o.jpg";
//   fImage = eval("Image" + picNum);
   fImage.src = "Images/NewInfomed/p" + picNum + "n.gif";


}

function ImgOff (picNum)
{
   fImage =  PosWor_myGetName("Image" + picNum);
   fImage.src = "Images/NewInfomed/p" + picNum + ".gif";
}


  function ImgOn2 (picNum)
{
//	alert(eval(this));
//	alert(theField.name)
   fImage =  PosWor_myGetName("Image" + picNum);
//   fImage.src = theImg + "_o.jpg";
//   fImage = eval("Image" + picNum);
   fImage.src = "../Images/NewInfomed/p" + picNum + "n.gif";
//   if (picNum == '59') {
//	   MM_showMenu(window.mm_menu_0518162609_0,30,9,null,'popup');
//   }

}

function ImgOff2 (picNum)
{
   fImage =  PosWor_myGetName("Image" + picNum);
   fImage.src = "../Images/NewInfomed/p" + picNum + ".gif";
//   if (picNum == '59') {
//	   MM_startTimeout();
//   }
}



 function doSelectSearch() 
 {
       document.searchSite.submit()
 }

   function loadImagesOther()
   {
       var docu = document;
       var arraySz = 10;
   if (docu.images)
    {
       if (!docu.PW_img) {
 	     docu.PW_img = new Array(arraySz);
 		 for(j=1; j<arraySz; j++) {
            docu.PW_img[j] = new Image;
         } // for
	   	 for (j=1; j<arraySz; j++)
		 {
	        docu.PW_img[j].src = "Images/NewInfomed/p" + (j+51) + "n.gif";
     	 }  // for loading
        } // !docu.PW_img

//        mmLoadMenus("")
   } // if docu.images
  } // loadImagesOther

   function loadImagesOther2()
   {
       var docu = document;
       var arraySz = 10;
   if (docu.images)
    {
       if (!docu.PW_img) {
 	     docu.PW_img = new Array(arraySz);
 		 for(j=1; j<arraySz; j++) {
            docu.PW_img[j] = new Image;
        } // for
		for (j=1; j<arraySz; j++)
		{
	        docu.PW_img[j].src = "../Images/NewInfomed/p" + (j+51) + "n.gif";
     	}  // for loading
       } // !docu.PW_img

   } // if docu.images
  } // loadImagesOther


 function infoOpenWin (theURL,winName,features) { //v2.0
   if (features == "width=450,height=460")
   {
//	   features = "width=450,height=526";
//	   features = "width=450,height=551";
//	   features = "width=450,height=621";
	   features = "width=550,height=621";
   }
   features = features+",resizable=yes,status=yes"

   glosWindow = window.open(theURL,winName,features);
 //  glosWindow.focus();
 } //   infoOpenWin

 
 function openOuterWindow (theURL,winName,features) {
//	 alert("here");
   theWindow = window.open (theURL,winName,features);
 }



function checkGender ()
{
   with  (document.personalTest) {
   toSend = true
		if (!gender[0].checked && !gender[1].checked && !gender[2].checked) {
          errCode = 1
          toSend = false
	   }
      if (toSend)
      {
	      return true
      } else {
       switch (errCode) {
	     case 1:
            alert ("You must select one of the gender buttons")
			break;
	  } // switch	    
	  return false
	 }
   } // with
}

function checkEnteredTest ()
{
   toSend = true
   with  (document.perTestForm) {
	   if (tID.selectedIndex == 0 && tIDeng.selectedIndex == 0)
	   {
          errCode = 1
          toSend = false
	   }
      if (toSend)
      {
	      return true
      } else {
       switch (errCode) {
	     case 1:
            alert ("You must select a medical test (from the Hebrew or English menus)");
			break;
	  } // switch	    
	  return false
	 }
   }
} // checkEnteredTest

function checkEnteredDrug (modify)
{
   toSend = true
   with  (document.perDrugForm) {
	  if (modify != 2) {
  // let's make sure that no more than one drug option is selected
      drugSel = 0;
       if (dID.selectedIndex != 0) {
           drugSel++;
	   }
       if (dIDeng.selectedIndex != 0) {
           drugSel++;
	   }
       if (drugName.value) {
           drugSel++;
	   }

      switch (drugSel) {
	     case 0:
            errCode = 1;
            toSend = false;
			break;
	     case 1:
            errCode = 0;
			break;
	     case 2:
            errCode = 3;
			break;
	     case 3:
            errCode = 3;
			break;
	  } // switch

	  if (errCode == 3) {
		  // we selected more than one menu, let give the user a chance
         theMsg = "You have selected drugs in more than one options\n";
		 if (dID.selectedIndex != 0) {
			 theMsg = theMsg + "If you confirmed this message, than the Hebrew menu drug will be used";
		 } else {
			 theMsg = theMsg + "If you confirmed this message, than the English menu drug will be used";
		 }
		 if (confirm(theMsg))
	     {
              toSend = true
	     } else {
              toSend = false
	     }
     }
	  } // if not modify = 2

	  if (toSend) {
		  if (pillDosage.value && !floatOnly.test(pillDosage.value)) {
			  errCode = 2
              toSend = false
		  }
	  }

// and now for the date format
 // check date formats
 if (toSend) {
    tmpYear = nowYear.value
	 tmpYear =parseInt(tmpYear)  // convert it to number
	 if (!isNaN(tmpYear) ) {
         if (tmpYear < 100) {
            curDate = new Date()
	        curYear = curDate.getFullYear()
	        tmpYear = tmpYear + 2000
	        if (tmpYear > curYear)  {
	           tmpYear = tmpYear - 100  // in the future, then it is 1900 base
	        }
         }
	    
	 }
    tmpDate = new Date(tmpYear, nowMon.value-1, nowDay.value)
	if (isNaN(tmpDate) ) {
        toSend = false;
		errCode = 4
	} else {
      if (tmpYear < 100) {
         curDate = new Date()
	     curYear = curDate.getFullYear()
	     tmpYear = tmpYear + 2000
	     if (tmpYear > curYear)  {
	        tmpYear = tmpYear - 100  // in the future, then it is 1900 base
	     }
      }
//	  alert(tmpDate)
	   nowDay.value = tmpDate.getDate()
	   nowMon.value = tmpDate.getMonth()+1
	   nowYear.value = tmpDate.getFullYear()
	}
 }


      if (toSend)
      {
	      return true
      } else {
       switch (errCode) {
	     case 1:
            alert ("You must select a drug  (from the Hebrew or English menus) or enter it manually");
			break;
	     case 2:
            alert ("pill dosage must be numeric");
            pillDosage.focus()
            pillDosage.select()
			break;
	     case 4:
            alert ("Illegal Date");
			break;
	  } // switch	    
	  return false
	 }
   }
} // checkEnteredDrug


function checkNumOnly(theField) 
{
   theRetValue = true;
//   alert (theField.value)
   if (theField.value && numOnly.test(theField.value))
   {
   } else {
       theRetValue = false;
       errCode = 2
   }
   document.retVal = theRetValue;
   return theRetValue
} // checkNumOnly

function jsPrntVersion(theField)
{
	/*
	if (theField.checked)
	{ 
		    document.getElementById("sideBanner").style.display = 'none';
		    document.getElementById("topBanner").style.display = 'none';
		    document.getElementById("rightBanner").style.display = 'none';
		
	} else {
		    document.getElementById("sideBanner").style.display = 'block';
		    document.getElementById("topBanner").style.display = 'block';
		    document.getElementById("rightBanner").style.display = 'block';
	}
	*/
	
	var bans = new Array("sideBanner","topBanner","rightBanner");
	
	for(i=0;i<bans.length;i++) {
		id = bans[i];
		var obj = "";
		if(document.getElementById)
			obj = document.getElementById(id);
		else if(document.all)
			obj = document.all[id];
		else if(document.layers)
			obj = document.layers[id];
		else
			return false;
			
		if (!obj)
			return false;
		else if (obj.style) {
			if (theField.checked)
				obj.style.display="none";
			else {
				obj.style.display="";
				obj.visibility = "show";
			}
		}
	}
	
} // prntVersion`

function showId(theID,tOrF) {
		if(document.getElementById)
			obj = document.getElementById(theID);
		else if(document.all)
			obj = document.all[theID];
		else if(document.layers)
			obj = document.layers[theID];
		else
			return false;
		if (!obj)
			return false;
		else if (obj.style) {
			if (!tOrF)
				obj.style.display="none";
			else {
				obj.style.display="";
				obj.visibility = "show";
			}
		}
}

function myGetID(theID)
{
		if(document.getElementById)
			obj = document.getElementById(theID);
		else if(document.all)
			obj = document.all[theID];
		else if(document.layers)
			obj = document.layers[theID];
		else
			return false;
		return obj;
}


function showId1(theID) {
//		alert(theID);
		var obj = myGetID(theID);
//		alert(obj);
		var objDisp = myGetID(theID + "Sp");
//		alert(theID + "Sp");
//		alert(objDisp.innerHTML);
		if (!obj) {
//			return false;
		}
		else if (obj.style) {
//			alert(obj.style.display)
			if (obj.style.display != "none") {
//				  alert( objDisp.innerHTML);
			      objDisp.innerHTML = "<b>הצג</b> <img src=../Images/common/showIcon.jpg border=0 align=absbottom>";
				  obj.style.display="none";
			}
			else {
				obj.style.display="";
			    objDisp.innerHTML = "<b>הסתר</b> <img src=../Images/common/hideIcon.jpg border=0 align=absbottom>";
				obj.visibility = "show";
			}
		}
}

function findSearchTarget(theForm, menuFld)
{
//	alert (menuFld.value);
	menuVal = menuFld.value;
	menuVal = menuVal - 0; // convert it to num
//		alert(theForm.action);
// alert(menuVal);
	switch (menuVal) {
	     case 1:
             theForm.action = "doSearch.asp";
			 break;

	     case 2:
             theForm.action = "doSearchTest.asp";
		     theForm.testName.value = theForm.drugName.value;
//		alert(theForm.action);
			 break;

	     case 3:
             theForm.action = "doSearchVacc.asp";
			 break;

		 case 4:
             theForm.action = "doSearchV.asp";
			 break;
} // switch

	return true;

}


// ------- popup section
/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */

 // -- Eli additions - Add dirPrefix

function preLoader(dirPrefix) {
} // mmLoadMenus()


// site 2009 routines
function hltMenuTab (tabID) {
//   -- Prototype version
//    theTAB = $("mainBtn" + tabID);
//    theTAB.setStyle({background:'url(/Images/site2009/tab_main_rollover.jpg)', cursor:"pointer"});
//   -- Non Prototype version
    theTAB = myGetID("mainBtn" + tabID);
    theTAB.style.background='url(/Images/site2009/tab_main_rollover.jpg)';
    theTAB.style.cursor='pointer';
}

function hltMenuTab2 (tabID) {
//   -- Prototype version
//    theTAB = $("mainBtn" + tabID);
//    theTAB.setStyle({background:'url(/Images/site2009/tab_main_rollover.jpg)', cursor:"pointer"});
//   -- Non Prototype version
    theTAB = myGetID("mainBtn" + tabID);
    theTAB.style.background='url(../Images/site2009/tab_main_rollover.jpg)';
    theTAB.style.cursor='pointer';
}

function dehltMenuTab (tabID) {
//   -- Prototype version
//    theTAB = $("mainBtn" + tabID);
//    theTAB.setStyle({background:'url(/Images/site2009/tab_main.jpg)', cursor:"default"});
//   -- Non Prototype version
    theTAB = myGetID("mainBtn" + tabID);
    theTAB.style.background='url(/Images/site2009/tab_main.jpg)';
    theTAB.style.cursor='default';
}

function dehltMenuTab2 (tabID) {
//   -- Prototype version
//    theTAB = $("mainBtn" + tabID);
//    theTAB.setStyle({background:'url(/Images/site2009/tab_main.jpg)', cursor:"default"});
//   -- Non Prototype version
    theTAB = myGetID("mainBtn" + tabID);
    theTAB.style.background='url(../Images/site2009/tab_main.jpg)';
    theTAB.style.cursor='default';
}

function hltBtn (btnID) {
//   -- Prototype version
//    theBTN = $(btnID);
    theBTN = myGetID(btnID);
//    theBTN.style.color='#2a5e97';
    theBTN.style.color='#000000';
}
function dehltBtn (btnID) {
//   -- Prototype version
//    theBTN = $(btnID);
    theBTN = myGetID(btnID);
    theBTN.style.color='white';
}


function mySubmitForm(theFormStr) {

    switch (theFormStr)
    {
        case 'searchDr':
        {
            SearchDoctors();
            break;
        }
    }
    //theForm = myGetID(theFormStr);
	//theForm.submit();
}

function myResetForm(theFormStr) {
    theForm = myGetID(theFormStr);
	theForm.reset();
}




function setTab(tabNum, stStr, targetCtlPostFix)
{

    if (targetCtlPostFix == null)
        targetCtlPostFix = "";
        
	for (idx=1;idx<= 5 ; idx++)
	{
		theBlock = stStr + "Blk" + idx;
		theBtn = stStr + "Tab" + idx;
		theBtnTxt = stStr + "TabTxt" + idx;
	    theTabObj = myGetID(theBlock);
	    theBtnObj = myGetID(theBtn);
	    theBtnTxtObj = myGetID(theBtnTxt);
		if (idx == tabNum)
    	{
	       if (theTabObj!=null){
               theTabObj.style.display="";
               theTabObj.visibility = "show";	
               if (theBtnObj!=null)
		            theBtnObj.className = "srchBtnOn" + targetCtlPostFix;
		       if (theBtnTxtObj!=null)
		            theBtnTxtObj.className = "srchBtnTxtOn";
		   }
	    } else {
	        if (theTabObj!=null){
		    theTabObj.style.display="none";
            theTabObj.visibility = "hidden";		
            if (theBtnObj!=null)
		        theBtnObj.className = "srchBtn" + targetCtlPostFix;
		    if (theBtnTxtObj!=null)
	 	        theBtnTxtObj.className = "srchBtnTxt";
	 	    }
		}
		
	}
}

function setWideTab(tabNum, stStr)
{
    
    var theBlock = null;
    var theBtn = null;
    var theBtnTxt = null;
    var theTabObj = null;
    var theBtnObj = null;
    var theBtnTxtObj = null;
    var idx = 0;
    
	for (idx=1;idx<= 4 ; idx++)
	{
		theBlock = stStr + 'Blk' + idx;
		theBtn = stStr + 'Tab' + idx;
		theBtnTxt = stStr + 'TabTxt' + idx;
	    theTabObj = myGetID(theBlock);
	    theBtnObj = myGetID(theBtn);
	    theBtnTxtObj = myGetID(theBtnTxt);
		if (idx == tabNum)
		{
		   if (theTabObj != null){ 
               theTabObj.style.display='';
               theTabObj.visibility = 'show';	
               if (theBtnObj != null)
		           theBtnObj.className = 'srchBtnOn145px';
		       if (theBtnTxtObj!= null)
		            theBtnTxtObj.className = 'srchBtnTxtOn';
		   }
	    } else {
	       if (theTabObj != null){  
    	        theTabObj.style.display='none';
                theTabObj.visibility = 'hidden';		
                if (theBtnObj != null)
		            theBtnObj.className = 'srchBtn145px';
		        if (theBtnTxtObj!= null)
	 	            theBtnTxtObj.className = 'srchBtnTxt';
	 	   }
		}
		
	}
	return true;
}


function setTabWithBottomDiv(tabNum, stStr, bottomDiv)
{
    //set tab visibility
    setTab(tabNum, stStr);
    //var theBlock = stStr + "Blk" + tabNum;
    //now move the bottom div to the right position
    //if (navigator.appName.indexOf("Microsoft")!=-1) {
    //toppos = document.getElementById(theBlock).style.top + document.getElementById(theBlock).style.height;
    //document.getElementById(bottomDiv).style.top = toppos;
        //leftpos = document.body.clientWidth / 2 - 100;
    //}else{
    //    toppos = window.innerHeight / 2 - 100;
        //leftpos = window.innerWidth / 2 - 100;
    //}
    
    //var theTabObj = myGetID(theBlock);
    //$(bottomDiv).top = theTabObj.top + theTabObj.height;
    //return;

}

// structures that stroed the values of the search fields prior to last character (not sure if needed)
var MINACLEN = 2;
var typeAheadDrugsObj = {menuStr:"",
	                            delay:2000,
	                            lastAccess:0};
var lastVisitedVal;
var acArray = new Array();

function initAC() 
{
	   for (var i = 0; i < arguments.length; i++) {
		   theField = arguments[i] +  "AC";
		   acArray[i] = theField;
	   }
}


// myAutoComplete functions
function ourAutoComplete(theField, ev,acType,theWidthAdd) {
	ourFieldVal = theField.value;
//	inFld = myGetID(theField.id);
	acFld = myGetID(theField.id + "AC");
	clearOtherAC(theField.id + "AC");
	fldLen = ourFieldVal.length;
	switch (acType) {
		case 'drug':
			aspService="utils/getACdrugs.asp";
		    successFunc = parseResponseDrugNames;
			forASPtype = 1
			break;

		case 'usage':
			aspService="utils/getACusage.asp";
		    successFunc = parseResponseUsage;
			forASPtype = 1
			break;

		case 'group':
			aspService="utils/getACusage.asp";
		    successFunc = parseResponseUsage;
			forASPtype = 2
			break;

		case 'inform':
			aspService="utils/getACusage.asp";
		    successFunc = parseResponseUsage;
			forASPtype = 3
			break;
	}

	if (fldLen >= MINACLEN) {
           acFld.style.display="";
           acFld.visibility = "show";	
		   absButton = absPosLocal(theField);
//           acFld.style.right = "0px";
           theTop = absButton.y+20;
           acFld.style.top = theTop + "px";
		   totWidth = getWidth(theField) + theWidthAdd
		   acFld.style.left = absButton.x - theWidthAdd;
		   acFld.style.width = totWidth + "px";
		  new Ajax.Request(aspService, {
			method: 'post',
				parameters: {theType: forASPtype, theField: theField.id, fldVal: ourFieldVal},
				onSuccess: successFunc,
				onFailure: function(xhrResponse) {
					alert('There was a problem: ' + xhrResponse.statusText);
				}
		});

	} else { // < MIN CHAR hide the AC field
		     acFld.style.display="none";
             acFld.visibility = "hidden";		
             acFld.innerHTML = "";
	}
//	alert(theField.id);
//    alert(ourFieldVal);
}


	function parseResponseDrugNames (xhrResponse) {
		var response = xhrResponse.responseText;
//		alert(response);
		var bigList = response.split("|");
		theField = bigList[0];
		var theACfld = $(theField);
     	var theFieldDiv = $(theField+'AC');
        theFieldDiv.innerHTML = "";
		theResult='<ul>';
        theResult += '<li class="closeScroll" onMouseUp="reallyStopAC(\'' + theField + '\')">סגור</li>';
  		for (idx = 1; idx < bigList.length; idx++) {
			theResult+='<li id="theField'+idx+'" onMouseOver="hlACline(\'theField'+idx+'\')"  onMouseOut="deACline(\'theField'+idx+'\')"   onMouseUp="selectACline(\'theField'+idx+'\',\''+theField+'\')" >'+bigList[idx]+'</li>';
		}
		theResult+='</ul>'
//		alert(theResult);
        theFieldDiv.innerHTML = theResult;
		if (bigList.length <= 1) {
			 theFieldDiv.style.display="none";
             theFieldDiv.visibility = "hidden";		
	    }
   }

	function parseResponseUsage (xhrResponse) {
		var response = xhrResponse.responseText;
//		alert(response);
		var bigList = response.split("@");
		theField = bigList[0];
		var theACfld = $(theField);
     	var theFieldDiv = $(theField+'AC');
//        theFieldDiv.observe('mouseDown', alert("click"));

        theFieldDiv.innerHTML = "";
		theResult='<ul>';
        theResult += '<li class="closeScroll" onMouseUp="reallyStopAC(\'' + theField + '\')">סגור</li>';
  		for (idx = 1; idx < bigList.length; idx++) {
            theLine = bigList[idx];
			var bigLine = theLine.split("|")
			theResult+='<li id="theField'+idx+'" onMouseOver="hlACline(\'theField'+idx+'\')"  onMouseOut="deACline(\'theField'+idx+'\')"   onMouseUp="selectACUsageline(\'theField'+idx+'\',\''+theField+'\','+bigLine[1]+')" >'+bigLine[0]+'</li>';
		}
		theResult+='</ul>'
//		alert(theResult);
        theFieldDiv.innerHTML = theResult;
		if (bigList.length <= 1) {
			 theFieldDiv.style.display="none";
             theFieldDiv.visibility = "hidden";		
	    }
   }

// my routine that returns the absolute location of an object
function absPosLocal(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}  // if
	return {x:curleft, y:curtop};
}


function getWidth(obj) {
	return obj.offsetWidth || obj.style.pixelWidth;
}

function hlACline(divName) {
	    var divName = $(divName);
        divName.setAttribute("class", "autoCompleteHL");
        divName.setAttribute("className", "autoCompleteHL");
		lastVisitedVal = divName.innerHTML;
}

function deACline(divName) {
	    var divName = $(divName);
		if (divName != null) {
           divName.setAttribute("class", "autoCompleteDL");
           divName.setAttribute("className", "autoCompleteDL");
		}
}

function selectACline(divName, parentName) {
//        alert(divName + " " + parentName);
	    var divName = $(divName);
     	var theFieldDiv = $(parentName+'AC');
     	var theForm = $(parentName);
		tmpval = divName.innerHTML;
		tmpval = tmpval.replace(/<b>/i,'');
		tmpval = tmpval.replace(/<\/b>/i,'');
		theForm.value = tmpval;
		theFieldDiv.style.display="none";
        theFieldDiv.visibility = "hidden";		
        theFieldDiv.innerHTML = "";
}

function selectACUsageline(divName, parentName, valValue) {
//        alert(divName + " " + parentName);
	    var divName = $(divName);
     	var theFieldDiv = $(parentName+'AC');
     	var theForm = $(parentName);
		tmpval = divName.innerHTML;
		tmpval = tmpval.replace(/<b>/i,'');
		tmpval = tmpval.replace(/<\/b>/i,'');
		theForm.value = tmpval;
		// now find the other field where we store the real value
		valName = parentName.replace(/Txt$/i,'');
		valField = $(valName);
        valField.value = valValue;
		theFieldDiv.style.display="none";
        theFieldDiv.visibility = "hidden";		
        theFieldDiv.innerHTML = "";
}


function clearOtherAC(acFld) {
//	alert("called");
   for (var i = 0; i < acArray.length; i++) {
	     if  (acArray[i] != acFld) {
			    var theAC = $(acArray[i]);
	        	theAC.style.display="none";
                theAC.visibility = "hidden";		
                 theAC.innerHTML = "";
		 }
   }
}

// well, both have problems, since clicking on the scroller on explorer is
// detected as losing the focus
function stopAC(acID)
{
//    alert(acID);
	acFld = myGetID(acID);
	if (!acFld.hasFocus) {
		reallyStopAC(acFld)
	}
//    setTimeout('reallyStopAC(\''+theField.id+'\')',500);
}

function reallyStopAC(theFieldID) {
//    alert("called");
	acFld = myGetID(theFieldID + "AC");
		     acFld.style.display="none";
             acFld.visibility = "hidden";		
             acFld.innerHTML = "";
}

function hasFocus(theField) {
	alert("focus: " + theField.id);
	theField.hasFocus = true;
}

function lostFocus(theField) {
	theField.hasFocus = false;
}

function tryToHide(nonAcFld) {
//	alert(acFld.id);
  
   acID = nonAcFld.id + "AC";
   lostFocus($(acID));
//   alert('stopAC('+acFld+')');
   setTimeout('stopAC(\''+acID+'\')',500);
}

