  /* crossarrow - www.crossarrow.co.uk */
	
	
/* JAVASCRIPT STARTS HERE */


//VALIDATION FUNCTIONS FOR THE ALERT BOX ERROR REPORTING.

			function validateFirstName(myForm) 
			{
//Test to check Family Name is just letters.  Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			reFirstName = /^(\D+)$/
			if (reFirstName.test(myForm))
				return true;
						 else
        return false;
			}
						
			function validateSurname(myForm) 
			{
//Test to check Surname is just letters.  Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			reSurname = /^(\D+)$/
			if (reSurname.test(myForm))
				return true;
						 else
        return false;
			}
			
			
			function validateEmail(myForm) 
			{
//Test to check Email address input is correct.  Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			reEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
			if (reEmail.test(myForm))
				return true;
						 else
        return false;
				}
				
function validatePnumber(myForm) 
			{
//Test to check Email address input is correct.  Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			rePnumber = /^\(?[0](\d{3,4})\)?[ -]?(\d{3,6})[ -]?(\d{4})?$/
			if (rePnumber.test(myForm))
				return true;
						 else
        return false;
				}

function validatePassword1(myForm) 
			{
//Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			rePassword1 = /^(\w{3})(\w{0,7})$/
			if (rePassword1.test(myForm))
				return true;
						 else
        return false;
			}
			
function validatePassword2(myForm) 
			{
//Uses regular 
//expression below to test pattern and puts up alert box if incorrect.
			rePassword2 = /^(\w{3})(\w{0,7})$/
			if (rePassword2.test(myForm))
				return true;
						 else
        return false;
			}





// ALERT BOX FORM VALIDATIONS: The function is called from the form, which 
//then calls the appropriate validation functions. If false an alert appears.
// First is the family Name followed by Phone Number then Email address.

			function validateForm(myForm) 
			{
			if (validateFirstName(myForm.FirstName.value) == false) 
			{
				 alert("Please enter your first name.");
				 							 myForm.FirstName.focus();
				 							 myForm.FirstName.select();
			return false;
		}
		
			 
			if (validateSurname(myForm.Surname.value) == false) 
			{
				 alert("Please enter your surname.");
				 							 myForm.Surname.focus();
				 							 myForm.Surname.select();
			return false;
		}
			
											
			if (validateEmail(myForm.Email.value) == false) 
			{
				 alert("Sorry your email address does not seem right!  please try again.");
				 							myForm.Email.focus();
				 							myForm.Email.select();
			return false;
		}
		   if (validatePnumber(myForm.Pnumber.value) == false) 
			{
				 alert("Sorry your phone number does not seem right!  please try again.");
				 							myForm.Pnumber.focus();
				 							myForm.Pnumber.select();
			return false;
		}
		if (validatePassword1(myForm.Password1.value) == false) 
			{
				 alert("Sorry your password needs to be more than 3 or more characters but not more than 10.  please try again.");
				 							myForm.Password1.focus();
				 							myForm.Password1.select();
			return false;
		}
		if (validatePassword2(myForm.Password2.value) == false) 
			{
				 alert("Sorry your password confirmation does not match.  please try again.");
				 							myForm.Password2.focus();
				 							myForm.Password2.select();
			return false;
		}
					return true;
}
			
//FORM VALIDATIONS END HERE

/* Javascript for the slideshow. */

//This creates an array of the images.
	 var myPix = new Array("picture1.jpg","picture2.jpg","picture3.jpg","picture4.jpg","picture5.jpg","picture6.jpg","picture7.jpg");
//This sets the beginning value in the code. 
	 var thisPic = 0;
//This is the number of elements in the array, making it easy to add more pictures later. The -1 is set to one less than the true value is the Javascript begins at 0
	 var imgCt = myPix.length - 1;
//This creates an array of the texts to go with the images.
   var captionText = new Array("The Baptisms at New Hall on the 1st October 2006. Here is Cass! Use the next and previous keys below to move the slide on.","Aaron...(I think!)....","Those being baptised and helpers.","....the moment!","Simon's big moment and Tony barely getting his toes wet!!","Nicky's turn..","...If you would like to get baptised contact the church office on 01245 354695. Thanks to Simon Moston for the photographs.")
// This operates the number of elements in the words array making it easier to add new slides or words later.
	 var imgCt = captionText.length;
	
	
//The function to create the slideshow with parameter to declare the direction.
	function newSlide(direction)  
	 {
//Check browser understands images
		if (document.images) 
		{
//thisPic, which starts at 0 is set to it's own value plus the direction parameter.
			thisPic = thisPic + direction;
//If the pic is less than 0.
			 if (thisPic < 0)
			 {
//Sets the value of this pic to the imgCt -1.
				thisPic = imgCt-1;
			 }
//If it was less than 0 then set imgCt.
				if (thisPic == imgCt)
			  {
// setting picture to 0
				 thisPic = 0;
			 }
//Starts the pictures by stating the document and the HTM name
			document.slideshow.src =myPix[thisPic];
// Starts the words to go with the slides.
			document.imgForm.imgText.value = captionText[thisPic];
		}
	}
	 
/* This script is based on scripts in the book JavaScript for the World Wide Web: 
Negrino & Smith.  The script is a combination of script 5.6 Building Wraparound Slideshows
and 16.6 A slideshow with captions. */
/* JAVASCRIPT ENDS HERE */