function confirmleaving(newlink)
{
	alert("YOU ARE LEAVING THE COMMUNITY TRUST BANK WEB SITE.\n\nThe Web site you have selected is an external one located on another server. Community Trust Bank has no responsibility for any external web site. It neither endorses the information, content, presentation, or accuracy nor makes any warranty, express or implied, regarding any external site.");
	window.location=(newlink);
}

function emailalert(newlink)
{
	alert("Warning about E-mail\n\nInformation that is transmitted by e-mail over the Internet is not secure and can be intercepted and read by other Internet users. Please be aware that sending confidential information by unencrypted email is considered unsafe and you do so at your own risk. Community Trust Bank will not use e-mail to transmit responses that contain private or confidential information on an individual.");
	window.location=(newlink);
}

function preloadImages()
{
	if(document.images)
	{
		var loadedImages = new Array;
		for(arg=0;arg<preloadImages.arguments.length;arg++)
		{
			loadedImages[arg] = new Image;
            loadedImages[arg].src = preloadImages.arguments[arg];
		}
	}
}

function imageSwap(daImage, daSrc)
{
	if(document.images)
	{
		if (typeof daImage == 'string' || typeof daImage == 'number')
		{
			document.images[daImage].src = daSrc;
		}
		
		else if (daImage && daImage.src)
		{
			daImage.src = daSrc;
		}
	}
}

function Popup(title,filename,w,h,scroll,resizable,menubar) {
	title = (title == '') ? 'popup' : title;
	scroll = (scroll == 'scroll') ? 'yes' : 'no';
	resizable = (resizable == 'lock') ? 'no' : 'yes';
	menubar = (menubar == 'menu') ? 'yes' : 'no';

	winOptions = eval("'width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar="+menubar+",scrollbars="+scroll+",resizable="+resizable+",copyhistory=no'");
	w = window.open(filename,title,winOptions)
	if (!w) {
		alert("\nAn important message could not be displayed because a popup blocker was detected.\nPlease set your blocker to allow popups for this site and refresh this page.");
		return false;
	}
}

function ValidateForm()
{
	if (!MoreInfo.firstname.value)
	{
		alert("Please enter your First Name.");
		MoreInfo.firstname.focus();
		MoreInfo.firstname.select();
		return false;
	}
	
	else if (!MoreInfo.lastname.value)
	{
		alert("Please enter your Last Name.");
		MoreInfo.lastname.focus();
		MoreInfo.lastname.select();
		return false;
	}
	
	else if (!validEmail(MoreInfo.email.value))
	{
		alert("Please enter your valid Email Address.");
		MoreInfo.email.focus();
		MoreInfo.email.select();
		return false;
	}
	
	else if (!MoreInfo.daytime_tel.value)
	{
		alert("Please enter your Daytime Telephone Number.");
		MoreInfo.daytime_tel.focus();
		MoreInfo.daytime_tel.select();
		return false;
	}

	else if (!MoreInfo.address.value)
	{
		alert("Please enter your Street Address.");
		MoreInfo.address.focus();
		MoreInfo.address.select();
		return false;
	}

	else if (!MoreInfo.city.value)
	{
		alert("Please enter your City.");
		MoreInfo.city.focus();
		MoreInfo.city.select();
		return false;
	}

	else if (!MoreInfo.zip.value)
	{
		alert("Please enter your Zip Code.");
		MoreInfo.zip.focus();
		MoreInfo.zip.select();
		return false;
	}

	return true;
}

function validEmail(email)
{
	var emailReg = /^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$/;
	var regex = new RegExp(emailReg);
	return regex.test(email.toLowerCase());
}