//Hey Sarah and Ben, thanks for working on this!

// PublicAccessValidation.js
//
// The following JavaScript functions are for validating user
// input search criteria based upon established business rules
// for Public and Premium Access non-confidential court records'
// searches in Broward County, FL.
//
// These validation functions support the following Broward 
// Clerk Portal pages:
//
// 1.  public_search.asp
// 2.  premium_party_search.asp
// 3.  premium_case_identifier_search.asp
// 4.  premium_citation_search.asp
// 5.  premium_tag_search.asp - Phase II
// 6.  premium_event_search.asp
// 7.  premium_filing_search.asp
// 8.  premium_disposition_search.asp
// 9.  premium_docket_search.asp
//
//
// The following page specific functions are included in 
// this file:
//
// 1.  chkPublicPartyForm (frmPublicParty)
// 2.  chkPublicCaseForm (frmPublicCase)
// 3.  chkPublicCitationForm (frmPublicCitation)
// 4.  chkPublicTagForm (frmPublicTag) - Phase II
// 5.  chkPremiumPartyForm (frmPremiumParty)
// 6.  chkPremiumIDForm
// 7.  chkPremiumIdentifierForm (frmPremiumIdentifier)
// 8.  chkPremiumCitationForm (frmPremiumCitation)
// 9.  chkPremiumTagForm (frmPremiumTag) - Phase II
// 10. chkPremiumEventForm (frmPremiumEvent)
// 11. chkPremiumFilingForm (frmPremiumFiling)
// 12. chkPremiumDispositionForm (frmPremiumDisposition)
// 13. chkPremiumDocketForm (frmPremiumDocket)
//
//
// The following support functions are included in this file:
//
//  - text fields are not blank
//  - text field is a specified length
//  - select field is not set to option[0]
//  - text field is letters only
//  - text field is digits only
//  - text field is letters or digits    
//  - text field date formatted correctly
//  - text field case number formatted correctly based upon 
//    court type
//  - radio button selected
//
//
// Data validation functions:
//
// isWhitespace (s)                    Check whether string s is empty or whitespace.
// isLetter (c)                        Check whether character c is an English letter 
// isDigit (c)                         Check whether character c is a digit 
// isValidLength (s, min,max)          Check whether string is between min and max length.
// isLetterOrDigit (c)                 Check whether character c is a letter or digit.
// isInteger (s [,eok])                True if all characters in string s are numbers.
// isAlphabetic (s [,eok])             True if string s is English letters 
// isAlphanumeric (s [,eok])           True if string s is English letters and numbers only.
// isDate (year, month, day)           True if string arguments form a valid date.
//
//
// Reformat data functions:
//
// stripWhitespace (s)                 Removes all whitespace characters from s.
// stripInitialWhitespace (s)          Removes initial (leading) whitespace characters from s.
// reformat (TARGETSTRING, STRING,     Function for inserting formatting characters or
//   INTEGER, STRING, INTEGER ... )       delimiters into TARGETSTRING.                                       


// User prompt functions:
//
// warnEmpty (theField, s)             Notify user that required field theField is empty.
// warnInvalid (theField, s)           Notify user that contents of field theField are invalid.

// FUNCTIONS TO INTERACTIVELY CHECK FIELD CONTENTS:
//
// checkString (theField, s [,eok])    Check that theField.value is not empty or all whitespace.
// checkValidLength (theField, min, max)      Check that theField.value.length is between min and max
// checkAlphabetic (theField [,eok])   Check that theField.value is alphabetic.
// checkDate (yearField, monthField, dayField, labelString, OKtoOmitDay)
//                                     Check that field values form a valid date.
// getRadioButtonValue (radio)         Get checked value from radio button.




function posttopage(name)
{ document.forms[0].action = name; 
document.forms[0].submit(); } 






//////////////////////////////////////////////////////////////
//			public_search.asp				      //
//////////////////////////////////////////////////////////////
function chkPublicPartyForm(ControlName)
{
//validation rules
//1.  if First Name not blank, then Last Name not blank
//2.  if Middle Initial not blank, then Last Name not blank, and First Name not blank
//3.  either Last Name and First Name or Business or Organization Name must not be blank
//4.  if Business or Organization Name not blank, then Last Name blank, First Name blank, and Middle Initial blank
//5.  Last Name alpha only
//6.  First Name alpha only
//7.  Middle Initial alpha only
//8.  Last Name 45 or fewer characters
//9.  First Name 20 or fewer characters
//10. Middle Initial must be 1 character
//11. Business or Organization Name 45 or fewer characters

//cross-field validation rules
//1.  Either Last Name Business or Organization Name must not be blank
//2.  If either Last Name, First Name, or Middle Initial is not blank then Business or Organization name must be blank
//3.  If First Name is not blank, then Last Name must not be blank\
//4.  If Middle Initial is not blank, then Last Name and First Name must not be blank
//5.  If Business or Organization Name is not blank then Last Name, First Name, and Middle Initial must be blank


// variable declarations and assignments
alertCourtType = "Please enter a Court Type to conduct a search.";
alertNeither =	"Please enter a Party Last Name or Business Name to conduct a search.";
alertLast = 	"Please enter a Party Last Name in order to conduct a search.";
alertComplete =	"Please enter a Complete Party Name.";
alertLastLong = 	"The Last Name field may not be longer than 45 characters.";
alertFirstLong =	"The First Name field may not be longer than 20 characters.";
alertMILong =	"The Middle Initial field may not be longer than 1 character.";

//Ben's alerts for alpha only validation
alertLastAlpha = "The Last Name field may not contain numeric or special characters.";
alertFirstAlpha = "The First Name field may not contain numeric or special characters.";
alertMIAlpha = "The Middle Initial field may not contain numeric or special characters.";

var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, -.'";
var ok = "yes";
var temp;


	//Rule: Either Last Name or Business or Organization Name must be entered to conduct a Search by Party
	//Invalid Input: Both Last Name and Business or Organization Name are blank
	if((document.getElementById(ControlName + 'txtLastName').value == "") && (document.getElementById(ControlName + 'txtBusinessEntity').value == "") && (document.getElementById(ControlName + 'txtFirstName').value == "") && (document.getElementById(ControlName + 'txtMiddleInitial').value == ""))
	{
		//alert(alertNeither);
		return alertNeither;
	}

	//Rule: If user input First Name, Last Name must also be entered
	//Invalid Input: First Name populated, but not Last Name
	if(document.getElementById(ControlName + 'txtFirstName').value != "")
	{
		if(document.getElementById(ControlName + 'txtLastName').value == "")
		{
			//alert(alertLast);
			return alertLast;
		}
	} 

	//Rule: If a user inputs a Middle Initial, Last Name and First Name must also be entered
	//Invalid Input:  Middle Initial populated without either Last Name or First Name
	if(document.getElementById(ControlName + 'txtMiddleInitial').value != "")
	{
		if((document.getElementById(ControlName + 'txtFirstName').value == "") || (document.getElementById(ControlName + 'txtLastName').value == ""))
		{
			//alert(alertComplete);
			return alertComplete;
		}
	}

	//Rule: Last Name may not be longer than 45 characters
	if(document.getElementById(ControlName + 'txtLastName').value != "")
	{
		if(document.getElementById(ControlName + 'txtLastName').value.length > 45)
		{
			//alert(alertLastLong);
			return alertLastLong;
		}
	}

	//Rule: First Name may not be longer than 20 characters
	if(document.getElementById(ControlName + 'txtFirstName').value != "")
	{
		if(document.getElementById(ControlName + 'txtFirstName').value.length > 20)
		{
			//alert(alertFirstLong);
			return alertFirstLong;
		}
	}
	
	//Rule: Middle Initial may not be longer than 15 character
	if(document.getElementById(ControlName + 'txtMiddleInitial').value != "")
	{
		if(document.getElementById(ControlName + 'txtMiddleInitial').value.length > 15)
		{
			//alert(alertMILong);
			return alertMILong;
		}
	}
	
	
	//Rule: Must select court type
//    if(document.getElementById(ControlName + 'DropDownList1').options[0].selected)
//    {
//	    //alert(alertCourtType);
//	    return alertCourtType;
//    }
	
	
	//Rule: All entries in Last Name, First Name, and Middle Initial fields must be letters only
	//made by Benjamin Camp on 9-25-00 at 2:30 PM
	//Last Name
	for (var i=0; i<document.getElementById(ControlName + 'txtLastName').value.length; i++) 
	{
		temp = "" + document.getElementById(ControlName + 'txtLastName').value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		//alert(alertLastAlpha);
		document.getElementById(ControlName + 'txtLastName').focus();
		document.getElementById(ControlName + 'txtLastName').select();
   		return alertLastAlpha;
   		}
	
	//First Name
	for (var i=0; i<document.getElementById(ControlName + 'txtFirstName').value.length; i++)
	{
		temp = "" + document.getElementById(ControlName + 'txtFirstName').value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		//alert(alertFirstAlpha);
		document.getElementById(ControlName + 'txtFirstName').focus();
		document.getElementById(ControlName + 'txtFirstName').select();
   		return alertFirstAlpha;
   		}
   		
   	//Middle Initial
   	for (var i=0; i<document.getElementById(ControlName + 'txtMiddleInitial').value.length; i++)
	{
		temp = "" + document.getElementById(ControlName + 'txtMiddleInitial').value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		//alert(alertMIAlpha);
		document.getElementById(ControlName + 'txtMiddleInitial').focus();
		document.getElementById(ControlName + 'txtMiddleInitial').select();
   		return alertMIAlpha;
   		}


//else return '';
return '';

}

//////////////////////////////////////////////////////////////
//			Numeric Check			                        //
//////////////////////////////////////////////////////////////
var numbers=".0123456789";
function isNumeric(x) {
	// is x a String or a character?
	if(x.length>1) {
		// remove negative sign
		x=Math.abs(x)+"";
		for(j=0;j<x.length;j++) {
			// call isNumeric recursively for each character
			number=isNumeric(x.substring(j,j+1));
			if(!number) return number;
			}
		return number;
	}
	else {
		// if x is number return true
		if(numbers.indexOf(x)>=0) return true;
		return false;
		}
	}
	
//////////////////////////////////////////////////////////////
//			public_search.asp				      //
//////////////////////////////////////////////////////////////
function chkPublicCaseForm(ControlName)
{

//validation rules
//1.  Case Number not blank
//2.  Case Number alpha-numeric only
//3.  Case Number must be 14 or fewer characters
//4.  ***Court Type not set to option[0]<--- no longer valid!!!!****

//cross-field validation rules
//  N/A

//variable declarations and assignments
alertNeedBoth =	"Please enter a Case Number in order to conduct a Search by Case Number.";
alertAlphaNum = "Please enter only letters or numbers in the Case Number field.";
alertCaseLong = "Case Number may not be longer than 14 characters.";
alertCourtType = "A court type must be selected from the drop down list.";
alertCaseTypes = "Only Traffic Infraction, Traffic Criminal, Felony, Misdemeanor and Municipal Ordinance case types may be searched for fine payments.";

	//Rule: Both Case Number and Court Type must be entered to Search by Case Number
	//Invalid Input:  Case Number is blank
	if(document.getElementById(ControlName + 'txtCaseNumber').value == "")
	{
		//alert(alertNeedBoth);
		document.getElementById(ControlName + 'txtCaseNumber').focus();
		document.getElementById(ControlName + 'txtCaseNumber').select();
		return alertNeedBoth;
	}

	//Rule: Case Number must be alpha-numeric only
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.getElementById(ControlName + 'txtCaseNumber').value.length; i++)
	{
		temp = "" + document.getElementById(ControlName + 'txtCaseNumber').value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			//alert(alertAlphaNum);
			document.getElementById(ControlName + 'txtCaseNumber').focus();
			document.getElementById(ControlName + 'txtCaseNumber').select();
			return alertAlphaNum;
		}
		
	
	//Rule: Case Number may not be longer than 14 characters
	if(document.getElementById(ControlName + 'txtCaseNumber').value != "")
	{
		if(document.getElementById(ControlName + 'txtCaseNumber').value.length > 14)
		{
			//alert(alertCaseLong);
			document.getElementById(ControlName + 'txtCaseNumber').focus();
			document.getElementById(ControlName + 'txtCaseNumber').select();
			return alertCaseLong;
		}
	}
	
	var temp2 = "" + document.getElementById(ControlName + 'txtCaseNumber').value + "";
	temp2 = temp2.toUpperCase();
	temp2 = temp2.substring(8, temp2.length);
	temp2 = temp2.substring(0, 2);
	if((temp2 == "MM") || (temp2 == "MO") || (temp2 == "CF") || (temp2 == "TI") || (temp2 == "TC"))
	{
	    //do nothing
	}
	else
	{
		document.getElementById(ControlName + 'txtCaseNumber').focus();
		document.getElementById(ControlName + 'txtCaseNumber').select();
		return alertCaseTypes;
	}
	

//NOT YET ADDRESSED:
	//Case Numbers must be checked for correct formatting by Court Type??
		
//else return '';
return '';

}

//////////////////////////////////////////////////////////////
//			public_search.asp						        //
//////////////////////////////////////////////////////////////
function chkPublicCitationForm(ControlName)
{
//alert('Test');
//validation rules
//1.  Citation Number not blank
//2.  Citation Number alpha-numeric only
//3.  Citation Number 8 or fewer characters
//4.	3-13-01 SIR #308 If Citation/NTA Number less than 8 characters, pad with leading zero(s).
//5.	If it is an NTA number fill the middle with zeros.
//cross-field validation rules
//  N/A

//variable declarations and assignments
alertNeedCitation = "Please enter a Citation Number or NTA Number in order to conduct a Search by Citation Number.";
alertAlphaCitation = "Please enter only letters or numbers in the Citation/NTA Number field.";
alertCitationLong="The Citation/NTA Number field may not be longer than 8 characters.";


	//Rule:  Citation Number must be entered
	//Invalid Input:  Citation Number is blank
	if(document.getElementById(ControlName + 'txtCitationNumber').value == "")
	{
		//alert(alertNeedCitation);
		document.getElementById(ControlName + 'txtCitationNumber').focus();
		document.getElementById(ControlName + 'txtCitationNumber').select();
		return alertNeedCitation;
	}

	//Rule: Citation Number may only be alpha-numeric
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	var validalpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.getElementById(ControlName + 'txtCitationNumber').value.length; i++)
	{
		temp = "" + document.getElementById(ControlName + 'txtCitationNumber').value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			//alert(alertAlphaCitation);
			document.getElementById(ControlName + 'txtCitationNumber').focus();
			document.getElementById(ControlName + 'txtCitationNumber').select();
			return alertAlphaCitation;
		}

	//Rule: Citation Number may not be longer than 8 characters
	if(document.getElementById(ControlName + 'txtCitationNumber').value != "")
	{
		if(document.getElementById(ControlName + 'txtCitationNumber').value.length > 8)
		{
			//alert(alertCitationLong);
			document.getElementById(ControlName + 'txtCitationNumber').focus();
			document.getElementById(ControlName + 'txtCitationNumber').select();
			return alertCitationLong;
		}
	}



	//ZZZ START 3-13-01 Added based SIR #308
	//Rule: if users selects to search by Citation or NTA then number must be = to 8 characters (padding w/ 0's)
	if(document.getElementById(ControlName + 'txtCitationNumber').value.length < 8)
		{

			var oldNum = document.getElementById(ControlName + 'txtCitationNumber').value;
			var firstChar = document.getElementById(ControlName + 'txtCitationNumber').value.substring(0, 1);
			iZ = 8 - document.getElementById(ControlName + 'txtCitationNumber').value.length;
			var ilength = document.getElementById(ControlName + 'txtCitationNumber').value.length;
			//alert("sara");
			//alert (validalpha.indexOf(document.frmPublicCitation.txtCitationNumber.value.substring(0, 1)));
			if (validalpha.indexOf(firstChar) != "-1")
			{
				for (p=0; p<iZ; p++)
					{
						if (p==0)
						{
							oldNum = firstChar + "0";
						}
						else
						{
							oldNum =  oldNum + "0" ;
						}
					}
				oldNum = oldNum + document.getElementById(ControlName + 'txtCitationNumber').value.substring(1,ilength);
			}
			else
			{
				for(p=0; p<iZ; p++)
				{
					oldNum = "0" + oldNum;
				}
			}
			document.getElementById(ControlName + 'txtCitationNumber').value = oldNum;
	}

	//ZZZ END 3-13-01 Added based SIR #308



		
//NOT YET ADDRESSED:
	//Citation Numbers may need to be checked for correct formatting??
	
//else return '';
return '';

}

//////////////////////////////////////////////////////////////
//			public_search.asp							    //
//////////////////////////////////////////////////////////////
function chkPublicTagForm()
{
//validation rules
//1.  Vehicle Tag Number not blank
//2.  Vehicle Tag Number 7 or fewer characters

//cross-field validation rules
//  N/A

//variable declarations and assignments
alertTag = 		"Please enter both a Vehicle Tag Number and State.";
alertTagLong =	"Vehicle Tag Numbers may not be longer than 7 characters.";

	//Rule:  Both Tag Number and Tag State must be entered to Search by Tag
	//Invalid Input: Tag Number is blank
	if(document.frmPublicTag.txtVehicleTag.value == "")
	{
		alert(alertTag);
		return false;
	}

	//Rule:  Vehicle Tag Number may not be longer than 7 characters
	if(document.frmPublicTag.txtVehicleTag.value != "")
	{
		if(document.frmPublicTag.txtVehicleTag.value.length > 7)
		{
			alert(alertTagLong);
			return false;
		}
	}

//NOT YET ADDRESSED:
	//Vehicle Tag Numbers may have special symbols if not, check letters and digits only

else return true;

}

//////////////////////////////////////////////////////////////
//			premium_party_search.asp			//
//////////////////////////////////////////////////////////////
//this is a fix for the ID search on the Premium Party search!!!**
function chkPremiumIDNumberForm()
{
//validation rules
//1. Id type and Id number must both be filled in
//2. Id number cannot be more than 20 characters
//3. ID number alphanumeric only

//variable declararions and assignments
alertIDType = "Please select a search criteria for ID Type.";
alertIDNumLong = "ID Number may not be longer than 20 characters.";
alertIDSearch = "Both ID Number and Party ID must be filled in to search by ID.";
alertIDNumAlpha = "Please enter only letters and numbers in the ID Number Field.";

//Rule: ID Number may only be alpha-numeric
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var ok = "yes";
	var temp;
	
	for (var i=0; i<document.frmPremiumID.txtIDNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumID.txtIDNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertIDNumAlpha);
			document.frmPremiumID.txtIDNumber.focus();
			document.frmPremiumID.txtIDNumber.select();
			return false;
		}

	//Rule: ID Number may not be longer than 20 characters
	if(document.frmPremiumID.txtIDNumber.value != "")
	{
		if(document.frmPremiumID.txtIDNumber.value.length > 20)
		{
			alert(alertIDNumLong);
			return false;
		}
	} 

	//Rule ID Number cannot be left blank.
	if(document.frmPremiumID.txtIDNumber.value == "")
	{
		alert(alertIDSearch);
		document.frmPremiumID.txtIDNumber.focus();
		document.frmPremiumID.txtIDNumber.select();				
		return false;
	}
	
	//Rule: ID Type cannot be left Blank
	if(document.frmPremiumID.cboIDType.options[0].selected)
	{
		alert(alertIDSearch);
		return false;
	}
	
	//Rule: if users selects to search by BARID then ID number must be = to 12 characters (padding w/ 0's)
	if(document.frmPremiumID.cboIDType.options.value == "BARID")
	{
		if (document.frmPremiumID.txtIDNumber.value.length < 12)
		{
			
			var oldIDNum = document.frmPremiumID.txtIDNumber.value;
			iL = 12 - document.frmPremiumID.txtIDNumber.value.length;
			
			for(i=0; i<iL; i++)
			{
				oldIDNum = "0" + oldIDNum;
			}
			
			document.frmPremiumID.txtIDNumber.value = oldIDNum;
		}
		if (document.frmPremiumID.txtIDNumber.value == "000000000000")
			{
				alert("Bar ID of '000000000000' is invalid.  Please enter a non-zero Bar ID.");
				document.frmPremiumID.txtIDNumber.focus();
				document.frmPremiumID.txtIDNumber.select();		
				return false;

			}
	} 

else return true;

}



function chkPremiumPartyForm()
{
//validation rules
//1.	Last Name alpha only
//2.	First Name alpha only
//3.	Middle Initial alpha only
//4.	Last Name 45 or fewer characters
//5.	First Name 20 or fewer characters
//6.	Middle Initial must be 1 character
//7.	Business or Organization Name 45 or fewer characters
//8.	D.O.B. date format only
//9.	D.O.B. numeric only
//10.	D.O.B. must be 10 characters
//11.	ID Number alpha-numeric only
//12.	ID Number 13 or fewer characters
//13.   D.O.B. field must be date formatted (MM-DD-YYYY)

//cross-field validation rules
//1.	Either Last Name or Business or Organization Name must not be blank
//2.	If either Last Name, First Name, or Middle Initial is not blank then Business or Organization name must be blank
//3.	If First Name is not blank, then Last Name must not be blank
//4.	If Middle Initial is not blank, then Last Name and First Name must not be blank
//5.	If Business or Organization Name is not blank then Last Name, First Name, and Middle Initial must be blank
//6.	If ID Type is not blank then ID Number must not be blank and vice versa


//variable declarations and assignments
alertNeither =	"Please enter a Party Last Name or Business or Organization Name to conduct a search.";
alertBoth = 	"Please enter only a Party Last Name or Business or Organization Name to conduct a search.";
alertLast = 	"Please enter a Party Last Name in order to conduct a search.";
alertComplete =	"Please enter a Complete Party Name.";
alertLastLong = "The Last Name field may not be longer than 45 characters.";
alertEntityLong = "The Business or Organization Name field may not be longer than 45 characters.";
alertFirstLong ="The First Name field may not be longer than 20 characters.";
alertMILong =	"The Middle Initial field may not be longer than 1 character.";
alertDOBLong = 	"The D.O.B. field must be equal to 10 or 4 characters.  Please enter D.O.B. as MM/DD/YYYY or YYYY.";

//Ben's alerts for alpha only validation
alertLastAlpha = "The Last Name field may not contain numeric or special characters.";
alertFirstAlpha = "The First Name field may not contain numeric or special characters.";
alertMIAlpha = "The Middle Initial field may not contain numeric or special characters.";
alertDOBNum = "Only numbers and '/' may be entered in the DOB field or just the 4 digit year.";

//More of Ben's--these are homemade variables and for testing purposes only!!!
var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, -.'";
var ok = "yes";
var temp;

//variables for numeric validation on date
var valid1 = "1234567890/-";
var ok1 = "yes";
var temp1;
	
	
	//Rule: If text in Business Entity field then cannot also choose gender, alias search, nor, D.O.B.
	if (document.frmPremiumParty.txtBusinessEntity.value != "")
	{
		if (document.frmPremiumParty.txtDOB.value != "")
		{
			alert("If you are searching by a business name, then you may not have a value in the D.O.B. field.");
			document.frmPremiumParty.txtDOB.select();
			document.frmPremiumParty.txtDOB.focus();
			return false;
		}
		
		if (document.frmPremiumParty.chkAliasSearch.checked == true)
		{
			alert("If you want to search by a Business or an Organization name you may not have the Alias Box checked.");
			return false;
		} 
		
		if (document.frmPremiumParty.rdoGender.value == true)
		{
			alert("If you are searching by a business name, then you may not have either of the Gender buttons selected.");
			return false;
		}
	}		
		
	//Rule: Either Last Name or Business or Organization Name must be entered to conduct a Search by Party
	//Invalid Input: Both Last Name and Business or Organization Name are blank
	if((document.frmPremiumParty.txtLastName.value == "") && (document.frmPremiumParty.txtBusinessEntity.value == "") && (document.frmPremiumParty.txtFirstName.value == "") && (document.frmPremiumParty.txtMiddleInitial.value == ""))
	{
		alert(alertNeither);
		return false;
	}

	//Rule: Only one of Last Name and Business or Organization Name may be populated to conduct a search
	//Invalid Input: Both Last Name and Business or Organization Name are populated
	if((document.frmPremiumParty.txtLastName.value != "") && (document.frmPremiumParty.txtBusinessEntity.value != ""))
	{
		alert(alertBoth);
		return false;
	}

	//Rule: If user input First Name, Last Name must also be entered
	//Invalid Input: First Name populated, but not Last Name
	if(document.frmPremiumParty.txtFirstName.value != "")
	{
		if(document.frmPremiumParty.txtLastName.value == "")
		{
			alert(alertLast);
			return false;
		}
		
		
	} 

	//Rule: If a user inputs a Middle Initial, Last Name and First Name must also be entered
	//Invalid Input:  Middle Initial populated without either Last Name or First Name
	if(document.frmPremiumParty.txtMiddleInitial.value != "")
	{
		if((document.frmPremiumParty.txtFirstName.value == "") || (document.frmPremiumParty.txtLastName.value == ""))
		{
			alert(alertComplete);
			return false;
		}
	}

	//Rule: Last Name may not be longer than 45 characters
	if(document.frmPremiumParty.txtLastName.value != "")
	{
		if(document.frmPremiumParty.txtLastName.value.length > 45)
		{
			alert(alertLastLong);
			return false;
		}
	}

	//Rule: Business or Organization Name may not be longer than 45 characters
	if(document.frmPremiumParty.txtBusinessEntity.value != "")
	{
		if(document.frmPremiumParty.txtBusinessEntity.value.length > 45)
		{
			alert(alertEntityLong);
			return false;
		}
	}

	//Rule: First Name may not be longer than 20 characters
	if(document.frmPremiumParty.txtFirstName.value != "")
	{
		if(document.frmPremiumParty.txtFirstName.value.length > 20)
		{
			alert(alertFirstLong);
			return false;
		}
	}
	
	//Rule: Middle Initial may not be longer than 15 character
	if(document.frmPremiumParty.txtMiddleInitial.value != "")
	{
		if(document.frmPremiumParty.txtMiddleInitial.value.length > 15)
		{
			alert(alertMILong);
			return false;
		}
	}

	//Rule: Date must be numeric
	for (var i=0; i<document.frmPremiumParty.txtDOB.value.length; i++) 
	{
		temp1 = "" + document.frmPremiumParty.txtDOB.value.substring(i, i+1);

		if (valid1.indexOf(temp1) == "-1") ok1 = "no";
	}


	if (ok1 == "no")
		{
			alert(alertDOBNum);
			document.frmPremiumParty.txtDOB.focus();
			document.frmPremiumParty.txtDOB.select();
   			return false;
   		}
	
	//Rule: DOB may not be longer than 10 characters
	if(document.frmPremiumParty.txtDOB.value != "")
	{
		if(document.frmPremiumParty.txtDOB.value.length == 4)
		{
			return true;
		}
		
		if(document.frmPremiumParty.txtDOB.value.length != 10)
		{
			alert(alertDOBLong);
			return false;
		}
	}
   			
	 //Rule: DOB fields fields must be date formatted (MM-DD-YYYY)
		if(document.frmPremiumParty.txtDOB.value != "")
		{

				var inputStr = document.frmPremiumParty.txtDOB.value;
				
				while (inputStr.indexOf("-") != -1)
				{
					
					inputStr = inputStr.replace("-","/");
				}
				
				var delim1 = inputStr.indexOf("/");
				var delim2 = inputStr.lastIndexOf("/");
				
				if (delim1 != -1 && delim1 == delim2)
				{
					alert("The DOB entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
				
				if (delim1 != -1)
				{
					var mm = parseInt(inputStr.substring(0,delim1),10);
					var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
					var yyyy = parseInt(inputStr.substring(delim2 +1, inputStr.length),10);
				}
				
				if (isNaN(mm) || isNaN(dd) || isNaN(yyyy))
				{
					alert("The DOB entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
				
				if (mm < 01 || mm > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
				
				if (mm == 01 || mm == 03 || mm == 05 || mm == 07 || mm == 08 || mm == 10 || mm == 12)
				{
					if (dd < 01 || dd > 31)
					{
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumParty.txtDOB.focus();
						document.frmPremiumParty.txtDOB.select();
						return false;
					}
				}
				
				if (mm == 04 || mm == 06 || mm == 09 || mm == 11)
				{
					if (dd < 01 || dd > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumParty.txtDOB.focus();
						document.frmPremiumParty.txtDOB.select();
						return false;
					}
				}
				
				if (yyyy < 1800)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
				
				if (yyyy > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
				
				now = new Date();
				
				if (yyyy > now.getFullYear())
				{
					alert("The Date you provided is invalid, please enter a valid D.O.B.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
				}
			
				if (yyyy >= now.getFullYear())
				{
					mm = mm - 1;
					
					if (mm > now.getMonth())
					{
					alert("The Date you provided is invalid, please enter a valid D.O.B.");
					document.frmPremiumParty.txtDOB.focus();
					document.frmPremiumParty.txtDOB.select();
					return false;
					}
					
					mm = mm + 1;
				}
				
				if ((yyyy >= now.getFullYear()))
				{
					mm = mm - 1;
					
					if (mm >= now.getMonth())
					{
						if (dd > now.getDate())
						{
						alert("The Date you provided is invalid, please enter a valid D.O.B.");
						document.frmPremiumParty.txtDOB.focus();
						document.frmPremiumParty.txtDOB.select();
						return false;
						}
					}
					
					mm = mm + 1;
				}
				
				if (mm == 02)
				{
					if (dd < 01 || dd > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumParty.txtDOB.focus();
						document.frmPremiumParty.txtDOB.select();
						return false;
					}
					
					if (dd == 29)
					{
						if(yyyy % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumParty.txtDOB.focus();
							document.frmPremiumParty.txtDOB.select();
							return false;
						}
					}
				
				}
				
				if (dd < 10)
				{
					dd = "0" + dd;
				}
				if (mm < 10)
				{
					mm = "0" + mm;
				}
				
				document.frmPremiumParty.txtDOB.value = mm + "/" + dd + "/" + yyyy;
				return true;
			}
	
	//Rule: Advanced Search and Alias Search checkboxes cannot both be checked at the sametime.
	if ((document.frmPremiumParty.chkAdvSearch.checked == true) && (document.frmPremiumParty.chkAliasSearch.checked == true))
	{
		alert("You cannot conduct an Advanced Search and an Alias Search simultaneously.  Please uncheck one of the boxes.");
		return false;
	}
	
	//Rule: All entries in Last Name, First Name, and Middle Initial fields must be letters only
	//made by Benjamin Camp on 9-25-00 at 2:30 PM
	//Last Name
	for (var i=0; i<document.frmPremiumParty.txtLastName.value.length; i++) 
	{
		temp = "" + document.frmPremiumParty.txtLastName.value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		alert(alertLastAlpha);
		document.frmPremiumParty.txtLastName.focus();
		document.frmPremiumParty.txtLastName.select();
   		return false;
   		}
	
	//First Name
	for (var i=0; i<document.frmPremiumParty.txtFirstName.value.length; i++) 
	{
		temp = "" + document.frmPremiumParty.txtFirstName.value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		alert(alertFirstAlpha);
		document.frmPremiumParty.txtFirstName.focus();
		document.frmPremiumParty.txtFirstName.select();
   		return false;
   		}
   		
   	//Middle Initial
   	for (var i=0; i<document.frmPremiumParty.txtMiddleInitial.value.length; i++) 
	{
		temp = "" + document.frmPremiumParty.txtMiddleInitial.value.substring(i, i+1);

		if (valid.indexOf(temp) == "-1") ok = "no";
	}


	if (ok == "no")
		{
		alert(alertMIAlpha);
		document.frmPremiumParty.txtMiddleInitial.focus();
		document.frmPremiumParty.txtMiddleInitial.select();
   		return false;
   		}


//NOT YET ADDRESSED:
	//Rule: Alias Search = query the Alias-Entity view
	//Date formatting 

else return true;

}


//////////////////////////////////////////////////////////////
//		premium_case_identifier_search.asp					//
//////////////////////////////////////////////////////////////
function chkPremiumCaseIdentifierForm()
{
//validation rules
//1.	****Court Type not set to option[0] <--no longer valid!!!!***
//2.	Case Number alpha-numeric only
//3.	State Reporting Number alpha-numeric only
//4.	Case Number 14 characters or less
//5.	State Reporting Number 20 characters or less

//cross-field validation rules
//6.  Either Case Number or State Reporting Number must not be blank.
//7.  Both Case Number and State Reporting Number cannot both be entered.

//variable declarations and assignments
alertCourt =		"Please select a Court Type.";
alertCaseLong =		"Case Numbers may not be longer than 14 characters.";
alertUniformLong =	"State Reporting Numbers may not be longer than 20 characters.";
alertNeither =		"Please enter a Case Number or State Reporting Number.";
alertBoth =			"Please enter only a Case Number or State Reporting Number.";
alertAlphaCase =	"Please enter only letters and numbers in the Case Number field.";
alertAlphaState =	"Please enter only letters and numbers in the State Reporting Number field.";
	
	//Rule 2: Case Number alpha-numeric only
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var ok = "yes";
	var temp;
	
	for (var i=0; i<document.frmPremiumCaseIdentifier.txtCaseNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumCaseIdentifier.txtCaseNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertAlphaCase);
			document.frmPremiumCaseIdentifier.txtCaseNumber.focus();
			document.frmPremiumCaseIdentifier.txtCaseNumber.select();
			return false;
		}
		
	
	//Rule 3: State Reporting Number alpha-numeric only
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumCaseIdentifier.txtUniformNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumCaseIdentifier.txtUniformNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertAlphaState);
			document.frmPremiumCaseIdentifier.txtUniformNumber.focus();
			document.frmPremiumCaseIdentifier.txtUniformNumber.select();
			return false;
		}
		
	
	//Rule 4: Case Numbers may not be longer than 14 characters
	if(document.frmPremiumCaseIdentifier.txtCaseNumber.value != "")
	{
		if(document.frmPremiumCaseIdentifier.txtCaseNumber.value.length > 14)
		{
			alert(alertCaseLong);
			return false;
		}
	}
	
	//Rule: If searching by Case Number and companion case is checked need to take off last character if it is alpha
	if (document.frmPremiumCaseIdentifier.txtCaseNumber.value != "")
	{
		if (document.frmPremiumCaseIdentifier.chkCompanionCase.checked == true)
		{	
				strLastChar = document.frmPremiumCaseIdentifier.txtCaseNumber.value.substr(document.frmPremiumCaseIdentifier.txtCaseNumber.value.length-1,1);
				
				if(document.frmPremiumCaseIdentifier.txtCaseNumber.value.length < 12)
					{
						alert("Case Number needs to be at least 12 characters \nlong in order to do a search on companion cases.");
						document.frmPremiumCaseIdentifier.txtCaseNumber.focus();
						document.frmPremiumCaseIdentifier.txtCaseNumber.select();
						return false;
					}
				
								
			 	if ((strLastChar >= "A" && strLastChar <= "Z") || (strLastChar >= "a" && strLastChar <= "z"))				
				{					
					alert("In order to complete this query the last character in the Case Number will be removed.");
					vCaseNum = document.frmPremiumCaseIdentifier.txtCaseNumber.value;
					iL = document.frmPremiumCaseIdentifier.txtCaseNumber.value.length;
					vNewCaseNum = vCaseNum.substr(0,iL-1);
					document.frmPremiumCaseIdentifier.txtCaseNumber.value = vNewCaseNum;					
				}
		}
	}
	
	
	//Rule 5: Uniform Number cannot be longer than 20 characters
	if(document.frmPremiumCaseIdentifier.txtUniformNumber.value != "")
	{
		if(document.frmPremiumCaseIdentifier.txtUniformNumber.value.length > 20)
		{
			alert(alertUniformLong);
			return false;
		}
	}
	
	//Rule 6: Either Case Number or Uniform Number must be entered
	//Invalid Input:  Neither Case Number or Uniform Number is entered
	if((document.frmPremiumCaseIdentifier.txtCaseNumber.value == "") && (document.frmPremiumCaseIdentifier.txtUniformNumber.value == ""))
	{
		alert(alertNeither);
		return false;
	}
	
	//Rule 7: Only one of Case Number or Uniform Number can be entered
	//Invalid Input: Both Case Number and Uniform Number are not blank
	if((document.frmPremiumCaseIdentifier.txtCaseNumber.value != "") && (document.frmPremiumCaseIdentifier.txtUniformNumber.value != ""))
	{
		alert(alertBoth);
		return false;
	}		
	
	
else return true;
}

//////////////////////////////////////////////////////////////
//			premium_citation_search.asp						//
//////////////////////////////////////////////////////////////
function chkPremiumCitationForm()
{
//validation rules
//1.	Citation Number not blank	
//2.    Citation Number alpha-numeric only.
//3.	Citation Number 8 characters or less.
//4.	3-13-01 SIR #308 If Citation/NTA Number less than 8 characters, pad with leading zero(s).

//cross-field validation rules
//  N/A


//variable declarations and assignments
alertCitation =		"Please enter a Citation Number or NTA Number.";
alertAlphaCitation = "Please enter only letters and numbers in the Citation/NTA Number field.";
alertCitationLong =	"The Citation/NTA Number field may not be longer than 8 characters.";

	//Rule 1: Citation Number must be entered
	//Invalid Input:  Citation Number field blank
	if (document.frmPremiumCitation.txtCitationNumber.value == "")
	{
		alert(alertCitation);
		return false;
	}
	
	//Rule 2: Citation number only alpha-numeric
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var ok = "yes";
	var temp;
	
	for (var i=0; i<document.frmPremiumCitation.txtCitationNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumCitation.txtCitationNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertAlphaCitation);
			document.frmPremiumCitation.txtCitationNumber.focus();
			document.frmPremiumCitation.txtCitationNumber.select();
			return false;
		}
	
	//Rule 3: Citation Numbers may not be longer than 8 characters
	if(document.frmPremiumCitation.txtCitationNumber.value != "")
	{
		if(document.frmPremiumCitation.txtCitationNumber.value.length > 8)
		{
			alert(alertCitationLong);
			return false;
		}
	}


	//ZZZ START 3-13-01 Added based SIR #308
	//Rule: if users selects to search by Citation or NTA then number must be = to 8 characters (padding w/ 0's)
	if(document.frmPremiumCitation.txtCitationNumber.value.length < 8)
		{
			var oldNum = document.frmPremiumCitation.txtCitationNumber.value;
			iZ = 8 - document.frmPremiumCitation.txtCitationNumber.value.length;
			
			for(p=0; p<iZ; p++)
			{
				oldNum = "0" + oldNum;
			}
			document.frmPremiumCitation.txtCitationNumber.value = oldNum;
		}

	//ZZZ END 3-13-01 Added based SIR #308


else return true;
}


//////////////////////////////////////////////////////////////
//			premium_tag_search.asp				//
//////////////////////////////////////////////////////////////
function chkPremiumTagForm()
{
//validation rules
//1.	Vehicle Tag Number not blank
//2.	Vehicle Tag Number alpha-numeric only????  (How to deal with symbols?)
//3.	Vehicle Tag Number 7 characters or less

//cross-field validation rules
//  N/A

//variable declarations and assignments
alertTagLong =	"Vehicle Tag Numbers may not be longer than 7 characters.";

	//Rule: Vehicle Tag Numbers cannot be longer than 7 characters
	if(document.frmPremiumTag.txtVehicleTag.value != "")
	{
		if(document.frmPremiumTag.txtVehicleTag.value.length > 7)
		{
			alert(alertTagLong);
			return false;
		}
	}

else return true;
}


//////////////////////////////////////////////////////////////
//			premium_event_search.asp			//
//////////////////////////////////////////////////////////////
function chkPremiumEventForm()
{
//validation rules
//1.	ID Type not option [0].
//2.	ID Number not blank.
//3.	ID Number 20 or fewer characters.
//4.	ID Number alpha-numeric only.
//5.	Event Type not option [0]. -***Client wanted to do away with this***
//6.	Event Date Range fields numeric only.
//7.	Event Date Range fields not blank.
//8.	Event Date Range fields must be 10 characters.
//9.   Event Date Range fields must be date formatted (MM/DD/YYYY)

//cross-field validation rules
//  N/A

//variable declarations and assignments
alertIDType = "Please select a value from the ID Type drop down list.";
alertIDBlank = "Please enter a value in the the ID Number field.";
alertIDLong =	"ID Numbers may not be longer than 20 characters.";
alertIDAlpha = "Please enter only letters and numbers in the ID Number field.";
//alertEventType = "Please select a value from the Event Type drop down list.";
alertEventNum = "Please enter only numbers in the Event Date Range fields.";
alertEventBlank = "Event Date Range fields not blank.";
alertEventLong = "Event Date Range fields must be equal to 10 characters.";
alertEventDate = "Event Date Range fields must be date formatted (MM/DD/YYYY).";
alertEventDateDup = "You may not enter duplicate dates in the date range.";
alertInvalidDate = "Event Date Range fields must be date formatted (MM/DD/YYYY).";

	//Rule 1: ID Type not option [0].
	if(document.frmPremiumEvent.cboIDType.options[0].selected)
	{
		alert(alertIDType);
		return false;
	}	
	
	//Rule 2: ID Number not blank
	if (document.frmPremiumEvent.txtIDNumber.value == "")
	{
		alert(alertIDBlank);
		return false;
	}
	
	//Rule 3: ID Number alpha-numeric only
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var ok = "yes";
	var temp;
	
	for (var i=0; i<document.frmPremiumEvent.txtIDNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumEvent.txtIDNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertIDAlpha);
			document.frmPremiumEvent.txtIDNumber.focus();
			document.frmPremiumEvent.txtIDNumber.select();
			return false;
		}
		
	
	//Rule: if users selects to search by BARID then ID number must be = to 12 characters (padding w/ 0's)
	if(document.frmPremiumEvent.cboIDType.options.value == "BARID")
	{
		if(document.frmPremiumEvent.txtIDNumber.value != "")
		{
			var valid="1234567890";
			var ok = "yes";
			var temp;
	
			for (var i=0; i<document.frmPremiumEvent.txtIDNumber.value.length; i++)
			{
				temp = "" + document.frmPremiumEvent.txtIDNumber.value.substring(i, i+1);
				if (valid.indexOf(temp) == "-1") 
				{
					ok = "no";
				}
			}
			
			if (ok == "no")
			{
				alert("When searching by BARID the ID Number may not contain any alpha or special characters.");
				document.frmPremiumEvent.txtIDNumber.focus();
				document.frmPremiumEvent.txtIDNumber.select();
				return false;
			}
		}		
		
		if(document.frmPremiumEvent.txtIDNumber.value.length < 12)
		{
			var oldIDNum = document.frmPremiumEvent.txtIDNumber.value;
			iL = 12 - document.frmPremiumEvent.txtIDNumber.value.length;
			
			for(i=0; i<iL; i++)
			{
				oldIDNum = "0" + oldIDNum;
			}
			document.frmPremiumEvent.txtIDNumber.value = oldIDNum;
		}
				
	} 
	
	//Rule 4: ID Numbers cannot be longer than 20 characters
	if(document.frmPremiumEvent.txtIDNumber.value != "")
	{
		if(document.frmPremiumEvent.txtIDNumber.value.length > 20)
		{
			alert(alertIDLong);
			return false;
		}
	}

	//Rule 5: Event Type not option 0 - ***Client wanted to do away with this***
	//if(document.frmPremiumEvent.cboEventType.options[0].selected)
	//{
	//	alert(alertEventType);
	//	return false;
	//}
	
	//6. Event Date Range fields numeric only (includes date format characters).
	//starting Date Range field
	var valid="1234567890/-"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumEvent.txtEventDateLow.value.length; i++)
	{
		temp = "" + document.frmPremiumEvent.txtEventDateLow.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertEventNum);
			document.frmPremiumEvent.txtEventDateLow.focus();
			document.frmPremiumEvent.txtEventDateLow.select();
			return false;
		}
	
	//Ending Date Range field
	var valid1="1234567890/-"
	var ok1 = "yes"
	var temp1
	
	for (var i=0; i<document.frmPremiumEvent.txtEventDateHigh.value.length; i++)
	{
		temp1 = "" + document.frmPremiumEvent.txtEventDateHigh.value.substring(i, i+1);
		if (valid1.indexOf(temp1) == "-1") 
		{
			ok1 = "no";
		}
	}
		if (ok1 == "no")
		{
			alert(alertEventNum);
			document.frmPremiumEvent.txtEventDateHigh.focus();
			document.frmPremiumEvent.txtEventDateHigh.select();
			return false;
		}

	//7.	Event Date Range fields not blank.
			if ((document.frmPremiumEvent.txtEventDateLow.value == "") || (document.frmPremiumEvent.txtEventDateHigh.value == ""))
			{
				alert(alertEventBlank);
				return false;
			}

	//8.	Event Date Range fields must be 10 characters.
			//starting date range
			if(document.frmPremiumEvent.txtEventDateLow.value != "")
			{
				if(document.frmPremiumEvent.txtEventDateLow.value.length != 10)
				{
					alert(alertEventLong);
					return false;
				}
			}
			//ending date range field
			if(document.frmPremiumEvent.txtEventDateHigh.value != "")
			{
				if(document.frmPremiumEvent.txtEventDateHigh.value.length != 10)
				{
					alert(alertEventLong);
					return false;
				}
			}

			//Rule: Date range cannot have duplicate dates
			//if(document.frmPremiumEvent.txtEventDateLow.value == document.frmPremiumEvent.txtEventDateHigh.value)
			//{
			//	alert(alertEventDateDup);
			//	return false;
			//}

	//9.   Event Date Range fields must be date formatted (MM-DD-YYYY)
		if((document.frmPremiumEvent.txtEventDateLow.value != "") || (document.frmPremiumEvent.txtEventDateHigh.value != ""))
		{

				var inputStr = document.frmPremiumEvent.txtEventDateLow.value;
				var inputStrHigh = document.frmPremiumEvent.txtEventDateHigh.value;
				
				while (inputStr.indexOf("-") != -1)
				{
					
					inputStr = inputStr.replace("-","/");
				}
				
				while (inputStrHigh.indexOf("-") != -1)
				{
					inputStrHigh = inputStrHigh.replace("-","/");
				}
				
				var delim1 = inputStr.indexOf("/");
				var delim2 = inputStr.lastIndexOf("/");
				
				var delim1High = inputStrHigh.indexOf("/");
				var delim2High = inputStrHigh.lastIndexOf("/");
				
				if (delim1 != -1 && delim1 == delim2)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (delim1High != -1 && delim1High == delim2High)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumEvent.txtEventDateHigh.focus();
					document.frmPremiumEvent.txtEventDateHigh.select();
					return false;
				}
				
				if (delim1 != -1)
				{
					var mm = parseInt(inputStr.substring(0,delim1),10);
					var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
					var yyyy = parseInt(inputStr.substring(delim2 +1, inputStr.length),10);
				}
				
				if (delim1High != -1)
				{
					var mmHigh = parseInt(inputStrHigh.substring(0,delim1High),10);
					var ddHigh = parseInt(inputStrHigh.substring(delim1High + 1,delim2High),10);
					var yyyyHigh = parseInt(inputStrHigh.substring(delim2High +1, inputStrHigh.length),10);
				}
				
				if (isNaN(mm) || isNaN(dd) || isNaN(yyyy))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (isNaN(mmHigh) || isNaN(ddHigh) || isNaN(yyyyHigh))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumEvent.txtEventDateHigh.focus();
					document.frmPremiumEvent.txtEventDateHigh.select();
					return false;
				}
				
				if (mm < 01 || mm > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (mmHigh < 01 || mmHigh > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumEvent.txtEventDateHigh.focus();
					document.frmPremiumEvent.txtEventDateHigh.select();
					return false;
				}
				
				if (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 || mm == 12)
				{
					if (dd < 1 || dd > 31)
					{
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateLow.focus();
						document.frmPremiumEvent.txtEventDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 1 || mmHigh == 3 || mmHigh == 5 || mmHigh == 7 || mmHigh == 8 || mmHigh == 10 || mmHigh == 12)
				{
					if (ddHigh < 1 || ddHigh > 31)
					{	
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateHigh.focus();
						document.frmPremiumEvent.txtEventDateHigh.select();
						return false;
					}
				}
				
				if (mm == 4 || mm == 6 || mm == 9 || mm == 11)
				{
					if (dd < 1 || dd > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateLow.focus();
						document.frmPremiumEvent.txtEventDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 4 || mmHigh == 6 || mmHigh == 9 || mmHigh == 11)
				{
					if (ddHigh < 1 || ddHigh > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateHigh.focus();
						document.frmPremiumEvent.txtEventDateHigh.select();
						return false;
					}
				}
				
				if (yyyy < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (yyyyHigh < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumEvent.txtEventDateHigh.focus();
					document.frmPremiumEvent.txtEventDateHigh.select();
					return false;
				}
				
				if (yyyy > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (yyyyHigh > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumEvent.txtEventDateHigh.focus();
					document.frmPremiumEvent.txtEventDateHigh.select();
					return false;
				}
				
				if (Date.parse(document.frmPremiumEvent.txtEventDateLow.value) > Date.parse(document.frmPremiumEvent.txtEventDateHigh.value))
				{
					alert("The date in the Low Date Range field may not be higher than the date in the High Date Range field."); 
					document.frmPremiumEvent.txtEventDateLow.focus();
					document.frmPremiumEvent.txtEventDateLow.select();
					return false;
				}
				
				if (mm == 2)
				{
					if (dd < 1 || dd > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateLow.focus();
						document.frmPremiumEvent.txtEventDateLow.select();
						return false;
					}
					
					if (dd == 29)
					{
						if(yyyy % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumEvent.txtEventDateLow.focus();
							document.frmPremiumEvent.txtEventDateLow.select();
							return false;
						}
					}
				
				}
				
				if (mmHigh == 2)
				{
					if (ddHigh < 1 || ddHigh > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumEvent.txtEventDateHigh.focus();
						document.frmPremiumEvent.txtEventDateHigh.select();
						return false;
					}
					
					if (ddHigh == 29)
					{
						if(yyyyHigh % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumEvent.txtEventDateHigh.focus();
							document.frmPremiumEvent.txtEventDateHigh.select();
							return false;
						}
					}
				
				}
				
				if (dd < 10)
				{
					dd = "0" + dd;
				}
				
				if (ddHigh < 10)
				{
					ddHigh = "0" + ddHigh;
				}
				
				if (mm < 10)
				{
					mm = "0" + mm;
				}
				
				if (mmHigh < 10)
				{
					mmHigh = "0" + mmHigh;
				}
				
				document.frmPremiumEvent.txtEventDateLow.value = mm + "/" + dd + "/" + yyyy;
				document.frmPremiumEvent.txtEventDateHigh.value = mmHigh + "/" + ddHigh + "/" + yyyyHigh;
				return true;
			}

else return true;
}


//////////////////////////////////////////////////////////////
//			premium_filing_search.asp						//
//////////////////////////////////////////////////////////////

function chkPremiumFilingForm()
{
//validation rules
//1.	Court Type not set to option [0]
//2.	Case Location not set to option [0]
//3.	Case Type not option [0]
//4.	Date Range Fields numeric only
//5.	Date Range fields must be 10 characters
//6.    Date Range fields must be date formatted (MM-DD-YYYY)
//7.    Date Range fields not blank
//8.    Date Type not option [0]

//cross-field validation rules
//  N/A

//variable declarations and assignments
//alertCourtType = "Please select a value from the court type field.";
//alertCourtLoc = "Please select a value from the court location field.";
alertCaseType = "Please select a value from the case type field.";
alertDateType = "Please select a value from the date type field.";
alertFilingLong =	"Date Range fields must be equal to 10 characters.";
alertFilingNum = "Please enter only numbers in the the Date Range fields.";
alertFilingBlank = "Please enter a value in the Date Range fields.";
alertFilingDateDup = "You may not enter duplicate dates in the date range.";

	//Rule 1 and 2 are commented out.  Due to change to relax search criteria. SKK 3/27/2001
	//Rule 1: Court Type not set to option [0]
	//if(document.frmPremiumFiling.cboCourtType.options[0].selected)
	//{
	//	alert(alertCourtType);
	//	return false;
	//}	
	
	//Rule 2.	Case Location not set to option [0]
	//if(document.frmPremiumFiling.cboCourtLocation.options[0].selected)
	//{
	//	alert(alertCourtLoc);
	//	return false;
	//}	
	
	//Rule 3.	Case Type not option [0]
	if(document.frmPremiumFiling.cboCaseType.options[0].selected)
	{
		alert(alertCaseType);
		return false;
	}	
	
	//Rule 8.    Date Type not option [0]
	if(document.frmPremiumFiling.cboDateType.options[0].selected)
	{
		alert(alertDateType);
		return false;
	}	
	
	//Rule 4. Filing Date Range fields numeric only (includes date format characters).
	//starting Date Range field
	var valid="1234567890/-"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumFiling.txtFilingDateLow.value.length; i++)
	{
		temp = "" + document.frmPremiumFiling.txtFilingDateLow.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertFilingNum);
			document.frmPremiumFiling.txtFilingDateLow.focus();
			document.frmPremiumFiling.txtFilingDateLow.select();
			return false;
		}
	
	//Ending Date Range field
	var valid1="1234567890/-"
	var ok1 = "yes"
	var temp1
	
	for (var i=0; i<document.frmPremiumFiling.txtFilingDateHigh.value.length; i++)
	{
		temp1 = "" + document.frmPremiumFiling.txtFilingDateHigh.value.substring(i, i+1);
		if (valid1.indexOf(temp1) == "-1") 
		{
			ok1 = "no";
		}
	}
		if (ok1 == "no")
		{
			alert(alertFilingNum);
			document.frmPremiumFiling.txtFilingDateHigh.focus();
			document.frmPremiumFiling.txtFilingDateHigh.select();
			return false;
		}

	//Rule 5.	Date Range fields must be 10 characters.
			//starting date range
			if(document.frmPremiumFiling.txtFilingDateLow.value != "")
			{
				if(document.frmPremiumFiling.txtFilingDateLow.value.length != 10)
				{
					alert(alertFilingLong);
					return false;
				}
			}
			//ending date range field
			if(document.frmPremiumFiling.txtFilingDateHigh.value != "")
			{
				if(document.frmPremiumFiling.txtFilingDateHigh.value.length != 10)
				{
					alert(alertFilingLong);
					return false;
				}
			}
	
	//Rule 6.    Date Range fields must be date formatted (MM-DD-YYYY)
	

	//Rule 7.	Date Range fields not blank.
			if ((document.frmPremiumFiling.txtFilingDateLow.value == "") || (document.frmPremiumFiling.txtFilingDateHigh.value == ""))
			{
				alert(alertFilingBlank);
				return false;
			}	
	
	//Rule: Date range cannot have duplicate dates
			//if(document.frmPremiumFiling.txtFilingDateLow.value == document.frmPremiumFiling.txtFilingDateHigh.value)
			//{
			//	alert(alertFilingDateDup);
			//	return false;
			//}
			
	//Rule:	Filing Date Range fields must be date formatted (MM-DD-YYYY)
		if((document.frmPremiumFiling.txtFilingDateLow.value != "") || (document.frmPremiumFiling.txtFilingDateHigh.value != ""))
		{

				var inputStr = document.frmPremiumFiling.txtFilingDateLow.value;
				var inputStrHigh = document.frmPremiumFiling.txtFilingDateHigh.value;
				
				while (inputStr.indexOf("-") != -1)
				{
					
					inputStr = inputStr.replace("-","/");
				}
				
				while (inputStrHigh.indexOf("-") != -1)
				{
					inputStrHigh = inputStrHigh.replace("-","/");
				}
				
				var delim1 = inputStr.indexOf("/");
				var delim2 = inputStr.lastIndexOf("/");
				
				var delim1High = inputStrHigh.indexOf("/");
				var delim2High = inputStrHigh.lastIndexOf("/");
				
				if (delim1 != -1 && delim1 == delim2)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				}
				
				if (delim1High != -1 && delim1High == delim2High)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
				
				if (delim1 != -1)
				{
					var mm = parseInt(inputStr.substring(0,delim1),10);
					var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
					var yyyy = parseInt(inputStr.substring(delim2 +1, inputStr.length),10);
				}
				
				if (delim1High != -1)
				{
					var mmHigh = parseInt(inputStrHigh.substring(0,delim1High),10);
					var ddHigh = parseInt(inputStrHigh.substring(delim1High + 1,delim2High),10);
					var yyyyHigh = parseInt(inputStrHigh.substring(delim2High +1, inputStrHigh.length),10);
				}
				
				if (isNaN(mm) || isNaN(dd) || isNaN(yyyy))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				}
				
				if (isNaN(mmHigh) || isNaN(ddHigh) || isNaN(yyyyHigh))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
				
				if (mm < 01 || mm > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				}
				
				if (mmHigh < 01 || mmHigh > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
				
				if (mm == 01 || mm == 03 || mm == 05 || mm == 07 || mm == 08 || mm == 10 || mm == 12)
				{
					if (dd < 01 || dd > 31)
					{
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateLow.focus();
						document.frmPremiumFiling.txtFilingDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 01 || mmHigh == 03 || mmHigh == 05 || mmHigh == 07 || mmHigh == 08 || mmHigh == 10 || mmHigh == 12)
				{
					if (ddHigh < 01 || ddHigh > 31)
					{	
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateHigh.focus();
						document.frmPremiumFiling.txtFilingDateHigh.select();
						return false;
					}
				}
				
				if (mm == 04 || mm == 06 || mm == 09 || mm == 11)
				{
					if (dd < 01 || dd > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateLow.focus();
						document.frmPremiumFiling.txtFilingDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 04 || mmHigh == 06 || mmHigh == 09 || mmHigh == 11)
				{
					if (ddHigh < 01 || ddHigh > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateHigh.focus();
						document.frmPremiumFiling.txtFilingDateHigh.select();
						return false;
					}
				}
				
				if (yyyy < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				}
				
				if (yyyyHigh < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
				
				if (yyyy > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				}
				
				if (yyyyHigh > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
				
				now = new Date();
				
				if (yyyyHigh > now.getFullYear())
				{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
				}
			
				if (yyyyHigh >= now.getFullYear())
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh > now.getMonth())
					{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumFiling.txtFilingDateHigh.focus();
					document.frmPremiumFiling.txtFilingDateHigh.select();
					return false;
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if ((yyyyHigh >= now.getFullYear()))
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh >= now.getMonth())
					{
						if (ddHigh > now.getDate())
						{
						alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
						document.frmPremiumFiling.txtFilingDateHigh.focus();
						document.frmPremiumFiling.txtFilingDateHigh.select();
						return false;
						}
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if (Date.parse(document.frmPremiumFiling.txtFilingDateLow.value) > Date.parse(document.frmPremiumFiling.txtFilingDateHigh.value))
				{
					alert("The date in the Low Date Range field may not be higher than the date in the High Date Range field."); 
					document.frmPremiumFiling.txtFilingDateLow.focus();
					document.frmPremiumFiling.txtFilingDateLow.select();
					return false;
				} 
				
				if (mm == 02)
				{
					if (dd < 01 || dd > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateLow.focus();
						document.frmPremiumFiling.txtFilingDateLow.select();
						return false;
					}
					
					if (dd == 29)
					{
						if(yyyy % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumFiling.txtFilingDateLow.focus();
							document.frmPremiumFiling.txtFilingDateLow.select();
							return false;
						}
					}
				
				}
				
				if (mmHigh == 02)
				{
					if (ddHigh < 01 || ddHigh > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumFiling.txtFilingDateHigh.focus();
						document.frmPremiumFiling.txtFilingDateHigh.select();
						return false;
					}
					
					if (ddHigh == 29)
					{
						if(yyyyHigh % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumFiling.txtFilingDateHigh.focus();
							document.frmPremiumFiling.txtFilingDateHigh.select();
							return false;
						}
					}
				
				}
				
				if (dd < 10)
				{
					dd = "0" + dd;
				}
				
				if (ddHigh < 10)
				{
					ddHigh = "0" + ddHigh;
				}
				
				if (mm < 10)
				{
					mm = "0" + mm;
				}
				
				if (mmHigh < 10)
				{
					mmHigh = "0" + mmHigh;
				}
				
				document.frmPremiumFiling.txtFilingDateLow.value = mm + "/" + dd + "/" + yyyy;
				document.frmPremiumFiling.txtFilingDateHigh.value = mmHigh + "/" + ddHigh + "/" + yyyyHigh;
				return true;
			}

	
else return true;
}


//////////////////////////////////////////////////////////////
//			premium_diposition_search.asp					//
//////////////////////////////////////////////////////////////
function chkPremiumDispositionForm()
{
//validation rules
//1.	ID Number alpha-numeric only
//2.	ID Number 20 characters or less
//3.	Disposition not option [0]
//4.	Disposition Date Range Fields numeric only
//5.	Disposition Date Range fields must be 10 characters
//6.	Disposition Date Range fields not blank
//7.    Disposition Date Range fields must be date formatted (MM-DD-YYYY)

//cross-field validation rules
//6.  If ID Type not option [0], then ID Number must not be blank and vice versa.

//variable declarations and assignments
alertIDLong =		"ID Numbers may not be longer than 20 characters.";
alertDisposition =	"Please select a Disposition.";
alertIDType =		"To search by ID Number, please select an ID Type.";
alertLowDate =		"Please enter a low Disposition Date Range.";
alertHighDate =		"Please enter a high Disposition Date Range.";
alertLowDateLong =	"Date Range fields may not be longer or shorter than 10 characters.";
alertHighDateLong =	"Date Range fields may not be longer or shorter than 10 characters.";
alertDispositionNum = "Please enter only numbers in the the Date Range fields.";
alertDispositionDateDup = "You may not enter duplicate dates in the Date Range fields.";
alertAdjudicationLowDate =	"Please enter a low Adjudication Date Range.";
alertAdjudicationHighDate =	"Please enter a high Adjudication Date Range.";

	//Rule 3: Disposition must be selected
	if(document.frmPremiumDisposition.cboDisposition.options[0].selected)
	{
		alert(alertDisposition);
		return false;
	}
	
	//Rule 6: Disposition Date Range fields must not be blank
	//Invalid Input: Low Disposition Date Range field is blank
	if(document.frmPremiumDisposition.txtDispositionDateLow.value == "")
	{
		alert(alertLowDate);
		return false;
	}
	
	//Rule 6: Disposition Date Range fields must not be blank
	//Invalid Input: High Disposition Date Range field is blank
	if(document.frmPremiumDisposition.txtDispositionDateHigh.value == "")
	{
		alert(alertHighDate);
		return false;
	}
	
	//Rule 4. Filing Date Range fields numeric only (includes date format characters).
	//starting Date Range field
	var valid="1234567890/-"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumDisposition.txtDispositionDateLow.value.length; i++)
	{
		temp = "" + document.frmPremiumDisposition.txtDispositionDateLow.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertDispositionNum);
			document.frmPremiumDisposition.txtDispositionDateLow.focus();
			document.frmPremiumDisposition.txtDispositionDateLow.select();
			return false;
		}
	
	//Ending Date Range field
	var valid1="1234567890/-"
	var ok1 = "yes"
	var temp1
	
	for (var i=0; i<document.frmPremiumDisposition.txtDispositionDateHigh.value.length; i++)
	{
		temp1 = "" + document.frmPremiumDisposition.txtDispositionDateHigh.value.substring(i, i+1);
		if (valid1.indexOf(temp1) == "-1") 
		{
			ok1 = "no";
		}
	}
		if (ok1 == "no")
		{
			alert(alertDispositionNum);
			document.frmPremiumDisposition.txtDispositionDateHigh.focus();
			document.frmPremiumDisposition.txtDispositionDateHigh.select();
			return false;
		}
	
	
	//Rule 5: Disposition Dates cannot be longer than 10 characters (MM-DD-YYYY)
	if(document.frmPremiumDisposition.txtDispositionDateLow.value != "")
	{
		if(document.frmPremiumDisposition.txtDispositionDateLow.value.length != 10)
		{
			alert(alertLowDateLong);
			return false;
		}
	}
	
	//Rule 5: Disposition Dates cannot be longer than 10 characters (MM-DD-YYYY)
	if(document.frmPremiumDisposition.txtDispositionDateHigh.value != "")
	{
		if(document.frmPremiumDisposition.txtDispositionDateHigh.value.length != 10)
		{
			alert(alertHighDateLong);
			return false;
		}
	}
		
	//Rule : Adjudication Dates cannot be longer than 10 characters (MM-DD-YYYY)
	if(document.frmPremiumDisposition.txtAdjudicationDateLow.value != "")
	{
		if(document.frmPremiumDisposition.txtAdjudicationDateLow.value.length != 10)
		{
			alert(alertLowDateLong);
			return false;
		}
	}
	
	//Rule : Adjudication Dates cannot be longer than 10 characters (MM-DD-YYYY)
	if(document.frmPremiumDisposition.txtAdjudicationDateHigh.value != "")
	{
		if(document.frmPremiumDisposition.txtAdjudicationDateHigh.value.length != 10)
		{
			alert(alertHighDateLong);
			return false;
		}
	}
	
	//Rule: Date range cannot have duplicate dates
	//	if((document.frmPremiumDisposition.txtDispositionDateHigh.value) && (document.frmPremiumDisposition.txtDispositionDateLow.value) != "")
	//	{
	//		if(document.frmPremiumDisposition.txtDispositionDateLow.value == document.frmPremiumDisposition.txtDispositionDateHigh.value)
	//		{
	//			alert(alertDispositionDateDup);
	//			return false;
	//		}
	//	}	

	//Rule 7: If ID Number entered, ID Type must be selected
	//Invalid Input: ID Number entered with ID Type selected
	if(document.frmPremiumDisposition.txtIDNumber.value != "")
	{
		if(document.frmPremiumDisposition.cboIDType.options[0].selected)
		{
			alert(alertIDType);
			return false;
		}
	}

	//Rule 2: ID Numbers cannot be longer than 20 characters
	if(document.frmPremiumDisposition.txtIDNumber.value != "")
	{
		if(document.frmPremiumDisposition.txtIDNumber.value.length > 20)
		{
			alert(alertIDLong);
			return false;
		}
	}

	//Rule: if users selects to search by BARID then ID number must be = to 12 characters (padding w/ 0's)
	if(document.frmPremiumDisposition.cboIDType.options.value == "BARID")
	{
		if (document.frmPremiumDisposition.txtIDNumber.value.length < 12)
		{
			var oldIDNum = document.frmPremiumDisposition.txtIDNumber.value;
			iL = 12 - document.frmPremiumDisposition.txtIDNumber.value.length;
			
			for(i=0; i<iL; i++)
			{
				oldIDNum = "0" + oldIDNum;
			}
			document.frmPremiumDisposition.txtIDNumber.value = oldIDNum;
		}
	} 
	
	//Rule: Date range cannot have duplicate dates
	//	if((document.frmPremiumDisposition.txtAdjudicationDateHigh.value) && (document.frmPremiumDisposition.txtAdjudicationDateLow.value) != "")
	//	{
	//		if(document.frmPremiumDisposition.txtAdjudicationDateLow.value == document.frmPremiumDisposition.txtAdjudicationDateHigh.value)
	//		{
	//			alert(alertDispositionDateDup);
	//			return false;
	//		}
	//	}	

//Rule: To search by date (Adjudication) dates must be present in both the lower and higher date range fields
	if(document.frmPremiumDisposition.txtAdjudicationDateHigh.value != "")
	{
		if(document.frmPremiumDisposition.txtAdjudicationDateLow.value == "")
		{
			alert(alertAdjudicationLowDate);
			return false;
		}
	}

if(document.frmPremiumDisposition.txtAdjudicationDateLow.value != "")
	{
		if(document.frmPremiumDisposition.txtAdjudicationDateHigh.value == "")
		{
			alert(alertAdjudicationHighDate);
			return false;
		}
	}

	
	//Rule:  Disposition Date Range fields must be date formatted (MM-DD-YYYY)
		if(((document.frmPremiumDisposition.txtDispositionDateLow.value != "") || (document.frmPremiumDisposition.txtDispositionDateHigh.value != "")) || ((document.frmPremiumDisposition.txtAdjudicationDateLow.value != "") || (document.frmPremiumDisposition.txtAdjudicationDateHigh.value != "")))
		{

				var inputStr = document.frmPremiumDisposition.txtDispositionDateLow.value;
				var inputStrHigh = document.frmPremiumDisposition.txtDispositionDateHigh.value;
				
				while (inputStr.indexOf("-") != -1)
				{
					
					inputStr = inputStr.replace("-","/");
				}
				
				while (inputStrHigh.indexOf("-") != -1)
				{
					inputStrHigh = inputStrHigh.replace("-","/");
				}
				
				var delim1 = inputStr.indexOf("/");
				var delim2 = inputStr.lastIndexOf("/");
				
				var delim1High = inputStrHigh.indexOf("/");
				var delim2High = inputStrHigh.lastIndexOf("/");
												
				if (delim1 != -1 && delim1 == delim2)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				}
				
				if (delim1High != -1 && delim1High == delim2High)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
				
				if (delim1 != -1)
				{
					var mm = parseInt(inputStr.substring(0,delim1),10);
					var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
					var yyyy = parseInt(inputStr.substring(delim2 +1, inputStr.length),10);
				}
				
				if (delim1High != -1)
				{
					var mmHigh = parseInt(inputStrHigh.substring(0,delim1High),10);
					var ddHigh = parseInt(inputStrHigh.substring(delim1High + 1,delim2High),10);
					var yyyyHigh = parseInt(inputStrHigh.substring(delim2High +1, inputStrHigh.length),10);
				}
				
				if (isNaN(mm) || isNaN(dd) || isNaN(yyyy))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				}
				
				if (isNaN(mmHigh) || isNaN(ddHigh) || isNaN(yyyyHigh))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
				
				if (mm < 01 || mm > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				}
				
				if (mmHigh < 01 || mmHigh > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
				
				if (mm == 01 || mm == 03 || mm == 05 || mm == 07 || mm == 08 || mm == 10 || mm == 12)
				{
					if (dd < 01 || dd > 31)
					{
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateLow.focus();
						document.frmPremiumDisposition.txtDispositionDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 01 || mmHigh == 03 || mmHigh == 05 || mmHigh == 07 || mmHigh == 08 || mmHigh == 10 || mmHigh == 12)
				{
					if (ddHigh < 01 || ddHigh > 31)
					{	
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateHigh.focus();
						document.frmPremiumDisposition.txtDispositionDateHigh.select();
						return false;
					}
				}
				
				if (mm == 04 || mm == 06 || mm == 09 || mm == 11)
				{
					if (dd < 01 || dd > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateLow.focus();
						document.frmPremiumDisposition.txtDispositionDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 04 || mmHigh == 06 || mmHigh == 09 || mmHigh == 11)
				{
					if (ddHigh < 01 || ddHigh > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateHigh.focus();
						document.frmPremiumDisposition.txtDispositionDateHigh.select();
						return false;
					}
				}
				
				if (yyyy < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				}
				
				if (yyyyHigh < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
				
				if (yyyy > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				}
				
				if (yyyyHigh > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
				
				now = new Date();
				
				if (yyyyHigh > now.getFullYear())
				{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
				}
			
				if (yyyyHigh >= now.getFullYear())
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh > now.getMonth())
					{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumDisposition.txtDispositionDateHigh.focus();
					document.frmPremiumDisposition.txtDispositionDateHigh.select();
					return false;
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if ((yyyyHigh >= now.getFullYear()))
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh >= now.getMonth())
					{
						if (ddHigh > now.getDate())
						{
						alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
						document.frmPremiumDisposition.txtDispositionDateHigh.focus();
						document.frmPremiumDisposition.txtDispositionDateHigh.select();
						return false;
						}
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if (Date.parse(document.frmPremiumDisposition.txtDispositionDateLow.value) > Date.parse(document.frmPremiumDisposition.txtDispositionDateHigh.value))
				{
					alert("The date in the Low Date Range field may not be higher than the date in the High Date Range field."); 
					document.frmPremiumDisposition.txtDispositionDateLow.focus();
					document.frmPremiumDisposition.txtDispositionDateLow.select();
					return false;
				} 				
				
				if (mm == 02)
				{
					if (dd < 01 || dd > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateLow.focus();
						document.frmPremiumDisposition.txtDispositionDateLow.select();
						return false;
					}
					
					if (dd == 29)
					{
						if(yyyy % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumDisposition.txtDispositionDateLow.focus();
							document.frmPremiumDisposition.txtDispositionDateLow.select();
							return false;
						}
					}
				
				}
				
				if (mmHigh == 02)
				{
					if (ddHigh < 01 || ddHigh > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumDisposition.txtDispositionDateHigh.focus();
						document.frmPremiumDisposition.txtDispositionDateHigh.select();
						return false;
					}
					
					if (ddHigh == 29)
					{
						if(yyyyHigh % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumDisposition.txtDispositionDateHigh.focus();
							document.frmPremiumDisposition.txtDispositionDateHigh.select();
							return false;
						}
					}
				
				}
				
				//	**  Added by AMT in FL on 10-17-2000
				if (document.frmPremiumDisposition.cboAdjudication.options.value != "")
				{
					if((document.frmPremiumDisposition.txtAdjudicationDateLow.value == "")||(document.frmPremiumDisposition.txtAdjudicationDateHigh.value == ""))
						{
							alert("You must enter an Adjudication date range in order to search by adjudication.");
							return false;
						}	
				}
						
				///	** End Ann's add
				
				if ((document.frmPremiumDisposition.txtAdjudicationDateLow.value != "") || (document.frmPremiumDisposition.txtAdjudicationDateHigh.value != ""))
				{
					if(document.frmPremiumDisposition.cboAdjudication.options[0].selected)
						{
							alert("You must select an option from the Adjudication dropdown menu.");
							return false;
						}
				
					
					var inputStrAdj = document.frmPremiumDisposition.txtAdjudicationDateLow.value;
					var inputStrHighAdj = document.frmPremiumDisposition.txtAdjudicationDateHigh.value;
					
					while (inputStrAdj.indexOf("-") != -1)
					{
						inputStrAdj = inputStrAdj.replace("-","/");
					}
				
					while (inputStrHighAdj.indexOf("-") != -1)
					{
						inputStrHighAdj = inputStrHighAdj.replace("-","/");
					}
					
					var delim1Adj = inputStrAdj.indexOf("/");
					var delim2Adj = inputStrAdj.lastIndexOf("/");
				
					var delim1HighAdj = inputStrHighAdj.indexOf("/");
					var delim2HighAdj = inputStrHighAdj.lastIndexOf("/");
					
					if (delim1Adj != -1 && delim1Adj == delim2Adj)
					{
						alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
				
					if (delim1HighAdj != -1 && delim1HighAdj == delim2HighAdj)
					{
						alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
					}
					
					if (delim1Adj != -1)
					{
						var mmAdj = parseInt(inputStrAdj.substring(0,delim1Adj),10);
						var ddAdj = parseInt(inputStrAdj.substring(delim1Adj + 1,delim2Adj),10);
						var yyyyAdj = parseInt(inputStrAdj.substring(delim2Adj +1, inputStrAdj.length),10);
					}
				
					if (delim1HighAdj != -1)
					{
						var mmHighAdj = parseInt(inputStrHighAdj.substring(0,delim1HighAdj),10);
						var ddHighAdj = parseInt(inputStrHighAdj.substring(delim1HighAdj + 1,delim2HighAdj),10);
						var yyyyHighAdj = parseInt(inputStrHighAdj.substring(delim2HighAdj +1, inputStrHighAdj.length),10);
					}
					
					if (isNaN(mmAdj) || isNaN(ddAdj) || isNaN(yyyyAdj))
					{
						alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
				
					if (isNaN(mmHighAdj) || isNaN(ddHighAdj) || isNaN(yyyyHighAdj))
					{
						alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
					}
					
					if (mmAdj < 01 || mmAdj > 12)
					{
						alert("Months must be entered between the range of 01 (January) and 12(December).");
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
				
					if (mmHighAdj < 01 || mmHighAdj > 12)
					{
						alert("Months must be entered between the range of 01 (January) and 12(December).");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
					}
					
					if (mmAdj == 01 || mmAdj == 03 || mmAdj == 05 || mmAdj == 07 || mmAdj == 08 || mmAdj == 10 || mmAdj == 12)
					{
						if (ddAdj < 01 || ddAdj > 31)
						{
							alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
							document.frmPremiumDisposition.txtAdjudicationDateLow.select();
							return false;
						}
					}
				
					if (mmHighAdj == 01 || mmHighAdj == 03 || mmHighAdj == 05 || mmHighAdj == 07 || mmHighAdj == 08 || mmHighAdj == 10 || mmHighAdj == 12)
					{
						if (ddHighAdj < 01 || ddHighAdj > 31)
						{	
							alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
							document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
							return false;
						}
					}
										
					if (mmAdj == 04 || mmAdj == 06 || mmAdj == 09 || mmAdj == 11)
					{
						if (ddAdj < 01 || ddAdj > 30)
						{
							alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
							document.frmPremiumDisposition.txtAdjudicationDateLow.select();
							return false;
						}
					}
				
					if (mmHighAdj == 04 || mmHighAdj == 06 || mmHighAdj == 09 || mmHighAdj == 11)
					{
						if (ddHighAdj < 01 || ddHighAdj > 30)
						{
							alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
							document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
							return false;
						}
					}
					
					if (yyyyAdj < 1901)
					{
						alert("You have entered a year that is too early to search.  Please enter a new year to search.");
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
				
					if (yyyyHighAdj < 1901)
					{
						alert("You have entered a year that is too early to search.  Please enter a new year to search.");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
					}
										
					if (yyyyAdj > 9999)
					{
						alert("You have entered a year that is too late to search.  Please enter a new year to search.");
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
				
					if (yyyyHighAdj > 9999)
					{
						alert("You have entered a year that is too late to search.  Please enter a new year to search.");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
					}
					
					now = new Date();
				
				if (yyyyHighAdj > now.getFullYear())
				{
					alert("The Date you provided is invalid, please enter a valid date to search in the HighAdj Date Range field.");
					document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
					document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
					return false;
				}
			
				if (yyyyHighAdj >= now.getFullYear())
				{
					mmHighAdj = mmHighAdj - 1;
					
					if (mmHighAdj > now.getMonth())
					{
					alert("The Date you provided is invalid, please enter a valid date to search in the HighAdj Date Range field.");
					document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
					document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
					return false;
					}
					
					mmHighAdj = mmHighAdj + 1;
				}
				
				if ((yyyyHighAdj >= now.getFullYear()))
				{
					mmHighAdj = mmHighAdj - 1;
					
					if (mmHighAdj >= now.getMonth())
					{
						if (ddHighAdj > now.getDate())
						{
						alert("The Date you provided is invalid, please enter a valid date to search in the HighAdj Date Range field.");
						document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
						document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
						return false;
						}
					}
					
					mmHighAdj = mmHighAdj + 1;
				}
					
					if (Date.parse(document.frmPremiumDisposition.txtAdjudicationDateLow.value) > Date.parse(document.frmPremiumDisposition.txtAdjudicationDateHigh.value))
					{
						alert("The date in the Low Date Range field may not be higher than the date in the High Date Range field."); 
						document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
						document.frmPremiumDisposition.txtAdjudicationDateLow.select();
						return false;
					}
					
					if (mmAdj == 02)
					{
						if (ddAdj < 01 || ddAdj > 29)
						{
							alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
							document.frmPremiumDisposition.txtAdjudicationDateLow.select();
							return false;
						}
					
						if (ddAdj == 29)
						{
							if(yyyyAdj % 4 != 0)
							{
								alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
								document.frmPremiumDisposition.txtAdjudicationDateLow.focus();
								document.frmPremiumDisposition.txtAdjudicationDateLow.select();
								return false;
							}
						}
				
					}
				
					if (mmHighAdj == 02)
					{
						if (ddHighAdj < 01 || ddHighAdj > 29)
						{
							alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
							document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
							document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
							return false;
						}
					
						if (ddHighAdj == 29)
						{
							if(yyyyHighAdj % 4 != 0)
							{
								alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
								document.frmPremiumDisposition.txtAdjudicationDateHigh.focus();
								document.frmPremiumDisposition.txtAdjudicationDateHigh.select();
								return false;
							}
						}
				
					}
				
				if (ddAdj < 10)
				{
					ddAdj = "0" + ddAdj;
				}
				
				if (ddHighAdj < 10)
				{
					ddHighAdj = "0" + ddHighAdj;
				}
				
				if (mmAdj < 10)
				{
					mmAdj = "0" + mmAdj;
				}
				
				if (mmHighAdj < 10)
				{
					mmHighAdj = "0" + mmHighAdj;
				}
				
				document.frmPremiumDisposition.txtAdjudicationDateLow.value = mmAdj + "/" + ddAdj + "/" + yyyyAdj;
				document.frmPremiumDisposition.txtAdjudicationDateHigh.value = mmHighAdj + "/" + ddHighAdj + "/" + yyyyHighAdj;
				}
				
				if (dd < 10)
				{
					dd = "0" + dd;
				}
				
				if (ddHigh < 10)
				{
					ddHigh = "0" + ddHigh;
				}
				
				if (mm < 10)
				{
					mm = "0" + mm;
				}
				
				if (mmHigh < 10)
				{
					mmHigh = "0" + mmHigh;
				}
				document.frmPremiumDisposition.txtDispositionDateLow.value = mm + "/" + dd + "/" + yyyy;
				document.frmPremiumDisposition.txtDispositionDateHigh.value = mmHigh + "/" + ddHigh + "/" + yyyyHigh;
				
				return true;
			}

else return true;
}

//////////////////////////////////////////////////////////////
//			premium_docket_search.asp						//
//////////////////////////////////////////////////////////////
function chkPremiumDocketForm()
{
//validation rules
//1.	Case Number alpha-numeric only.
//2.	Case Number 14 characters or less.
//3.	Docket Entry not option [0].
//4.	Docket Date Range fields numeric only.
//5.	Docket Date Range fields must be 10 characters.
//6.    Docket Date Range fields must be date formatted (MM-DD-YYYY)
//7.    Docket Date Range fields not blank

//cross-field validation rules
//1.	If Case Number is entered, Case Type must not be set to option [0].
//2.	Case Number and Court Type match formats.

//variable declarations and assignments
alertCaseAlpha = "Please enter only letters and numbers in the Case Number field.";
alertCaseLong =		"Case Numbers may not be longer than 14 characters.";
alertDateLong =	"Date Range fields may not be longer than 10 characters.";
alertDocketNum = "Please enter only numbers in the the Date Range fields.";
alertDocketBlank = "Please enter a value in the Date Range fields.";
alertDocketEntry = "Please select a value from the Docket Entry field.";
alertDocketDateDup = "You may not enter duplicate dates in the Date Range fields.";


	//Rule 1: Case Number alpha-numeric only
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumDocket.txtCaseNumber.value.length; i++)
	{
		temp = "" + document.frmPremiumDocket.txtCaseNumber.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertCaseAlpha);
			document.frmPremiumDocket.txtCaseNumber.focus();
			document.frmPremiumDocket.txtCaseNumber.select();
			return false;
		}
	
	//Rule 2 : Case Numbers cannot be longer than 14 characters
	if(document.frmPremiumDocket.txtCaseNumber.value != "")
	{
		if(document.frmPremiumDocket.txtCaseNumber.value.length > 14)
		{
			alert(alertCaseLong);
			return false;
		}
	}
		
	//Rule 3: Require the selection of a Docket Entry
	if(document.frmPremiumDocket.cboDocket.options[0].selected)
		{
			alert(alertDocketEntry);
			return false;
		}
	
	//Rule 4: Docket Dates numeric only (includes date format characters).
	//starting Date Range field
	var valid="1234567890/-"
	var ok = "yes"
	var temp
	
	for (var i=0; i<document.frmPremiumDocket.txtDocketDateLow.value.length; i++)
	{
		temp = "" + document.frmPremiumDocket.txtDocketDateLow.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
	}
		if (ok == "no")
		{
			alert(alertDocketNum);
			document.frmPremiumDocket.txtDocketDateLow.focus();
			document.frmPremiumDocket.txtDocketDateLow.select();
			return false;
		}
	
	//Ending Date Range field
	var valid1="1234567890/-"
	var ok1 = "yes"
	var temp1
	
	for (var i=0; i<document.frmPremiumDocket.txtDocketDateHigh.value.length; i++)
	{
		temp1 = "" + document.frmPremiumDocket.txtDocketDateHigh.value.substring(i, i+1);
		if (valid1.indexOf(temp1) == "-1") 
		{
			ok1 = "no";
		}
	}
		if (ok1 == "no")
		{
			alert(alertDocketNum);
			document.frmPremiumDocket.txtDocketDateHigh.focus();
			document.frmPremiumDocket.txtDocketDateHigh.select();
			return false;
		}

		
	//Rule 5: Docket Dates cannot be longer than 10 characters 
	//starting date range
			if(document.frmPremiumDocket.txtDocketDateLow.value != "")
			{
				if(document.frmPremiumDocket.txtDocketDateLow.value.length != 10)
				{
					alert(alertDateLong);
					return false;
				}
			}
			//ending date range field
			if(document.frmPremiumDocket.txtDocketDateHigh.value != "")
			{
				if(document.frmPremiumDocket.txtDocketDateHigh.value.length != 10)
				{
					alert(alertDateLong);
					return false;
				}
			}

	
	//Rule 7.	Date Range fields not blank.
			if ((document.frmPremiumDocket.txtDocketDateLow.value == "") || (document.frmPremiumDocket.txtDocketDateHigh.value == ""))
			{
				alert(alertDocketBlank);
				return false;
			}
			
	//Rule: Date range cannot have duplicate dates
	//		if(document.frmPremiumDocket.txtDocketDateLow.value == document.frmPremiumDocket.txtDocketDateHigh.value)
	//		{
	//			alert(alertDocketDateDup);
	//			return false;
	//		}	
	
	 //Rule: Docket Date Range fields must be date formatted (MM-DD-YYYY)
		if((document.frmPremiumDocket.txtDocketDateLow.value != "") || (document.frmPremiumDocket.txtDocketDateHigh.value != ""))
		{

				var inputStr = document.frmPremiumDocket.txtDocketDateLow.value;
				var inputStrHigh = document.frmPremiumDocket.txtDocketDateHigh.value;
				
				while (inputStr.indexOf("-") != -1)
				{
					
					inputStr = inputStr.replace("-","/");
				}
				
				while (inputStrHigh.indexOf("-") != -1)
				{
					inputStrHigh = inputStrHigh.replace("-","/");
				}
				
				var delim1 = inputStr.indexOf("/");
				var delim2 = inputStr.lastIndexOf("/");
				
				var delim1High = inputStrHigh.indexOf("/");
				var delim2High = inputStrHigh.lastIndexOf("/");
				
				if (delim1 != -1 && delim1 == delim2)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}
				
				if (delim1High != -1 && delim1High == delim2High)
				{
					alert("The date entry is not in an acceptable format.  \n  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
				
				if (delim1 != -1)
				{
					var mm = parseInt(inputStr.substring(0,delim1),10);
					var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10);
					var yyyy = parseInt(inputStr.substring(delim2 +1, inputStr.length),10);
				}
				
				if (delim1High != -1)
				{
					var mmHigh = parseInt(inputStrHigh.substring(0,delim1High),10);
					var ddHigh = parseInt(inputStrHigh.substring(delim1High + 1,delim2High),10);
					var yyyyHigh = parseInt(inputStrHigh.substring(delim2High +1, inputStrHigh.length),10);
				}
				
				if (isNaN(mm) || isNaN(dd) || isNaN(yyyy))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}
				
				if (isNaN(mmHigh) || isNaN(ddHigh) || isNaN(yyyyHigh))
				{
					alert("The date entry is not in an acceptable format.  You can enter dates in the following format: MM/DD/YYYY.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
				
				if (mm < 01 || mm > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}
				
				if (mmHigh < 01 || mmHigh > 12)
				{
					alert("Months must be entered between the range of 01 (January) and 12(December).");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
				
				if (mm == 01 || mm == 03 || mm == 05 || mm == 07 || mm == 08 || mm == 10 || mm == 12)
				{
					if (dd < 01 || dd > 31)
					{
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateLow.focus();
						document.frmPremiumDocket.txtDocketDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 01 || mmHigh == 03 || mmHigh == 05 || mmHigh == 07 || mmHigh == 08 || mmHigh == 10 || mmHigh == 12)
				{
					if (ddHigh < 01 || ddHigh > 31)
					{	
						alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateHigh.focus();
						document.frmPremiumDocket.txtDocketDateHigh.select();
						return false;
					}
				}
				
				if (mm == 04 || mm == 06 || mm == 09 || mm == 11)
				{
					if (dd < 01 || dd > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateLow.focus();
						document.frmPremiumDocket.txtDocketDateLow.select();
						return false;
					}
				}
				
				if (mmHigh == 04 || mmHigh == 06 || mmHigh == 09 || mmHigh == 11)
				{
					if (ddHigh < 01 || ddHigh > 30)
					{
						alert("Days must be entered between the range of 01 and a maximum of 30 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateHigh.focus();
						document.frmPremiumDocket.txtDocketDateHigh.select();
						return false;
					}
				}
				
				if (yyyy < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}
				
				if (yyyyHigh < 1901)
				{
					alert("You have entered a year that is too early to search.  Please enter a new year to search.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
				
				if (yyyy > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}
				
				if (yyyyHigh > 9999)
				{
					alert("You have entered a year that is too late to search.  Please enter a new year to search.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
				
				now = new Date();
				
				if (yyyyHigh > now.getFullYear())
				{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
				}
			
				if (yyyyHigh >= now.getFullYear())
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh > now.getMonth())
					{
					alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
					document.frmPremiumDocket.txtDocketDateHigh.focus();
					document.frmPremiumDocket.txtDocketDateHigh.select();
					return false;
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if ((yyyyHigh >= now.getFullYear()))
				{
					mmHigh = mmHigh - 1;
					
					if (mmHigh >= now.getMonth())
					{
						if (ddHigh > now.getDate())
						{
						alert("The Date you provided is invalid, please enter a valid date to search in the High Date Range field.");
						document.frmPremiumDocket.txtDocketDateHigh.focus();
						document.frmPremiumDocket.txtDocketDateHigh.select();
						return false;
						}
					}
					
					mmHigh = mmHigh + 1;
				}
				
				if (Date.parse(document.frmPremiumDocket.txtDocketDateLow.value) > Date.parse(document.frmPremiumDocket.txtDocketDateHigh.value))
				{
					alert("The date in the Low Date Range field may not be higher than the date in the High Date Range field."); 
					document.frmPremiumDocket.txtDocketDateLow.focus();
					document.frmPremiumDocket.txtDocketDateLow.select();
					return false;
				}	
				
				if (mm == 02)
				{
					if (dd < 01 || dd > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateLow.focus();
						document.frmPremiumDocket.txtDocketDateLow.select();
						return false;
					}
					
					if (dd == 29)
					{
						if(yyyy % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumDocket.txtDocketDateLow.focus();
							document.frmPremiumDocket.txtDocketDateLow.select();
							return false;
						}
					}
				
				}
				
				if (mmHigh == 02)
				{
					if (ddHigh < 01 || ddHigh > 29)
					{
						alert("Days must be entered between the range of 01 and a maximum of 29 (depending on the month and year).");
						document.frmPremiumDocket.txtDocketDateHigh.focus();
						document.frmPremiumDocket.txtDocketDateHigh.select();
						return false;
					}
					
					if (ddHigh == 29)
					{
						if(yyyyHigh % 4 != 0)
						{
							alert("You have entered the date as a Leap Year when it is not.  \n  You will need to enter a correct date.");
							document.frmPremiumDocket.txtDocketDateHigh.focus();
							document.frmPremiumDocket.txtDocketDateHigh.select();
							return false;
						}
					}
				
				}
				if (dd < 10)
				{
					dd = "0" + dd;
				}
				
				if (ddHigh < 10)
				{
					ddHigh = "0" + ddHigh;
				}
				
				if (mm < 10)
				{
					mm = "0" + mm;
				}
				
				if (mmHigh < 10)
				{
					mmHigh = "0" + mmHigh;
				}
				
				document.frmPremiumDocket.txtDocketDateLow.value = mm + "/" + dd + "/" + yyyy;
				document.frmPremiumDocket.txtDocketDateHigh.value = mmHigh + "/" + ddHigh + "/" + yyyyHigh;
				return true;
			}

else return true;
}

//This next function is for validating management_new.asp <-- this is a 1B validation **DONT ERASE!!**
//Created by Benjamin J. Camp on 11/09/2000

function chkManagementForm()
{
//validation rules
//1. If P_TYPE_CODE is not blank then no fields in BBS file information section can be blank

	if (document.frmManagement.p_type_code.value == "")
	{
		if (document.frmManagement.file_name == "")
		{
			alert("You may not leave File Name blank.");
			document.frmManagement.file_name.focus();
			document.frmManagement.file_name.select();
			return false;
		}
		
		if (document.frmManagement.filelocation.value == "")
		{
			alert("You may not leave File Location blank.");
			document.frmManagement.filelocation.focus();
			document.frmManagement.filelocation.select();
			return false;
		}
		
		if (document.frmManagement.create_date.value == "")
		{
			alert("You may not leave Create Date blank.");
			document.frmManagement.create_date.focus();
			document.frmManagement.create_date.select();
			return false;
		}
		
		if (document.frmManagement.category.options[0].selected)
		{
			alert("You may not leave Category blank.");
			return false;
		}
		
		if (document.frmManagement.file_size.value == "")
		{
			alert("You may not leave File Size blank.");
			document.frmManagement.file_size.focus();
			document.frmManagement.file_size.select();
			return false;
		}
		
		if (document.frmManagement.file_type.value == "")
		{
			alert("You may not leave File Type blank.");
			document.frmManagement.file_type.focus();
			document.frmManagement.file_type.select();
			return false;
		}
		
		if (document.frmManagement.exp_date.value == "")
		{
			alert("You may not leave Exp. Date blank.");
			document.frmManagement.exp_date.focus();
			document.frmManagement.exp_date.select();
			return false;
		}
	}
	
else return true;
}

