<!-- Begin

// Check required fields

<!-- Copyright 2003 Bontrager Connection, LLC
// Code obtained from http://WillMaster.com/
//
// Each required form field can be checked with JavaScript. Here are 
//    the function names for the different kinds of checks:
//
//       1. WithoutContent() -- check if the text, textarea, password, 
//              or file fields has no content.
//       2. NoneWithContent() -- check if none of the set of text, 
//              textarea, password, or file fields have content. 
//              (Set: More than one with the same field name.)
//
//       3. NoneWithCheck() -- check if none of the set of radio buttons 
//              or checkboxes are checked. (Set: More than one with the 
//              same field name.)
//       4. WithoutCheck() -- check if the single radio button or checkbox 
//              is unchecked.
//
//       5. WithoutSelectionValue() -- check if selected drop-down list or 
//              select box entries have no value.
//
//
// The format for using the above functions is
//             if(       WithoutContent([FORMFIELDVALUE])) [ERRORMESSAGE]
//             if(      NoneWithContent([FORMFIELD])     ) [ERRORMESSAGE]
//             if(        NoneWithCheck([FORMFIELD])     ) [ERRORMESSAGE]
//             if(         WithoutCheck([FORMFIELD])     ) [ERRORMESSAGE]
//             if(WithoutSelectionValue([FORMFIELD])     ) [ERRORMESSAGE]
//
// The if(...) part and the error message part may be on separate lines, like
//             if(WithoutContent([FORMFIELDVALUE]))
//                [ERRORMESSAGE]
//             if(NoneWithContent([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(NoneWithCheck([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(WithoutCheck([FORMFIELD]))
//                [ERRORMESSAGE]
//             if(WithoutSelectionValue([FORMFIELD]))
//                [ERRORMESSAGE]
//
//
//      FORMFIELD -- The format for specifying a "form field" is 
//                         document.[FORMNAME].[FIELDNAME]
// FORMFIELDVALUE -- The format for specifying a "form field value" is 
//                         document.[FORMNAME].[FIELDNAME].value
//   ERRORMESSAGE -- The format for specifying an "error message" is
//                         { errormessage += "\n\n[MESSAGE]"; }
//                   If the message itself contains quotation marks, 
//                      they must be preceded with a back slash. 
//                      Example: \"
//
//
//      FORMNAME -- The name assigned to the form in the <FORM... tag. 
//     FIELDNAME -- The field name being checked.
// 
//
// For use with this JavaScript, the only non-alphanumeric character a 
//    fieldname may have is the underscore. Replace any hyphens, colons, 
//    spaces, or other non-alphanumeric characters in your field names 
//    with an underscore character.
//
//
// Put field checks into the function CheckRequiredFields(), in the order 
//    you want the fields checked.
//


function CheckRequiredFields(input) {
var errormessage = new String();
// Put field checks below this point.

//if(WithoutSelectionValue(document.referral.Referring_Provider))
//	{ errormessage += "\n\nPlease select a Referring Provider from the dropdown list."; }

	// Check Text Fields
	if (checkRequiredFields_text(input) != true)
	{
//		errormessage += "\n\nBlahblahblah";
		return false;
	}

// Put field checks above this point.
if(errormessage.length > 2) {
	alert('NOTE:' + errormessage);
	return false;
	}
	
//return true;
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

function NoneWithContent(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].value.length > 0) { return false; }
	}
return true;
}

function NoneWithCheck(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function WithoutCheck(ss) {
if(ss.checked) { return false; }
return true;
}

function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) {
		if(ss[i].value.length) { return false; }
		}
	}
return true;
}

//-->

//=Validate fields and send Form if OK or generate proper alert message=====
function checkRequiredFields_text(input)
{
    var requiredFields = new Array("First_Name", "Last_Name", "City", "State", "Zip", "Phone", "Email");

    // TEXT TO DISPLAY THAT DESCRIBES THE MISSING FIELD(S) TO THE USER
    var fieldNames = new Array("First Name", "Last Name", "City", "State", "Zip", "Phone", "Email");


    // YOU SHOULD NOT NEED TO MAKE ANY CHANGES BELOW THIS POINT ------

    var fieldCheck   = true;
    var fieldsNeeded = "A value must be entered in the following field(s):\n\n";

    for(var fieldNum=0; fieldNum < requiredFields.length; fieldNum++) {
        if ((input.elements[requiredFields[fieldNum]].value == "") ||
            (input.elements[requiredFields[fieldNum]].value == " ")) {

//            if (requiredFields.length == fieldNum) {
            	fieldsNeeded += fieldNames[fieldNum] + "\n";
//            }
//           else {
//             	fieldsNeeded += fieldNames[fieldNum] + ",\t";
//            }
            fieldCheck = false;
        }
    }

    // ALL REQUIRED FIELDS HAVE BEEN ENTERED
    if (fieldCheck == true)
    {
        return true;
    }
    // SOME REQUIRED FIELDS ARE MISSING VALUES
    else
    {
        alert(fieldsNeeded);
        return false;
    }
}

// Reset form
function reset_form()  
{
	window.document.referral.reset();
}

function resetAllForms (windowOrLayer) {
  if (!windowOrLayer)
    windowOrLayer = window;
  if (document.forms.length>0){
  for (var f = 0; f < document.forms.length; f++)
        windowOrLayer.document.forms[f].reset();
  }
  if (document.layers){
    for (var l = 0; l < windowOrLayer.document.layers.length;l++ )
       resetAllForms(windowOrLayer.document.layers[l]);
  }
}
//-->

//  End -->