function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		pre_yum_o = newImage('Buttons/yum_o.jpg'); // Dont need this It is a small image
		preloadFlag = true;   // Need this it sets the flag for changeImagesArray()
	}
}
////////////////////////////////////////////////////////////////////////////////
/////////////////////////// from ted B site
var num;
var dly;
var j =1;
var a_on = 0  // auto_on indicator 0=off, 1=On
var dly_change = 0

function m_over (n) {   // Mouse over on Index Page
document.images["picwin"].src= "m"+n + ".jpg";
}

function m_out() {document.images["picwin"].src= "m1.jpg";} // Mouse out  on Home page return to map1
function step() {
if (j<max) 
   {j++}
 else {j = 1}
document.images["picwin"].src= "P"+j + ".jpg";
////////////////////////////////document.Dbug.debug.value = "picture # " +j + " of " + max

}
function step_back(){
if(j > 1){
j =j - 1;}
else{j=max}
document.images["picwin"].src= "P"+ j + ".jpg";
//////////////////////////document.Dbug.debug.value = "picture # " + j + " of " + max;
}

function setup() {j = 1;   // Initalization "ONLOAD"
//  max=10;
///////////////////////////////////////document.Dbug.debug.value = "picture # " + "1"+ " of " + max;
dly = 3000;  // Initial speed
}

function auto_on() {
a_on=1;
if (dly_change == 0){j++}
///////////////////////////document.Dbug.debug.value = "picture # " + j + " of " + max;
document.images["picwin"].src= "P"+ "2" + ".jpg";

auto_id=setInterval('step()',dly)
}

function auto_off() {
a_on=0;
clearInterval(auto_id);
}

function set_dly(m){
document.Dbug.debug.value = "got it " + m;
if(a_on == 1) {
    document.Dbug.debug.value ="a_on is ON";
    auto_off()
    dly = m*1000;
    dly_change = 1;
    auto_on();
    dly_change = 0;
	}
else{dly = m*1000;  // Auto Mode is off
      document.Dbug.debug.value ="dly= "  + dly;
	}
}
// Script for email Validation
//**************************************************************************
var valid ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_ '";

function validate()
{
	var email = document.emailform.email.value;
	//Reference Wev Sites\varification code
	


	//var reason = document.emailform.reason.value;
	var name = document.emailform.full_name.value;
	//var middle = document.emailform.middle.value;
	//var last = document.emailform.last.value;
	//var challenge = document.frmAllowMe.challenge.value;
	var regx = /^[A-Za-z0-9\@\+=%\\'\?\^!\$(\);\"&]+[\w\.\@\+=%\\'\?\^!\$(\);\"&-_]*@[A-Za-z0-9\@\+=%\\'\?\^!\$\(\);\"&]+[\w\.\@\+=%\\'\?\^!\$\(\);\"&-]*\.[\w\.\@\+=%\\'\?\^!\$\(\);\"&-]+$/;

	if (name.length ==0)
	{
		alert("Your Name is required.");
		document.emailform.full_name.focus();
		return false;
	}

	for (j = 0; j < name.length; j++) {
		if (valid.indexOf(name.charAt(j)) == -1)
		{
			alert("Your Name contains invalid characters (only A-Z, a-z, ', - and _ are supported.)");
			document.emailform.full_name.focus();
			return false;
		}
	}
//*********************************************************************************************
	if (email.length ==0)
	{
		alert("Your Email Address is Required.");
		document.emailform.email.focus();
		return false;
	}

	if ((email != "") && (!isValidEmailAddress(email, regx)))
	{
		alert("The email address you entered is not valid. Please re-enter a valid email address.");
		document.emailform.email.focus();
		return false;
	}

	alert("Your Message has been sent");
	return true;

}



//****************************************************************************
// Script for custom alert box 
/***************************************************************************

	Custom Alert Demonstration
	version 1.0
	last revision: 02.02.2005
	steve@slayeroffice.com

	Should you improve upon this source please
	let me know so that I can update the version
	hosted at slayeroffice.

	Please leave this notice in tact!
	http://slayeroffice.com/code/custom_alert

************************************/

// constants to define the title of the alert and button text.
var ALERT_TITLE = "Notice!";
var ALERT_BUTTON_TEXT = "Ok";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	// shortcut reference to the document object
	d = document;

	// if the modalContainer object already exists in the DOM, bail out.
	if(d.getElementById("modalContainer")) return;

	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.documentElement.scrollHeight + "px";

	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	// center the alert box
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

	// create an H1 element as the title bar
	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	// create a paragraph element to contain the txt argument
	msg = alertObj.appendChild(d.createElement("p"));
	msg.appendChild(d.createTextNode(txt));

	// create an anchor element to use as the confirmation button.
	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	// set up the onclick event to remove the alert when the anchor is clicked
	btn.onclick = function() { removeCustomAlert();return false; }

	
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
// END of Custom Alert Script