//start text area character counter
function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
        countfield.value = maxlimit - field.value.length;
}

function textCounter2(field1, field2, field3, countfield, maxlimit) {
    countfield.value = field1.value.length + field2.value.length + field3.value.length;
}

// **************************************
function showSaveMessage() {
	alert("Please note: after saving this page, be sure to click Submit for Approval button.");
}

// **************************************
function deleteNews(which) {

	var agree=confirm("Are you sure you want to delete this news item?\n\nThis action cannot be undone!");
	if (agree)
		return true ;
	else
		return false ;
}

// ##############################
function validateZip(field) {
var valid = "0123456789"
var ok1 = "yes";
var ok2 = "yes";
var temp;
if (field.value.length == 0) {
} else {
	for (var i=0; i<field.value.length; i++) {
	temp = "" + field.value.substring(i, i+1);
	if (valid.indexOf(temp) == "-1") ok1 = "no";
	}
	if (field.value.length == 5) {
	} else {
	  ok2 = "no";
	}
	if (ok1 == "no") {
	alert("Invalid entry!  Only numbers are accepted!");
    field.value = "";
	field.focus();
	field.select();
	   }
	if (ok2 == "no") {
	alert("Field must contain five numbers");
	field.value = "";
	field.focus();
	field.select();
	   }
	}
}

// **************************************
function showNotSelectable(which) {

	var agree=confirm("This class is not orderable based on your membership type.");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function deleteAsset(which) {

	var agree=confirm("Are you sure you want to delete this asset?\n\nThis action cannot be undone.");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function addToCart(which) {

	var agree=confirm("Are you sure you want to add this program to your shopping cart?\n");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function removeFromCart(which) {

	var agree=confirm("Are you sure you want to remove this program from your shopping cart?\n");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function closeForm(which) {

	var agree=confirm("Are you sure you want to close this window?\n\nYour form data must be saved prior to closing this window\n\nClick Cancel to go back and save information.\n\nClick OK to close without saving.");
	if (agree) {
		refreshParent();
	} else {
		return false ;
    }
}

// **************************************
function closeFormPage(which,pageID) {

	var agree=confirm("Are you sure you want to close this window?\n\nYour form data must be saved prior to closing this window\n\nClick Cancel to go back and save information.\n\nClick OK to close without saving.");
	if (agree) {
		refreshParentPage(pageID);
	} else {
		return false ;
    }
}

// **************************************
function closeForm730(which) {

	var agree=confirm("Are you sure you want to close this window?\n\nYour form data must be saved prior to closing this window\n\nClick Cancel to go back and save information.\n\nClick OK to close without saving.");
	if (agree) {
		refreshParent730();
	} else {
		return false ;
    }
}

// **************************************
function removeYForm(which) {

	var agree=confirm("Are you sure you want to remove this form from your selected list?\n");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function programSearch350a(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="branchID" && tempobj.value=='X') {
			fieldlist = "Location";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function programSearch350b(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="ageGroupID" && tempobj.value=='X') {
			fieldlist = "Age Group";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}


// **************************************
function programSearch350c(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="pnnbr" && tempobj.value=='X') {
			fieldlist = "Class";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}


// **************************************
function programSearch273(which) {

var pass=true;
fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";
 
    var pc1cod = document.form99.PC1COD.value;  
    var pnnbr = document.form99.pnnbr.value;

    if (pc1cod=='X' && pnnbr=='') {
        alert("You must select a Program Type or enter a Program Code");
        return false;
    } else {
        if (pnnbr!='') {
            var valid = "0123456789"
            var ok1 = "yes";
            var ok2 = "yes";
            var temp;
            for (var i=0; i<pnnbr.length; i++) {
                temp = "" + pnnbr.substring(i, i+1);
                if (valid.indexOf(temp) == "-1") ok1 = "no";
            }
            if (pnnbr.length == 5) {
            } else {
                ok2 = "no";
            }
            if (ok1 == "no") {
                alert("Invalid entry!  Only numbers are accepted!");
                document.form99.pnnbr.focus();
                document.form99.pnnbr.select();
                return false;
            }
            if (ok2 == "no") {
                alert("Field must contain five numbers");
                document.form99.pnnbr.focus();
                document.form99.pnnbr.select();
                return false;
            }
        } else {   
            return true;
        } 
    }        
}

// **************************************
function clearFld(which) {
    document.form99.pnnbr.value='';
}


// **************************************
function programSearch864(which) {

var pass=true;
fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";
 
    var pnnbr = document.form99.pnnbr.value;
    var branchID = document.form99.branchID[document.form99.branchID.selectedIndex].value;
	var PC1COD1 = document.form99.PC1COD[0].checked;
	var PC1COD2 = document.form99.PC1COD[1].checked;
	var PC1COD3 = document.form99.PC1COD[2].checked;
	var PC1COD4 = document.form99.PC1COD[3].checked;
	var PC1COD5 = document.form99.PC1COD[4].checked;
	var PC1COD6 = document.form99.PC1COD[5].checked;
	var PC1COD7 = document.form99.PC1COD[6].checked;
	var ageGroupID1 = document.form99.ageGroupID[0].checked;
	var ageGroupID2 = document.form99.ageGroupID[1].checked;
	var ageGroupID3 = document.form99.ageGroupID[2].checked;
	var ageGroupID4 = document.form99.ageGroupID[3].checked;
	var ageGroupID5 = document.form99.ageGroupID[4].checked;
	var ageGroupID6 = document.form99.ageGroupID[5].checked;
	var startTimeID1 = document.form99.startTimeID[0].checked;
	var startTimeID2 = document.form99.startTimeID[1].checked;
	var startTimeID3 = document.form99.startTimeID[2].checked;
	var startTimeID4 = document.form99.startTimeID[3].checked;
	var startTimeID5 = document.form99.startTimeID[4].checked;
	var startTimeID6 = document.form99.startTimeID[5].checked;
	var startTimeID7 = document.form99.startTimeID[6].checked;
	var startTimeID8 = document.form99.startTimeID[7].checked;

    if (pnnbr=='' || pnnbr=='Enter Program Code') {
        if (branchID=='X' || 
            (PC1COD1==false && PC1COD2==false && PC1COD3==false && PC1COD4==false && PC1COD5==false && PC1COD6==false && PC1COD7==false) ||
            (ageGroupID1==false && ageGroupID2==false && ageGroupID3==false && ageGroupID4==false && ageGroupID5==false && ageGroupID6==false) ||
            (startTimeID1==false && startTimeID2==false && startTimeID3==false && startTimeID4==false && startTimeID5==false && startTimeID6==false && startTimeID7==false && startTimeID8==false)) {
            alert("Please select all search fields (1-4) or enter a program code");
            return false;
        }
    } else {
        if (pnnbr!='' && pnnbr!='Enter Program Code') {
            var valid = "0123456789"
            var ok1 = "yes";
            var ok2 = "yes";
            var temp;
            for (var i=0; i<pnnbr.length; i++) {
                temp = "" + pnnbr.substring(i, i+1);
                if (valid.indexOf(temp) == "-1") ok1 = "no";
            }
            if (pnnbr.length == 5) {
            } else {
                ok2 = "no";
            }
            if (ok1 == "no") {
                alert("Invalid entry!  Only numbers are accepted!zz");
                document.form99.pnnbr.focus();
                document.form99.pnnbr.select();
                return false;
            }
            if (ok2 == "no") {
                alert("Field must contain five numbers");
                document.form99.pnnbr.focus();
                document.form99.pnnbr.select();
                return false;
            }
        } else {   
            return true;
        } 
    }        
}

// **************************************
function programSearch274(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="ageGroupID" && tempobj.value=='X') {
			fieldlist = "Age Group";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}


// **************************************
function programSearch275(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="startTimeID" && tempobj.value=='X') {
			fieldlist = "Start Time";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function programSearch276(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="branchID" && tempobj.value=='X') {
			fieldlist = "Location/Area";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredSelectClasses(whichForm,whichCheckBoxArray,myMax,myMin,whichQuestion)
/*
  This function takes 5 paramaters:
  whichForm -- the NAME of the form to be validated, a string
  whichCheckBoxArray -- the NAME of the checkbox to be checked, a string
  myMax -- the most you want the user to be able to check, an integer
  myMin -- the least you want the user to be able to check, an integer
  whichQuestion -- a short description of the question, a string
  
  example use:
  howManyChecked('myform','cb_industry',6,1,'Industry');
*/
{

    var _countChecked = 0;
    var err = 0;

    var numCheckboxes = document[whichForm][whichCheckBoxArray].length;
    if (numCheckboxes>1) {
    } else {
        numCheckboxes = 1;
    }    
    /* iterate through all the elements in the checkbox array */
    if (numCheckboxes==1) {
        if (document.form99.selectedLineitems.checked) {
            _countChecked++;
        } else {
        }    
    } else {  
        for(i=0;i<numCheckboxes;i++)
        {
	        /* and check to see if each is checked */
	        if(document.form99.selectedLineitems[i].checked==true)
		        /* if it is, increment a counter */
		        { _countChecked++; }
        }
    }
    /* is the count too high? */
    if(_countChecked > myMax) { 
        alert('Too many classes selected.');
        return false; 
    }
    /* of is the count too low */
    else if(_countChecked < myMin) { 
	    alert('You must choose at least one Class.');
        return false; 
    }

}


// **************************************
function checkrequiredEnterPayment(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "paymentTypeID" && tempobj.value == 'X') {
                fieldlist = "Payment Type";
                pass = false;
                break;
            }
            if (tempobj.name == "ccTypeID" && tempobj.value == 'X') {
                fieldlist = "Credit Card Type";
                pass = false;
                break;
            }
            if (tempobj.name == "ccNumber" && tempobj.value == '') {
                fieldlist = "Credit Card Number";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpMon" && tempobj.value == 'X') {
                fieldlist = "Credit Card Expiration Month";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpYear" && tempobj.value == 'X') {
                fieldlist = "Credit Card Expiration Year";
                pass = false;
                break;
            }
            if (tempobj.name == "ccThreeDigit" && tempobj.value == '') {
                fieldlist = "Three-Digit Security Code";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else
        return true;
}


// **************************************
function checkrequiredVendors(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";

    var edi1 = document.form1.edi[0].checked;
    var edi2 = document.form1.edi[1].checked;

    var centralInvoice1 = document.form1.centralInvoice[0].checked;
    var centralInvoice2 = document.form1.centralInvoice[1].checked;

    var minority1 = document.form1.minority[0].checked;
    var minority2 = document.form1.minority[1].checked;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "vendorName" && tempobj.value == '') {
                fieldlist = "Company Name";
                pass = false;
                break;
            }
            if (tempobj.name == "ownerName" && tempobj.value == '') {
                fieldlist = "CEO/Owner Name";
                pass = false;
                break;
            }
            if (tempobj.name == "address1" && tempobj.value == '') {
                fieldlist = "Address 1";
                pass = false;
                break;
            }
            if (tempobj.name == "city" && tempobj.value == '') {
                fieldlist = "City";
                pass = false;
                break;
            }
            if (tempobj.name == "stateID" && tempobj.value == 'X') {
                fieldlist = "State";
                pass = false;
                break;
            }
            if (tempobj.name == "zip" && tempobj.value == '') {
                fieldlist = "Zip Code";
                pass = false;
                break;
            }
            if (tempobj.name == "phone" && tempobj.value == '') {
                fieldlist = "Main Phone #";
                pass = false;
                break;
            }
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Order Processing Email";
                pass = false;
                break;
            }
            if (tempobj.name == "contactName" && tempobj.value == '') {
                fieldlist = "Primary Contact Name";
                pass = false;
                break;
            }
            if (tempobj.name == "contactTitle" && tempobj.value == '') {
                fieldlist = "Primary Contact Title";
                pass = false;
                break;
            }
            if (tempobj.name == "contactPhone" && tempobj.value == '') {
                fieldlist = "Primary Contact Phone #";
                pass = false;
                break;
            }
            if (tempobj.name == "contactCell" && tempobj.value == '') {
                fieldlist = "Primary Contact Cell #";
                pass = false;
                break;
            }
            if (tempobj.name == "contactEmail" && tempobj.value == '') {
                fieldlist = "Primary Contact Email";
                pass = false;
                break;
            }
            if (tempobj.name == "insuranceCarrier" && tempobj.value == '') {
                fieldlist = "Insurance Carrier";
                pass = false;
                break;
            }
            if (tempobj.name == "salesVolume" && tempobj.value == '') {
                fieldlist = "Projected volume for the current year";
                pass = false;
                break;
            }
            if (tempobj.name == "salesVolume1" && tempobj.value == '') {
                fieldlist = "Projected volume for the last year";
                pass = false;
                break;
            }
            if (tempobj.name == "brandNames" && tempobj.value == '') {
                fieldlist = "Brand Name(s)";
                pass = false;
                break;
            }
        }
    }

    if (edi1 == false && edi2 == false) {
        alert("Please select an EDI option");
        return false;
    }

    if (centralInvoice1 == false && centralInvoice2 == false) {
        alert("Please select a central invoice option");
        return false;
    }

    if (minority1 == false && minority2 == false) {
        alert("Please select a minority or women owned business option");
        return false;
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else
        return true;
}


// **************************************
function checkrequiredReferralForm(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "firstName" && tempobj.value == '') {
                fieldlist = "First Name";
                pass = false;
                break;
            }
            if (tempobj.name == "lastName" && tempobj.value == 'X') {
                fieldlist = "Last Name";
                pass = false;
                break;
            }
            if (tempobj.name == "memberNumber" && tempobj.value == '') {
                fieldlist = "Member Number";
                pass = false;
                break;
            }
            if (tempobj.name == "address" && tempobj.value == '') {
                fieldlist = "Address";
                pass = false;
                break;
            }
            if (tempobj.name == "phone" && tempobj.value == '') {
                fieldlist = "Phone";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else
        return true;
}


// **************************************
function checkrequiredSummerReferralForm(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#f1f12c';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "firstName" && tempobj.value == '') {
                fieldlist = "First Name";
                pass = false;
                break;
            }
            if (tempobj.name == "lastName" && tempobj.value == 'X') {
                fieldlist = "Last Name";
                pass = false;
                break;
            }
            if (tempobj.name == "address" && tempobj.value == '') {
                fieldlist = "Address";
                pass = false;
                break;
            }
            if (tempobj.name == "phone" && tempobj.value == '') {
                fieldlist = "Phone";
                pass = false;
                break;
            }
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "E-Mail";
                pass = false;
                break;
            }
            if (tempobj.name == "ymcaBranch" && tempobj.value == '') {
                fieldlist = "YMCA Branch or Program Location";
                pass = false;
                break;
            }
            if (tempobj.name == "friendFirstName" && tempobj.value == '') {
                fieldlist = "Referral First Name";
                pass = false;
                break;
            }
            if (tempobj.name == "friendLastName" && tempobj.value == 'X') {
                fieldlist = "Referral Last Name";
                pass = false;
                break;
            }
            if (tempobj.name == "friendAddress" && tempobj.value == '') {
                fieldlist = "Referral Address";
                pass = false;
                break;
            }
            if (tempobj.name == "friendPhone" && tempobj.value == '') {
                fieldlist = "Referral Phone";
                pass = false;
                break;
            }
            if (tempobj.name == "friendEmail" && tempobj.value == '') {
                fieldlist = "Referral E-Mail";
                pass = false;
                break;
            }
            if (tempobj.name == "friendRelationship" && tempobj.value == '') {
                fieldlist = "Relationship";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else
        return true;
}


// **************************************
function checkrequiredMemberLogin(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";
 
    var email = document.form99.email.value;
    var birthDate = document.form99.birthDate.value;
    var phone = document.form99.phone.value; 

    if ((email=='' && birthDate=='' && phone=='') || (email=='' && birthDate=='' && phone!='') || (email=='' && birthDate!='' && phone=='') || (email!='' && birthDate=='' && phone=='')) {
        alert("You must enter two or three fields.");
        return false;
    }
    if (email!='') {
        if (echeck(email)==false) {
            return false;
        }
    }
    if (phone!='') {
        if (validatePhone(phone)==false) {
            return false;
        }
    }      
    return true;   
}

// **************************************
function checkrequiredBranchLogin(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="login" && tempobj.value=='') {
			fieldlist = "Login";
			pass=false;
			break;
		}
		if (tempobj.name=="password" && tempobj.value=='') {
			fieldlist = "Password";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredFormProperties(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="pageName" && tempobj.value=='') {
			fieldlist = "Form Name";
			pass=false;
			break;
		}
		if (tempobj.name=="navName" && tempobj.value=='') {
			fieldlist = "Name Displayed on Web Site";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredBranchSchedule(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="scheduleTypeID" && tempobj.value=='X') {
			fieldlist = "Schedule Type";
			pass=false;
			break;
		}
		if (tempobj.name=="uploadFile1" && tempobj.value=='') {
			fieldlist = "PDF File";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredLogin(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="login" && tempobj.value=='') {
			fieldlist = "Login";
			pass=false;
			break;
		}
		if (tempobj.name=="password" && tempobj.value=='') {
			fieldlist = "Password";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredEmail(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "E-Mail";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkrequiredRegistration(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#f1f12c';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="title" && tempobj.value=='X') {
			fieldlist = "Title";
			pass=false;
			break;
		}
		if (tempobj.name=="firstName" && tempobj.value=='') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="lastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="birthDate" && tempobj.value=='') {
			fieldlist = "Birth Date";
			pass=false;
			break;
		}
		if (tempobj.name=="address" && tempobj.value=='') {
			fieldlist = "Address";
			pass=false;
			break;
		}
		if (tempobj.name=="street" && tempobj.value=='') {
			fieldlist = "Street";
			pass=false;
			break;
		}
		if (tempobj.name=="city" && tempobj.value=='') {
			fieldlist = "City";
			pass=false;
			break;
		}
		if (tempobj.name=="stateID" && tempobj.value=='X') {
			fieldlist = "State";
			pass=false;
			break;
		}
		if (tempobj.name=="zip" && tempobj.value=='') {
			fieldlist = "Zip";
			pass=false;
			break;
		}
		if (tempobj.name=="homePhone1" && tempobj.value=='') {
			fieldlist = "Home Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="homePhone2" && tempobj.value=='') {
			fieldlist = "Home Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="homePhone3" && tempobj.value=='') {
			fieldlist = "Home Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name=="emergencyContact" && tempobj.value=='') {
			fieldlist = "Emergency Contact Name";
			pass=false;
			break;
		}
		if (tempobj.name=="emergencyContactPhone" && tempobj.value=='') {
			fieldlist = "Emergency Contact Phone";
			pass=false;
			break;
		}
		if (1==2) {
		    if (tempobj.name=="title2" && tempobj.value=='X') {
			    fieldlist = "Title";
			    pass=false;
			    break;
		    }
		    if (tempobj.name=="firstName2" && tempobj.value=='') {
			    fieldlist = "First Name";
			    pass=false;
			    break;
		    }
		    if (tempobj.name=="lastName2" && tempobj.value=='') {
			    fieldlist = "Last Name";
			    pass=false;
			    break;
		    }
		    if (tempobj.name=="birthDate2" && tempobj.value=='') {
			    fieldlist = "Birth Date";
			    pass=false;
			    break;
		    }
	    }
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}

// **************************************
function checkAll(field) 
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

// **************************************
function uncheckAll(field) 
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

// **************************************
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

// **************************************
function validate(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.value="";
field.focus();
field.select();
   }
}

// **************************************
function validate2(field) {
var valid = "0123456789."
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.value="";
field.focus();
field.select();
   }
}

// **************************************
function validateProgramNumber(field) {
var valid = "0123456789"
var ok1 = "yes";
var ok2 = "yes";
var temp;
if (field.value.length == 0) {
} else {
	for (var i=0; i<field.value.length; i++) {
	temp = "" + field.value.substring(i, i+1);
	if (valid.indexOf(temp) == "-1") ok1 = "no";
	}
	if (field.value.length == 5) {
	} else {
	  ok2 = "no";
	}
	if (ok1 == "no") {
	alert("Invalid entry!  Only numbers are accepted!");
	field.focus();
	field.select();
    return false;
	   }
	if (ok2 == "no") {
	alert("Field must contain five numbers");
	field.focus();
	field.select();
    return false;
	   }
	}
}


// **************************************
function validatePhone(str) {
var valid = "0123456789-"
var ok1 = "yes";
var ok2 = "yes";
var temp;
if (str.length == 0) {               // no phone entered
} else {
	for (var i=0; i<str.length; i++) {
	    temp = "" + str.substring(i, i+1);
	    if (valid.indexOf(temp) == "-1") ok1 = "no";
	    if ((i==3 || i==7) && str.substring(i,i+1)!="-") {
	        alert("Invalid entry!  Format must be: nnn-nnn-nnnn");
	        return false;
	    }  
	}
	if (str.length == 12) {             // must be xxx-xxx-xxxx
	} else {
	      ok2 = "no";
	}
	if (ok1 == "no") {
	    alert("Invalid entry!  Only numbers are accepted!");
        return false;
   }
	if (ok2 == "no") {
        alert("Phone number field must use be entered in xxx-xxx-xxxx format");
        return false;
   }
	}
}


// **************************************
function validateChars(field,chars) {
	if (field.value.length < chars) {
		alert("Entry must be at least "+chars+" characters");
		field.focus();
		field.select();
   }
}

// **************************************
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 19xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '19' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      DateField.select();
	  DateField.focus();
   }
}

// **************************************
function check_date2(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      DateField.value="";
      DateField.select();
	  DateField.focus();
   }
}

// **************************************
function ClearOptionsspecialtySearch(OptionList) {

   // Always clear an option list from the last entry to the first
   for (x = OptionList.length; x >= 0; x = x - 1) {
      OptionList[x] = null;
   }
}

// **************************************
function gtpage(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=no,'
        var p7 = 'scrollbars=no,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }

// **************************************
function gtpage2(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=yes,'
        var p7 = 'scrollbars=yes,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }


// **************************************
function gtpage3(url,frname,height,width) {

var left = Math.floor((screen.availWidth - 950) / 2);
var top = Math.floor((screen.availHeight - 750) / 2);

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=yes,'
        var p7 = 'scrollbars=yes,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+','
        var p10 = 'height='+height+','
        var p11 = 'left='+left+','
        var p12 = 'top='+top+';'
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10+p11+p12;
        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }


// **************************************
	function printpage() {
	window.print();
	}
	
// **************************************
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid e-mail address entered")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid e-mail address entered")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid e-mail address entered")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 return true					
}

// **************************************
function Left(str, n)
/***
        IN: str - the string we are LEFTing
            n - the number of characters we want to return

        RETVAL: n characters from the left side of the string
***/
{
        if (n <= 0)     // Invalid bound, return blank string
                return "";
        else if (n > String(str).length)   // Invalid bound, return
                return str;                // entire string
        else // Valid bound, return appropriate substring
                return String(str).substring(0,n);
}

// ###################################
function MM_goToURL_removeEvent() { //v3.0
	var agree=confirm("Are you sure you want to remove this item?\n\nThis action cannot be undone!");
	if (agree) {
      var i, args=MM_goToURL_removeEvent.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
		return false ;
    }
}

// ###################################
function MM_goToURL_deleteEvent() { //v3.0
	var agree=confirm("Are you sure you want to delete this item?\n\nThis action cannot be undone!");
	if (agree) {
      var i, args=MM_goToURL_deleteEvent.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
		return false ;
    }
}
