//validation of email address in contact form
function validEmail(email) {
	invalidChars = " /:,;"
	
	if (email == "") {// cannot be empty
				return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
	badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
			return false
		}
	periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {			// and at least one "." after the "@"
			return false
		}
		if (periodPos+3 > email.length)	{	// must be at least 2 characters after the "."
			return false
		}
	return true
}

//contact form validation
function validateMe() {
	var myFname = document.frmContact.txtFname;
	var myLname = document.frmContact.txtLname;
	//var myAddress = document.frmContact.txtAddress;
	//var myCity = document.frmContact.txtCity;
	//var myState = document.frmContact.cboStates[document.frmId.cboStates.selectedIndex];
	//var myZip = document.frmContact.txtZip;
	var myAreaCode = document.frmContact.txtAreaCode;
	var myExtension = document.frmContact.txtExtension;
	var myPhoneNumber = document.frmContact.txtPhoneNumber
	var myEmail = document.frmContact.txtEmail;
	var myMessage = document.frmContact.memMessage;
	
	if (myFname.value == ""){
		alert("Please enter your first name.");
		myFname.focus();
		return false;
		}
	if (myLname.value == ""){
		alert("Please enter your last name.");
		myLname.focus();
		return false;
		}
	/*if (myAddress.value == ""){
		alert("Please enter your street address.");
		myAddress.focus();
		return false;
		}
	if (myCity.value == ""){
		alert("Please enter your city.");
		myCity.focus();
		return false;
		}
	if (myState.value == ""){
		alert("Please select your state.");
		document.frmId.cboStates.focus();
		return false;
		}
	if (myZip.value == "" || isNaN(myZip.value) || myZip.value.length < 5){
		alert("Please enter a valid zip code.");
		myZip.focus();
		myZip.select();
		return false;
		}*/
	if (myAreaCode.value == "" || isNaN(myAreaCode.value) || myAreaCode.value.length < 3){
		alert("Please enter a valid area code.");
		myAreaCode.focus();
		myAreaCode.select();
		return false;
		}
	if (myExtension.value == "" || isNaN(myExtension.value) || myExtension.value.length < 3){
		alert("Please enter a valid phone extension.");
		myExtension.focus();
		myExtension.select();
		return false;
		}
	if (myPhoneNumber.value == "" || isNaN(myPhoneNumber.value) || myPhoneNumber.value.length < 4){
		alert("Please enter a valid phone number.");
		myPhoneNumber.focus();
		myPhoneNumber.select();
		return false;
		}
	if (!validEmail(myEmail.value)) {
	alert("Please enter a valid e-mail address");
	myEmail.focus();
	myEmail.select();
	return false;
	}
		if (myMessage.value == ""){
		alert('Please type a short message.');
		myMessage.focus();
		return false;
		}
	return true;
	}
	
	//anthology page buttons
	function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//slideshow
myPix=new Array("images/anthology/photo_01.jpg","images/anthology/photo_02.jpg","images/anthology/photo_03.jpg","images/anthology/photo_04.jpg","images/anthology/photo_05.jpg","images/anthology/photo_06.jpg","images/anthology/photo_07.jpg","images/anthology/photo_08.jpg","images/anthology/photo_09.jpg","images/anthology/photo_10.jpg","images/anthology/photo_11.jpg","images/anthology/photo_12.jpg","images/anthology/photo_13.jpg","images/anthology/photo_14.jpg","images/anthology/photo_15.jpg","images/anthology/photo_16.jpg","images/anthology/photo_17.jpg")

thisPic = 0

imgCt = myPix.length - 1

function chgSlide(direction) {
	if (document.images){
	thisPic = thisPic + direction
	if (thisPic > imgCt) {
		thisPic = 0
	}
	if (thisPic < 0) {
		thisPic = imgCt
	}
	document.myPicture.src=myPix[thisPic]
	}
}
