var IE4 = (document.all) ? 1 : 0;
var NS4 = (document.layers) ? 1 : 0;
var ver4 = (IE4 || NS4) ? 1 : 0;
var mBadNumber = 'This does not appear to be a valid number.  It should have no letters or characters other than commas and periods. Please re-enter.'
var mBadCurrency = 'This does not appear to be a valid currency.  It should have no letters or characters other than commas and periods. Please re-enter.'
var mBadZip = 'This does not appear to be a valid Zip Code.  It should be in the form 99999 or 99999-9999. Please re-enter.'
var mBadEmail = 'This does not appear to be a valid Email.  It should be in the form name@domain.xxx. Please re-enter.'
var mBadURL = 'This does not appear to be a valid web URL.  It should be in the form [www or server name].site.xxx.  Please re-enter.'
var mBadDate = 'This does not appear to be a valid date.  It should be a real date in the format of MM/DD/YY or MM/DD/YYYY. Please re-enter.'
var mBadPhone = 'This does not appear to be a valid Phone Number.  It should be in the form 999-9999 or (999)999-9999 . Please re-enter.'
var jPos="Positive";
var jNeg="Negative";
var jBrowserType;
var jIsMac;
var jIsSafari;
var preloadFlag = false;
var jRows=new Array

if (navigator.appName.indexOf("Netscape")!=-1) { jBrowserType="NS" } else { jBrowserType="IE" } 
v=navigator.userAgent.toLowerCase()
if (v.indexOf("mac")>-1) { jIsMac=true } else { jIsMac=false } 
if (v.indexOf("safari")!=-1) { jIsSafari=true } else { jIsSafari=false } 
//document.onkeypress=jsTab;  
//document.onkeydown=jsTab;  
var submitclicked= false;

var jPrevZipVal
var jPrevZipCodeVal
var jCurrentField
var jIsMac;
var jBrowserType;
var jIsOpera;
var jDtSize;

if (navigator.appName.indexOf("Netscape")!=-1) { jBrowserType="NS" } else { jBrowserType="IE" } 
v=navigator.userAgent.toLowerCase()
if (v.indexOf("mac")>-1) { jIsMac=true } else { jIsMac=false } 
if (v.indexOf("safari")!=-1) { jIsSafari=true } else { jIsSafari=false } 
if (v.indexOf("opera")>-1) { jIsOpera=true } else { jIsOpera=false } 
if (jIsOpera) {	jDtSize=11 } else { jDtSize=8 }

function jsEditThis(f,v) {
document.thisForm.hdnNextMode.value="EDIT"
document.thisForm.hdnCurIDFld.value=f
document.thisForm.hdnNextID.value=v
document.thisForm.submit()
}
function jsAppSaveRec(jTblName,t,vPageToCall,jMsg,jMode) {
jNm=jTblName.toUpperCase()
if (jNm.indexOf("SCHOOLS")>-1) {
	v1=document.thisForm.CourseList.value
	v2=document.thisForm.Editable_CourseList.value
	if ((v1=="") && (v2=="OFF")) { 
		rv=confirm("Your course list is empty and yet the Editable Course List is unchecked.  Continue anyways?")
		if (!rv) { return }
		}	
	if ((v1!="") && (v2=="ON")) { 
		rv=confirm("Your course list is not empty and yet the Editable Course List is checked.  Continue anyways?")
		if (!rv) { return }
		}	
	rv=confirm("Do you want to make a new download?")
	if (rv) { document.thisForm.MakeNewDownload.value="ON" } else { document.thisForm.MakeNewDownload.value="OFF" }
	//alert(document.thisForm.MakeNewDownload.value); 
	}
jsSaveRec(t,vPageToCall,jMsg,jMode)
}
function jsMakeNbr(x) {
if (x=="") { return 0 }
x=x.toString()
z=""
for (i=0;i<x.length;i++) {
	y=x.substr(i,1)
	if (y!=",") { z=z + y }
	}
z=new Number(z)	
return z
}
function jsFormatNbr(x) {
z=""
k=x.toString()
m=k.substr(0,1)
m=""
if (m=="-") { k=k.substr(1); } else { m="" }
p=k.indexOf(".")
d=0
jAddOne=0
if (p>-1) { 
	d=k.substr(p+1); 
	k=k.substr(0,p); 
	if (d.length>0) {
		y=d.substr(0)
		y=new Number(y)
		if (y>4) { jAddOne=1; }
		}
	}
z=k
z=new Number(z)
z=z + jAddOne
if (k.length>3) {
	if (k.length<=6) {
		l=(k.length-3)
		z=k.substr(0,l) + "," + k.substr(l,3) 
		return z
		}
	if (k.length<=9) {
		l=(k.length-6)
		z=k.substr(0,l) + "," + k.substr(l,3) + "," + k.substr(k.length-3,3)
		}
	}
return m + z
}
function jsSubmit() {
var i
var els=document.thisForm.getElementsByTagName("INPUT")
vTotUn=0
vTotAl=0
for (i=0;i<els.length;i++) {
	n=els[i].name
	v=els[i].value
	if (n.substr(0,6)=="Total_") { 
		vCol=n.substr(6)
		vTt=jsMakeNbr(v)
		vUn=document.getElementById("Unalloc_" + vCol).value
		vUn=jsMakeNbr(vUn)
		vUn=Math.abs(vUn)
		vAl=document.getElementById("Alloc_" + vCol).value
		vAl=jsMakeNbr(vAl)
		vAl=Math.abs(vAl)
		if ((vUn + vAl)>vTt) { 
			alert("Your Unallocated plus Allocated amounts for " + vCol + " are greater than your Total amounts.")
			return
			}
		}
	}
for (i=0;i<els.length;i++) {
	n=els[i].name
	v=els[i].value
	if (n.substr(0,8)=="Unalloc_") { vTotUn=vTotUn+v }
	if (n.substr(0,6)=="Alloc_") { vTotAl=vTotAl+v }
	}
d=((vTotUn/vTotAl)/vTotAl)
if (d>.2) {
	alert("Your overall unallocated amounts are greater than 20% of the total.")
	return
	}
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="SUBMIT"
document.thisForm.submit()
}
function noenter() {
  return !(window.event && window.event.keyCode == 13); }

function jsAddByZone(t) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="ADDBYZONE"
document.thisForm.hdnNextVal.value=t.value
document.thisForm.submit()
}
function jsFlagDirty(r) {
document.getElementById("hdnDirty_" + r).value="Y"
}
function jsZones(jMastheadID,jZipHeaderID) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnGotoPage.value="_Zones.asp?MH=" + jMastheadID + "&ZHID=" + jZipHeaderID
document.thisForm.submit()
}
function jsSaveZips(t,p,m) {
document.thisForm.hdnNextOp.value=""
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsAddSome(v,z) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="ADDSOME"
document.thisForm.hdnNextVal.value=v
document.thisForm.submit()
}
function jsUnsubmit() {
rv=prompt('Please explain the reason for the Un-Submit action:','')
if (rv!="") {
	document.thisForm.hdnSaveThis.value="SAVE"
	document.thisForm.hdnPromptResponse.value=rv
	document.thisForm.hdnNextOp.value="UNSUBMIT"
	document.thisForm.submit()
	}
}
function jsSort(f,d) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="SORT"
document.thisForm.hdnSortFld.value=f
document.thisForm.hdnSortDir.value=d
document.thisForm.submit()
}
function jsSumZipRow(t,r,n) {
vThisVal=jsMakeNbr(t.value)
document.getElementById("hdnDirty_" + r).value="Y"
if (vThisVal<0) {
	alert("Please enter a non-negative number.")
	t.value=jPrevZipVal
	event.returnValue=false; 
	t.select()
	return
	}
jDiff=vThisVal-jPrevZipVal
v=document.getElementById("Unalloc_" + n).value
v=jsMakeNbr(v)
if (jDiff>v) {
	alert("This amount (" + t.value + ") is greater than your unallocated total (" + v + ").")
	t.value=jPrevZipVal
	event.returnValue=false; 
	t.select()
	return
	}
jUnalloc=new Number(v)
jUnalloc=jUnalloc-jDiff
jUnalloc=jsFormatNbr(jUnalloc)
v=document.getElementById("Alloc_" + n).value
v=jsMakeNbr(v)
jAlloc=new Number(v)
jAlloc=jAlloc + jDiff
jAlloc=jsFormatNbr(jAlloc)
v=document.getElementById("ZipTtl_" + r).value
v=jsMakeNbr(v)
jZipTtl=new Number(v)
jZipTtl=jZipTtl + jDiff
jZipTtl=jsFormatNbr(jZipTtl)
document.getElementById("ZipTtl_" + r).value=jZipTtl
document.getElementById("Alloc_" + n).value=jAlloc
document.getElementById("UnAlloc_" + n).value=jUnalloc
}
function jsGetZip(t,f,zID,jMastheadID,r) {
document.getElementById("hdnDirty_" + r).value="Y"
parent.frHeader.location="VerifiedHeader.asp?Z=" + t.value + "&F=" + f + "&ID=" + zID + "&O=" + jPrevZipCodeVal + "&MH=" + jMastheadID
}
function jsShowRows(t) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="SHOWROWS"
document.thisForm.hdnNextVal.value=t
document.thisForm.submit()
}
function jsSaveCallPage(t,p,m,g) {
document.thisForm.hdnNextPage.value=g
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsListSelect(f) {
if (f.selectedIndex==-1) { alert("Please select a " + f.name); return }
v=f.options[f.selectedIndex].value
x=f.options[f.selectedIndex].text
if (v=="") { alert("Please select a " + f.name); return }
jGotoPage="_Masts.asp?MD=EDIT&MH=" + v  + "&PUB=" + document.thisForm.hdnCurID.value
document.thisForm.hdnGotoPage.value=jGotoPage
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsChgChkVal(t,f) {
if (f.substr(0,3)=="chk") { f=f.substr(3) }
rv=eval("v=document.thisForm.elements['" + f + "'].value")
v=v.toUpperCase()
if ((v=="") || (v=="ON")) { rv=eval("document.thisForm.elements['" + f + "'].value='OFF'") } else rv=eval("document.thisForm.elements['" + f + "'].value='ON'")
rv=eval("v=document.thisForm.elements['" + f + "'].value")
if (f.toUpperCase()=="BULKDISTGROSSYN") { 
	if (v=="OFF") {
		if (document.thisForm.GetFreeGrossTarget.value=="ON") {
			document.thisForm.GetFreeTargetReturns.value="ON"
			document.thisForm.chkGetFreeTargetReturns.checked=true
			}
		if (document.thisForm.GetPaidGrossRack.value=="ON") {
			document.thisForm.GetPaidRackReturns.value="ON"
			document.thisForm.chkGetPaidRackReturns.checked=true
			}
		if (document.thisForm.GetPaidGrossDealer.value=="ON") {
			document.thisForm.GetPaidDealerReturns.value="ON"
			document.thisForm.chkGetPaidDealerReturns.checked=true
			}
		}
	else {
		document.thisForm.GetFreeTargetReturns.value="OFF"
		document.thisForm.GetPaidDealerReturns.value="OFF"
		document.thisForm.GetPaidRackReturns.value="OFF"
		document.thisForm.chkGetFreeTargetReturns.checked=false
		document.thisForm.chkGetPaidDealerReturns.checked=false
		document.thisForm.chkGetPaidRackReturns.checked=false
		}
	}
}
function jsHideShow(l,hs) {
v=document.getElementById(l); v.style.visibility=hs
}
function lstChange(t,vRS) {
vFldName=t.name
if (vFldName.toUpperCase()=="FREQUENCY") {
   if (divFreqExpl) {
		divFreqExpl.innerText=""
		rv=jsHideShow("spanFrequencyDays","hidden")
		rv=jsHideShow("spanFrequencyDOW1","hidden")
		rv=jsHideShow("spanFrequencyDOW2","hidden")
		rv=jsHideShow("spanFrequencyDOM1","hidden")
		rv=jsHideShow("spanFrequencyDOM2","hidden")
		rv=jsHideShow("spanFrequencyPosition","hidden")
		rv=jsHideShow("spanFrequency2ndPosition","hidden")
		rv=jsHideShow("spanFrequencyDate1","hidden")
		rv=jsHideShow("spanFrequencyDate2","hidden")
		v=t.value
		v=new Number(v)
		if (v==1) {	//once or more per week
			divFreqExpl.innerText="Select one or more days of the week by ctrl-clicking."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=false;
				document.thisForm.BulkDistGrossYN.value="OFF";
				document.thisForm.chkGetFreeTargetReturns.checked=true;
				document.thisForm.GetFreeTargetReturns.value="ON";
				document.thisForm.chkGetPaidRackReturns.checked=true;
				document.thisForm.GetPaidRackReturns.value="ON";
				document.thisForm.chkGetPaidDealerReturns.checked=true;
				document.thisForm.GetPaidDealerReturns.value="ON";
				}
			rv=jsHideShow("spanFrequencyDays","visible")
			}
		if (v==2) {	//every two weeks
			divFreqExpl.innerText="Select the day of week."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=false;
				document.thisForm.BulkDistGrossYN.value="OFF";
				document.thisForm.chkGetFreeTargetReturns.checked=true;
				document.thisForm.GetFreeTargetReturns.value="ON";
				document.thisForm.chkGetPaidRackReturns.checked=true;
				document.thisForm.GetPaidRackReturns.value="ON";
				document.thisForm.chkGetPaidDealerReturns.checked=true;
				document.thisForm.GetPaidDealerReturns.value="ON";
				}
			rv=jsHideShow("spanFrequencyDOW1","visible")
			}
		if (v==3) {	//twice per month
			divFreqExpl.innerText="Select the position and day of week (i.e. 1st Wednesday) OR specific days of the month (i.e. 1 and 15)."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=false;
				document.thisForm.BulkDistGrossYN.value="OFF";
				document.thisForm.chkGetFreeTargetReturns.checked=true;
				document.thisForm.GetFreeTargetReturns.value="ON";
				document.thisForm.chkGetPaidRackReturns.checked=true;
				document.thisForm.GetPaidRackReturns.value="ON";
				document.thisForm.chkGetPaidDealerReturns.checked=true;
				document.thisForm.GetPaidDealerReturns.value="ON";
				}
			rv=jsHideShow("spanFrequencyDOW1","visible")
			rv=jsHideShow("spanFrequencyDOW2","visible")
			rv=jsHideShow("spanFrequencyDOM1","visible")
			rv=jsHideShow("spanFrequencyDOM2","visible")
			rv=jsHideShow("spanFrequencyPosition","visible")
			rv=jsHideShow("spanFrequency2ndPosition","visible")
			}
		if (v==4) {	//once per month
			divFreqExpl.innerText="Select a position and day of week (i.e. 1st Wednesday) OR a specific day of the month (i.e. 15)."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=true;
				document.thisForm.BulkDistGrossYN.value="ON";
				document.thisForm.chkGetFreeTargetReturns.checked=false;
				document.thisForm.GetFreeTargetReturns.value="OFF";
				document.thisForm.chkGetPaidRackReturns.checked=false;
				document.thisForm.GetPaidRackReturns.value="OFF";
				document.thisForm.chkGetPaidDealerReturns.checked=false;
				document.thisForm.GetPaidDealerReturns.value="OFF";
				}
			rv=jsHideShow("spanFrequencyDOW1","visible")
			rv=jsHideShow("spanFrequencyPosition","visible")
			rv=jsHideShow("spanFrequencyDOM1","visible")
			}
		if ((v==5)) {	//Bi-monthly
			divFreqExpl.innerText="Enter the exact distribution date(s)."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=true;
				document.thisForm.BulkDistGrossYN.value="ON";
				document.thisForm.chkGetFreeTargetReturns.checked=false;
				document.thisForm.GetFreeTargetReturns.value="OFF";
				document.thisForm.chkGetPaidRackReturns.checked=false;
				document.thisForm.GetPaidRackReturns.value="OFF";
				document.thisForm.chkGetPaidDealerReturns.checked=false;
				document.thisForm.GetPaidDealerReturns.value="OFF";
				}
			rv=jsHideShow("spanFrequencyDate1","visible")
			rv=jsHideShow("spanFrequencyDate2","visible")
			}
		if ((v==6)) {	//Quarterly
			divFreqExpl.innerText="Enter the exact distribution date(s)."
			if (document.thisForm.chkBulkDistGrossYN) {
				document.thisForm.chkBulkDistGrossYN.checked=true;
				document.thisForm.BulkDistGrossYN.value="ON";
				document.thisForm.chkGetFreeTargetReturns.checked=false;
				document.thisForm.GetFreeTargetReturns.value="OFF";
				document.thisForm.chkGetPaidRackReturns.checked=false;
				document.thisForm.GetPaidRackReturns.value="OFF";
				document.thisForm.chkGetPaidDealerReturns.checked=false;
				document.thisForm.GetPaidDealerReturns.value="OFF";
				}
			rv=jsHideShow("spanFrequencyDate1","visible")
			}
		}
	}
}
var jPrevQPDVal
var jRows=new Array()
var jCols=new Array()
var jPrevDateVal
var jCurrentField
var jDiff
var jIsMac;
var jBrowserType;
var jIsOpera;
var jDtSize;

if (navigator.appName.indexOf("Netscape")!=-1) { jBrowserType="NS" } else { jBrowserType="IE" } 
v=navigator.userAgent.toLowerCase()
if (v.indexOf("mac")>-1) { jIsMac=true } else { jIsMac=false } 
if (v.indexOf("safari")!=-1) { jIsSafari=true } else { jIsSafari=false } 
if (v.indexOf("opera")>-1) { jIsOpera=true } else { jIsOpera=false } 
if (jIsOpera) {	jDtSize=11 } else { jDtSize=8 }

function noenter() {
  return !(window.event && window.event.keyCode == 13); }

function jsSubmitQPD(t,q) {
document.thisForm.hdnGotoPage.value="_Submit.asp?QHID=" + q
rv=jsRecalcQPD()
rv=jsSaveRec(t,"","")
}
function jsTab(t,e) {
if ((jIsOpera==true) || (jIsMac==true) || (jBrowserType=="NS")) {
	if (!jIsMac) { if ((e==undefined) || (!(e))) { return } }
	var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	if (keyCode==13) {
		if (jBrowserType=="NS") {
			x=t.tabIndex
			}
		else {
			x=e.srcElement.tabIndex
			}
		els=document.getElementsByTagName("INPUT")
		for (j=1;j<20;j++) {
			z=new Number(x)+j
			for (i=0;i<els.length;i++) {
				y=els[i].tabIndex;
				y=new Number(y) 
				if (y==z) { els[i].select(); return false; }		
				}
			}
		return false;
		}
	}
else {
	if (event.keyCode==13) { event.keyCode=9 }
	}
}
function jsCopyCol() {
if (!jCurrentField) { alert("Please put your cursor on a data field and try again.") }
if (jCurrentField.id=="") { alert("Please put your cursor on a data field and try again.") }
vID=jCurrentField.id
p=vID.indexOf("_")
n=vID.substr(0,p)
d=document.getElementById("RunDate" + vID.substr(p)).value
if (!confirm("Confirm copying the value in " + n + " for " + d + " across your columns?")) { return; }
document.thisForm.hdnNextOp.value="COPYCOL"
document.thisForm.hdnNextID.value=vID.substr(p+1)
document.thisForm.hdnNextVal.value=n
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsSumQPDAvg(t,f) {
f=f.toUpperCase()
v=t.name
p=v.indexOf("_")
x=v.substr(0,p+1)
if (f=="PAIDRACKRETURNS") {
	e=document.getElementById(x + "PaidGrossRack")
	v=jsMakeNbr(e.value)
	z=v-jsMakeNbr(t.value)
	e=document.getElementById(x + "NetRackReturns")
	e.value=jsFormatNbr(z)
	v1=document.getElementById(x + "PaidRackReturns").value
	v2=document.getElementById(x + "FreeTargetReturns").value
	v3=document.getElementById(x + "PaidDealerReturns").value
	document.getElementById(x + "Returns").value=jsMakeNbr(v1)+jsMakeNbr(v2)+jsMakeNbr(v3)
	}
if (f=="FREETARGETRETURNS") {
	e=document.getElementById(x + "FreeGrossTarget")
	v=jsMakeNbr(e.value)
	z=v-jsMakeNbr(t.value)
	e=document.getElementById(x + "NetTargetReturns")
	e.value=jsFormatNbr(z)
	v1=document.getElementById(x + "PaidRackReturns").value
	v2=document.getElementById(x + "FreeTargetReturns").value
	v3=document.getElementById(x + "PaidDealerReturns").value
	document.getElementById(x + "Returns").value=jsMakeNbr(v1)+jsMakeNbr(v2)+jsMakeNbr(v3)
	}
if (f=="PAIDDEALERRETURNS") {
	e=document.getElementById(x + "PaidGrossDealer")
	v=jsMakeNbr(e.value)
	z=v-jsMakeNbr(t.value)
	e=document.getElementById(x + "NetDealerReturns")
	e.value=jsFormatNbr(z)
	v1=document.getElementById(x + "NetRackReturns").value
	v2=document.getElementById(x + "NetDealerReturns").value
	document.getElementById(x + "NetRackDealerReturns").value=jsMakeNbr(v1)+jsMakeNbr(v2)
	v1=document.getElementById(x + "PaidRackReturns").value
	v2=document.getElementById(x + "FreeTargetReturns").value
	v3=document.getElementById(x + "PaidDealerReturns").value
	document.getElementById(x + "Returns").value=jsMakeNbr(v1)+jsMakeNbr(v2)+jsMakeNbr(v3)
	}
}
function jsFillTots(t) {
v=t.value
n=t.id
if (v!="") {
	vNbrIssues=document.thisForm.hdnNbrCols.value
	vNbrIssues=new Number(vNbrIssues)
	p=n.indexOf("_")
	f=n.substr(p)
	v=jsMakeNbr(v)
	q=v/vNbrIssues
	v=v/3
	a=v/3
	v=jsFormatNbr(v)
	a=jsFormatNbr(a)
	q=jsFormatNbr(q)
	e=document.getElementById("QtrAvg" + f)
	if ((e.value=="") || (e.value==0)) { e.value=q }
	e=document.getElementById("Mth1Ttl" + f)
	if ((e.value=="") || (e.value==0)) { e.value=v }
	e=document.getElementById("Mth1Avg" + f)
	if ((e.value=="") || (e.value==0)) { e.value=a }
	e=document.getElementById("Mth2Ttl" + f)
	if ((e.value=="") || (e.value==0)) { e.value=v }
	e=document.getElementById("Mth2Avg" + f)
	if ((e.value=="") || (e.value==0)) { e.value=a }
	e=document.getElementById("Mth3Ttl" + f)
	if ((e.value=="") || (e.value==0)) { e.value=v }
	e=document.getElementById("Mth3Avg" + f)
	if ((e.value=="") || (e.value==0)) { e.value=a }
	}
}
function jsRecalcQPD() {
var i
document.thisForm.hdnSaveAll.value="Y"
jFlds=document.thisForm.getElementsByTagName("INPUT")
for (i=0;i<jFlds.length;i++) {
	n=jFlds[i].id
	p=n.indexOf("_")
	if (p>-1) {
		c=n.substr(0,p)
		x=n.substr(p+1)
		if (c=="RunDate") {
			e=document.getElementById("FreeCarrier_" + x); jFreeCarrier=jsMakeNbr(e.value)
			e=document.getElementById("FreeMail_" + x); jFreeMail=jsMakeNbr(e.value)
			e=document.getElementById("FreeOTC_" + x); jFreeOTC=jsMakeNbr(e.value)
			e=document.getElementById("FreeGrossTarget_" + x); jFreeGrossTarget=jsMakeNbr(e.value)
			e=document.getElementById("FreeTargetReturns_" + x); jFreeTargetReturns=jsMakeNbr(e.value)
				document.getElementById("NetTargetReturns_" + x).value=jsFormatNbr(jFreeGrossTarget-jFreeTargetReturns)
			e=document.getElementById("NetTargetReturns_" + x); jNetTargetReturns=jsMakeNbr(e.value)
				document.getElementById("FreeCirculation_" + x).value=jsFormatNbr(jFreeCarrier+jFreeMail+jFreeOTC+jFreeGrossTarget-jFreeTargetReturns)
			e=document.getElementById("FreeCirculation_" + x); jFreeCirculation=jsMakeNbr(e.value)
			
			e=document.getElementById("PaidCarrier_" + x); jPaidCarrier=jsMakeNbr(e.value)
			e=document.getElementById("PaidMail_" + x); jPaidMail=jsMakeNbr(e.value)
			e=document.getElementById("PaidGrossRack_" + x); jPaidGrossRack=jsMakeNbr(e.value)
			e=document.getElementById("PaidRackReturns_" + x); jPaidRackReturns=jsMakeNbr(e.value)
				document.getElementById("NetRackReturns_" + x).value=jsFormatNbr(jPaidGrossRack-jPaidRackReturns)
			e=document.getElementById("NetRackReturns_" + x); jNetRackReturns=jsMakeNbr(e.value)
			e=document.getElementById("SponsoredThirdPty_" + x); jSponsoredThirdPty=jsMakeNbr(e.value)
			e=document.getElementById("NIE_" + x); jNIE=jsMakeNbr(e.value)
			e=document.getElementById("PaidGrossDealer_" + x); jPaidGrossDealer=jsMakeNbr(e.value)
			e=document.getElementById("PaidDealerReturns_" + x); jPaidDealerReturns=jsMakeNbr(e.value)
				document.getElementById("NetDealerReturns_" + x).value=jsFormatNbr(jPaidGrossDealer-jPaidDealerReturns)
			e=document.getElementById("NetDealerReturns_" + x); jNetDealerReturns=jsMakeNbr(e.value)
				document.getElementById("NetRackDealerReturns_" + x).value=jsFormatNbr(jNetRackReturns+jNetDealerReturns)
			e=document.getElementById("NetRackDealerReturns_" + x); jNetRackDealerReturns=jsMakeNbr(e.value)
				document.getElementById("PaidCirculation_" + x).value=jsFormatNbr(jPaidCarrier+jPaidMail+jSponsoredThirdPty+jNIE+jNetRackDealerReturns)
			e=document.getElementById("PaidCirculation_" + x); jPaidCirculation=jsMakeNbr(e.value)

				document.getElementById("QualifiedCirculation_" + x).value=jsFormatNbr(jFreeCirculation+jPaidCirculation)
			e=document.getElementById("QualifiedCirculation_" + x); jQualifiedCirculation=jsMakeNbr(e.value)
				document.getElementById("Returns_" + x).value=jsFormatNbr(jFreeTargetReturns+jPaidRackReturns+jPaidDealerReturns)
			e=document.getElementById("Returns_" + x); jReturns=jsMakeNbr(e.value)
			e=document.getElementById("Printed_" + x); jPrinted=jsMakeNbr(e.value)
			e=document.getElementById("MailNonQual_" + x); jMailNonQual=jsMakeNbr(e.value)
				document.getElementById("OtherNonQual_" + x).value=jsFormatNbr(jPrinted-jQualifiedCirculation-jReturns-jMailNonQual)
			e=document.getElementById("OtherNonQual_" + x); jOtherNonQual=jsMakeNbr(e.value)
				document.getElementById("ReturnsNonQual_" + x).value=jsFormatNbr(jReturns+jMailNonQual+jOtherNonQual)
			e=document.getElementById("ReturnsNonQual_" + x); jReturnsNonQual=jsMakeNbr(e.value)
			document.getElementById("hdnDirty_" + x).value="Y";
			}			
		}
	}
jsSaveRec(document.thisForm.hdnCurID,'','')	
}
function jsMakeRedAll() {
var i,j
for (i=1;i<=jRows.length;i++) {
	for (j=1;j<=jCols.length;j++) {
		if (j>1) {
			jsMakeRed(i,j)
			}
		}	
	}
}
function jsMakeRed(i,j) {
e1=document.getElementById(jRows[i] + "_" + jCols[j])
e2=document.getElementById(jRows[i] + "_" + jCols[j-1])
if ((e1) && (e2)) {
	jOldVal=jsMakeNbr(e1.value)
	jNewVal=jsMakeNbr(e2.value)
	if (Math.abs(((jNewVal-jOldVal)/jOldVal))>.1) {
		e1.style.color="red"
		}
	else {
		e1.style.color="black"
		}
	}
}
function jsFootnote() {
if (!jCurrentField) { alert("Please put your cursor on a data field and try again.") }
if (jCurrentField.id=="") { alert("Please put your cursor on a data field and try again.") }
vID=jCurrentField.id
p=vID.indexOf("_")
d=vID.substr(p+1)
vFN=prompt('Please enter a footnote for this field (' + vID + '):','')
v=document.getElementById("QPDDetailNotes_" + d).value
jToday=new Date()
document.getElementById("QPDDetailNotes_" + d).value=v + ":: " + vFN
vNotes=document.getElementById("QPDDetailNotes_" + d).value
document.getElementById("hdnDirty_" + d).value="Y"
d=d.toString()
o=document.getElementById("divDays_" + d)
v=o.innerHTML
h="<input type=button onmouseout=javascript:this.style.color='black' onmouseover=javascript:this.style.color='red'  onclick=javascript:jsViewFootnote(" + d + ") value='*'  style='width:10;border:0px;background:transparent;text-decoration:underline;font-size:xx-small;'>"
if (v.indexOf("*")==-1) { o.innerHTML=o.innerHTML + h }
}
function jsViewFootnote(d) {
o=document.getElementById("QPDDetailNotes_" + d)
alert(o.value)
}
function jsChgRunDate(t,n) {
rv=couldBeDate(t.value)
if (rv!="") { alert("Please enter a valid date."); event.preventDefault; event.returnValue=null;t.value=jPrevDateVal; return; }
if (!(confirm("Please confirm that you mean to change this date."))) { event.preventDefault; event.returnValue=null; t.value=jPrevDateVal; return; }
parent.frHeader.location="VerifiedHeader.asp?T=CHKDATE&V=" + t.value + "&QID=" + document.thisForm.hdnQPDHeaderID.value
d=new Date(t.value)
v=t.value
f="OldRunDate_" + n
document.getElementById(f).value=jPrevDateVal
document.getElementById("hdnDirty_" + n).value="Y"
var x = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
v=d.getUTCDay()
o=document.getElementById("divDays_" + n)
z=o.innerHTML
p=z.indexOf("<A")
if (p>-1) { z=z.substr(p) }
o.innerHTML=x[v] + z
}
function jsExplainNoChk(t) {
v=t.name
a=v.substr(3)
p=v.indexOf("_")
q=v.substr(p+1)
d=document.thisForm.elements['RunDate_' + q].value
v=document.thisForm.hdnNbrCols.value
z=new Number(v)
document.getElementById("QPDDetailNotes_" + q).value
document.getElementById("hdnDirty_" + q).value="Y"
if (!t.checked) {
	rv=prompt('Please explain the reason for the not using this date (' + d + '):','')
	document.getElementById("QPDDetailNotes_" + q).value=document.getElementById("QPDDetailNotes_" + q).value + ":  User unchecked column for [" + d + "] : " + rv
	document.thisForm.hdnSaveThis.value="SAVE"
	document.thisForm.submit()
	}
else {
	}
}
function jsAddCol() {
if (!confirm("Confirm adding a new column to this QPD?")) { return; }
document.thisForm.hdnNextOp.value="ADDCOL"
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsCallZips() {
d=""
if (document.thisForm.cmbZips) {
	i=document.thisForm.cmbZips.selectedIndex
	d=document.thisForm.cmbZips.options[i].text
	}
jID=""
if (d!="") {
	jID=document.thisForm.cmbZips.value
	}
else	{
	if (!jCurrentField) {
		alert("Put your cursor on a data field and try again.")
		return
		}
	v=jCurrentField.id
	p=v.indexOf("_")
	if (p>-1) {
		jID=v.substr(p+1)
		}
	jRunDate=document.getElementById("RunDate_" + jID).value
	if (!confirm("Confirm working with Zip data for Run Date of " + jRunDate + "?")) {
		return
		}
	}
if (jID!="") {	
	document.thisForm.hdnSaveThis.value="SAVE"
	document.thisForm.hdnGotoPage.value="_Zips.asp?QDID=" + jID
	document.thisForm.submit()
	}
}
function jsSaveQPD(t,p,m) {
jsRecalcQPD
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsShowRow(t,jFld,jNbrCols) {
document.thisForm.hdnSaveAll.value="Y"
jsShowHide(t,jFld)
if (t.name=="GetFreeGrossTarget") {
	if (t.checked) {
		document.thisForm.GetFreeTargetReturns.checked=true
		}
	else	{
		document.thisForm.GetFreeTargetReturns.checked=false
		}
	jsShowHide(t,"FreeTargetReturns")
	jsShowHide(t,"NetTargetReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
if (t.name=="GetFreeTargetReturns") {
	if (t.checked) {
		document.thisForm.GetFreeGrossTarget.checked=true
		}
	else	{
		document.thisForm.GetFreeGrossTarget.checked=false
		}
	jsShowHide(t,"FreeGrossTarget")
	jsShowHide(t,"NetTargetReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
if (t.name=="GetPaidRackReturns") {
	if (t.checked) {
		document.thisForm.GetPaidGrossRack.checked=true
		}
	else	{
		document.thisForm.GetPaidGrossRack.checked=false
		}
	jsShowHide(t,"PaidGrossRack")
	jsShowHide(t,"NetRackReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
if (t.name=="GetPaidGrossRack") {
	if (t.checked) {
		document.thisForm.GetPaidRackReturns.checked=true
		}
	else	{
		document.thisForm.GetPaidRackReturns.checked=false
		}
	jsShowHide(t,"PaidRackReturns")
	jsShowHide(t,"NetRackReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
if (t.name=="GetPaidGrossDealer") {
	if (t.checked) {
		document.thisForm.GetPaidDealerReturns.checked=true
		}
	else	{
		document.thisForm.GetPaidDealerReturns.checked=false
		}
	jsShowHide(t,"PaidDealerReturns")
	jsShowHide(t,"NetDealerReturns")
	jsShowHide(t,"NetRackDealerReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
if (t.name=="GetPaidDealerReturns") {
	if (t.checked) {
		document.thisForm.GetPaidGrossDealer.checked=true
		}
	else	{
		document.thisForm.GetPaidGrossDealer.checked=false
		}
	jsShowHide(t,"PaidGrossDealer")
	jsShowHide(t,"NetDealerReturns")
	jsShowHide(t,"NetRackDealerReturns")
	jsShowHide(t,"Returns")
	jsShowHide(t,"ReturnsNonQual")
	}
}
function jsShowHide(t,jFld) {
jFlds=document.thisForm.getElementsByTagName("INPUT")
for (i=0;i<jFlds.length;i++) {
	n=jFlds[i].name
	if (n.indexOf("_")>-1) {
		l=jFld.length
		x=n.substr(0,l)
		if (x==jFld) {
			if (t.checked) {
				jFlds[i].style.visibility="visible"
				}
			else	{
				jFlds[i].style.visibility="hidden"
				}
			}
		}
	}
}
function jsShowAvg(t,jNbrRows) {
jFld=t.value
for (i=1;i<jNbrRows+1;i++) {
	document.getElementById("Avg_" + jRows[i]).value=document.getElementById("Avg" + jFld + "_" + jRows[i]).value
	}	
}
function jsSort(f,d) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnNextOp.value="SORT"
document.thisForm.hdnSortFld.value=f
document.thisForm.hdnSortDir.value=d
document.thisForm.submit()
}
function jsShowCols(t) {
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.hdnShowCols.value=v
document.thisForm.hdnNextOp.value="SHOWCOLS"
document.thisForm.hdnNextVal.value=t
document.thisForm.hdnShowFields.value=t
document.thisForm.submit()
}
function jsListSelect(f) {
if (f.selectedIndex==-1) { alert("Please select a " + f.name); return }
v=f.options[f.selectedIndex].value
x=f.options[f.selectedIndex].text
if (v=="") { alert("Please select a " + f.name); return }
jGotoPage="_Masts.asp?MD=EDIT&MH=" + v  + "&PUB=" + document.thisForm.hdnCurID.value
document.thisForm.hdnGotoPage.value=jGotoPage
document.thisForm.hdnSaveThis.value="SAVE"
document.thisForm.submit()
}
function jsIsMT(s) {
if (s==null) { return true }
if (s=="") { return true }
if (s==0) { return true }
}
function jsCheckSave(e) {
if (!document.thisForm.hdnSaveThis) { return }
v=document.thisForm.hdnSaveThis.value
//alert(v)
if (v!="SAVE") {
	event.returnValue="!WARNING!  Have you saved your work?  Select Cancel now and press the Save button before closing." 
	document.thisForm.hdnSaveThis.value="SAVE"
	document.thisForm.submit();
	}
}
function jsGotoPageNbr(p,t) {
v=t.value
if (v!="") { window.location=p + "&SP=" + v }
}
function jsFindArrayMatch(jArray,jVal) {
var i
for (i=1;i<=jArray.length;i++) {
	if (jArray[i]==jVal) {
		return i
		}
	}
}
function jsEnter2Tab() {
if (event.keyCode==13) { event.keyCode=9 }
}
function jsSaveRec(t,vPageToCall,jMsg) {
//jCurID=t.value;
for (eli=0;eli<document.thisForm.elements.length;eli++) { 
	var e=document.thisForm.elements[eli]
	if (!e.dataFld=="") { 
		vc=e.dataFld
		vv=e.value
		vn=e.name
		if (vn.substr(0,4)=="DOM_") { vn=vn.substr(4) }
		if ((vv=="") && (vc.indexOf("|VC_REQUIRED|")>-1)) { 
			alert("Entry error.  " + vn + " requires a value."); e.focus();
			return
			}
		if ((vv!="") && (vc.indexOf("|VC_NUMBER|")>-1)) { 
			rv=isNumber(e.value);
			if (rv!="") { alert(mBadNumber + ":" + e.name + ":" + rv); e.focus(); return; }
			e.value=MakeNumber(e)
			}
		if ((vv!="") && (vc.indexOf("|VC_CURRENCY|")>-1)) { 
			rv=isCurrency(e.value);
			if (rv!="") { alert(mBadCurrency + ":" + e.name + ":" + rv); e.focus(); return; }
			e.value=MakeNumber(e)
			}
		if ((vv!="") && (vc.indexOf("|VC_DATE|")>-1)) { 
			rv=couldBeDate(e.value);
			if (rv!="") { alert(mBadDate + ":" + e.name + ":" + rv); e.focus(); return; }
			}
		if ((vv!="") && (vc.indexOf("|VC_ZIP|")>-1)) { 
			rv=isZip(e);
			if (rv!="") { alert(mBadZip + ":" + e.name + ":" + rv); e.focus(); return; }
			}
		if ((vv!="") && (vc.indexOf("|VC_PHONE|")>-1)) { 
			rv=isPhone(e);
			if (rv!="") { alert(mBadPhone + ":" + e.name + ":" + rv); e.focus(); return; }
			}
		if ((vv!="") && (vc.indexOf("|VC_EMAIL|")>-1)) { 
			rv=isEmail(e);
			if (rv!="") { alert(mBadEmail + ":" + e.name + ":" + rv); e.focus(); return; }
			}
		if ((vv!="") && (vc.indexOf("|VC_URL|")>-1)) { 
			rv=isURL(e);
			if (rv!="") { alert(mBadURL + ":" + e.name + ":" + rv); e.focus(); return; }
			}
		if ( (vv!="") && (vc.indexOf("|VC_STRIPQUOTES|")>-1) ) { 
			v=e.value;
			x=""
			for (iz=0;iz<v.length;iz++) {
				if ((v.charCodeAt(iz)!=34) && (v.charCodeAt(iz)!=39)) { x=x + v.charAt(iz) }
				}
			e.value=x;
			}
		}
	}
rv=true;
if (jMsg!="") { rv=confirm(jMsg) }
if (rv) {
	document.thisForm.hdnSaveThis.value="SAVE"
	document.thisForm.hdnCurID.value=t.value
	if (vPageToCall!="") { document.thisForm.hdnGotoPage.value=vPageToCall }
	document.thisForm.submit()
	}
}
function jsGetMonthInQuarter(d) {
nd=new Date(d)
m=nd.getMonth()
if ((m==0) || (m==3) || (m==6) || (m==9)) { return 1 }
if ((m==1) || (m==4) || (m==7) || (m==10)) { return 2 }
if ((m==2) || (m==5) || (m==8) || (m==11)) { return 3 }
}
function jsMakeNbr(x) {
if (x=="") { return 0 }
x=x.toString()
z=""
for (i=0;i<x.length;i++) {
	y=x.substr(i,1)
	if (y!=",") { z=z + y }
	}
z=new Number(z)	
return z
}
function jsFormatNbr(x) {
z=""
k=x.toString()
m=k.substr(0,1)
if (m=="-") { k=k.substr(1); } else { m="" }
p=k.indexOf(".")
d=0
jAddOne=0
if (p>-1) { 
	d=k.substr(p+1); 
	k=k.substr(0,p); 
	if (d.length>0) {
		y=d.substr(0)
		y=new Number(y)
		if (y>4) { jAddOne=1; }
		}
	}
z=k
z=new Number(z)
z=z + jAddOne
if (k.length>3) {
	if (k.length<=6) {
		l=(k.length-3)
		z=k.substr(0,l) + "," + k.substr(l,3) 
		return z
		}
	if (k.length<=9) {
		l=(k.length-6)
		z=k.substr(0,l) + "," + k.substr(l,3) + "," + k.substr(k.length-3,3)
		}
	}
return m + z
}
function jsGotoRec(r) {
document.thisForm.hdnSaveThis.value="SAVE";
document.thisForm.hdnNextOp.value="GOTOREC";
document.thisForm.hdnGotoRec.value=r;
document.thisForm.submit()
}
function jsSaveCallPage(t,p,m,g) {
document.thisForm.hdnNextPage.value=g
document.thisForm.hdnSaveThis.value="SAVE"
v=document.thisForm.hdnSaveThis.value
document.thisForm.submit()
}
function jsSaveAndGotoPage(vCall,vx) {
if (document.thisForm.Recalc) { 
	vOriginalVal=document.thisForm.Recalc.value
	document.thisForm.Recalc.value="ON"
	rv=jsRecalcSheet()
	document.thisForm.Recalc.value=vOriginalVal
	}
document.thisForm.hdnSaveThis.value="SAVE";
document.thisForm.hdnGotoPage.value=vCall + vx;
document.thisForm.submit()
}
function jsExport(t,pg) {
document.thisForm.hdnSaveThis.value="SAVE";
document.thisForm.hdnNextOp.value="EXPORT";
document.thisForm.submit()
}
function jsReport(t,pg) {
document.thisForm.hdnSaveThis.value="SAVE";
document.thisForm.hdnNextOp.value="REPORT";
document.thisForm.submit()
}
function jsDelRec(t,pg) {
if (pg.indexOf("?")==-1) { ad="?" } else { ad="&" }
if (confirm("Please confirm deleting this record?")) {
	document.thisForm.hdnNextOp.value="DELETE";
	document.thisForm.submit()
	}
}
function jsAddRec(t,pg) {
if (pg.indexOf("?")==-1) { ad="?" } else { ad="&" }
if (confirm("Please confirm adding a record.")) {
	document.thisForm.hdnSaveThis.value="SAVE";
	document.thisForm.hdnNextOp.value="ADD";
	document.thisForm.submit()
	}
}
function jsChgMode(m) {
document.thisForm.hdnNextMode.value=m
document.thisForm.submit()
}
function jsChangeListFontSize(v) {
document.thisForm.hdnNextOp.value="FONTSIZE"
document.thisForm.hdnFromVal.value=v
document.thisForm.submit()
}
function jsShowRows(v) {
document.thisForm.hdnNextOp.value="SHOWROWS"
document.thisForm.hdnFromVal.value=v
document.thisForm.hdnShowRows.value=v
document.thisForm.submit()
}
function jsSaveUserRec() {
e=document.thisForm.Email; if (e.value=="") { alertm("",e); return }; if (e.value=="NEW") { alertm("Please provide a valid User Name.",e); return };
e=document.thisForm.Phone; 
if (e.value!="") { rv=isPhone(e); if (rv!="") { alertm("Please provide a valid phone.  " + rv,e); return } }
e=document.thisForm.Email; if (e.value=="") { alertm("",e); return };
rv=isEmail(e); if (rv!="") { alertm("Please provide a valid email address.  " + rv,e); return }
e=document.thisForm.ConfirmEmail; if (e.value=="") { alertm("",e); return };
rv=isEmail(e); if (rv!="") { alertm("Please provide a valid email address.  " + rv,e); return }
if (e.value!=document.thisForm.Email.value) { alertm("Your email and your confirm email values do not match.",e); return }
e=document.thisForm.UserPW; if (e.value=="") { alertm("",e); return };
e=document.thisForm.ConfirmPW; if (e.value=="") { alertm("",e); return };
if (e.value!=document.thisForm.UserPW.value)  { alertm("Your password and your confirm password values do not match.",e); return }
document.thisForm.hdnNextMode.value="SAVE";
document.thisForm.submit();
}
function jsLogin() {
jUN=document.thisForm.Email;
jPW=document.thisForm.Password;
if (jUN.value=="") { alert("Please enter an Email Address"); jUN.focus(); return; }
if (jPW.value=="") { alert("Please enter a Password"); jPW.focus(); return; }
rv=isEmail(jUN)
if (rv!="") { alert("Please enter a valid Email Address " + rv); jUN.focus(); return; }
document.thisForm.hdnNextOp.value="LOGIN"
document.thisForm.submit();
}
function jsForgotPW() {
jUN=document.thisForm.Email;
if (jUN.value=="") { alert("Please enter an Email Address"); jUN.focus(); return; }
rv=isEmail(jUN)
if (rv!="") { alert("Please enter a valid Email Address " + rv); jUN.focus(); return; }
document.thisForm.hdnNextOp.value="SENDPW"
document.thisForm.submit();
}
function jsRegister() {
document.thisForm.hdnNextOp.value="REGISTER"
document.thisForm.submit();
}
function test() {
alert("You have called the Test function.")
}
function jsTurnOn(vID) {
var p1,vN
p1=vID.indexOf("_")
vN=vID.substr(p1)
var e=document.getElementById(vID)
if (e) { 
	e.style.color='white'
	e.style.backgroundColor='FireBrick'
	e.style.fontWeight='bolder' 
	}
if (e) { 
	var e=document.getElementById("hrfMenu" + vN)
	e.style.fontWeight='bolder'
	e.style.color='white'
	}
var e=document.getElementById("imgMenu" + vN)
if (e) { e.src='imgs/squares_2_hl.gif' }
}
function jsTurnOff(vID) {
p1=vID.indexOf("_")
vN=vID.substr(p1)
vLvl=vN.substr(1,1)
var e=document.getElementById(vID)
if (e) { 
	e.style.color='navy' 
	if (vLvl=="1") { e.style.backgroundColor='#dde1ec' } else { e.style.backgroundColor='#b5c0e0' } 
	e.style.fontWeight='lighter' 
	}
var e=document.getElementById("hrfMenu" + vN)
if (e) { 
	e.style.fontWeight='lighter'
	e.style.color='navy'
	}
var e=document.getElementById("imgMenu" + vN)
if (e) { e.src='imgs/squares_2.gif' }
}
function jsHighlight(t) {
var i,vLvl,vLen,vID
vID=t.id
p=vID.lastIndexOf("_")
vLvl=vID.substr(0,p)
vLen=vID.length
var aDivs=document.getElementsByTagName("DIV");
for (i=0;i<aDivs.length;i++) {
	vID=aDivs[i].id
	if ((vID.length==vLen) && (vLvl==vID.substr(0,p))) {
		rv=jsTurnOff(vID)
		}
	}
rv=jsTurnOn(t.id)
}
function jsShowMenu(t,jMenu) {
var vMainLevel,vNextLevel
vID=t.id
p=vID.indexOf("_")
vMainLevel=vID.substr(p+1,1)
z=new Number(vMainLevel)
rv=jsHideMenus(t,z+1)
vNextLevel=z+1
//alert(divTop.offsetLeft)
if (jMenu) {
	jMenu.style.visibility="visible"
	jMenu.style.zIndex=10
	if (vMainLevel==1) { 
		jMenu.style.left=divTop.offsetLeft+t.offsetLeft+1
		jMenu.style.top=(divTop.offsetTop+t.offsetHeight+1)
		}
	else	{
		jMenu.style.left=(t.parentElement.offsetLeft+t.offsetLeft+t.offsetWidth-5) 
		jMenu.style.top=(t.parentElement.offsetTop+t.offsetTop)
		}
	for (i=0;i<jMenu.children.length;i++) {
		jMenu.children(i).style.visibility="visible"
		}
	}
if (t) { rv=jsHighlight(t) }
}
function jsMouseOut(t) {
vID=t.id
p=vID.indexOf("_")
vN=vID.substr(p)
l=vN.length
vL=vN.substr(0,l-1)
var aDivs=document.getElementsByTagName("DIV");
for (i=0;i<aDivs.length;i++) {
	vID=aDivs[i].id
	if (vID.indexOf("divMenu"+vL)>-1) {
		var e=document.getElementById(vID)
		e.style.color='navy'
		e.style.backgroundColor='#b5c0e0'
		e.style.fontWeight='lighter' 
		var e=document.getElementById("hrfMenu" + vN)
		e.style.fontWeight='lighter'
		e.style.color='navy'
		var e=document.getElementById("imgMenu" + vN)
		e.src='imgs/squares_2.gif'
		}
	}
}
function jsHideMenus(t,vLvl) {
vNP=t.id
p=vNP.indexOf("_")
vNP=vNP.substr(p)
x=vNP.substr(1,1)
vMainLevel=new Number(x)
lNP=vNP.length
var aDivs=document.getElementsByTagName("DIV");
z=new Number(vLvl)
for (i=0;i<aDivs.length;i++) {
	vID=aDivs[i].id
	if (vID.substr(0,9)=="divGMenu_") {
		x=vID.substr(9,1)
		vL=new Number(x)
		if (vL>=z) {
			if (aDivs[i]) {
				aDivs[i].style.visibility="hidden" 
				for (x=0;x<aDivs[i].children.length;x++) {
					aDivs[i].children(x).style.visibility="hidden"
					}
				}
			}
		}
    }
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}
function preloadImages() {
	if (document.images) {
		pre_studentportal_o = newImage('imgs/2ndtierbuttons/studentportal_o.gif');
		pre_charityinfo_o = newImage('imgs/2ndtierbuttons/charityinfo_o.gif');
		pre_memberservices_o = newImage('imgs/2ndtierbuttons/memberservices_o.gif');
		preloadFlag = true;
	}
}

function jsCallPage(vFrame,vPage) {
//alert(vPage)
if (vFrame!="") { 
	jFrame=findFrame(vFrame);
	if (typeof(jFrame)!="undefined") { 
		rv=eval("parent." + vFrame + ".location.href=vPage") 
		} 
	}
else { window.location.href=vPage }
}
function jsFieldListChange(t,p,m,jTblName) {
document.thisForm.hdnFilterFld.value=document.thisForm.lstFields.value
document.thisForm.hdnFilterVal.value=document.thisForm.txtFilterVal.value
document.thisForm.submit()
}
function jsClearFilter(t,p,m,jTblName) {
document.thisForm.hdnFilterFld.value=""
document.thisForm.hdnFilterVal.value=""
document.thisForm.submit()
}
function alertm(m,f) {
if (m=="") { m="Please provide a value for " + f.name }
alert(m);
f.focus();
}
function jsChgRdoVal(t,f) {
v=t.getAttribute("dataFld")
//v=t.dataFld
//alert(v)
rv=document.getElementById(f).value=v
}
function jsShowAlert(m) {
alert(m)
}
function jsOpenWin(n,w) {
jBtnSelectedColor="Orange"
rv=jsSelectThis(n)
window.open(w)
}
function jsOpenSmallWin(n,w) {
jBtnSelectedColor="Orange"
rv=jsSelectThis(n)
vHeight=500
vWidth=500
vProps='resizable=yes,menu=yes,scrollbars=yes,height=' + vHeight + ',width=' + vWidth
window.open(w,'Edit',vProps)
}
function jsOpenMedWin(w) {
vHeight=500
vWidth=700
vProps='resizable=yes,location=yes,menubar=yes,menu=yes,scrollbars=yes,height=' + vHeight + ',width=' + vWidth
window.open(w,'View',vProps)
}
function jsMoveUpList(f) {
x=f.selectedIndex
if (x<0) { return }
if (!f.options[x]) { return }
t=f.options[x].text
v=f.options[x].value
x=x-1
for (i=0;i<f.options.length;i++) {
	t2=f.options[i].text
	v2=f.options[i].value
	if (i==x) {
		f.options[i].innerText=t
		f.options[i].value=v
		for (j=i+1;j<f.options.length;j++) {
			f.options[j].innerText=t2
			f.options[j].value=v2
			if (j+1<f.options.length) {
				t2=f.options[j+1].text
				v2=f.options[j+1].value
				}
			}
		i=j;
		}		
	} 
f.selectedIndex=x
}
function jsMoveDownList(f) {
x=f.selectedIndex
if (x<0) { return }
if (x==f.options.length) { return }
t=f.options[x].text
v=f.options[x].value
x=x+1
for (i=f.options.length-1;i>-1;i--) {
	t2=f.options[i].text
	v2=f.options[i].value
	if (i==x) {
		f.options[i].innerText=t
		f.options[i].value=v
		for (j=i-1;j>-1;j--) {
			f.options[j].innerText=t2
			f.options[j].value=v2
			if (j-1>-1) {
				t2=f.options[j-1].text
				v2=f.options[j-1].value
				}
			}
		i=j;
		}		
	} 
f.selectedIndex=x
}
function jsAddToListTo(f,t) {
for (i=0;i<f.options.length;i++) {
	if (f.options(i).selected) { 
		x=f.options[i].text
		v=f.options[i].value
		var oOption = document.createElement("OPTION");
		t.options.add(oOption);
		oOption.innerText = x
		oOption.value = v
		}
	} 
return
if (f.selectedIndex<0) { return }
}
function jsDelFromListTo(f) {
for (i=f.options.length-1;i>-1;i--) {
	if (f.options(i).selected) { 
		x=f.options.remove(i)
		}
	} 
return
if (f.selectedIndex<0) { return }
x=f.options.remove([f.selectedIndex])
}
function jsShowCoverArt(jID,jType,jInit,jTitle) {
window.location="Sys_CoverArt.asp?ID=" + jID + "&TYP=" + jType + "&INIT=" + jInit + "&TITLE=" + jTitle
}
function CleanChrs(s) {
x=""
for (i=0;i<s.length;i++) {
	y=s.charCodeAt(i)
	if ((y==47) || (y==40) || (y==41) || (y==32) || (y==37) || (y==38) || (y==31) || (y==44) || (y==39) || (y==31)) {}
	else { x=x + s.charAt(i) } 
	}
return x;
}
function findFrame(jFrame) {
if (jFrame=="_self") { return "window" }
p="";
if ((jBrowserType=="NS") || (jBrowserType=="ESCAPE")) {
	for (ffj=0;ffj<6;ffj++) {
		rv=eval("var frm=window." + p + "frames")
		for (ffj=0;ffj<frm.length;ffj++) {
			if (frm[ffj].name.toUpperCase()==jFrame.toUpperCase()) {
				return p + jFrame
				}
			}
		p="parent." + p;
		}
	return;
	}
else {
	p="";
	for (j=0;j<6;j++) {
		v="window." + p + "document.frames"
		var frm=eval(v)
		rv=eval(v + "[jFrame]")
		if (typeof(rv)!="undefined") { 
			return p + jFrame 
			}
		p="parent." + p;
		}
	p="";
	p="parent.fraView.document.frames"
	if (!parent.fraView) { return "" }
	if (parent.fraView.document.frames[jFrame]) { return "parent.fraView.document.frames['" + jFrame + "']" } 
	p="parent.fraView.frames['fControlFrames'].document.frames"
	if (!parent.fraView.frames['fControlFrames']) { return "" }
	if (parent.fraView.document.frames['fControlFrames'].document.frames[jFrame]) { return "parent.fraView.document.frames['fControlFrames'].document.frames['" + jFrame + "']" } else { return "" };
	return;
	for (i=0;i<10;i++) {
		for (j=0;j<10;j++) {
			rv=eval(v + "[jFrame]")
			if (typeof(rv)!="undefined") { 
			alert("##" + v)
				return v + "['" + jFrame + "']"
				}
			}
		v=p + "[" + i + "].frames";
		}
	return "";
	}
}
function ShowTime() {
d = new Date();
t = d.toLocaleString();
p1 = t.lastIndexOf(" ");
p2 = t.lastIndexOf(":");
p3 = t.lastIndexOf(":",p2-1);
p4 = t.lastIndexOf(" ",p3-1);
AMPM = t.substr(p1+1);
vSeconds = t.substr(p2+1,p1-p2-1);
vMinutes = t.substr(p3+1,p2-p3-1);
vHours = t.substr(p4+1,p3-p4-1);
vHours = Math.round(vHours)
if ((AMPM != "AM") && (AMPM != "PM")) {
	x = t.substr(p1+1);
	p = x.indexOf(":");
	z = x.substr(p+1)
	x = x.substr(0,p);
	vSeconds = t.substr(p2+1,t.length-p2);
	var y = new Number(vHours);
	if (y>12) {
		AMPM = "PM";
		y = y-12;
		t = y.toString() + ":" + z;
		}
	else {
		t = AMPM;
		AMPM = "AM";
		}
	}
else {
	t = t.substr(0,p1);
	p1 = t.lastIndexOf(" ");
	t = t.substr(p1+1);
	}
if (vHours>12) { vHours=vHours-12 }
tdTime.style.fontSize="xx-small"
tdTime.style.fontFamily="Arial"
tdTime.style.color="black"
tdTime.innerText = vHours + ":" + vMinutes + ":" + vSeconds + " " + AMPM;
}
function jsNotToExceed(t,x) {
v=new Number(t.value)
if (v>x) { alert("Sorry, value of " + t.name + " cannot exceed " + x); event.returnValue=false; t.focus(); }
}
function jsMinMax(t,vMin,vMax) {
v=new Number(t.value)
if ((v<vMin) || (v>vMax)) { alert("Sorry, value of " + t.name + " must be between " + vMin + " and " + vMax + "."); event.returnValue=false; t.focus(); }
}
function jsMakeAbbr(t,fAbbr) {
vValue=t.value;
vValue=CleanChrs(vValue);
vValue=vValue.toUpperCase();
vValue=vValue.substr(0,10);
if (fAbbr.value=="") { fAbbr.value=vValue; }
}
function jsGetNameValue(vParam,vLookFor) {
var p1=0
var p2=0
var l=0
var p3=0
p1=vParam.indexOf(vLookFor)
l=vLookFor.length
if (p1>-1) { p2=vParam.indexOf(";",p1+l+1); }
if ((p1>-1) && (p2==-1)) { p2=vParam.indexOf("^",p1+l+1); }
if ((p1>-1) && (p2==-1)) { p2=vParam.length+1 }
if (p2>-1) { 
	p3=p2-(p1+l+1)
	v=vParam.substr(p1+l+1,p3) 
	} 
else 
	{
	v="" 
	}
return v	
}
function jsSaveAndAdd(t,vPageToCall,jMsg) {
document.thisForm.hdnNextOp.value="ADD"
document.thisForm.hdnNextMode.value="ADD"
if (t) { rv=jsSaveRec(t,vPageToCall,jMsg) } 
}
function jsDeleteRecord(t,vPageToCall,jMsg) {
if (confirm("Please confirm deleting this record.")) {
	document.thisForm.hdnNextMode.value=""
	document.thisForm.hdnNextOp.value="DEL"
	document.thisForm.submit()
	}
}
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_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_findObj(n, d) { //v4.0
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 && document.getElementById) x=document.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();
}
function jsToggleBtn(jBtn,jColor) {
v=jBtn.src
if (!v) { return }
p=v.indexOf("_BC_")
if (p>0) {
	p2=v.indexOf("_",p+4)
	x = v.substr(p+4,p2-p-4);
	x=jColor
	v=v.substr(0,p+4) + x + v.substr(p2);
	jBtn.src=v
	}
}
function ChgMode(lMode,nMode,cID) {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnLastMode.value = lMode;
	parent.fParent.thisForm.hdnCurMode.value = nMode;
	}
}
function CEF(jType,jMode,jID) {
vSH=screen.availHeight;
vFH=.9*vSH;
vSW=screen.availWidth;
vFW=.85*vSW;
parent.parent.fRight.location="SysEditFrames.asp?FS=SMALL&CP=APPINDEX&T=" + jType + "&ID=" + jID + "&MD=" + jMode + "&FW=" + vFW + "&FH=" + vFH
}
function CEFF(jType,jMode,jID) {
vSH=screen.availHeight;
vFH=.9*vSH;
vSW=screen.availWidth;
vFW=.85*vSW;
parent.parent.fRight.location="SysEditFrames.asp?FS=ALL&CP=APPINDEX&T=" + jType + "&ID=" + jID + "&MD=" + jMode + "&FW=" + vFW + "&FH=" + vFH
}
function CEFM(jType,jMode,jID) {
vSH=screen.availHeight;
vFH=.9*vSH;
vSW=screen.availWidth;
vFW=.85*vSW;
parent.parent.fRight.location="SysM1Frames.asp?CP=APPINDEX&T=" + jType + "&ID=" + jID + "&MD=" + jMode + "&FW=" + vFW + "&FH=" + vFH
}
function cpx(btn,src) {
pt=btn.src.lastIndexOf("/");
btnPath=btn.src.substr(0,pt+1);
btn.src=btnPath + src;
}
function btnCallSave(N,jCurID) {
ToggleBtns(N);
if (parent.fParent) { 
	parent.fParent.btnSave_onclick(true);
	}
else { btnSave_onclick(true); }
}
function btnQuery_onclick(N) {
ToggleBtns(N);
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"QUERY",0);
	parent.fParent.thisForm.submit();
	}
}
function btnPrint_onclick(N) {
ToggleBtns(N);
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurOP.value="PRINT";
	parent.fParent.thisForm.submit();
	}
}
function btnExport_onclick(N) {
ToggleBtns(N);
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"EXPORT",0);
	parent.fParent.thisForm.submit();
	}
}
function CallIt(jType,jMode,jID,jFS) {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurID.value=jID
	parent.fParent.thisForm.hdnCurMode.value=jMode
	parent.fParent.thisForm.hdnFieldSet.value=jFS
	parent.fParent.thisForm.submit();
	}
}
function btnSetupSets(t) {
ToggleBtns(t);
parent.fParent.location="SysEdit.asp?T=" + jPageType + "&MD=SETSSETUP"
}
function btnShowOtherSets(t) {
ToggleBtns(t);
parent.fParent.location="SysEdit.asp?T=" + jPageType + "&MD=SHOWSETS"
}
function getCookies() {
var dWrite, dUID, dDONE
dWrite = "";
if ((document.cookie != "")) {
	vUID = "";
	cookieArray = document.cookie.split(";");
	for (i=0;i<cookieArray.length;i++) {
		vCookieName = cookieArray[i].split("=")[0];
		if (vCookieName.indexOf("UserID")>-1) {
			vUID = cookieArray[i].split("=")[1];
			dUID = vUID;
			dDONE = "Yes";
			}
		if (vCookieName.indexOf("UserName")>-1) {
			vUNM = cookieArray[i].split("=")[1];
			dWrite = "<font face=arial size=1>Welcome back, " + vUNM + ".  If you're not " + vUNM + " then click <a target=fParent href=AppLogin.asp?T=FORCE>here</a></font>.  Click <a href=SysEdit.asp?P=Members&ID=" + vUID + " target=fParent>here</a> to edit your Member record";
			}
		}
	parent.fParent.location = "Home.asp?UID=" + vUID
	}
}
function ToggleBtns(t) {
for (imgs in document.images) {
	if ((imgs!="length") && (document.all(imgs))) { 
		v=document.all(imgs).src; 
		p=v.indexOf("_BC_");
		if (p>0) {
			p2=v.indexOf("_",p+4);
			v=v.substr(0,p+4) + jBtnMainColor + v.substr(p2);
			document.all(imgs).src=v;
			}
		}
	}
v=t.src; 
p=v.indexOf("_BC_");
if (p>0) {
	p2=v.indexOf("_",p+4);
	v=v.substr(0,p+4) + jBtnSelectedColor + v.substr(p2);
	t.src=v;
	}
}
function windowUnload() {
if (window.opener) {
//	window.opener.location.reload();
	}
}
function btnAddAnother_onclick(N,jCurID) {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurID.value=jCurID
	}
if (btnSave_onclick(true)) {
	if (parent.fParent) { 
		ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEADD",0);
		parent.fParent.thisForm.hdnCurID.value=jCurID
		}
	btnSave_onclick(true);
	}
}
function btnSaveAndEdit_onclick(N,jCurID) {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurID.value=jCurID
	}
if (btnSave_onclick(true)) {
	if (parent.fParent) { 
		ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0);
		parent.fParent.thisForm.hdnCurID.value=jCurID
		}
	btnSave_onclick(true);
	}
}
function chkSystemType(N,c) {
if (N.checked) {
	SaveAndCall(c,N); 
	}
else {
	rv = confirm("You are deselecting " + N.name + ".  Should I delete all associated records?")
	if (rv) {
		SaveAndCall("SysEdit.asp?MD=FORCEDEL&T=" + N.name,N); 
		}
	}
}
function SaveAndCall(p,jCurID) {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnLastMode.value=parent.fParent.thisForm.hdnCurMode.value;
	parent.fParent.thisForm.hdnNextMode.value="";
	parent.fParent.thisForm.hdnGotoPage.value=p;
	}
btnSave_onclick(true);
}
function isPhone(vField) {
v = vField.value;
n = ''
for (i=0;i<v.length;i++) {
	if ((v.charCodeAt(i)!=32) && (v.charCodeAt(i)>47) && (v.charCodeAt(i)<58)) {
		n = n + v.charAt(i);
		}
	}
if ((n.length != 7) && (n.length != 10)) { 
	return "Phone numbers should be 7 or 10 digits long"
	}
if (n.length==7) {
	n = n.substr(0,3) + '-' + n.substr(3,4);
	vField.value=n;
	}
else { 
	if (n.length==10) {
		n = '(' + n.substr(0,3) + ')' + n.substr(3,3) + '-' + n.substr(6,4);
		vField.value=n;
		}
	}
return "";
}
function isZip(vField) {
v = vField.value;
for (iz=0;iz<v.length;iz++) {
	if ((v.charCodeAt(iz) != 45) && ((v.charCodeAt(iz)<48) || (v.charCodeAt(iz)>57))) {
		return ' (not a number)'
		}
	}
if (v.length<5) {
	return ' (length is less than 5)'
	}
if (v.length>5) {
	if (v.indexOf("-")==-1) { 
		v=v.substr(0,5) + "-" + v.substr(5) 
		vField.value=v;
		}
	if (v.length != 10) {
		return ' (length is less than 10)'
		}
	if (v.indexOf('-') != 5) {
		return ' (no dash)'
		}
	}
return "";
}	
function isURL(vField) {
v=vField.value
u = v.toUpperCase();
if ((u.substr(0,7) != 'HTTP://') || (u.substr(0,7) != 'HTTP:\\')) {
	vField.value = 'http://' + vField.value;
	}
ct = 0;
for (i=0;i<v.length;i++) {
	if (v.charAt(i) == '.') {
		ct = ct + 1;
		}
	}
if (ct<2) {
	return " (missing periods) ";
	}
return "";
}
function OKtoValidate(vField) {
if (vField) {
	t = vField.type;
	v = vField.value;
	if (v != '') {
		if ((t != 'checkbox') && (t != 'button') && (v.length>0)) {
			return true;
			}
		}
	}
return false;
}
function MakeNumber(vField) {
v = vField.value;
p = v.indexOf('.');
if (p>0) {
	vdollars = v.substr(0,p);
	vcents = v.substr(p+1);
	}
else { 
	vdollars = v;
	vcents = '';
	}
n1 = '';
n2 = '';
for (i=0;i<vdollars.length;i++) {
	if ((vdollars.charCodeAt(i)>47) && (vdollars.charCodeAt(i)<58)) {
		n1 = n1 + vdollars.charAt(i);
		}	
	}
	for (i=0;i<vcents.length;i++) {
		if ((vcents.charCodeAt(i)>47) && (vcents.charCodeAt(i)<58)) {
			n2 = n2 + vcents.charAt(i);
			}
		}
v = n1;
if (n2 != '') { v = n1 + '.' + n2 }
return v;
}
function MakeCurrency(vField) {
v = vField.value;
p = v.indexOf('.');
if (p>0) {
	vdollars = v.substr(0,p);
	vcents = v.substr(p+1);
	}
else { 
	vdollars = v;
	vcents = '';
	}
n1 = '';
n2 = '';
for (i=0;i<vdollars.length;i++) {
	if ((vdollars.charCodeAt(i)>47) && (vdollars.charCodeAt(i)<58)) {
		n1 = n1 + vdollars.charAt(i);
		}	
	}
	for (i=0;i<vcents.length;i++) {
		if ((vcents.charCodeAt(i)>47) && (vcents.charCodeAt(i)<58)) {
			n2 = n2 + vcents.charAt(i);
			}
		}
v = n1;
if (n2 == '') { n2 = '00'; }
if (n2.length == 1) { n2 = n2 + '0'; }
n2 = n2.substr(0,2);
if (n2 != '') { v = n1 + '.' + n2 }
return v;
}
function btnCheckFileType(f,t) {
if (t.value == "") {
	alert("Please select a file to upload by pressing the Browse button.");
	t.focus;
	return;
	}
v = t.value;
p = v.lastIndexOf(".");
if (p == 0) {
	alert("Sorry, I cannot determine the file type without an extension.  Try again.");
	t.focus;
	return;
	}
x=""
z=""	
if (1==0) {
	p=v.lastIndexOf("/")
	if (p==-1) {
		s=String.fromCharCode(92)
		p=v.lastIndexOf(s)
		}
	if (p>-1) {
		n=v.substr(p+1)
		for (i=0;i<n.length;i++) {
			x=n.substr(i,1)
			if (x==" ") { x="_" }
			z=z + x
			}
		v=v.substr(0,p+1) + z
		}
	t.value=v
	}
p = v.lastIndexOf(".");
x=v.substr(p+1)
x=x.toUpperCase()
if ((x != "ZIP") && (x != "MDB") && (x != "DOC") && (x != "GIF") && (x != "JPG") && (x != "BMP") && (x != "TXT") && (x != "RTF")) {
	alert("Sorry, I can only upload files with an extension of .zip, .mdb, .txt, .doc, .rtf, .gif, .jpg, or .bmp.  Try again.");
	document.forms[f].txtUploadFile.focus;
	return;
	}
document.forms[f].submit();	
}
function isEmail(v) {
n=v.value
if (n.indexOf('.')==-1) { return " (missing period)" }
if (n.indexOf('@')==-1) { return " (missing @)" }
return "";
}
function isNumber(v) {
for (iN=0;iN<v.length;iN++) {
	x=v.charCodeAt(iN)
	if ( (x!=44) && (x!=46) && ( (x<48) || (x>57) ) ) {
		return "Non-numeric character.";
		}
	}
return "";
}
function isCurrency(v) {
for (iN=0;iN<v.length;iN++) {
	x=v.charCodeAt(iN)
	if ( (x!=36) && (x!=44) && (x!=46) && ( (x<48) || (x>57) ) ) {
		return "Non-currency character.";
		}
	}
return "";
}
function isChar(v) {
for (iN=0;iN<v.length;iN++) {
	if ((v.charCodeAt(iN)<65) || (v.charCodeAt(iN)>90)) {
		if ((v.charCodeAt(iN)<97) || (v.charCodeAt(iN)>122)) {
			return 0;
			}
		}
	}
return 1;
}
function couldBeDate(v) {
if (v.length>10) {
	return "Too Long";
	}
nn=""
for (iN=0;iN<v.length;iN++) {
	if ((v.charCodeAt(iN)<48) || (v.charCodeAt(iN)>57)) {
		if ((v.charCodeAt(iN) != 32) && (v.charCodeAt(iN) != 47) && (v.charCodeAt(iN) != 92) && (v.charCodeAt(iN) != 46) && (v.charCodeAt(iN) != 45)) { 		//back/forward slash, period, dash
			return "Illegal Characters (" + v.charCodeAt(iN) + ")";
			}
		else
			nn = nn + "/";
		}
	else	{
		nn = nn + v.charAt(iN);
		}
	}
p = nn.indexOf("/");
m = nn.substr(0,p);
if ((m<1) || (m>12)) { return "Bad Month"; }
y = nn.substr(nn.lastIndexOf("/")+1)
if (y.length==3) { return "Bad Year"; }
var ny = new Number(y)
if (y.length<3) {
	if ((ny>50) && (ny<100) && (y.length=2)) { y = "19" + y }
	if ((ny<50) && (ny<100) && (y.length=2)) { y = "20" + y }
	}
var ny = new Number(y)
if (y.length=4) {
	if ((ny<1900) || (ny>2100)) { return "Bad Year"; }
	}
d = nn.substr(nn.indexOf("/")+1,nn.lastIndexOf("/")-nn.indexOf("/")-1);
var ny = new Number(d)
if ((ny>31) || (ny<1)) { return "Day out of range"; }
if (d == "31") { if ((m != 1) && (m != 3) && (m != 5) && (m != 7) && (m != 8) && (m != 10) && (m != 12)) { return "Day out of range"; } else { return ""; }	}
if (d == "30") { if ((m!=3) && (m != 4) && (m != 6) && (m != 9) && (m != 11)) { return "Day out of range"; }	else { return ""; }	}
if (d == "29") { if ((m == 2)) { return "Day out of range"; }	}
return "";
}
function btnEditFind_onclick(N) {
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FIND",0);
	parent.fParent.thisForm.submit();
	}
}
function btnCancel_onclick(N) {
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEVIEW",0);
	}
window.history.go(-2)
}
function btnListFind_onclick(N) {
if (lstFields.value=="") {
	alert("Please select a field to find on.");
	return;
	}
ToggleBtns(N);
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurMode.value = "LIST";
	parent.fParent.thisForm.hdnLstFields.value = lstFields.value;
	parent.fParent.thisForm.hdnTxtRefineList.value = txtRefineList.value;
	parent.fParent.thisForm.hdnListMode.value = "FIND";
	parent.fParent.thisForm.submit();
	}
}
function btnListFilter_onclick(N) {
if (lstFields.value=="") {
	alert("Please select a field to filter on.");
	return;
	}
ToggleBtns(N);
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurMode.value = "LIST";
	parent.fParent.thisForm.hdnLstFields.value = lstFields.value;
	parent.fParent.thisForm.hdnTxtRefineList.value = txtRefineList.value;
	parent.fParent.thisForm.hdnListMode.value = "FILTER";
	parent.fParent.thisForm.submit();
	}
}
function btnListSort_onclick(N,D) {
if (lstFields.value=="") {
	alert("Please select a field to sort on.");
	return;
	}
ToggleBtns(N);
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurMode.value = "LIST";
	parent.fParent.thisForm.hdnListMode.value = "SORT";
	parent.fParent.thisForm.hdnLstFields.value = lstFields.value;
	parent.fParent.thisForm.hdnSortDir.value = D;
	parent.fParent.thisForm.submit();
	}
}
function btnFieldSet_onclick(t,v) {
ToggleBtns(t);
if (parent.fParent) { 
	jCurMode=parent.fParent.thisForm.hdnCurMode.value;
	if (jCurMode=="EDIT") { jCurMode="FORCEEDIT" }
	if (jCurMode=="ADD") { jCurMode="FORCEADD" }
	if (jCurMode=="VIEW") { jCurMode="FORCEVIEW" }
	parent.fParent.thisForm.hdnCurMode.value = jCurMode;
	parent.fParent.thisForm.hdnNextMode.value = jCurMode;
	parent.fParent.thisForm.hdnFieldSet.value = v;
	parent.fParent.thisForm.submit();
	}
}
function btnDetail_onclick(t,v) {
ToggleBtns(t);
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurMode.value = "LIST";
	parent.fParent.thisForm.hdnViewDetail.value = v;
	parent.fParent.thisForm.submit();
	}
}
function cp(N,A) { 
N.src="images/" + N.name + A + ".gif"; 
}
function btnHelp_onclick(N) {
parent.fParent.location = "SysHelp.asp?T=HELP"
}
function btnFind_onclick(N) {
ToggleBtns(N)
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FIND",0);
	parent.fParent.thisForm.submit();
	}
}
function btnList_onclick(N,T) {
ToggleBtns(N)
//rv=eval("CallIt('FORCELIST','" + jPageType + "',0)")
//alert(T);
window.location.href = "SysEditHeader.asp?MD=FORCELIST&T=" + T;
parent.fParent.location = "SysEdit.asp?MD=FORCELIST&T=" + T;
}
function btnAdd_onclick(N) { 
ToggleBtns(N)
if (parent.fParent) { 
	parent.fParent.thisForm.hdnFieldSet.value="ALL";
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEADD",0);
	parent.fParent.thisForm.submit();
	}
}
function btnEdit_onclick(N) { 
ToggleBtns(N)
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0);
	parent.fParent.thisForm.submit();
	}
}
function btnView_onclick(N) { 
ToggleBtns(N)
if (parent.fParent) { 
	ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEVIEW",0);
	parent.fParent.thisForm.submit();
	}
}
function btnDel_onclick(N) { 
rv=confirm("Please confirm deleting this record.") ;
if (rv==true) {	
	if (parent.fParent) { 
		ChgMode(parent.fParent.thisForm.hdnCurMode.value,"DEL",0); 
		parent.fParent.thisForm.submit();
		}
	}
ToggleBtns(N)
}
function callTblView() {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurView.value = "Table";
	parent.fParent.thisForm.submit();
	}
}
function callRecView() {
if (parent.fParent) { 
	parent.fParent.thisForm.hdnCurView.value = "Record";
	parent.fParent.thisForm.submit();
	}
}
function mainRSNav_First_onclick(N,r) {
ToggleBtns(N)
if (parent.fParent) { 
	if (jCurMode=="FORCEADD") { ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0); parent.fParent.thisForm.submit(); }
	parent.fParent.thisForm.hdnCurMove.value = "First";
	parent.fParent.thisForm.submit() ;
	}
}
function mainRSNav_Prev_onclick(N,r) {
ToggleBtns(N)
if (parent.fParent) { 
	if (jCurMode=="FORCEADD") { ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0); parent.fParent.thisForm.submit();  }
	parent.fParent.thisForm.hdnCurMove.value = "Prev";
	parent.fParent.thisForm.submit() ;
	}
}
function mainRSNav_Next_onclick(N,r) {
ToggleBtns(N)
if (parent.fParent) { 
	if (jCurMode=="FORCEADD") { ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0); parent.fParent.thisForm.submit();  }
	parent.fParent.thisForm.hdnCurMove.value = "Next";
	parent.fParent.thisForm.submit() ;
	}
}
function mainRSNav_Last_onclick(N,r) {
ToggleBtns(N)
if (parent.fParent) { 
	if (jCurMode=="FORCEADD") { ChgMode(parent.fParent.thisForm.hdnCurMode.value,"FORCEEDIT",0); parent.fParent.thisForm.submit();  }
	parent.fParent.thisForm.hdnCurMove.value = "Last";
	parent.fParent.thisForm.submit() ;
	}
}
function chgPix(img,a) {
s = img.src;
x = s.lastIndexOf(".")-1;
y = s.lastIndexOf("/")+1;
z = s.substr(y,x-y);
if (document.images) {
	for (imgi = 0; imgi < iCt; imgi++) {
		if (pix[imgi][3] == z) { img.src = pix[imgi][a].src }
		}
	}
}
function btnGetTitle_onclick(){
if (parent.fParent) { 
	vURL = parent.fParent.thisForm.URL.value;
	}
if (vURL == "") { return 0 }
if (vURL.substr(0,5) != "http:") { vURL = "http://" + vURL }
parent.botFrame.location.href = "_blank.htm";
parent.botFrame.location.href = "gMbrGetURLInfo.asp?U=" + vURL;
}
var pix;
pix = new Array();
var iCt = 0;
var iOut = 0;
var iOver = 1;
var iDown = 2;

function preload(name) {
if (document.images) {
	pix[iCt] = new Array(4);
	pix[iCt][0] = new Image();
	pix[iCt][0].src = "images/" + name + "A.gif";
	pix[iCt][1] = new Image();
	pix[iCt][1].src = "images/" + name + "O.gif";
	pix[iCt][2] = new Image();
	pix[iCt][2].src = "images/" + name + "D.gif";
	pix[iCt][3] = name;
	iCt++;
	}
}
function preload2(name) {
if (document.images) {
	pix[iCt] = new Array(4);
	pix[iCt][0] = new Image();
	pix[iCt][0].src = "images/" + name + ".gif";
	pix[iCt][1] = new Image();
	pix[iCt][1].src = "images/" + name + "_over.gif";
	pix[iCt][2] = new Image();
	pix[iCt][2].src = "images/" + name + "_down.gif";
	pix[iCt][3] = name;
	iCt++;
	}
}

