total1=0;
total2=0;
function calcTotal(obj){
	for (x=0; x<obj.elements.length; x++){
		if(obj.elements[x].value=="Academy Registration" && obj.elements[x].checked==true){
			total1=135;
		}
		if(obj.elements[x].value=="Spouse or Parent" && obj.elements[x].checked==true){
			total1=100;
		}
		if(obj.elements[x].value=="Addl Band Member or CoSongwriter" && obj.elements[x].checked==true){
			total1=95;
		}
		if(obj.elements[x].name=="CompeteType0" && obj.elements[x].checked==true){
			total2=total2+50;
		}
		if(obj.elements[x].name=="CompeteType1" && obj.elements[x].checked==true){
		total2=total2+50;
		}
		if(obj.elements[x].name=="CompeteType2" && obj.elements[x].checked==true){
		total2=total2+50;
		}
		if(obj.elements[x].name=="CompeteType3" && obj.elements[x].checked==true){
		total2=total2+50;
		}
	}
	obj.Total.value=total1+total2;
}

function areEqual(fld1, fld2)
{
	var string1, string2;

	string1 = fld1.value;
	string2 = fld2.value;
	if (string1 != string2)
	{
		if (fld1.type == "password")
		{
			alert ("Passwords entered do not match.\nPlease retype.");
		}
		else if (fld1.type == "text")
		{
			alert ("E-mail addresses entered do not match.\nPlease retype.");
		}
		fld1.value = ""
		fld2.value = ""
		fld1.focus()
	}
}

function StripChars(theField)
{
	var strOut,i,curChar
	var theFilter;

	strOut = ""
	theFilter = "*() -./_\n\r";
	for (i=0;i < theField.length; i++)
	{		
		curChar = theField.charAt(i)
		if (theFilter.indexOf(curChar) < 0)	// if it's not in the filter, send it thru
			strOut += curChar		
	}	
	return strOut
}


function stripChar(str, chars) {
var i
var newstring = ""
for (i = 0; i < str.length; i++) {
mychar = str.charAt(i)
if (chars.indexOf(mychar) == -1)
newstring += mychar
}
return newstring
}




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 ValidateEmail(theField)
{
	var msg = "";
	var theString = "";
	var msgInvalid = "Please enter a valid Email Address."

	theString = theField.value;

	if (theString != "")
	{
		if ((theString.indexOf("@") < 1) || (theString.indexOf(".") >= (theString.length-2)) || (theString.indexOf(".") < 0) || (theString.indexOf(".") < theString.indexOf('@'))){
			msg = msgInvalid;
		}
		if (msg != "")
		{
			alert(msg);
			theField.value = '';
			theField.focus();
			return false;
		}else{
			return true;
		}
	}else{
		alert(msgInvalid);
		theField.value = '';
		theField.focus();
		return false;
	}
}

function ValidateUSPhone(theField)
{
	var msg = "";
	var theString = "";
	var msgInvalid = "Please enter a valid 9 digit U.S. phone number without parenthesis or dashes.\nExample: (760) 555-1212 should be 7605551212"

	theString = theField.value;

	if (theString != "")
	{
		theString = StripChars(theString)		

		if (!AllInRange("0","9",theString))
		{
			msg = msgInvalid;
		}
		else if (theString.length == 11)
		{
			 if (theString.charAt(0) != "1")	
				msg = msgInvalid
		}
		else if (theString.length != 10 && theString.length != 7)
		{
			msg = msgInvalid
		}

		if (msg == "")
		{
			if (theString.length == 10)
				theString = reformat(theString,"(",3,") ",3,"-",4);
			else if (theString.length == 7)
				theString = reformat(theString,"",3,"-",4);
			else //len == 11
				theString = reformat(theString,"",1,"(",3,") ",3,"-",4);

			theField.value = theString;
		}
		else
		{
			alert(msg);
			theField.value="";
			theField.focus();
		}
	}
}

function Require(obForm,szFields)
{
	var fields = szFields.split(",");

	for (x=0; x<obForm.elements.length; x++)
	{
		for (y=0; y<fields.length;y++)
		{
			if ((obForm.elements[x].name == fields[y]) && (obForm.elements[x].value == ""))
			{
				alert("Please make sure that all required fields are filled in before continuing.");
				obForm.elements[x].focus();
				return false;
			}
		}
	}
	return true;
}

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("The 'Page Complete' field at the bottom of the form was not selected. You may be getting this alert because you accidentally hit the ENTER key instead of TAB while trying to move to the next field. Please make sure your information is complete and resubmit this page!")
return false
}
else
return true
}

function validateZIP(field) {
	if (field.value.length!=5){
		alert("Please enter your 5 digit zip code.");
		field.value='';
		field.focus();
		return false;
	}
	for(i=0;i<field.value.length;i++){
		if(isNaN(field.value.charAt(i))){
			alert("Please enter a valid zip!");
			field.value='';
			field.focus();
			return false;
		}
	}
}

function checkRadio(obj){
	singleoption=-1;
	waiveroption=-1;
	for(i=0;i<obj.SingleRegType.length;i++){
		if(obj.SingleRegType[i].checked){
			singleoption=i;
		}
	}
	
	if(singleoption==-1){
		alert("Please go back to the top to choose a registration type.")
		return false
		
		
	}
	
	for(i=0;i<obj.Waiver.length;i++){
		if(obj.Waiver[i].checked){
			waiveroption=i;
		}
	}
	
	if(waiveroption==-1){
		alert("You haven't chosen an agreement");
		return false		
	}
}

function isLength(field,field_name) {
	if (field.length != "")
	{
		if (field.length<4) {
			msg = "Please enter at least 4 numbers or letters."
			alert(msg);
			field_name.value="";
			field_name.focus();
			return false;
		}
		return true;
	}
}

function show_bas_major(){			
		document.form1.major.disabled=false;
		document.form1.concentration1.value="";
		document.form1.concentration2.value="";
		document.form1.concentration1.disabled=true;
		document.form1.concentration2.disabled=true;					
		document.form1.major.options[0]=new Option("Select One",true);		
		document.form1.major.options[1]=new Option("Art","Art");
		document.form1.major.options[2]=new Option("Christian_Ministries","Christian Ministries");
		document.form1.major.options[3]=new Option("Communication","Communication");
		document.form1.major.options[4]=new Option("Computer_Information_Science","Computer Information Science");
		document.form1.major.options[5]=new Option("Criminal_Justice","Criminal Justice");
		document.form1.major.options[6]=new Option("Health_Care_Management","Health Care Management");
		document.form1.major.options[7]=new Option("Interdisciplinary_Studies","Interdisciplinary Studies");
		document.form1.major.options[8]=new Option("Psychology","Psychology");
		document.form1.major.options[9]=new Option("Sociology","Sociology");			
}

function show_bbs_major(){	
		document.form1.major.disabled=false;
		document.form1.concentration1.value="";
		document.form1.concentration2.value="";
		document.form1.concentration1.disabled=true;
		document.form1.concentration2.disabled=true;					
		document.form1.major.options[0]=new Option("Select One",true);		
		document.form1.major.options[1]=new Option("Accounting","Accounting");
		document.form1.major.options[2]=new Option("Business_Administration","Business Administration");
		document.form1.major.options[3]=new Option("Finance","Finance");
		document.form1.major.options[4]=new Option("Management","Management");
		document.form1.major.options[5]=new Option("Management_Information_Systems","Management Information Systems");
		document.form1.major.options[6]=new Option("Marketing","Marketing");
		document.form1.major.options[7]=new Option("","");
		document.form1.major.options[8]=new Option("","");
		document.form1.major.options[9]=new Option("","");			
}

function enable_textbox(){
	document.form1.concentration1.disabled=false;
	document.form1.concentration2.disabled=false;					
	document.form1.major.options[0]=new Option("","");
	document.form1.major.options[1]=new Option("","");
	document.form1.major.options[2]=new Option("","");
	document.form1.major.options[3]=new Option("","");
	document.form1.major.options[4]=new Option("","");
	document.form1.major.options[5]=new Option("","");
	document.form1.major.options[6]=new Option("","");
	document.form1.major.options[7]=new Option("","");
	document.form1.major.options[8]=new Option("","");
	document.form1.major.options[9]=new Option("","");
	document.form1.major.disabled=true;
	
}
