// Support Script (694)
function AddToValidateArray(strElementName)
{
    var strName = strElementName

    if (!document.ValidateArray) 
    {
        document.ValidateArray = new Array
    }

    document.ValidateArray[document.ValidateArray.length] = strName
}

// Support Script (582)
function ValidateNonBlank()
{
  var msg = "";
  var val = this.getText();  

  if (StripChars(" \n\t\r",val).length == 0)
  {
    if (Trim(this.ErrorMsg) != "")
      msg = "Required field. " + this.ErrorMsg
    else
      msg = "Required field. Please enter an appropriate value."
  }

  return msg;
}

// Support Script (695)
function StripChars(theFilter,theString)
{
	var strOut,i,curChar

	strOut = ""
	for (i=0;i < theString.length; i++)
	{		
		curChar = theString.charAt(i)
		if (theFilter.indexOf(curChar) < 0)	// if it's not in the filter, send it thru
			strOut += curChar		
	}	
	return strOut
}

function AllInRange(x,y,theString)
{
	var i, curChar
	
	for (i=0; i < theString.length; i++)
	{
		curChar = theString.charAt(i)
		if (curChar < x || curChar > y) //the char is not in range
			return false
	}
	return true
}


function reformat (s)
{
    var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) 
           resultString += arg;
       else 
       {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function Trim(theString)
{
 var i,firstNonWhite

 if (StripChars(" \n\r\t",theString).length == 0 ) return ""

	i = -1
	while (1)
	{
		i++
		if (theString.charAt(i) != " ")
			break	
	}
	firstNonWhite = i
	//Count the spaces at the end
	i = theString.length
	while (1)
	{
		i--
		if (theString.charAt(i) != " ")
			break	
	}	

	return theString.substring(firstNonWhite,i + 1)

}
// Support Script (575)
function ValidateNumChars()
{	
	var theString = this.getText()
	var MinLength = this.MinLength
	var MaxLength = this.MaxLength
	var msgInvalid = ""

	if (StripChars(" \n\t\r",this.ErrorMsg).length == 0)
	{
				
		if (MinLength == 1 && MaxLength == 1)		
			msgInvalid = "Please enter a value one character long."		
		else if (MinLength > 1 && MaxLength == MinLength)		
			msgInvalid = "Please enter a value " + MinLength + " characters long."				
		else if (MinLength > 0 && MaxLength > 0)		
			msgInvalid = "Please enter a value between\n" + MinLength + " and " + MaxLength + " characters long."		
		else if (MinLength == 1)		
			msgInvalid = "Please enter a value at least one character long."
		else if (MinLength > 1)
			msgInvalid = "Please enter a value at least " + MinLength + " characters long."
		else if (MaxLength == 1)		
			msgInvalid = "Please enter a value no more than one character long."
		else if (MaxLength > 1)
			msgInvalid = "Please enter a value no more than " + MaxLength + " characters long."		
 	else
	 	msgInvalid = this.ErrorMsg	

	}
	else
		msgInvalid = this.ErrorMsg	


	if (StripChars(" \n\r",theString).length == 0)	
		if (!this.Required) return ""		
		else return "Required field.  " + msgInvalid

	theString = Trim(theString)

	if (this.StripSpaces)
		theString = StripChars(" \n\r",theString)

	if (MinLength > 0 && theString.length < MinLength)
		return msgInvalid

	if (MaxLength > 0 && theString.length > MaxLength)
		return msgInvalid

	// we passed the tests
	this.setText(theString)

	return ""
}
// Support Script (688)
function Validate(stopOnFailure)
{
	var ErrorMsg = "";
	var i
	var msg
	var tofocus = true;
	var ErrorMsg = "";
	
	// Go through the Validate Array that may or may not exist
	// and call the Validate function for all elements that have one.
	if (document.ValidateArray)
	{
		for (i = 0; i < document.ValidateArray.length; i ++)
		{
			msg = eval( document.ValidateArray[i] + ".Validate()")
			if (msg != "")
			{
				ErrorMsg += "\n\n" + document.ValidateArray[i] + ":  " + msg;
				if (tofocus) 
				{
					eval(document.ValidateArray[i] + ".focus()")
					tofocus = false;
				}
				
				if (stopOnFailure == "1") return ErrorMsg;
			}
  	}
  }
	return ErrorMsg;
}

function document_onLoad() {
Recordset1_LastName.Validate=ValidateNonBlank;
Recordset1_LastName.ErrorMsg = "Last Name cannot be blank."
AddToValidateArray("Recordset1_LastName")
Recordset1_Password.ErrorMsg = "Password length must be 4- 10 characters ...";
Recordset1_Password.MaxLength = Number("10");
Recordset1_Password.MinLength = Number("4");
Recordset1_Password.StripSpaces = Number("0");
Recordset1_Password.Required = Number("1");
Recordset1_Password.Validate = ValidateNumChars;
AddToValidateArray("Recordset1_Password")
Recordset1_FirstName.Validate=ValidateNonBlank;
Recordset1_FirstName.ErrorMsg = "First Name cannot be left blank."
AddToValidateArray("Recordset1_FirstName")
Recordset1_FirstName.focus();
 }
function document_onUnLoad() {
SaveCookieInfo(RegFindCookie);
 }
function Form1_onSubmit() {
errorMsg = Validate("0"); // don't stop on first error

if (errorMsg != "")
    alert("The form could not be submitted:" + errorMsg);

return (errorMsg == ""); // false prevents form submission
 }
function _Form1_onSubmit() { if (Form1) return Form1.onSubmit(); }
function FormButton1__onClick() {
if ("http://www.bbs4kids.com".length > 0)
    document.location.href="http://www.bbs4kids.com";
else
    document.location.href="Home.asp";
 }
function _FormButton1__onClick() { if (FormButton1) return FormButton1.onClick(); }


