var strActiveDocument = ""

function hltCell(prm)
{
 prm.className="hltCell"
}
function clrCell(prm)
{
 prm.className="clrCell"
}

function manAction()
{
 var tmpVal = objBrowser("b").value.split('AP')
 if (tmpVal.length > 1)
  {
   nPage = "/ProceduresAction.asp?proLoc=" + objBrowser("b").options(objBrowser("b").selectedIndex).id + "&procedure=" + objBrowser("b").options(objBrowser("b").selectedIndex).value
   window.open (nPage,'Content')
  }
 else
  {
   nPage = "/PoliciesAction.asp?polLoc=" + objBrowser("b").options(objBrowser("b").selectedIndex).id + "&policy=" +objBrowser("b").options(objBrowser("b").selectedIndex).value
   window.open (nPage,'Content')
  }
}

function SmartSelect(oInput, oSelect)
{
	var sInput = String(oInput.value).toUpperCase();
	var iLength = sInput.length;

	if (iLength <= 0)
		return -1;

	var oOptions = oSelect.options;
	var i, diff, bFound, sTemp;

	var iHigh = prStart - 1;
	var iLow = 0;
	var iCurrent = Math.floor((iHigh + 1) / 2);

	bFound = false;
	do
	{
		// Get the current option
		sTemp = oOptions(iCurrent).value.toUpperCase();
		var sSubstr = sTemp.substr(0, iLength);

		if (sSubstr < sInput)
		{
			// Search the upper half of the branch
			iLow = iCurrent + 1;
		}
		else if (sSubstr > sInput)
		{
			// Search the lower half of the branch
			iHigh = iCurrent - 1;
		}
		else
		{
			bFound = true;
			break;
		}

		// Pick the middle of the branch again	
		iCurrent = Math.floor(iLow + ((iHigh + 1) - iLow) / 2);

	} while (iHigh >= iLow)

	// Is there a better prefix match?
	if (iLength < sTemp.length)
	{
		// Store the current old value
		var iOld = iCurrent--;

		// Now go back until we find one that doesn't match the prefix
		while (iCurrent >= 0)
		{
			// Gone too far -- the prefix no longer matches.
			if (oOptions(iCurrent).value.toUpperCase().substr(0, iLength) != sInput)
				break;

			iOld = iCurrent--;
		}

		iCurrent = iOld;
	}

	if (bFound)
		return iCurrent;
	else
		return -1;
}
function SmartSelectBackwards(oInput, oSelect)
{
	var sInput = String(oInput.value).toUpperCase();
	var iLength = sInput.length;

	if (iLength <= 0)
		return -1;

	var oOptions = oSelect.options;
	var i, diff, bFound, sTemp;

	var iHigh = oOptions.length - 1;
	var iLow = prStart;
	var iCurrent = prStart;

	bFound = false;
	do
	{
		// Get the current option
		sTemp = oOptions(iCurrent).value.toUpperCase();
		var sSubstr = sTemp.substr(0, iLength);

		if (sSubstr < sInput)
		{
			// Search the upper half of the branch
			iLow = iCurrent + 1;
		}
		else if (sSubstr > sInput)
		{
			// Search the lower half of the branch
			iHigh = iCurrent - 1;
		}
		else
		{
			bFound = true;
			break;
		}

		// Pick the middle of the branch again	
		iCurrent = Math.floor(iLow + ((iHigh + 1) - iLow) / 2);

	} while (iHigh >= iLow)

	// Is there a better prefix match?
	if (iLength < sTemp.length)
	{
		// Store the current old value
		var iOld = iCurrent--;

		// Now go back until we find one that doesn't match the prefix
		while (iCurrent >= 0)
		{
			// Gone too far -- the prefix no longer matches.
			if (oOptions(iCurrent).value.toUpperCase().substr(0, iLength) != sInput)
				break;

			iOld = iCurrent--;
		}

		iCurrent = iOld;
	}
	if (bFound)
		return iCurrent;
	else
		return -1;
}
function DoIt()
{
 var i = SmartSelect(objBrowser("a"), objBrowser("b"));
 var msgStr = "<a href='#' onclick='manAction();'><b>Click to continue</b></a>"
 if (i < 0)
  {
   var i = SmartSelectBackwards(objBrowser("a"), objBrowser("b"));
    objBrowser("b").selectedIndex = i;
    if (i < 0)
    msgStr = "<b>Enter a policy or procedure...</b>"
  }
 objBrowser("b").selectedIndex = i;
 objBrowser("navText").innerHTML= msgStr
}

function menuOver(btn)
{
 btn.src="../_images/" + btn.name + "_on.gif"
}
function menuOut(btn)
{
 btn.src="../_images/" + btn.name + "_off.gif"
}
function slChapter()
{

 var poChap = poArray[objBrowser("lsChapters").selectedIndex];
 var prChap = prArray[objBrowser("lsChapters").selectedIndex];

 var poMenu = "<SELECT style='width:350px' name=lsPolicies id=lsPolicies onchange='polContent();'><OPTION selected>Please click here for policies...</option><option>----------------------------------------------------------------------</option>";
 var prMenu = "<SELECT style='width:350px' name=lsProcedures id=lsProcedures onchange='proContent();'><OPTION selected>Please click here for procedures...</option><option>---------------------------------------------------------------------------------------------------------</option>";

 for (i=0;i < poChap.length;i++)
  {poMenu = poMenu + poArray[objBrowser("lsChapters").selectedIndex][i]} 
 poMenu = poMenu + "</SELECT>" 

 for (i=0;i < prChap.length;i++)
  {prMenu = prMenu + prArray[objBrowser("lsChapters").selectedIndex][i]} 
 prMenu = prMenu + "</SELECT>"

 objBrowser("poList").innerHTML= poMenu
 objBrowser("prList").innerHTML= prMenu
}
function glbContent()
{
 var tmpVal = objBrowser("b").value.split('AP')
 
 if (docMode == 0)
  {
   if (tmpVal.length > 1)
    {
     nPage = "/ProceduresAction.asp?proLoc=" + objBrowser("b").options[objBrowser("b").selectedIndex].id + "&procedure=" +objBrowser("b").options[objBrowser("b").selectedIndex].value + "&District=" + strDistrict;
     window.open (nPage,'Content')
     strActiveDocument = objBrowser("b").options[objBrowser("b").selectedIndex].id;
    }
   else
    {
     nPage = "/PoliciesAction.asp?polLoc=" + objBrowser("b").options[objBrowser("b").selectedIndex].id + "&policy=" +objBrowser("b").options[objBrowser("b").selectedIndex].value + "&District=" + strDistrict;
     window.open (nPage,'Content') 
     strActiveDocument = objBrowser("b").options[objBrowser("b").selectedIndex].id
    }
  }
  
 if (docMode == 1)
  {
   nPage = "/demoPoliciesAction.asp?polLoc=" + objBrowser("b").options[objBrowser("b").selectedIndex].id + "&policy=" +objBrowser("b").options[objBrowser("b").selectedIndex].value  & "District=" & strDistrict;
   window.open (nPage,'Content')
  }
}

function polContent()
{
 if (objBrowser("lsPolicies").value != "")
  {
   nPage = "/PoliciesAction.asp?polLoc=" + objBrowser("lsPolicies").options[objBrowser("lsPolicies").selectedIndex].id + "&policy=" + objBrowser("lsPolicies").options[objBrowser("lsPolicies").selectedIndex].value + "&District=" + strDistrict;
   window.open (nPage,'Content');
   objBrowser("lsProcedures").selectedIndex=0;
   strActiveDocument = objBrowser("lsPolicies").options[objBrowser("lsPolicies").selectedIndex].id;
  }
}
function polSearchContent()
{
 if (objBrowser("lsSearchPolicies").value != "")
  {
   nPage = "/PoliciesAction.asp?polLoc=" + objBrowser("lsSearchPolicies").options[objBrowser("lsSearchPolicies").selectedIndex].id + "&policy=" +objBrowser("lsSearchPolicies").options[objBrowser("lsSearchPolicies").selectedIndex].value + "&District=" + strDistrict;
   window.open (nPage,'Content');
   objBrowser("lsSearchProcedures").selectedIndex=0;
   strActiveDocument = objBrowser("lsSearchPolicies").options[objBrowser("lsSearchPolicies").selectedIndex].id;
  }
}



function proSearchContent()
{
 if (objBrowser("lsSearchProcedures").value != "")
  {
   nPage = "/ProceduresAction.asp?proLoc=" + objBrowser("lsSearchProcedures").options[objBrowser("lsSearchProcedures").selectedIndex].id + "&procedure=" +objBrowser("lsSearchProcedures").options[objBrowser("lsSearchProcedures").selectedIndex].value + "&District=" + strDistrict;
   window.open (nPage,'Content')
   objBrowser("lsSearchPolicies").selectedIndex=0
   strActiveDocument = objBrowser("lsSearchProcedures").options[objBrowser("lsSearchProcedures").selectedIndex].id;
  }
}
function proContent()
{
 if (objBrowser("lsProcedures").value != "")
  {
   nPage = "/ProceduresAction.asp?proLoc=" + objBrowser("lsProcedures").options[objBrowser("lsProcedures").selectedIndex].id + "&procedure=" +objBrowser("lsProcedures").options[objBrowser("lsProcedures").selectedIndex].value + "&District=" + strDistrict;
   window.open (nPage,'Content');
   objBrowser("lsPolicies").selectedIndex=0;
   strActiveDocument = objBrowser("lsProcedures").options[objBrowser("lsProcedures").selectedIndex].id;
  }
}
function docPrint()
{
 var strLocation = window.parent.frames.Content.location.toString();
 var strDocument = strLocation.substring(strLocation.length-3,strLocation.length)
 
 if (strDocument=='doc'){
   alert('Procedures must be printed from a separate window.  When the new window opens click on file \ print.  When you are finished just close the window to return.')

   nPage = "/ProceduresAction.asp?proLoc=" + objBrowser("lsProcedures").options[objBrowser("lsProcedures").selectedIndex].id + "&procedure=" +objBrowser("lsProcedures").options[objBrowser("lsProcedures").selectedIndex].value;
   window.open (nPage)
 }
 else{
  window.parent.frames.Content.focus();
  window.parent.frames.Content.print();
 }

}

function bldMenu()
{
 var str= "<select id=b style='width: 350px' onchange='glbContent();'>"
 for (l=1;l < 11;l++)
  {
   for (c=0;c<poArray[l].length;c++)
    {
     str = str + poArray[l][c]
     prStart = prStart + 1
    }
  }
 for (l=1;l < 11;l++)
  {
   for (c=0;c<prArray[l].length;c++)
    {
     str = str + prArray[l][c]
    }
  }
 str = str + "</select>"
 objBrowser("completeMenu").innerHTML=str 
}













function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5
    // or is.ie6up to detect IE6.

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);


    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);

    this.webtv = (agt.indexOf("webtv") != -1); 

    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    this.AOLTV = this.TVNavigator;

    this.hotjava = (agt.indexOf("hotjava") != -1);
    this.hotjava3 = (this.hotjava && (this.major == 3));
    this.hotjava3up = (this.hotjava && (this.major >= 3));

}

var is;
var isIE3Mac = false;
// this section is designed specifically for IE3 for the Mac

if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && 
(parseInt(navigator.appVersion)==3))
       isIE3Mac = true;
else   is = new Is(); 

//--> end hide JavaScript

 function objBrowser(prmElement){
  if (is.nav){
   if (document.getElementById){
    return document.getElementById(prmElement)
   }
   else{
    return document.layers(prmElement)
   }
  }
  else if (is.ie){
   if (document.getElementById){
    return document.getElementById(prmElement)
   }
   else{
    return document.all(prmElement)
   }
  }
 }

