function swap(imgName,imgFile) {
 	document.images[imgName].src = imgFile;
}


function confirmSubmit(email){
   	var x=0;
	var email_str = '';
	for(i=0; i <  email.elements['del_records[]'].length; i++ ) {
		if(email.elements['del_records[]'][i].checked){
			x++;
   			email_str += "\n" + x + ")   " + email.elements['del_records[]'][i].value + ""; 
		}
	}
	var agree=confirm("Are you sure you to delete the email: "+email_str )
	agree = (agree)?true:false;
	return agree; 
}

/****** Form Validation  *******/
// version:		v.3.1
// author: 		Joel Pittet
// email: 		joel@joelpittet.com
// company: 	Applied Communications
// date: 		March 5, 2003
// licence: 	free to use under the following conditions

//********** CONDITIONS *********//
// Please leave above comments in when copying this code and if improved on 
// send it back to my email with your name so I can add your contribution to the internet 
//*******************************//

// Function used by checker to check fields against their custom regular expressions
function checkField( formName, fieldName, testChars, personalMessage ) {
	var fieldValue = eval( "document."+formName+"."+fieldName+".value" );
	var regResult = testChars.test( fieldValue );
	if (!regResult) { message += "\n     -  "+personalMessage; } 
	return regResult;
}

// Initializing Checker Variables
var message = "Please complete all required fields to ensure your request is received.";
var errors = 0;
// Generic Regular Expressions
var testCharsAll 				= /^([a-zA-Z0-9_\.\-# ])+(.){2,80}/;
var testCharsEmail  			= /^([a-zA-Z0-9_\.\- ])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]){2,4}$/;
var testCharsPhone  			= /^([0-9\-\(\).])+(.){7,17}/;
var testCharsNumbers  			= /^([0-9\-\(\)\. ]){3,24}/;
var testCharsLetters  			= /^([a-zA-Z\- ]){2,50}/;
var testCharsLettersNumbers  	= /^([a-zA-Z0-9\.\-# ]){2,80}/;

// onSubmit Checker Functions for each form to be checked  
// eg. onsubmit="return checkForm();"
function checkForm() {
	var formName = "reservations_form";
	if (checkField(formName, "customer_name", testCharsLetters, "Name") == 0)	{ errors = 1; }
	if (checkField(formName, "customer_email", testCharsEmail, "Email") == 0) 	{ errors = 1; }
	if (checkField(formName, "customer_phone", testCharsPhone, "Phone") == 0)	{ errors = 1; }
	return createAlert();
}

function checkEmail() {
	var formName = "subscribe_form";
	if ( checkField(formName, "email", testCharsEmail, "Email Address") == 0 )	{ errors = 1; }
	return createAlert();
}

// Supplementry Functions
function createAlert() {
	var alertError = errors;
	if (alertError) { alert(message); }
	
	// Reset global variables
	errors = 0;
	message = "Please complete all required fields to ensure your request is received.";
	
	// Return error to the checker to stop form
	if (alertError) { 
		return false;
	} else {
		return true;
	}
}

