function vPhone(objField){
	var re
	var y = objField.id
	var x = document.all[objField.name]
	switch (y){
	case "Area Code":
	re = /^[0,1,2,3,4,5,6,7,8,9]{3}$/
	if (re.test(x.value) == false){
		alert("Invalid " + y + ". Must be three numbers like 123")
		document.abcapp[objField.name].value=""
		document.abcapp[objField.name].select()
		document.abcapp[objField.name].focus()
		return false	
	}
		break	
	case "Phone Number":
	re = /^[0,1,2,3,4,5,6,7,8,9]{3}[-][0,1,2,3,4,5,6,7,8,9]{4}$/
	if (re.test(x.value) == false){
		alert("Invalid " + y + " format should be like 123-1234")
		document.abcapp[objField.name].value=""
		document.abcapp[objField.name].select()
		document.abcapp[objField.name].focus()
		return false
	}
		break
	default:
		
}
}

function vZIP(objField) {
var valid = "0123456789-";
var hyphencount = 0;
x=objField.value

if (x.length!=5 && x.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code. format: 97045 or 97045-6789");
//document.abcapp[objField.name].value=""
document.abcapp[objField.name].select()
document.abcapp[objField.name].focus()
return false;
}
for (var i=0; i < x.length; i++) {
temp = "" + x.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
//document.abcapp[objField.name].value=""
document.abcapp[objField.name].select()
document.abcapp[objField.name].focus()
return false;
}
if ((hyphencount > 1) || ((x.length==10) && ""+x.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
//document.abcapp[objField.name].value=""
document.all[objField.name].select()
document.all[objField.name].focus()
return false;
   }
}
return true;
}

function vName(objField){
	var re
	var y = objField.name
	var x = document.all[y]
	re = /^([A-Za-z' -.]{1,25}|[.]{0,1})$/
	if(objField.value.length != 0){
		if (re.test(x.value) == false){
			alert("Invalid " + y)
			x.value = ""
			x.select()
			x.focus()
			return false
		}
		else{
			changeCase(objField)
		}
	}
	else{
		alert(y+" is required")
		x.select()
		x.focus()
		return false
	}
}

function getSelText()
{
var y = document.getElementById("BoardID")
document.abcapp["BoardName"].value = y.options[y.selectedIndex].text
}

function changeCase(objField) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = objField.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
objField.value = tmpStr;
}

function vMail() {
    if(-1 == document.abcapp.Email.value.indexOf("@")) { 
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus(); 
       alert("Invalid email address"); 
       return false; 
       }
    if(-1 != document.abcapp.Email.value.indexOf(",")) { 
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus(); 
       alert("Your email must not have a ',' in it"); 
       return false; 
       }
    if(-1 != document.abcapp.Email.value.indexOf("#")) { 
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus(); 
       alert("Your email must not have an '#' in it." ); 
       return false; 
       }
    if(-1 != document.abcapp.Email.value.indexOf("!")) { 
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus(); 
       alert("Your email must not have a '!' in it." ); 
       return false; 
       }
    if(-1 != document.abcapp.Email.value.indexOf(" ")) { 
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus(); 
       alert("Your email must not have a space in it." ); 
       return false; 
       }
    if(document.abcapp.Email.value.length == (document.abcapp.Email.value.indexOf("@")+1) ) {
       document.abcapp.Email.select(); 
       document.abcapp.Email.focus();
       alert("Invalid email address.");
       return false;
       }

    if(document.abcapp.Email.value.length == 0) { 
       document.abcapp.Email.select(); 
      document.abcapp.Email.focus(); 
      alert("Please enter your email."); 
      return false; 
      }

    return true;
  }


function refresh(){
location.reload()
}

function chkEmpty(tForm){
var mess = ""
var firstfield = ""
y = document.all[tForm.name]
x = (y.length)-1
for (i = 1; i <= x; i++){
if(y[i].type == "text"){
mess = mess + y[i].value
	if(firstfield == ""){
		firstfield = y[i].name
	}
}
if((y[i].id != "HeightFT" && y[i].id != "HeightIN" && y[i].id != "State") && (y[i].type == "select-one")){
mess = mess + y[i].value
}
}
if(mess == ""){
var empty = confirm("Form is empty, do you want to exit without saving?")
	if (empty == true){
		document.location = 'ccadmin.asp'
	}
	else{
		y[firstfield].select()
		y[firstfield].focus()
		return false
	}
}
}

function chkNotEmpty(tForm){
var mess = ""
var firstfield = ""
y = document.all[tForm]
x = (y.length)-1

for (i = 1; i <= x; i++){
if(y[i].type == "text"){
mess = mess + y[i].value
	if(firstfield == ""){
		firstfield = y[i].name
	}
}
if((y[i].id != "HeightFT" && y[i].id != "HeightIN" && y[i].id != "State") && (y[i].type == "select-one")){
mess = mess + y[i].value
}
}
if(mess != ""){
var empty = confirm("Form is not empty, do you want to exit without saving?")
	if (empty == true){
		document.location = 'ccadmin.asp'
	}
	else{
		y[firstfield].select()
		y[firstfield].focus()
		return false
	}
}
else{
	document.location = 'abc.asp'
}
}

function reqInput(objField){
x=objField.name
y=objField.id
if(document.abcapp[x].value==""){
	alert(y+" is required")
	document.abcapp[x].select()
	document.abcapp[x].focus()
	return false
}
}

function chkPage(sPage){
formname = sPage.name
switch (formname){
	case "abcapp":
		if(document.abcapp.FirstName.value == ""){
			alert("First Name is required")
			document.abcapp.FirstName.select()
			document.abcapp.FirstName.focus()
			return false
		}
		if(document.abcapp.LastName.value == ""){
			alert("Last Name is required")
			document.abcapp.LastName.select()
			document.abcapp.LastName.focus()
			return false
		}
		if(document.abcapp.Street.value == ""){
			alert("Street address is required")
			document.abcapp.Street.select()
			document.abcapp.Street.focus()
			return false
		}
		if(document.abcapp.City.value == ""){
			alert("City is required")
			document.abcapp.City.select()
			document.abcapp.City.focus()
			return false
		}
		if(document.abcapp.State.value == ""){
			alert("State is required")
			document.abcapp.State.focus()
			return false
		}		
		if(document.abcapp.Zip.value == ""){
			alert("Zip code is required")
			document.abcapp.Zip.select()
			document.abcapp.Zip.focus()
			return false
		}
		if(document.abcapp.HCode.value == ""){
			alert("Home area code is required")
			document.abcapp.HCode.select()
			document.abcapp.HCode.focus()
			return false
		}
		if(document.abcapp.HPhone.value == ""){
			alert("Home phone number is required")
			document.abcapp.HPhone.select()
			document.abcapp.HPhone.focus()
			return false
		}
		if(document.abcapp.BoardID.value == 0){
			alert("Commission name is required")
			document.abcapp.BoardID.focus()
			return false
		}
}
}

function spChars(objField){
sText = ""
if(objField.value != ""){
	sText = objField.value
	if(objField.id == "CondList"){
 		while(sText.indexOf("\n") != -1){
 	 		sText = sText.replace("\n","<li>")
 		}
 	sText = "<li>" + sText 
	}
	else{
 		while(sText.indexOf("\n") != -1){
 	 		sText = sText.replace("\n","<br>")
 		}
	}
}
return sText
}

function getStatus(objField){
fID = objField.name
switch (fID){
	case "Last Name":
		window.status = "Enter last name."
		break
	case "First Name":
		window.status = "Enter first name."
		break
	case "MI":
		window.status = "Enter Middle initial."
		break
	case "Job":
		window.status = "Enter current occupation"
		break
	case "Street":
		window.status = "Enter home street address"
		break
	case "City":
		window.status = "Enter home city name."
		break
	case "State":
		window.status = "Select home state from drop down list."
		break
	case "Zip":
		window.status = "Enter 5 digit or 5 digit+4 home ZIP code"
		break
	case "Employer":
		window.status = "Enter employer name."
		break
	case "Position":
		window.status = "Enter position or title."
		break
	case "BStreet":
		window.status = "Enter businsess address"
		break
	case "BCity":
		window.status = "Enter business city name."
		break
	case "Business State":
		window.status = "Select business state from drop down list."
		break
	case "BZip":
		window.status = "Enter 5 digit or 5 digit+4 business ZIP code"
		break
	case "Area Code":
		window.status = "Enter area code for phone number."
		break
	case "Phone Number":
		window.status = "Enter phone number"
		break
	case "Email":
		window.status = "Enter full email address"
		break
	case "Commission":
		window.status = "Select Board or Commission from drop down list."
		break
	case "ComInt":
		window.status = "Enter community interest."
		break
	case "Background":
		window.status = "Enter all experience and educational background."
		break
	case "Reason":
		window.status = "Enter reasons for interest."
		break
	case "Serve":
		window.status = "Enter name of Boards or Commissions served."
		break
	case "Refer":
		window.status = "Enter name of reference."
		break
	case "Title":
		window.status = "Enter your business title"
		break
	default:
		window.status = "Advisory Boards and Commissions"
		break
}
      objField.select()
}

