
var boolIgnoreFormClick = false;
var contextMenus = new Array();

//main method to be called whenever the form is clicked
function FormClicked()
{
	ClearForm();
	boolIgnoreFormClick = false;
}

//clears the form when the user clicks anywhere on it other than on a context menu
function ClearForm()
{
	if(!boolIgnoreFormClick)
	{		
		for(var x=0; x<contextMenus.length; x++)
		{
			CloseContextMenu(contextMenus[x]);
		}
		try
		{
			if(gfPop != null)
			{
				gfPop.fHideCal();
			}
		}
		catch(error)
		{
			//do nothing... gfpop is just not defined yet...
			//alert('caught the error');
		}
	}
}

//used by various text fields that need to post back when the enter key is pressed
function ClickButton(e, buttonid)
{ 
	var bt = document.getElementById(buttonid); 
	if(bt != null)
	{
		if (typeof bt == 'object')
		{ 
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
			{ 
				if (event.keyCode == 13)
				{ 
					bt.click(); 
					return false; 
				} 
			} 
		}
	} 
}

//launches the passed context menu and remembers that it is open so it can be managed
function LaunchContextMenu (id)
{
	var contextMenu = document.getElementById(id);
	if(contextMenu != null)
	{
		contextMenus[contextMenus.length] = contextMenu;
		
		if (contextMenu.style.visibility == 'hidden') {
    		// Show menu
    		ClearForm();
    		contextMenu.style.visibility = 'visible';
		} else {
    		// Hide menu
    		ClearForm();
    		CloseContextMenu(contextMenu);
		}
	}
	boolIgnoreFormClick = true;
	return false;
}

//closes the passed context menu (div)
function CloseContextMenu(menu)
{
	menu.style.visibility = 'hidden';
}

var oldColor = new Array();
var HIGHLIGHT_ROW_COLOR = 'white';

//mouse over highlight table row
function HighlightRow(rowToHighlightId) 
{
	var rowToHighlight = document.getElementById(rowToHighlightId);
	oldColor[rowToHighlightId] = rowToHighlight.style.backgroundColor;
	rowToHighlight.style.backgroundColor = HIGHLIGHT_ROW_COLOR;
}

//mouse out unhighlight table row
function UnHighlightRow(rowToUnHighlightId) 
{
	var rowToUnHighlight = document.getElementById(rowToUnHighlightId);
	rowToUnHighlight.style.backgroundColor = oldColor[rowToUnHighlightId];
}

//toggles the visibile/hidden visibility of two passed controls
function ToggleVisibility(idToShow, idToHide)
{
	var ctlToShow = document.getElementById(idToShow);
	var ctlToHide = document.getElementById(idToHide);
	
	if(ctlToShow != null && ctlToHide != null)
	{
		ctlToShow.style.visibility = "visible";
		ctlToHide.style.visibility = "hidden";
	}
	
	return true;
}

//Toggles the block/none display of two passed controls
function ToggleDisplay(idToShow, idToHide)
{
	var ctlToShow = document.getElementById(idToShow);
	var ctlToHide = document.getElementById(idToHide);
	
	if(ctlToShow != null && ctlToHide != null)
	{
		ctlToShow.style.display = "block";
		ctlToHide.style.display = "none";
	}
	
	return true;
}

//Toggles the block/none display of one passed control
function ToggleOneDisplay(id)
{
	var ctlToShow = document.getElementById(id);
	
	if(ctlToShow != null)
	{
		//alert('here i am ' + id);
		if(ctlToShow.style.display == "block")
			ctlToShow.style.display = "none";
		else
			ctlToShow.style.display = "block";
		//alert(ctlToShow.style.display);
	}
	
	return true;
}

//Called whenever a body loads on the page...updates the scroll position (replaces the need to use smartnavigation)
function ScrollIt(xId, yId)
{
	var x = document.getElementById(xId);
	var y = document.getElementById(yId);
	if(x != null && y != null)
		window.scrollTo(x.value, y.value);
}

//whenever the page is scrolled, the coordinates of the scroll position is saved here
//used in coordination with ScrollIt to manage the scroll position on the page
function SetCoords(xId, yId)
{
	var myPageX;
	var myPageY;
    if(document.all)
    {
		myPageX = document.body.scrollLeft;
		myPageY = document.body.scrollTop;
	}
    else
    {
		myPageX = window.pageXOffset;
		myPageY = window.pageYOffset;
	}
	
	var x = document.getElementById(xId);
	var y = document.getElementById(yId);
	if(x != null && y != null)
	{
		x.value = myPageX;
		y.value = myPageY;
	}
}


//validates an array of controls to make sure that their value properties are integers
//to use pass a multi-dimensional array in the following format - 
// [['control1Id', 'Control1 Name for Display'], ['control2Id', 'Control2 Name for Display],...] 
function ValidateIntegerFields(integerFieldArray)
{
	var integerFields = "";
	
	for (var i = 0; i < integerFieldArray.length; i++) 
	{ 		
		var controlId = integerFieldArray[i][0]; 
		var integerValueControl = document.getElementById(controlId);
		
		if(integerValueControl != null)
		{
			if(integerValueControl.value.length > 0)
			{
				if(!IsInteger(integerValueControl.value))
				{
					integerFields += "\n     -" + integerFieldArray[i][1]; 
				}
			}
		}
		else
		{
			alert("DEBUG MSG: Cannot validate " + controlId + " has an integer because the control cannot be found on this page!");
		}
	} 
	
	if(integerFields == "")
	{
		return true;
	}
	else
	{
		alert("The following fields must be integer (numeric) values with no punctuation." + integerFields);
		return false;
	}
}

//validates an array of required controls to make sure that their value properties are not empty
//to use pass a multi-dimensional array in the following format - 
// [['control1Id', 'Control1 Name for Display'], ['control2Id', 'Control2 Name for Display],...] 
function ValidateRequiredStrings(requiredFieldArray)
{
	return ValidateRequiredStringsWithCustomMessage(requiredFieldArray, "");
}

function ValidateRequiredStringsWithCustomMessage(requiredFieldArray, customMessage)
{
	var requiredFields = "";
	
	for (var i = 0; i < requiredFieldArray.length; i++) 
	{ 		
		var controlId = requiredFieldArray[i][0]; 
		if(!ValidateRequiredStringValue(controlId))
			requiredFields += "\n     -" + requiredFieldArray[i][1]; 
	} 
	
	if(requiredFields == "")
	{
		return true;
	}
	else
	{
		var messageToDisplay = "";
		if(customMessage.length > 0)
		{
			messageToDisplay = customMessage + "\n\n";
		}
		alert(messageToDisplay + "The following fields are required:" + requiredFields);
		return false;
	}
}

function ToggleAllCheckBoxes(allCbId, cbIdArray)
{
	var allCb = document.getElementById(allCbId);
	if(allCb != null)
	{
		for(var i=0; i<cbIdArray.length; i++)
		{
			var controlId = cbIdArray[i];
			var control = document.getElementById(controlId);
			if(control != null)
			{
				control.checked = allCb.checked;
			}
		}
	}
	return true;
}

//validates that the control with the passed id has a non empty value
function ValidateRequiredStringValue(controlId)
{
	var stringValueControl = document.getElementById(controlId);
	if(stringValueControl == null)
	{
		alert("DEBUG MSG: Cannot validate " + controlId + " because the control cannot be found on this page!");
		return false;
	} 
	else 
	{
		if(TrimString(stringValueControl.value) == "")
			return false;
	}
	return true;
}

//Trims any leading spaces off of the front and end of a string 
function TrimString(sInString) 
{
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

//clears the value from any control that supports the value property
function ClearValueForControl(controlId)
{
	var stringValueControl = document.getElementById(controlId);
	if(stringValueControl != null)
	{
		stringValueControl.value = "";
	} 
	return false;
}

//validates a number to see if its a double value returns a bool
function IsDouble(sText)
{
	var validChars = "0123456789.";
	var isValid = true;
	var character;
	
	for(var i=0; i<sText.length && isValid==true; i++) 
	{
		character = sText.charAt(i); 
		if(validChars.indexOf(character) == -1) 
		{
			isValid = false;
		}
	}
	
	return isValid;
}

//validates a number to see if its an integer value returns a bool
function IsInteger(sText)
{
	var validChars = "0123456789";
	var isValid = true;
	var character;
	
	for(var i=0; i<sText.length && isValid==true; i++) 
	{
		character = sText.charAt(i); 
		if(validChars.indexOf(character) == -1) 
		{
			isValid = false;
		}
	}
	
	return isValid;
}

//expand or collapses a div panel depending on the current state of the panel (block/none)
//also updates a plus/minus image accordingly
function ExpandCollapsePanel(panelId, imageId)
{
	var panel = document.getElementById(panelId);
	var image = document.getElementById(imageId);
	
	if(panel != null)
	{	
		if (panel.style.display == 'none') 
		{
    		// Show panel
    		panel.style.display = 'block';
    		
    		if(image != null)
    		{
    			image.src = image.src.replace("Plus","Minus");
    			image.src = image.src.replace("plus","minus");
    		}
		} 
		else 
		{
    		// Hide panel
    		panel.style.display = 'none';
    		
    		if(image != null)
    		{
    			image.src = image.src.replace("Minus","Plus");
    			image.src = image.src.replace("minus","plus");
    		}
		}
	}
	
	return false;
}

//pops up a confirmation for a deletion before posting back to the server
function confirmDelete(message) 
{
	if(message=="")
	{
		message = "Are you sure you want to permanently delete this item?";
	}
	
	if (confirm(message)) 
	{
		return true;
	} 
	else 
	{
		// do nothing
		return false;
	} 
}









function CustomAccountEditValidation(requiredFieldArray, intArray, sendAuthId, usePopForSMTPId, smtpArray)
{
	if(ValidateRequiredStrings(requiredFieldArray))
	{
		if(ValidateIntegerFields(intArray))
		{
			var sendReqAuth = document.getElementById(sendAuthId);
			var usePopForSmtp = document.getElementById(usePopForSMTPId);
			
			if(sendReqAuth != null && usePopForSmtp != null)
			{
				if(sendReqAuth.checked == true)
				{
					if(usePopForSmtp.checked == true)
						return true;
					else
						return ValidateRequiredStrings(smtpArray);
				}
				else
					return true;				
			}
			else
			{
				alert("DEBUG MSG - Cannot validate form because the checkbox controls cannot be located.");
				return false;
			}
		}
	}
}

function LaunchMailErrorCode(accountId)
{
	window.open("Error.aspx?ID=" + accountId, "ErrorWindow", "height=115,width=260,resizable=no,menubar=no,toolbar=no,status=no");
	return false;
}

function ShowAddressBook(ToId, CcID, BccId)
{
	window.open("SelectAddresses.aspx?ToId=" + ToId + "&CcId=" + CcID + "&BccId=" + BccId, "AddressesWindow", "height=500,width=350,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no");
	return false;
}

function SynchWithNewMessage(rowcount, idTemplate, toId, ccId, bccId)
{
	var toVal = window.opener.document.getElementById(toId).value;
	var ccVal = window.opener.document.getElementById(ccId).value;
	var bccVal = window.opener.document.getElementById(bccId).value;
	
	//alert("to=" + toVal + "\ncc=" + ccVal + "\nbcc=" + bccVal);
	
	for(var i=1; i<rowcount + 1; i++)
	{
		var address = document.getElementById(idTemplate + "email." + i);
		if(address != null)
		{
			//alert(address.innerHTML);
			//alert("toVal=" + toVal + "\naddress=" + address.innerHTML);
			//alert(toVal.indexOf(address.innerHTML));
			if(toVal.indexOf(address.innerHTML) > -1)
				document.getElementById(idTemplate + "toCB." + i).checked = true;
			if(ccVal.indexOf(address.innerHTML) > -1)
				document.getElementById(idTemplate + "ccCB." + i).checked = true;
			if(bccVal.indexOf(address.innerHTML) > -1)
				document.getElementById(idTemplate + "bccCB." + i).checked = true;
		}
	}
	
	return false;
}

function PopulateAddresses(rowcount, idTemplate, toId, ccId, bccId)
{
	var toTB = window.opener.document.getElementById(toId);
	var ccTB = window.opener.document.getElementById(ccId);
	var bccTB = window.opener.document.getElementById(bccId);
	var toVal = toTB.value;
	var ccVal = ccTB.value;
	var bccVal = bccTB.value;
	
	//alert("to=" + toVal + "\ncc=" + ccVal + "\nbcc=" + bccVal);
	
	for(var i=1; i<rowcount + 1; i++)
	{
		var email = document.getElementById(idTemplate + "email." + i);
		var address = document.getElementById(idTemplate + "address." + i);
		var addressString = address.innerHTML.replace("&lt;","<").replace("&gt;",">");
		
		if(email != null && address != null)
		{
			if(document.getElementById(idTemplate + "toCB." + i).checked == true)
			{
				if(TrimString(toTB.value).length == 0)
					toTB.value = addressString;
				else
				{
					if(toVal.indexOf(email.innerHTML) == -1)
						toTB.value += "," + addressString;
				}
			}
			if(document.getElementById(idTemplate + "ccCB." + i).checked == true)
			{
				if(TrimString(ccTB.value).length == 0)
					ccTB.value = addressString;
				else
				{
					if(ccVal.indexOf(email.innerHTML) == -1)
						ccTB.value += "," + addressString;
				}
			}
			if(document.getElementById(idTemplate + "bccCB." + i).checked == true)
			{
				if(TrimString(bccTB.value).length == 0)
					bccTB.value = addressString;
				else
				{
					if(bccVal.indexOf(email.innerHTML) == -1)
						bccTB.value += "," + addressString;
				}
			}
		}
	}
	self.close();
	return false;
}

/* EXAMPLE CUSTOM VALIDATION

//Custom validation for the trans/reg Status - Sold form
function CustomValidateStatusSold(requiredFieldArray, jobOrderId)
{
	if(ValidateRequiredStrings(requiredFieldArray))
	{
		var jobOrderTB = document.getElementById(jobOrderId);
		if(IsInteger(TrimString(jobOrderTB.value)))
		{
			return true;
		}
		else
		{
			alert("The Job Order Number must be a round number.");
			return false;
		}
	}
	return false;
}

//Custom validation for the transformer replace screen
function CustomValidateTransformerReplace(requiredFieldArray, compNumId, validateCompNumId)
{
	if(ValidateRequiredStrings(requiredFieldArray))
	{
		var compNumberTB = document.getElementById(compNumId);
		var compNumberVerTB = document.getElementById(validateCompNumId);

		if(compNumberTB != null && compNumberVerTB != null)
		{
			if(TrimString(compNumberTB.value) != TrimString(compNumberVerTB.value))
			{
				alert("Transformer Company Number #2 has changed and has not been successfully validated. Please click the validate button before clicking the replace button.");
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			alert("DEBUG MSG - Cannot validate form because the company number control cannot be located.");
			return false;
		}
	}
	return false;
}

//Custom validation for the test edit screen for the Transformers and Regulators
function CustomValidateOilTest(requiredFieldArray, typeId, ppmId)
{	
	if(ValidateRequiredStrings(requiredFieldArray))
	{
		return CustomValidateOilTestTypeAndPPM(typeId, ppmId);
	}
	else
	{
		return false;
	}
	return true;
}

//custom validation for the test type and ppm levels of the transformer/regulator test screens
function CustomValidateOilTestTypeAndPPM(typeId, ppmId)
{	
	var typeDD = document.getElementById(typeId);
	var ppmTB = document.getElementById(ppmId);
	
	if(typeDD != null && ppmTB != null)
	{
		if(IsInteger(TrimString(ppmTB.value)))
		{
			if(typeDD.value == "S")
			{
				if(TrimString(ppmTB.value) != "49" && TrimString(ppmTB.value) != "51" && TrimString(ppmTB.value) != "501")
				{
					alert("If the test type is a Screen Test, the PPM can only be 49, 51, or 501. Please update the PPM and re-submit.");
					return false;
				}
			}
			if(typeDD.value == "R")
			{
				if(TrimString(ppmTB.value) != "0")
				{
					alert("If the test type is a Retrofill, the PPM must be 0. Please update the PPM and re-submit.");
					return false;
				}
			}
			if(typeDD.value == "L")
			{
				if(ppmTB.value < 0 || ppmTB.value > 999)
				{
					alert("If the test type is a Lab Test, the PPM must be between 0 and 999. Please update the PPM and re-submit.");
					return false;
				}
			}
		}
		else
		{
			alert("The PPM must be valid integer value between 0 and 999. Please correct and re-submit.");
			return false;
		}
	}
	else
	{
		alert("DEBUG MSG - Cannot validate form because either TestType or PPM value is null.");
		return false;
	}
	return true;
}

//custom validation for the transformer and regulator install screen
function CustomValidateInstallTransReg(gridCdId, distRefId, matTktId, coLocId, coLocVerifyId, reqFieldArray, reqMatTktFieldArray)
{
	if(ValidateRequiredStringValue(matTktId))
	{
		if(!ValidateRequiredStringsWithCustomMessage(reqMatTktFieldArray, "When the Material Ticket # is populated..."))
		{
			return false;
		}
	}
	else
	{
		if(!ValidateRequiredStrings(reqFieldArray))
		{
			return false;
		}
	}
	if(ValidateRequiredStringValue(coLocId))
	{
		var coLocTB = document.getElementById(coLocId);
		var coLocVTB = document.getElementById(coLocVerifyId);
	
		if(coLocTB != null && coLocVTB != null)
		{
			if(TrimString(coLocTB.value) != TrimString(coLocVTB.value))
			{
				alert("The Company Use Location Id value has changed and has not been validated. Please click the validate button before saving your changes.");
				return false;
			}
		}
	}
	else
	{
		if(!ValidateRequiredStringValue(distRefId))
		{
			alert("The Pole/Mounting number is required if a Company Use Location Id is not specified.\n\nPlease enter a Pole/Mounting number and attempt to save again.");
			return false;
		}
	}
	
	var gridCdTB = document.getElementById(gridCdId);
	if(gridCdTB != null)
	{
		if(TrimString(gridCdTB.value).length != 5)
		{
			alert("The Map # must be 5 characters, ex. CE05D");
			return false;
		}
	}
	else
	{
		alert("DEBUG MSG: Cannot validate form because a control cannot be found on this page!");
		return false;
	}
	
	return true;
}

//Custom validation for the installation of capacitor
function CustomValidateInstallCapacitor(gridCdId, woCheckBoxId, moCheckBoxId, woTextBoxId, moTextBoxId, 
										poleCheckBoxId, subCheckBoxId, poleFieldArray, subFieldArray,
										subTextBoxId, subVerifyId)
{
	var woCB = document.getElementById(woCheckBoxId);
	var moCB = document.getElementById(moCheckBoxId);
	
	if(woCB.checked)
	{
		if(ValidateRequiredStringValue(woTextBoxId) == false)
		{
			alert("The Work Order # is required when the corresponding radio button is checked.");
			return false;
		}
	}
	else
	{
		if(moCB.checked)
		{
			if(ValidateRequiredStringValue(moTextBoxId) == false)
			{
				alert("The Misc. Order Id is required when the corresponding radio button is checked.");
				return false;
			}
		}
	}
	
	var poleCB = document.getElementById(poleCheckBoxId);
	var subCB = document.getElementById(subCheckBoxId);
	
	if(poleCB.checked)
	{
		if(ValidateRequiredStrings(poleFieldArray))
		{		
			var gridCdTB = document.getElementById(gridCdId);
			if(gridCdTB != null)
			{
				if(TrimString(gridCdTB.value).length != 5)
				{
					alert("The Map # must be 5 characters, ex. CE05D");
					return false;
				}
				else
				{
					return true; 
				}
			}
			else
			{
				alert("DEBUG MSG: Cannot validate form because a control cannot be found on this page!");
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	else
	{
		if(subCB.checked)
		{
			if(ValidateRequiredStrings(subFieldArray))
			{
				var subTB = document.getElementById(subTextBoxId);
				var subVTB = document.getElementById(subVerifyId);
			
				if(subTB != null && subVTB != null)
				{
					if(TrimString(subTB.value) == TrimString(subVTB.value))
					{
						return true;
					}
					else
					{
						alert("The Substation Id value has changed and has not been validated. Please click the validate button before saving your changes.");
						return false;
					}
				}
			} 
			else
			{
				return false;
			}
		}
	}
	
}

//Custom validation for the search asset form (shared by xfr, reg, and cap)
function CustomValidateSearchAssetForm(compNumId, serialId)
{
	if(ValidateRequiredStringValue(compNumId) || ValidateRequiredStringValue(serialId))
	{
		var compNumTB = document.getElementById(compNumId);
		var serialTB = document.getElementById(serialId);
		
		if(TrimString(compNumTB.value).length < 4 && compNumTB.value.indexOf("%") > -1)
		{
			alert("When using the wildcard '%', please provide at least 3 other valid search characters. Otherwise the returned values will be too large for the web request to handle.");
			return false;
		}
		if(TrimString(serialTB.value).length < 4 && serialTB.value.indexOf("%") > -1)
		{
			alert("When using the wildcard '%', please provide at least 3 other valid search characters. Otherwise the returned values will be too large for the web request to handle.");
			return false;
		}
		return true;
	}
	else
	{
		alert("Either Company Number or Serial Number must be populated before clicking the Locate button.");
		return false;
	}
}

//Custom validation for the Transformer/Regulator Add/Edit Form
function CustomValidateTransRegForm(requiredFieldArray, integerFieldArray, sinId, sinValidatedId, compNumId, reqLength)
{
	if(ValidateRequiredStrings(requiredFieldArray))
	{
		if(ValidateIntegerFields(integerFieldArray))
		{
			var companyNumber = document.getElementById(compNumId);
			if(companyNumber != null)
			{
				if(TrimString(companyNumber.value).length != reqLength)
				{
					alert("The Company # must be exactly " + reqLength + " characters long. Please correct and re-submit.");
					return false;
				}
				else
				{				
					var sinControl = document.getElementById(sinId);
					var sinValidate = document.getElementById(sinValidatedId);
					
					if(sinControl != null && sinValidate != null)
					{
						//alert("sinControl='" + sinControl.value + "', sinValidate='" + sinValidate.value + "'");
						if(TrimString(sinControl.value) == TrimString(sinValidate.value))
						{
							return true;
						}
						else
						{
							alert("The S.I.N. value has changed and has not been validated. Please click the validate button before saving your changes.");
							return false;
						}
					}
					else
					{
						alert("DEBUG MSG: Cannot validate form because a control cannot be found on this page!");
						return false;
					}
				}
			}
			else
			{
				alert("DEBUG MSG: Cannot validate form because a control cannot be found on this page!");
				return false;
			}
		}
	}
	
	return false;
}

//launchs a new small window to display the MAPPS rejection code for the passed Id
function LaunchRejectionCode(rejectionId)
{
	window.open("CoordinatorRejectionDesc.aspx?ID=" + rejectionId, "RejectionWindow", "height=115,width=260,resizable=no,menubar=no,toolbar=no,status=no");
	return false;
}

//launches a new IE window to display the passed report
function ShowReport(report)
{	
	window.open(report, "_blank", "");
	return false;
}

//launches a new IE window to display the help system
function ShowSageHelp()
{	
	window.open("help/default.htm", "sagehelpwindow", "menubar=no,toolbar=no,status=no,resizable=yes");
	return false;
}

//updates the padmount inspection form based on inspection type selection
function InspectionTypeToggle(specificPad, distRefId, taxId, mapId)
{
	var distRefTB = document.getElementById(distRefId);
	var taxDD = document.getElementById(taxId);
	var mapTB = document.getElementById(mapId);

	if(distRefTB != null && taxDD != null && mapTB != null)
	{
		if(specificPad == true)
		{
			distRefTB.disabled = false;
			distRefTB.readonly = false;
			distRefTB.style.backgroundColor = "#FFFFFF";
			
			taxDD.disabled = true;
			taxDD.style.backgroundColor = "#CCCCCC";
			mapTB.disabled = true;
			mapTB.value = "";
			mapTB.style.backgroundColor = "#CCCCCC";
		}
		else
		{
			distRefTB.disabled = true;
			distRefTB.style.backgroundColor = "#CCCCCC";
			distRefTB.value = "";
			
			taxDD.disabled = false;
			taxDD.style.backgroundColor = "#FFFFFF";
			mapTB.disabled = false;
			mapTB.style.backgroundColor = "#FFFFFF";
		}
	}
	
	return true;
}

//validates the input for the PadMount inspection form
function CustomValidateInspection(padRadioId, reqFieldArray1, reqFieldArray2, gridCdId)
{
	var padRadio = document.getElementById(padRadioId);
	if(padRadio != null)
	{ 
		if(padRadio.checked)
		{
			return ValidateRequiredStrings(reqFieldArray1);
		}
		else
		{
			if(ValidateRequiredStrings(reqFieldArray2))
			{
				var gridCdTB = document.getElementById(gridCdId);
				if(TrimString(gridCdTB.value).indexOf("%") > -1)
				{
					alert("The chosen Map Grid Code must either be 5 digits for a 1/4 mile grid or 4 digits for a 1 mile grid and cannot include a '%'.\n\nPlease correct and re-submit.");
					return false;
				}
				if(TrimString(gridCdTB.value).length >= 4)
				{
					return true;
				}
				else
				{
					alert("The chosen Map Grid Code must either be 5 digits for a 1/4 mile grid or 4 digits for a 1 mile grid.\n\nPlease correct and re-submit.");
					return false;
				}
			}
			else
			{
				return false;
			}
		}
	}
	else
	{
		alert("DEBUGMSG - Could not get a handle on the pad # radio.");
	}
	return false;
}

*/
