//function brr() 
// Here you check weather user's navigator is IE5+ or NS6, 
// since those are the ones which support the input CSS properties.  
// If you have a lot of recordset fields, be sure to check to see if the input boxes get too wide for the page.
//			{ 
//                this.ns5 = (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==5)
//               this.ie5 = (navigator.appVersion.indexOf('MSIE 5')>0)
//                      }
//chk = new brr()
// Now you want to write a style sheet for your input in case they use IE5+ or NS6
//if (chk.ns5 || chk.ie5) {
//       document.write ('<STYLE TYPE="text/css"><!--input { background: #FFFFFF; color: #333333; border: 1px #000000 solid; font-family: Arial,Helvetica,Geneva,Swiss,SunSans-Regular; font-size: 10pt }//--></STYLE>');
//       document.write ('<STYLE TYPE="text/css"><!--a:hover	{  text-decoration: none; font-family: tahoma; color: #706A56}//--></STYLE>');                  
//}

function CheckFiscalYear(functionName,year,month) {
    var pattern      = /GeoCode/
    var selectedYear = document.mainform.FYSelect.value 
    var monthReturn  = CheckMonth(month)
    var returnValue = false
    //alert("selectedYear [" + selectedYear + "] >= year [" + year + "]")
    if (pattern.test(functionName)) {
        //alert("passed the pattern check")
        if (selectedYear >= year && monthReturn) {
            //alert (selectedYear)
            //alert (monthReturn)
            returnValue = true
        }
    }
    return returnValue
}

function CheckMonth(month) {
    var currentMonth = document.mainform.MonthSelect.value
    //alert("selectedMonth [" + currentMonth + "] month [" + month + "]")
    var returnValue  = false
    if ( month == null 
    || ( month <  7 && (currentMonth < 7 && currentMonth >= month))
    || ( month >= 7 && (currentMonth < 7 || currentMonth >= month))) {
        returnValue  = true
    }
    return returnValue
}

function ChkCurrFY(y)
{
	var ChosenFY=y;									//fiscal year selected by user
	var CurrentDate=new Date();						//get today's date as string						
	var CurrentMonth=CurrentDate.getMonth() + 1;	//get current month as int
	var CurrentYear=CurrentDate.getFullYear();		//get current year in 4 digits ex 2001
	var CurrentFY;
	
	//example) it's currently 2001 and the person chooses 2001
	//If it's June or earlier, they are in the FY of 2001.  If July or later, it's FY 2002.
	//FY 2002 should not show up until July 1, 2001 (this may change to July 25th for reporting reasons)
	
	//Get Current Fiscal Year
	if (CurrentMonth < 7)				// if it's June, 2001 then Current Month is 6
	{
		CurrentFY=CurrentYear;			// Current FY is 2001
	}
	else if (CurrentMonth > 6)			// if it's July 1, 2001 then Current MOnth is 7
	{
		CurrentFY=CurrentYear + 1;		// Current FY is 2002
	}
	
	if (ChosenFY != CurrentFY)			// if the Year Chosen is not same  as the CurrentFY
	{									// alert the user
		alert("Please note that " + ChosenFY + " is not the current Fiscal Year.\n\nThe CURRENT Fiscal Year is " + CurrentFY);
	}
}

function ChkActlHrs(Actl_Hrs) {
    var returnVal = false;
    var hours = Actl_Hrs.value;
    var pattern = /^\d*( *|\.( *|[05][0]?))$/
	var DecFoundAt;	 // is there a decimal, it's found at this position 
                     // (-1 if not found)
	DecFoundAt=hours.indexOf(".")

    if ((!pattern.test(hours)) || (hours == 0)||(hours > 24) ) {
        alert("ERROR! " + hours + " is not a valid entry. Please enter valid numbers between 0 and 24,\nwith partial hours rounded to the nearest 1/2 hour such as 3.5, .5, or 10.5.\nYou may enter only up to 1 decimal place.");
        Actl_Hrs.select();
        returnVal = true;
    }
    return returnVal;
}

function ChkFedCode(Fed_Code, pattern) {
    var returnVal = false;
    if (!pattern.test(Fed_Code.value)) //if it doesn't match the pattern 
                                       //when you test it
    {
		alert("ERROR! The Federal Strategy Code you entered: " + document.mainform1.Fed_Code.value +", is not a valid entry. Please enter valid numbers only, such as 3.14.\n If it does not apply, enter dna.");
		Fed_Code.focus();
		Fed_Code.value='';
        returnVal = true;
    }
    return returnVal;
}

function ChkPrgNum(program) {
    var returnVal = false;
    if (parseInt(program.value) < 1) {
		alert("You are required to select a valid program number");
		program.focus();	//take them back to that field
        returnVal = true;
    }
    return returnVal;
}

function ChkGeoCode(code)	//takes in the Geo_Code field and makes sure we have a value
{
    var returnVal = false;

        if (code.value == "")
        {
            //throw an error if no Geo Code
            alert("You are required to enter a valid Geo Code");
            code.focus();	//take them back to that field
            returnVal = true;
        }	

    return returnVal;
}

function ChkDayOfMonth(day)	//takes in a number and makes sure it's not greater than 31
{
    var returnVal = false;
	if ((day.value > 31) || (day.value < 1))
	{
		//throw an error if over 31
		alert("You are required to enter a day of the month between 1 and 31");
		day.focus();	//take them back to that field
        returnVal = true;
	}	
    return returnVal;
}

function chkDate(SomeDate)	//takes in a string to see if it can be converted to a date
{
	var DateVal=SomeDate.value;
	//this pattern will take in a string and check to see if it is a valid date
	var pattern = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
	
}
function chkLength(fld,max) //takes in any string from TEXTAREA
{
	//determine browser type
	var browser=new Object();
	//var charsleft;
	
	browser.isNavigator==false;
	browser.isIE==false;
	
	if (navigator.appName.indexOf("Netscape")!=-1)
	{ 
		browser.isNavigator=true;
		if (event && event.which == 13)	
		{
			alert("Please do not use the ENTER key.\n  It may cause your text to scroll off the screen." );					
			fld.value=fld.value.substring(0,fld.value.length-2) //get rid of the enter key just pressed
		}
	}
	else 
	if (navigator.appName.indexOf("Microsoft")!=-1)
	{
		browser.isIE=true;
		if (window.event && window.event.keyCode == 13)	
		{
			alert("Please do not use the ENTER key.\n  It may cause your text to scroll off the screen." );					
			fld.value=fld.value.substring(0,fld.value.length-2) //get rid of the enter key just pressed
		}
	}

	//if the go over the limit of characters
	chkLength.charsleft=max-fld.value.length;
	//alert("Characters left " + chkLength.charsleft);
	
	if (chkLength.charsleft<=0)
	{
		fld.value = fld.value.substring(0, max-1);	//cut it off at the max
	}
}

function CloseHTMLPage()	// redirect the user back to someURL if they decide to login again	
{
	var msg="\nIf you want to Logoff, select OK.  If you want to log back in again, select CANCEL.\nThe only way to ensure that no one will be able to go back and view your changes\nduring this session is to select OK or close the browser manually.";
	var someURL="default.asp";	//redirect to file
	
	if (confirm(msg))		//if user selects OK
	{
		self.close();
	}
}

function CloseMainFromPopup()
{
	//copy and paste this code --> <script>CloseMainFromPopup()</script>  <--to top of all
	//		 popup windows;this will close the main window that opened the popup
	
	window.opener.close()
}

function DisableBackButton()	//if user clicks back, the current history is replaced with 
								//	whatever page you want to navigate to
{
	window.history.forward(1);
}

//function EmailLinkToPage(To,Subj)
//{	
//	url = document.URL;
//	alert(url + " is the current URL");
//	window.location.href = "mailto:" + To + "?subject=" + Subj + "&body=" + document.title  + "    " + url;
//}															

function DisplayFYColumn()
{
	var CurrentDate=new Date();					//get today's date as string						
	var DisplayFYColDate
	var CurrentMonth=CurrentDate.getMonth() + 1;	//get current month as int
	var CurrentYear=CurrentDate.getFullYear();		//get current year in 4 digits ex 2001
	var CurrentFY;
	
	//Get Current Fiscal Year
	if (CurrentMonth < 7)				// if it's June, 2001 then Current Month is 6
	{
		CurrentFY=CurrentYear;			// Current FY is 2001
	}
	else if (CurrentMonth > 6)			// if it's July 1, 2001 then Current MOnth is 7
	{
		CurrentFY=CurrentYear + 1;		// Current FY is 2002
	}
	
	DisplayFYColDate=new Date(CurrentFY,6,30);	//date to display FY columns after for prev FY
	if (CurrentDate-1 > DisplayFYColDate)
	{
		window.location.href=window.location.href + '&Print=1'
	}
}

function ForceLength(fld,len) //takes a number of how long the field is required to be and forces entry
{
	if (fld.value.length != len)						//if it's too long
	{
		//give user error message
		alert("You are required to enter " + len + " characters exactly into this field." );
		fld.focus();	//take them back to that field
	}
}

function getEntryID(n)
{
	alert(n.value + " is the current entry ID");
	n.focus();
}

function GoBack()	//goes back to previous screen 
{
	history.go(-1);
}

function GoToSurvey(someURL) 
{
	window.location.href=someURL;
}

function GoToURL(someURL) //Send in someURL in form www.somedomain.com...direct link
{
	window.location.href="http://" + someURL;
}

function GoToUrlSameDir(someURL)	//Go to url but keep in the same directory path 
//onChange="GoToUrlSameDir(this.options[selectedIndex].value);" for select option
{
	window.location.href=someURL;
}

function checkValueAndRedirect(index) {
    var pattern = /add new/i;
    if (pattern.test(index.text)) {
        GoToUrlSameDir(index.value)
    }
}

function isblank(s) //returns true if string contains only whitespace characters
{
	for(var i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function isEmpty(s) //gives message if need to be filled in and reset focus onBlur
{
	if ((s.value == null) || (s.value == "") || isblank(s.value))
	{
		alert("Please enter data in this field.")
		s.focus();
	}
}

function MaxHrsPerDay(hrs)
{
	if (parseInt(hrs.value) > 24 || parseInt(hrs.value)<=0)
	{
		alert("ERROR! " + hrs.value + " is not a valid entry. Please enter 24 or less hours per day.\nPlease enter a value larger than 0.");
		hrs.value = "0";
		hrs.focus();
		
	}
}

function Maximize() 
{
	window.innerWidth = screen.width;
	window.innerHeight = screen.height;
	window.screenX = 0;
	window.screenY = 0;
	alwaysLowered = false;
}

			
function Minimize()
{
	window.innerWidth = 100;
	window.innerHeight = 100;
	window.screenX = screen.width;
	window.screenY = screen.height;
	alwaysLowered = true;
}

function numOnly(e)
{
	var strField = new String(e.value);
	var i = 0;
	for (i=0; i<strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
		{
			alert("ERROR! " + strField + " is not a valid numeric entry. Please enter numbers only.");
			e.focus();
			e.value = "0";
			break;
		}
}

function numOnlyFloat(e,AmtDec)			//Validates Decimal places of number specified in event
{//HTML onBlur="numOnlyFloat(this,1);"	//requires number > 0
	var NumVal=e.value;					//value brought in
	var DecFoundAt;						//is there a decimal, it's found at this position (-1 if not found)
	var txtAfterDec;					//text after the decimal
	var NumDec=AmtDec;					//number of decimal places allowed in NumVal
	
	//this pattern will take in any whole number or float
	var pattern = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
	
	DecFoundAt=NumVal.indexOf(".")
	
	if (DecFoundAt >= 0)							//if there is a decimal
	{
		txtAfterDec=NumVal.substr(DecFoundAt+1)		//get everything after the decimal
	}
	else
	{
		txtAfterDec=0;								//set to 0 if no decimal places exist
		e.focus();
	}
	if ((!pattern.test(NumVal)) || (txtAfterDec.length > NumDec) || (NumVal==0))
	{
		alert("ERROR! " + NumVal + " is not a valid entry. Please enter valid numbers greater than 0,\nsuch as 3.5, .5, or 10.5.  You may enter up to " + NumDec + " decimal places.");
		e.focus();
	}

}

function numOnlyFed(e)					//tab through if dna for Federal Strategy Code
{//MY VERY FIRST REGULAR EXPRESSION...THESE ARE SOOOO MUCH EASIER TO DO!
	var pattern1 = /\bdna\b|1.01|1.02|1.03|1.04|1.05|1.06|1.07|1.08|1.09|1.10|2.01|2.02|2.03|2.04|2.05|2.06|2.07|3.01|3.02|3.03|3.04|3.05|3.06|3.07|3.08|3.09|3.10|3.11|3.12|3.13|3.14|4.01|4.02|4.03|4.04|4.05|4.06|4.07|5.01|5.02|5.03|5.04|5.05|5.06|5.07|6.00/ //must be like 3.14  Fed Strat Code/
	var pattern = /\d\.\d{2}|dna/		//must be like 3.14 
										//1 digit, then a ., then 2 digits or text "dna"	
	if (!pattern.test(e.value) || !pattern1.test(e.value))			//if it doesn't ! match the pattern when you test it
	{
		alert("ERROR! " + e.value + " is not a valid entry. Please enter valid numbers only, such as 3.14.\n If it does not apply, enter dna.");
		e.focus();
		e.value='';
	}
}

function numOnlyServHrs(e)							//verify required entry for Service Hours
{//MY SECOND REGULAR EXPRESSION...I LIKED THE FIRST SO MUCH I FIGURED WHY THE H**L NOT!
	var NumVal=e.value;								//value brought in
	var DecFoundAt;									//is there a decimal, it's found at this position (-1 if not found)
	var txtAfterDec;								//text after the decimal
	var NumDec=1;									//number of decimal places allowed in NumVal
	
	//this pattern will take in any whole number or float
	var pattern = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
	
	DecFoundAt=NumVal.indexOf(".")
	
	if (DecFoundAt >= 0)							//if there is a decimal
	{
		txtAfterDec=NumVal.substr(DecFoundAt+1)		//get everything after the decimal
	}
	else
	{
		txtAfterDec=0;								//set to 0 if no decimal places exist
	}
	if ((!pattern.test(NumVal)) || (txtAfterDec.length > NumDec) || (NumVal==0))
	{
		alert("ERROR! " + NumVal + " is not a valid entry. Please enter valid numbers greater than 0,\nsuch as 3.5, .5, or 10.5.  You may enter up to " + NumDec + " decimal places.");
		e.focus();
	}
}

function parseUserID(usrName) //returns true if string contains only whitespace characters
{
	var NameLen;
	var UsrID;
	
	NameLen=usrName.length;
	UsrID=usrName.substring(NameLen-2,NameLen+1);
	alert("The User ID is " + usrid);
}

function HelpPopupWindow(URL) {
    var win = window.open(URL,'main_help','width=320,height=410,scrollbars,resizable,screenX=0,screenY=0,top=0,left=0');
    win.focus();
    return false;
}

function HelpPopupWindowLarge(URL) {
    var win = window.open(URL,'main_help','width=450,height=410,scrollbars,resizable,screenX=0,screenY=0,top=0,left=0');
    win.focus();
    return false;
}

function PopUpWindow(someURL)	//opens popup window small sized in center of users screen
{
	var width=screen.width/1.5;	//make width bigger by making divisor smaller
	var height=screen.height/2;	//make width bigger by making divisor smaller
	var left = (screen.availWidth - width)*.5;
	var top = (screen.availHeight - height)*.5;
	popupWin=window.open(someURL,"DisplayWindow1","toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",modal=yes")	
}

function PopUpWindowLarge(someURL)	//opens popup window medium sized in center of users screen
{
	var width=screen.width/1.5;		//make width bigger by making divisor smaller
	var height=screen.height/1.5;	//make width bigger by making divisor smaller
	var left = (screen.availWidth - width)*.5;
	var top = (screen.availHeight - height)*.5;
	popupWin=window.open(someURL,"DisplayWindow2","toolbar=yes,scrollbars=yes,location=0,statusbar=yes,menubar=yes,resizable=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",modal=yes")	
}

function PopUpWindowFullScreen(someURL)	//opens popup full window based on users screen size
{
	var width=screen.width;		
	var height=screen.height;
	var left=(screen.availWidth - width)*.5;
	var top=(screen.availHeight - height)*.5;
	popupWin=window.open(someURL,"DisplayWindow3","toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",modal=yes")
}

function PrintMe()	//prints the current document with Printer Defaults
//use this code in html doc...<input type="button" name="Print" value="Print" onClick="PrintMe();">
{
	window.print()
}

function PrintMeLandscape()		//prints the current document giving warning to change to Landscape
//use this code in html doc...<input type="button" name="Print" value="Print" onClick="PrintMe();">
{
	alert("Be sure to change your Page Layout to LANDSCAPE and margins to 0.5 inches \nbefore printing this document.");
	window.print();
}

function ReloadPage()	//reloads and refreshes current page
{
	location.reload();
}

function ReloadMainFromPopup()
{
	//copy and paste this code --> <script>ReloadMainFromPopup()</script>  <--to top of all
	//		popup windows;this will refresh the main window that opened the popup with changes made in popups
	//example: you open popup "Add Programs"; you add a program; after refresh, this new
	//		program will show up in main window;
	
	var MainWindowURL=window.opener.location					//gets URL of main (opener) window
	window.onblur=window.opener.location.href=MainWindowURL		//change location to previous URL
																//this will reload the same Main page														
}

function VerifyDeletion(SomeURL)
{
	var msg="\nClick OK to delete record.  Select CANCEL to cancel deletion.\n";
	
	if (confirm(msg))			//if user selects OK
	{
		window.location.href=SomeURL;
	}
	else
	{
		alert("Deletion cancelled.");
	}
}

function VerifyPassword(OrigPWD,VerifPWD, CEmail)
{
	var pw1 = OrigPWD.value;
	var pw2 = VerifPWD.value;
	
	//check to see if either are empty
	if  (pw1=='')	//if either is empty
	{
		alert("Sorry.  You cannot leave this field blank.");
		OrigPWD.focus();
		//return false; //uncomment if using onSubmit
	}
	else
	if  (pw2=='')	//if either is empty
	{
		alert("Sorry.  You cannot leave this field blank.");
		VerifPWD.focus();
		//return false; //uncomment if using onSubmit
	}
	
	else
	//check to make sure both are equal
	if (pw1 != pw2)
	{
		alert ("You did not enter the same new password twice.\nPlease re-enter your password.");
		
		//return focus to OrigPWD
		OrigPWD.focus();
		return false;
		
		//return false;	//uncomment if using onSubmit
	}
	
	if ( (CEmail.value== null) || (CEmail.value == "") || isblank(CEmail.value) )
	{
		alert("Please enter data in email field.")
		CEmail.focus();
		return false;
	}

	//return true; //uncomment if using onSubmit
}
function ChkForNulls(e)
{
	if ((e.value == null) || (e.value == "") || isblank(e.value))   //CHECK IF EMPTY, NULL, OR BLANK
	{	
//this will be transparent to the user and will automatically turn to zero and take them back to field
		e.focus();
		e.value="0";
	}
}
		

function ValidateTotalAge()
{
	document.mainform1.AgeTotal.value=	
        parseInt(document.mainform1.Under10.value) + 
        parseInt(document.mainform1.A10_17yrs.value) +
		parseInt(document.mainform1.A18_20yrs.value) +
		parseInt(document.mainform1.A21_64yrs.value) +
		parseInt(document.mainform1.A65PlusYrs.value);
}

function EthnicityValidateTotalAge()
{
	document.mainform1.AgeTotal.value=	
        parseInt(document.mainform1.Under12.value) + 
        parseInt(document.mainform1.A12_17yrs.value) +
		parseInt(document.mainform1.A18_20yrs.value) +
		parseInt(document.mainform1.A21_25yrs.value) +
		parseInt(document.mainform1.A26PlusYrs.value);
}
		
function ValidateTotalGender()
{
	document.mainform1.GenderTotal.value=	
        parseInt(document.mainform1.Female.value) + 
        parseInt(document.mainform1.Male.value);
}
				
function ValidateTotalRace()
{
	document.mainform1.RaceTotal.value  = 	
        parseInt(document.mainform1.Euro_Am.value) + 
        parseInt(document.mainform1.Af_Am.value) +
		parseInt(document.mainform1.Lat_Am.value) +
		parseInt(document.mainform1.Asian_Am.value) +
		parseInt(document.mainform1.NativeAm.value) +
		parseInt(document.mainform1.Intnl.value) +
		parseInt(document.mainform1.Oth_Race.value);
}

function EthnicityValidateTotalRace()
{
	document.mainform1.RaceTotal.value  = 	
        parseInt(document.mainform1.Euro_Am.value) + 
        parseInt(document.mainform1.Af_Am.value) +
		parseInt(document.mainform1.Asian.value) +
		parseInt(document.mainform1.NativeAm.value) +
		parseInt(document.mainform1.Hawaiian.value) +
		parseInt(document.mainform1.Intnl.value) +
		parseInt(document.mainform1.Oth_Race.value);
}

function ValidateTotalEthnicity()
{
	document.mainform1.EthnicityTotal.value=	
        parseInt(document.mainform1.Hisp.value) + 
        parseInt(document.mainform1.NotHisp.value);
}
//added ValidateFedCode function - S.C. Dey
function ValidateFedCode()
{

}
function ValidateTotals()
{
	//added var pattern 6.00 - S.C. Dey
    //  This should be replaced by a call to the new DB table.
	var pat = /\bdna\b|1.01|1.02|1.03|1.04|1.05|1.06|1.07|1.08|1.09|1.10|2.01|2.02|2.03|2.04|2.05|2.06|2.07|3.01|3.02|3.03|3.04|3.05|3.06|3.07|3.08|3.09|3.10|3.11|3.12|3.13|3.14|4.01|4.02|4.03|4.04|4.05|4.06|4.07|5.01|5.02|5.03|5.04|5.05|5.06|5.07|6.00/ //must be like 3.14  Fed Strat Code/
	var txtAfterDec;					//text after the decimal
	var txtBeforeDec;					//text before decimal
    var dontStopChecking = true;
	

	if ((document.mainform1.RaceTotal.value!=document.mainform1.GenderTotal.value) || (document.mainform1.RaceTotal.value != document.mainform1.AgeTotal.value) || (document.mainform1.GenderTotal.value != document.mainform1.AgeTotal.value))
	{
		alert("Please recheck your Totals.\n---Age Total:" + document.mainform1.AgeTotal.value + "\n---Race Total:" + document.mainform1.RaceTotal.value + "\n---Gender Total:" + document.mainform1.GenderTotal.value + "\nThis record has not been SAVEd.\nPlease change your numbers and then click SAVE again.")
		document.mainform1.Under10.focus();
        dontStopChecking = false;
	}
	else if (dontStopChecking && ChkDayOfMonth(document.mainform1.Day_Of_Month))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkPrgNum(document.mainform1.Prg_Num))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkActlHrs(document.mainform1.Actl_Hrs))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkFedCode(document.mainform1.Fed_Code,pat))
		{ dontStopChecking = false; }		
    else if (dontStopChecking && ChkGeoCode(document.mainform1.Geo_Code))
        { dontStopChecking = false; }
	else
	{
		document.mainform1.submit();
	}
}

//added by Rachel

function NewEthnicityValidateTotals()
{
	//added var pattern 6.00 - S.C. Dey
    //  This should be replaced by a call to the new DB table.
	var txtAfterDec;					//text after the decimal
	var txtBeforeDec;					//text before decimal
    var dontStopChecking = true;
	

	if ((document.mainform1.RaceTotal.value!=document.mainform1.GenderTotal.value) || (document.mainform1.RaceTotal.value != document.mainform1.AgeTotal.value) || (document.mainform1.GenderTotal.value != document.mainform1.AgeTotal.value) || (document.mainform1.GenderTotal.value != document.mainform1.EthnicityTotal.value))
	{
		alert("Please recheck your Totals.\n---Age Total:" + document.mainform1.AgeTotal.value + "\n---Race Total:" + document.mainform1.RaceTotal.value + "\n---Ethnicity Total:" + document.mainform1.EthnicityTotal.value + "\n---Gender Total:" + document.mainform1.GenderTotal.value + "\nThis record has not been SAVEd.\nPlease change your numbers and then click SAVE again.")
		document.mainform1.Under12.focus();
        dontStopChecking = false;
	}
	else if (dontStopChecking && ChkDayOfMonth(document.mainform1.Day_Of_Month))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkPrgNum(document.mainform1.Prg_Num))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkActlHrs(document.mainform1.Actl_Hrs))
        { dontStopChecking = false; }
    else if (dontStopChecking && ChkGeoCode(document.mainform1.Geo_Code))
        { dontStopChecking = false; }
	else
	{
		document.mainform1.submit();
	}
}

function NewEthnicityValidateTotals2009()
{
	//added var pattern 6.00 - S.C. Dey
    //  This should be replaced by a call to the new DB table.
	var txtAfterDec;					//text after the decimal
	var txtBeforeDec;					//text before decimal
    var dontStopChecking = true;
	

	if (dontStopChecking && ChkDayOfMonth(document.mainform1.Day_Of_Month))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkPrgNum(document.mainform1.Prg_Num))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkActlHrs(document.mainform1.Actl_Hrs))
        { dontStopChecking = false; }
    else if (dontStopChecking && ChkGeoCode(document.mainform1.Geo_Code))
        { dontStopChecking = false; }
	else
	{
		document.mainform1.submit();
	}
}

function NewValidateTotals()
{
	//added var pattern 6.00 - S.C. Dey
    //  This should be replaced by a call to the new DB table.
	var txtAfterDec;					//text after the decimal
	var txtBeforeDec;					//text before decimal
    var dontStopChecking = true;
	

	if ((document.mainform1.RaceTotal.value!=document.mainform1.GenderTotal.value) || (document.mainform1.RaceTotal.value != document.mainform1.AgeTotal.value) || (document.mainform1.GenderTotal.value != document.mainform1.AgeTotal.value))
	{
		alert("Please recheck your Totals.\n---Age Total:" + document.mainform1.AgeTotal.value + "\n---Race Total:" + document.mainform1.RaceTotal.value + "\n---Gender Total:" + document.mainform1.GenderTotal.value + "\nThis record has not been SAVEd.\nPlease change your numbers and then click SAVE again.")
		document.mainform1.Under10.focus();
        dontStopChecking = false;
	}
	else if (dontStopChecking && ChkDayOfMonth(document.mainform1.Day_Of_Month))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkPrgNum(document.mainform1.Prg_Num))
        { dontStopChecking = false; }
	else if (dontStopChecking && ChkActlHrs(document.mainform1.Actl_Hrs))
        { dontStopChecking = false; }
    else if (dontStopChecking && ChkGeoCode(document.mainform1.Geo_Code))
        { dontStopChecking = false; }
	else
	{
		document.mainform1.submit();
	}
}




    function ZeroCheck(c) {
	if (parseInt(c.value)<=0)
	{alert("ERROR! Please enter a value larger than 0.");
	c.focus();
	}
	}
	
    function ProgramNumbers(c) {
	if (parseInt(c.value)<100 || parseInt(c.value)>299)
	{alert("ERROR! Please enter a valid Program Number between 100 and 299.");
	c.value="000";
	c.focus();
	}
	}
	
	    function ProjectedHours(c) {
	if (parseInt(c.value)<=0)
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0.");
	c.focus();
	return false;
	}
	}
	
	    function ProgramType(c) {
	if (isblank(c.value))
	{alert("ERROR! Please select a Program Type.");
	c.focus();
	}
	}

// not in use---
		    function ProgramEvidence(c) {
	if (isblank(c.value) )
	{alert("ERROR! Please select a Evidence Level.");
	c.focus();
		return false;
	}
	}
//----

		    function ProgramSetting(c) {
	if (isblank(c.value))
	{alert("ERROR! Please select a Setting Category.");
	c.focus();
		return false;
	}
	}
	
	function CheckUpdate(c) {

	if ((c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 901) || (c.Prg_Num.value == 101 & c.Prg_Sub.value != 902)|| (c.Prg_Num.value == 102 & c.Prg_Sub.value != 903)|| (c.Prg_Num.value == 103 & c.Prg_Sub.value != 904)|| (c.Prg_Num.value == 104 & c.Prg_Sub.value != 905)|| (c.Prg_Num.value == 105 & c.Prg_Sub.value != 906)|| (c.Prg_Num.value == 106 & c.Prg_Sub.value != 907)|| (c.Prg_Num.value == 200 & c.Prg_Sub.value != 908)|| (c.Prg_Num.value == 201 & c.Prg_Sub.value != 909)) 
	{	
			var label;
			var code;
			
			if (c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 901) {label='Professional development'; code='901';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 101 & c.Prg_Sub.options[0].value != 902) {label='Mandatory DHS meetings/conferences'; code='902';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 102 & c.Prg_Sub.options[0].value != 903) {label='New worker training/PBU (18 hours per person attending)'; code='903';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 103 & c.Prg_Sub.options[0].value != 904) {label='Work plan development (50 hour max per work plan)'; code='904';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 104 & c.Prg_Sub.options[0].value != 905) {label='Community assessment and planning to inform the work plan'; code='905'; alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value != 906) {label='Consultation to COGs using the Illinois Strategic Prevention Framework'; code='906';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value != 907) {label='Sustainability of evidence based programs and environmental strategies'; code='907';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 200 & c.Prg_Sub.options[0].value != 908) {label='Professional development'; code='908';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value != 909) {label='Networking and Information Sharing with COGs'; code='909';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
	
			c.IOMClass.length=0;
			c.Prg_Sett.length=0;
			
			if ((c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value != 909)|| (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value != 906)||(c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value != 907))
			{c.IOMClass.options[0]= new Option("COG","3");
			c.Prg_Sett.options[0]= new Option("other setting(s)","3");}
			else
			{c.IOMClass.options[0]= new Option("Does not apply","4");
			c.Prg_Sett.options[0]= new Option("Does not apply","4");}
						
			return false;
	}	

	else if (isblank(c.IOMClass.value) )
	{alert("ERROR! Please select a Type of Population.");
	c.IOMClass.focus();
	return false;
	}
	
	else if (isblank(c.Prg_Sett.value) )
	{alert("ERROR! Please select a Setting Category.");
	c.Prg_Sett.focus();
	return false;
	}
	
	else if (parseInt(c.Proj_Hrs.value)<=0 & parseInt(c.Prg_Num.value)!=197 & parseInt(c.Prg_Num.value)!=198 )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}

	else if (parseInt(c.Proj_Hrs.value)>0 & (parseInt(c.Prg_Num.value)==197 ) )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year equal to 0 for Program Num 197&198.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	else if (parseInt(c.Proj_Hrs.value)>0 & (parseInt(c.Prg_Num.value)==198 ) )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year equal to 0 for Program Num 197&198.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	
	}

	function CheckUpdateNew(c) {
	
	if ((c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 931) || (c.Prg_Num.value == 101 & c.Prg_Sub.value != 932)|| (c.Prg_Num.value == 102 & c.Prg_Sub.value != 933)|| (c.Prg_Num.value == 103 & c.Prg_Sub.value != 934)|| (c.Prg_Num.value == 104 & c.Prg_Sub.value != 935)|| (c.Prg_Num.value == 105 & c.Prg_Sub.value != 936)|| (c.Prg_Num.value == 106 & c.Prg_Sub.value != 937)||  (c.Prg_Num.value == 199 & c.Prg_Sub.value != 938)||   (c.Prg_Num.value == 200 & c.Prg_Sub.value != 941)|| (c.Prg_Num.value == 201 & c.Prg_Sub.value != 942)) 
	{	
			var label;
			var code;
			
			c.IOMClass.length=0;
			c.Prg_Sett.length=0;
						
			if (c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 931) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Mandatory Training/Conferences'; code='931';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 101 & c.Prg_Sub.options[0].value != 932) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Work Plan Development (50 hours max)'; code='932';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 102 & c.Prg_Sub.options[0].value != 933) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='SAPP Work Plan Assessment (200 Hours max)'; code='933';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 103 & c.Prg_Sub.options[0].value != 934) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Promotion and Use of the Illinois Youth Survey'; code='934';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 104 & c.Prg_Sub.options[0].value != 935) {c.IOMClass.options[0]= new Option("Selected","2");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Referral to IDHS DASA Treatment Services'; code='935'; alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value != 936) {c.IOMClass.options[0]= new Option("Selected","2");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Referral to Social Services - Non DASA funded'; code='936';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value != 937) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Coordination of Synar Prevention Services'; code='937';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 199 & c.Prg_Sub.options[0].value != 938) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Ready by 21 Activities'; code='938';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 200 & c.Prg_Sub.options[0].value != 941) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Professional development'; code='941';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value != 942) {c.IOMClass.options[0]= new Option("COG","3");c.Prg_Sett.options[0]= new Option("other setting(s)","3");label='Networking and Information Sharing with COGs'; code='942';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
	
						
			return false;
	}



	else if (isblank(c.IOMClass.value) )
	{alert("ERROR! Please select a Type of Population.");
	c.IOMClass.focus();
	return false;
	}
	
	else if (isblank(c.Prg_Sett.value) )
	{alert("ERROR! Please select a Setting Category.");
	c.Prg_Sett.focus();
	return false;
	}
	
	else if (parseInt(c.Proj_Hrs.value)<=0 & parseInt(c.Prg_Num.value)!=104 & parseInt(c.Prg_Num.value)!=105 & parseInt(c.Prg_Num.value)!=106)
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}

	}

	function CheckInsert(c) {
	
	if (parseInt(c.Prg_Num.value)<100 || parseInt(c.Prg_Num.value)>299)
	{alert("ERROR! Please enter a valid Program Number between (100-199), (200-299).");
	c.Prg_Num.value="000";
	c.Prg_Num.focus();
	return false;
	}	
	
	if ((c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 901) || (c.Prg_Num.value == 101 & c.Prg_Sub.value != 902)|| (c.Prg_Num.value == 102 & c.Prg_Sub.value != 903)|| (c.Prg_Num.value == 103 & c.Prg_Sub.value != 904)|| (c.Prg_Num.value == 104 & c.Prg_Sub.value != 905)|| (c.Prg_Num.value == 105 & c.Prg_Sub.value != 906)|| (c.Prg_Num.value == 106 & c.Prg_Sub.value != 907)|| (c.Prg_Num.value == 199 & c.Prg_Sub.value != 910)|| (c.Prg_Num.value == 197 & c.Prg_Sub.value != 911)|| (c.Prg_Num.value == 198 & c.Prg_Sub.value != 912)|| (c.Prg_Num.value == 200 & c.Prg_Sub.value != 908)|| (c.Prg_Num.value == 201 & c.Prg_Sub.value != 909)) 
	{	
			var label;
			var code;
			
			if (c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 901) {label='Professional development'; code='901';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 101 & c.Prg_Sub.options[0].value != 902) {label='Mandatory DHS meetings/conferences'; code='902';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 102 & c.Prg_Sub.options[0].value != 903) {label='New worker training/PBU (18 hours per person attending)'; code='903';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 103 & c.Prg_Sub.options[0].value != 904) {label='Work plan development (50 hour max per work plan)'; code='904';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 104 & c.Prg_Sub.options[0].value != 905) {label='Community assessment and planning to inform the work plan'; code='905'; alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value != 906) {label='Consultation to COGs using the Illinois Strategic Prevention Framework'; code='906';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value != 907) {label='Sustainability of evidence based programs and environmental strategies'; code='907';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}

			else if (c.Prg_Num.value == 199 & c.Prg_Sub.options[0].value != 910) {label='Ready by 21 Activities'; code='910';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 197 & c.Prg_Sub.options[0].value != 911) {label='Referral to IDHS DASA Treatment Services'; code='911';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 198 & c.Prg_Sub.options[0].value != 912) {label='Referral to Local Community Service Provider-Other than Treatment'; code='912';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 196 & c.Prg_Sub.options[0].value != 913) {label='Workplan Development Assessment'; code='913';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
						
			else if (c.Prg_Num.value == 200 & c.Prg_Sub.options[0].value != 908) {label='Professional development'; code='908';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value != 909) {label='Networking and Information Sharing with COGs'; code='909';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
	
			c.IOMClass.length=0;
			c.Prg_Sett.length=0;
			
			if ((c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value == 909)|| (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value == 906)||(c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value == 907))
			{c.IOMClass.options[0]= new Option("COG","3");
			c.Prg_Sett.options[0]= new Option("other setting(s)","3");}
			else if ((c.Prg_Num.value == 197 & c.Prg_Sub.options[0].value == 911)|| (c.Prg_Num.value == 198 & c.Prg_Sub.options[0].value == 912))
			{c.IOMClass.options[0]= new Option("Selected","2");
			c.Prg_Sett.options[0]= new Option("Does not apply","4");}
			else
			{c.IOMClass.options[0]= new Option("Does not apply","4");
			c.Prg_Sett.options[0]= new Option("Does not apply","4");}
						
			return false;
	}		
	
	else if ( (parseInt(c.Prg_Num.value)<200 & parseInt(c.Prg_Num.value)>100 )& (parseInt(c.Prg_Type.value)!=1 & parseInt(c.Prg_Type.value)<9) || (parseInt(c.Prg_Num.value)<300 & parseInt(c.Prg_Num.value)>200 ) & ( parseInt(c.Prg_Type.value)!=2 & parseInt(c.Prg_Type.value)<9) )
	{alert ("ERROR! Please select a correct Program Activity for Program Num: "+ c.Prg_Num.value+".");
	return false;
	}
	
	else if (parseInt(c.Prg_Type.value)==9 & (c.Prg_Num.value >106&c.Prg_Num.value!=199&c.Prg_Num.value!=196&c.Prg_Num.value!=197&c.Prg_Num.value!=198&c.Prg_Num.value!=200&c.Prg_Num.value!=201) )
	{alert ("ERROR! This Program Activity is reserved for Prg_Num: 100-106, 200,201.");
	return false;		
	}
	
	else if (isblank(c.Prg_Sub.value) )
	{alert("ERROR! Please select a Program.");
	c.Prg_Sub.focus();
	return false;
	}
	
	else if (isblank(c.IOMClass.value) )
	{alert("ERROR! Please select a Type of Population.");
	c.IOMClass.focus();
	return false;
	}

	else if (isblank(c.Prg_Sett.value) )
	{alert("ERROR! Please select a Setting Category.");
	c.Prg_Sett.focus();
	return false;
	}
	



	else if (parseInt(c.Proj_Hrs.value)<=0 & parseInt(c.Prg_Num.value)!=197 & parseInt(c.Prg_Num.value)!=198 )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	
	else if (parseInt(c.Proj_Hrs.value)>0 & (parseInt(c.Prg_Num.value)==197 ) )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year equal to 0 for Program Num 197&198.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	else if (parseInt(c.Proj_Hrs.value)>0 & (parseInt(c.Prg_Num.value)==198 ) )
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year equal to 0 for Program Num 197&198.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	
	else if (c.Proj_Hrs!="")
	{
	var strField = new String(c.Proj_Hrs.value);
	var i = 0;
	for (i=0; i<strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
		{
			alert("ERROR! " + strField + " is not a valid numeric entry. Please enter numbers only. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
			c.Proj_Hrs.focus();
			c.Proj_Hrs.value = "0";
			return false;
		}
	}
	

	}

	function CheckInsertNew(c) {
	
	if (parseInt(c.Prg_Num.value)<100 || parseInt(c.Prg_Num.value)>250 || ( parseInt(c.Prg_Num.value)<199 & parseInt(c.Prg_Num.value)>150 ) )
	{alert("ERROR! Please enter a valid Program Number between (100-150), (199-250).");
	c.Prg_Num.value="000";
	c.Prg_Num.focus();
	return false;
	}	
	
	if ((c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 931) || (c.Prg_Num.value == 101 & c.Prg_Sub.value != 932)|| (c.Prg_Num.value == 102 & c.Prg_Sub.value != 933)|| (c.Prg_Num.value == 103 & c.Prg_Sub.value != 934)|| (c.Prg_Num.value == 104 & c.Prg_Sub.value != 935)|| (c.Prg_Num.value == 105 & c.Prg_Sub.value != 936)|| (c.Prg_Num.value == 106 & c.Prg_Sub.value != 937)||(c.Prg_Num.value == 199 & c.Prg_Sub.value != 938)|| (c.Prg_Num.value == 200 & c.Prg_Sub.value != 941)|| (c.Prg_Num.value == 201 & c.Prg_Sub.value != 942)) 
	{	
			var label;
			var code;
			
			c.IOMClass.length=0;
			c.Prg_Sett.length=0;
						
			if (c.Prg_Num.value == 100 & c.Prg_Sub.options[0].value != 931) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Mandatory Training/Conferences'; code='931';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 101 & c.Prg_Sub.options[0].value != 932) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Work Plan Development (50 hours max)'; code='932';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 102 & c.Prg_Sub.options[0].value != 933) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='SAPP Work Plan Assessment (200 Hours max)'; code='933';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 103 & c.Prg_Sub.options[0].value != 934) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Promotion and Use of the Illinois Youth Survey'; code='934';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 104 & c.Prg_Sub.options[0].value != 935) {c.IOMClass.options[0]= new Option("Selected","2");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Referral to IDHS DASA Treatment Services'; code='935'; alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 105 & c.Prg_Sub.options[0].value != 936) {c.IOMClass.options[0]= new Option("Selected","2");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Referral to Social Services - Non DASA funded'; code='936';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 106 & c.Prg_Sub.options[0].value != 937) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Coordination of Synar Prevention Services'; code='937';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 199 & c.Prg_Sub.options[0].value != 938) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Ready by 21 Activities'; code='938';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 200 & c.Prg_Sub.options[0].value != 941) {c.IOMClass.options[0]= new Option("Does not apply","4");c.Prg_Sett.options[0]= new Option("Does not apply","4");label='Professional development'; code='941';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
			else if (c.Prg_Num.value == 201 & c.Prg_Sub.options[0].value != 942) {c.IOMClass.options[0]= new Option("COG","3");c.Prg_Sett.options[0]= new Option("other setting(s)","3");label='Networking and Information Sharing with COGs'; code='942';alert("Program Num "+c.Prg_Num.value +" is reserved for "+label);c.Prg_Sub.options[0].text=label; c.Prg_Sub.options[0].value=code;}
	
						
			return false;
	}		
	
	else if ( (parseInt(c.Prg_Num.value)<199 & parseInt(c.Prg_Num.value)>100 )& (parseInt(c.Prg_Type.value)!=3 & parseInt(c.Prg_Type.value)<9) || (parseInt(c.Prg_Num.value)<300 & parseInt(c.Prg_Num.value)>200 ) & ( parseInt(c.Prg_Type.value)!=4 & parseInt(c.Prg_Type.value)<9) )
	{alert ("ERROR! Please select a correct Program Activity for Program Num: "+ c.Prg_Num.value+".");
	return false;
	}
	
	else if (parseInt(c.Prg_Type.value)==9 & (c.Prg_Num.value >110&c.Prg_Num.value!=199&c.Prg_Num.value!=200&c.Prg_Num.value!=201) )
	{alert ("ERROR! This Program Activity is reserved for Prg_Num: 100-110,199,200,201.");
	return false;		
	}
	
	else if (isblank(c.Prg_Sub.value) )
	{alert("ERROR! Please select a Program.");
	c.Prg_Sub.focus();
	return false;
	}
	
	else if (isblank(c.IOMClass.value) )
	{alert("ERROR! Please select a Type of Population.");
	c.IOMClass.focus();
	return false;
	}

	else if (isblank(c.Prg_Sett.value) )
	{alert("ERROR! Please select a Setting Category.");
	c.Prg_Sett.focus();
	return false;
	}
	
	else if (parseInt(c.Proj_Hrs.value)<=0 & parseInt(c.Prg_Num.value)!=104 & parseInt(c.Prg_Num.value)!=105 & parseInt(c.Prg_Num.value)!=106)
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	
	else if (c.Proj_Hrs!="")
	{
	var strField = new String(c.Proj_Hrs.value);
	var i = 0;
	for (i=0; i<strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
		{
			alert("ERROR! " + strField + " is not a valid numeric entry. Please enter numbers only. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
			c.Proj_Hrs.focus();
			c.Proj_Hrs.value = "0";
			return false;
		}
	}


	}


//Check for Geocodes.asp	
    function StaffNameCheck(c) {
	if (isblank(c.stfFirst.value)||isblank(c.stffLast.value) )
	{alert("ERROR! Please enter both First Name and Last Name.");
	return false;
	}
	
	if (isblank(c.Phone.value)||isblank(c.Email.value) )
	{alert("ERROR! Please enter both Phone # and Email address.");
	return false;
	}	
	
	if (!isblank(c.Email.value))
	{
		var strField = new String(c.Email.value);
		var i = 0;
		var tempat=0;
		var tempdot=0;
		for (i=0; i<strField.length; i++)
			if (strField.charAt(i) == '@')
			{tempat=tempat+1}
		for (i=0; i<strField.length; i++)
			if (strField.charAt(i) == '.')
			{tempdot=tempdot+1}	
		if (tempat!=1 || tempdot <1 )
		{	var msg="\nThis is not a valid email address! Click OK to continue.  Select CANCEL to cancel the operation.\n";
		
				if (confirm(msg))			//if user selects OK
				{
					return true;
				}
				else
				{
					c.Email.focus();
					return false;
				}
	
		}

	}
	
	}

    function CheckGeo(c) {
	if ( ( c.Geo_Code.value =="000" & c.Geo_Code2.value == "00" ) || ( c.Geo_Code.value =="999" & c.Geo_Code2.value == "99" ) )
	{alert("ERROR! Geo Codes 000-00 and 999-99 are all reserved.");
	return false;
	}
	
	else if (c.Geo_Code.value.length!=3 || c.Geo_Code2.value.length!=2 )
	{alert("ERROR! Geo Codes must be in the format of XXX-XX.");
	return false;
	}
	
	else if (c.Geo_Code!=""||c.Geo_Code2!="")
	{
	var strField = new String(c.Geo_Code.value+c.Geo_Code2.value);
	var i = 0;
	for (i=0; i<strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
		{	alert("ERROR! Geo Codes must be numbers.");
			return false;
		}
	}
	

	}

//Check for NewGeocodes.asp
    function CheckNewGeo(c) {
	
	if ( isblank(c.Geo_Lelv.value) || isblank(c.Geo_Num.value) )
	{	alert("ERROR! Please select both County Name and Geo Names.");
			return false;
	}
	
	}

	
//----not in use
function populate(n,tt,ts,p,s,h) 
{

	h.value = "0";
	ts.options[0]= new Option("Click to Select a Program...","");
	p.options[0]= new Option("Select a Program First...","");
	s.options[0]= new Option("Select a Program First...","");
	
	if (n.value == 100 || n.value == 101|| n.value == 102|| n.value == 103|| n.value == 104|| n.value == 105|| n.value == 106|| n.value == 200|| n.value == 201) 
	{
			var label;
			var code;
			
			if (n.value == 100) {label='Professional development'; code='901';}
			else if (n.value == 101) {label='Mandatory DHS meetings/conferences'; code='902';}
			else if (n.value == 102) {label='New worker training/PBU (18 hours per person attending)'; code='903';}
			else if (n.value == 103) {label='Work plan development (50 hour max per work plan)'; code='904';}
			else if (n.value == 104) {label='Community assessment and planning to inform the work plan'; code='905'; h.value = "50";}
			else if (n.value == 105) {label='Consultation to COGs using the Illinois Strategic Prevention Framework'; code='906';}
			else if (n.value == 106) {label='Sustainability of evidence based programs and environmental strategie'; code='907';}
			else if (n.value == 200) {label='Professional development'; code='908';}
			else if (n.value == 201) {label='Networking and Information Sharing with COGs'; code='909';}
			
			tt.value = "9";
			ts.options[0].text=label; 
			ts.options[0].value=code;
			
			if (n.value == 201||n.value == 105||n.value == 106)
			{p.options[0]= new Option("COG","3"); s.
			options[0]= new Option("Other Setting(s)","3");  }
			else {p.options[0]= new Option("Does not apply","4");
			s.options[0]= new Option("Does not apply","4");  }
		
	}

}
//---

	function CheckInsertIN(c) {
	
	if (isblank(c.Prg_Num.value))
	{alert("ERROR! Please select a Program Number.");
	c.Prg_Num.focus();
	return false;
	}	
		
	else if (isblank(c.Prg_Sub.value) )
	{alert("ERROR! Please select a Program.");
	c.Prg_Sub.focus();
	return false;
	}
	
	else if (isblank(c.IOMClass.value) )
	{alert("ERROR! Please select a Type of Population.");
	c.IOMClass.focus();
	return false;
	}

	else if (isblank(c.Prg_Sett.value) )
	{alert("ERROR! Please select a Setting Category.");
	c.Prg_Sett.focus();
	return false;
	}
	
	else if (parseInt(c.Proj_Hrs.value)<=0)
	{alert("ERROR! Please enter a Projected Hours for Fiscal Year larger than 0. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
	c.Proj_Hrs.value="0";
	c.Proj_Hrs.focus();
	return false;
	}
	
	else if (c.Proj_Hrs!="")
	{
	var strField = new String(c.Proj_Hrs.value);
	var i = 0;
	for (i=0; i<strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
		{
			alert("ERROR! " + strField + " is not a valid numeric entry. Please enter numbers only. Important Note: Only enter Program Activity information when there are projected hours indicated. Do not enter Program Activity information when there are no projected hours indicated.");
			c.Proj_Hrs.focus();
			c.Proj_Hrs.value = "0";
			return false;
		}
	}

	}
	

	
// end of Rachel's coding
//-------
