function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function qsearch()
{
var strVal = document.forms["search"].query.value;
var i;
var len = strVal.length;
var strOK = false;
 
for (i = 0; i < len; i++) {
   if (strVal.charAt(i) != " ") {
     strOK = true;
    break;
   }
}
 
if (strOK == "1") {
// if (document.forms["search"].query.value != "") {
 top.location.href='behavioralhealth_search.aspx?col=BJCBehavHealth&q=' + document.forms["search"].query.value;
 document.forms["search"].action = 'behavioralhealth_search.aspx?col=behavioralhealth&q=' + document.forms["search"].query.value;
 } 
 return false;
}
function secondSearch()
{
document.forms["search"].query.value = document.forms["search1"].query.value;
}
function newSearch()
{
document.forms["search"].query.value = document.forms["avsearch"].q.value;
}

function openPrintWin(url)
{
	winPrint = window.open(url,"","width=800,height=650,location=no,menubar=no,resizable=yes,scrollbars=yes");
	return false;
}

function simpleToBoolean()
{
	query = document.forms["avsearch"].q;
	queryString = query.value;
	if ((queryString.length > 0) && (queryString.indexOf(" ") > -1))
	{
		while (queryString != queryString.replace(/^ /,""))
			queryString = queryString.replace(/^ /,"");
		while (queryString != queryString.replace(/ $/,""))
			queryString = queryString.replace(/ $/,"");
		while (queryString != queryString.replace(/  /," "))
			queryString = queryString.replace(/  /," ");
		newQueryString = "";
		pos = 0;
		while (pos < queryString.length)
		{
			switch (queryString.charAt(pos))
			{
				case "'":
					if (queryString.indexOf("'",pos+1) > -1)
					{
						pos2 = queryString.indexOf("'",pos+1)
						newQueryString = newQueryString + queryString.substr(pos, pos2-pos+1);
						pos = pos2 + 1;
					}
					else
					{
						newQueryString = newQueryString + queryString.charAt(pos);
						pos = pos + 1;
					}
					break;
				case '"':
					if (queryString.indexOf('"',pos+1) > -1)
					{
						pos2 = queryString.indexOf('"',pos+1)
						newQueryString = newQueryString + queryString.substr(pos, pos2-pos+1);
						pos = pos2 + 1;
					}
					else
					{
						newQueryString = newQueryString + queryString.charAt(pos);
						pos = pos + 1;
					}
					break;
				case " ":
					newQueryString = newQueryString + " or ";
					pos = pos + 1;
					break;
				default:
					newQueryString = newQueryString + queryString.charAt(pos);
					pos = pos + 1;
			}
		}
		query.value = newQueryString;
	}
	document.forms["avsearch"].pg.value='aq'; 
	document.forms["avsearch"].submit();
}

function FontResize()
{
// setDefaults arguments: size unit, default size, minimum, maximum
// optional array of elements or selectors to apply these defaults to
dw_fontSizerDX.setDefaults('px', 12, 8, 16, ['body', 'td', 'div', 'p', 'a', 'li', 'font', 'span'],'fontSize_behavioralhealth');
dw_fontSizerDX.set(16, 12, 20, ['.pagetitle']);
dw_fontSizerDX.set(12, 12, 12, ['div#sizer'] );
dw_fontSizerDX.set(11, 11, 11, ['.sizer_small'] );
dw_fontSizerDX.set(13, 13, 13, ['.sizer_medium'] );
dw_fontSizerDX.set(15, 15, 15, ['.sizer_large'] );
dw_fontSizerDX.init();
}



//   ##############  SIMPLE  BROWSER SNIFFER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}


//  #########  popup text 
descarray = new Array(
"Quick Reference Guide is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"United Medical Resources Sample Explanation of Benefits is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"Overview of BJCBH & BHP's LOC Guidelines -- Level 1 & 2 is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"The Adult Continuous Treatment Teams is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"The BHP Treatment Plan & Service Authorization Form is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"Overview of Level of Care Guidelines -- LOCUS v. 2000 LOC for Adult Continuous Treatment Teams is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>.",
"Overview of Level of Care Guidelines -- CA-LOCUS v. 1.5 LOC for Childrens Treatment Teams is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a <a href='http://www.adobe.com/products/acrobat/readstep2.html' target=_blank>free download</a>."
);

//  #########  popup text 
//descarray = new Array(
//"Quick Reference Guide is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a free <a href='http://www.adobe.com/products/acrobat/readstep2.html'>download</a> or just <a href='/uploadedFiles/BJC_HealthCare/Clinical_Specialties/BJC_Behavioral_Health/SelfFundedBenefitPlanMembersQuickReferenceGuide.pdf' target='_blank'>open this guide</a>.",
//"United Medical Resources Sample Explanation of Benefits is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a free <a href='http://www.adobe.com/products/acrobat/readstep2.html'>download</a> or just <a href='/uploadedFiles/BJC_HealthCare/Clinical_Specialties/BJC_Behavioral_Health/EOBForm.pdf' target='_blank'>open this example</a>.",
//"Overview of Level of Care Guidelines -- Level 1 & 2 is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a free <a href='http://www.adobe.com/products/acrobat/readstep2.html'>download</a> or just <a href='http://www.bjcbehavioralhealth.com/BehavioralHealth/OverviewofBJCBHBHPsLOCGuidelinesLevel12.pdf' target='_blank'>open guidelines</a>.",
//"Adult Continuous Treatment Teams is in a PDF Format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a free <a href='http://www.adobe.com/products/acrobat/readstep2.html'>download</a> or just <a href='http://www.bjcbehavioralhealth.com/BehavioralHealth/AdultContinuousTreatmentTeams.pdf' target='_blank'>open treatment teams</a>.",
//"The BHP Treatment Plan & Service Authorization Form is in a PDF format and requires Adobe Acrobat Reader. If you don't have this software, go to Adobe for a free <a href='http://www.adobe.com/products/acrobat/readstep2.html'>download</a>."
//);

overdiv="0";
//  #########  CREATES POP UP BOXES 
function popLayer(a){
if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
desc = 	  "<table cellspacing=0 width=80% cellpadding="+pad+" border="+bord+"  bgcolor=000000><tr><td>\n"
	+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=CCCCCC>\n"
	+descarray[a]
	+"\n</td></tr></table>\n"
	+"</td></tr></table>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x+15;
	document.object1.top=y-5;
	}
else if(navigator.family =="ie4"){
	object1.innerHTML=desc;
	object1.style.pixelLeft=x+15;
	object1.style.pixelTop=y-5;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x+15;
	document.getElementById("object1").style.top=y-5;
	}
}
function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
//  End -->
