﻿// (Don't touch the next line; it declares the image array.)

var Pic = new Array





Pic[0] = '../images/frmsubbutton.gif'

Pic[1] = '../images/frmsubbutton_on.gif'

Pic[2] = '../images/frmsubbutton_down.gif'

Pic[3] = '../images/frmresetbutton.gif'

Pic[4] = '../images/frmresetbutton_on.gif'

Pic[5] = '../images/frmresetbutton_down.gif'





// ----------------------------------------------------------------------

// This section of code preloads the images you named in the Pic[] array

// above, so images will be ready as soon as the page opens.



var p = Pic.length

var preLoad = new Array()

var i = 0;

for (i = 0; i < p; i++){

     preLoad[i] = new Image()

     preLoad[i].src = Pic[i]

}





function switchImage(whichImage,imageNumber){

   document.images[whichImage].src = preLoad[imageNumber].src

}



//Proper Case a Form String

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 PCase





//Requires the entry to be a number

function anumber(string) {

    if (!string) return false;

    var Chars = "0123456789";



    for (var i = 0; i < string.length; i++) {

       if (Chars.indexOf(string.charAt(i)) == -1)

          alert('Entry must be numeric');

          return false;

    }

    return true;

} //End Function



function validateIForm() {

      //-- Check name, email, news field, reject if blank.

      if (document.frmIVisit.FirstName.value=="") {

        alert("Please fill in the Name field!");

        document.frmIVisit.FirstName.focus();

	return;

      }

      if (document.frmIVisit.LastName.value=="") {

        alert("Please fill in the Name field!");

        document.frmIVisit.LastName.focus();

	return;

      }

	var num = document.frmIVisit.HomePhone.value.replace(/[^\d]/g,'');

    if(num.length != 10) {

        //Alert the user that the phone number entered was invalid.

        alert('Please enter a valid phone number including area code (10 digits)');

        document.frmIVisit.HomePhone.focus();                   

	return;

	  }

    if (document.frmIVisit.Email.value=="") {

        alert("Please fill in your E-mail address!");

        document.frmIVisit.Email.focus();

	return;

      }

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;

	if(!(document.frmIVisit.Email.value.length == 0) && !document.frmIVisit.Email.value.match(emailExp)) {

		alert("Invalid email format!");

		document.frmIVisit.Email.focus();

	 return;

	}

		  //-- The statement below actually submits the form, if all OK.

        document.frmIVisit.submit();

return;

}



function validateGForm() {

      //-- Check name, email, news field, reject if blank.

      if (document.frmGVisit.FirstName.value=="") {

        alert("Please fill in the Name field!");

        document.frmGVisit.FirstName.focus();

	return;

      }

      if (document.frmGVisit.LastName.value=="") {

        alert("Please fill in the Name field!");

        document.frmGVisit.LastName.focus();

	return;

      }

	var num = document.frmGVisit.HomePhone.value.replace(/[^\d]/g,'');

    if(num.length != 10) {

        //Alert the user that the phone number entered was invalid.

        alert('Please enter a valid phone number including area code (10 digits)');

        document.frmGVisit.HomePhone.focus();                   

	return;

	  }

	var num = document.frmGVisit.SPhone.value.replace(/[^\d]/g,'');

    if(num.length != 10) {

        //Alert the user that the phone number entered was invalid.

        alert('Please enter a valid phone number including area code (10 digits)');

        document.frmGVisit.SHomePhone.focus();                   

	return;

	  }

	  

    if (document.frmGVisit.Email.value=="") {

        alert("Please fill in your E-mail address!");

        document.frmGVisit.Email.focus();

	return;

      }

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;

	if(!(document.frmGVisit.Email.value.length == 0) && !document.frmGVisit.Email.value.match(emailExp)) {

		alert("Invalid email format!");

		document.frmGVisit.Email.focus();

	 return;

	}

    if (document.frmGVisit.SEmail.value=="") {

        alert("Please fill in your E-mail address!");

        document.frmGVisit.SEmail.focus();

	return;

      }

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;

	if(!(document.frmGVisit.SEmail.value.length == 0) && !document.frmGVisit.SEmail.value.match(emailExp)) {

		alert("Invalid email format!");

		document.frmGVisit.SEmail.focus();

	 return;

	}

		  //-- The statement below actually submits the form, if all OK.

        document.frmGVisit.submit();

return;

}






