// JavaScript Document

<!-- Hide from old browsers

//Required Field Validator--------------------------------------------------------------------->

function verify() {
var themessage = "Please complete the following fields: ";
if (document.dcparentform.student1.value !== "" && document.dcparentform.stu1_school.value == "") {
	themessage = themessage + " - School Information for Student 1";
	document.dcparentform.stu1_school.focus();
}
if (document.dcparentform.student2.value !== "" && document.dcparentform.stu2_school.value == "") {
	themessage = themessage + " - School Information for Student 2";
	document.dcparentform.stu2_school.focus();
}
if (document.dcparentform.student3.value !== "" && document.dcparentform.stu3_school.value == "") {
	themessage = themessage + " - School Information for Student 3";
	document.dcparentform.stu3_school.focus();
}
if (document.dcparentform.student4.value !== "" && document.dcparentform.stu4_school.value == "") {
	themessage = themessage + " - School Information for Student 4";
	document.dcparentform.stu4_school.focus();
}
//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following fields: ") {
	//document.dcparentform.submit();
	//document.dcparentform.submit.focus();
}
else {
	alert(themessage)
	return false;
   }
}
//  End -->



// FIRST FORM FIELD FOCUS----------------------------------------------------->
<!-- Original:  Tom Khoury (twaks@yahoo.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}
//  End -->

//Adds the load event ---
function addLoadEvent(func) {

  var oldonload = window.onload;

  if (typeof window.onload != 'function') {

    window.onload = func;

  } else {

    window.onload = function() {

      oldonload();

      func();

    }

  }

}

 
addLoadEvent(placeFocus);

// ASSURES PROPER CASE FOR FORM FIELDS SUBMITTED----------------------------------------------------->
function PCase(STRING){
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}
var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();
for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter).toLowerCase();
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 32 || iChar == 45 || iChar == 46){
UcaseNext = true;
}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}

} //End For

return strReturn_Value;
} //End Function


// Formats phone numbers----------------------------------------------------->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Roman Feldblum (web.developer@programmer.net) -->

<!-- Begin
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.register.Phone.value="";
	document.register.Phone.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.register.Phone.value="";
		document.register.Phone.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.register.Phone.value="";
	pp="("+p13+")"+p14+p15;
	document.register.Phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.register.Phone.value="";
	document.register.Phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
//  End -->

// auto tab ssn fields----------------------------------------------------->
/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/

function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}
//  End -->