function validEmail(emailField) {
  email = emailField.value;
  if (email == "") {     //must contain something
    alert("Email address is empty")
    emailField.focus();
	return false
  }
  invalid = " /;,:"
  for (i=0; i<invalid.length; i++){   //cannot contain these characters
    bad = invalid.charAt(i)
    if (email.indexOf(bad,0) > -1){
      alert("Email address contains invalid characters")
      emailField.focus();
      return false
    }
  }
  atPos = email.indexOf("@",0)  //must have a @ character
  if (atPos == -1){
    alert("Email address is missing the @ character")
    emailField.focus();
    return false
  }
  if (atPos == 0){   //cannot start with @ character
    alert("Email address cannot start with the @ character")
    emailField.focus();
    return false
  }
  if (email.indexOf("@",atPos+1) != -1){  //can only have ONE @ character
    alert("Email address contains more than one @ character")
    emailField.focus();
    return false
  }
  dotPos = email.indexOf(".",atPos+1)  //must have a . character after the @
  if (dotPos == -1){
    alert("Email address must have a . character following the @ character")
    emailField.focus();
    return false
  }
  if (dotPos == 0){   //cannot start with . character
    alert("Email address cannot start with the . character")
    emailField.focus();
    return false
  }
  if ((dotPos-atPos) == 1){
    alert("Email address has no characters between the @ and . characters")
    emailField.focus();
    return false    
  }
  if (dotPos+3 > email.length){   //must have at least 2 characters after .
    alert("Email address must have at least two characters following the dot")
    emailField.focus();
    return false
  }        
}


function goBack()
{
  if (history.length > 0)
  {history.back()}
}


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_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_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];
    if(!x.oSrc) x.oSrc=x.title; x.title=a[i+4];
   }
}


function hideLayer(layerNum) {
	var v;
	if(obj=MM_findObj(layerNum)){
		if (obj.style){
			obj=obj.style; v='hidden';
		}
		else{
			v='hide';
		}
		obj.visibility=v;
	}
}


function showLayer(layerNum) {
	var v;
	if (obj=MM_findObj(layerNum)){
		if (obj.style){
			obj=obj.style; v='visible';
		}
		else{
			v='show';
		}
		obj.visibility=v;
	}
}


function openWin(url,wn,w,h,l,t,s,r,tb){
	//alert('url='+url+',wn='+wn+',width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+s+',resizable='+r+',toolbar='+tb)
	newWindow = window.open(url,wn,'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+s+',resizable='+r+',toolbar='+tb )
	newWindow.focus()
}


function addToFavorites(){
	if (window.external){
		// if the browser is IE open the add favorite window
		external.AddFavorite(location.href,document.title)
	}
	else{
		alert("Sorry, your browser doesn't support this feature.\nPlease use the bookmark feature of your browser to save the location of this page.");
	}
}


function tellaFriend(){
	openWin('tellafriend.asp?url='+document.URL,'tella',250,470,300,200,'no','yes','no');
}



//--- LAYER MANIPULATION CODE

function expand(d){
	document.getElementById(d).style.display = "block";
	eval("document.getElementById('" + d + "OFF').style.display = 'none';");
}


function contract(d){
	document.getElementById(d).style.display = "none";
	eval("document.getElementById('" + d + "OFF').style.display = 'block';");
}


//-- Gallery manipulation code
function selectThumb(arrayID){
	//--- set previous selection to class-photo
	if (selectID.length>0){change(selectID, 'lolight');}
	selectID = arrayID;
	//--- swap the preview image
	for (var i=0; i<photos.s[sectionID].p.length; i++){
		if (photos.s[sectionID].p[i].id == arrayID){
			MM_swapImage('preview','',photos.s[sectionID].p[i].mid,1);
			writeLayer('quote',null,photos.s[sectionID].p[i].title);
			var previewObj = MM_findObj('preview');
			previewObj.title = "";
			//previewObj.title = photos.s[sectionID].p[i].title;
			change(arrayID,'hilight');
			break;
		}
	}
}

function viewer(){
	if (selectID.length>0){
		eval("openWin('viewer.htm?" + sectionID + "|'+selectID,'viewer','610','525','100','60','no','no','no')");
	}
}

function writeLayer(ID,parentID,sText) { 
	if (document.layers){ 
		var oLayer; 
		if(parentID){ 
			oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
		}else{ 
		oLayer = document.layers[ID].document; 
		} 
		oLayer.open(); 
		oLayer.write(sText); 
		oLayer.close(); 
	} 
	else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape"){
		document.getElementById(ID).innerHTML = sText; 
	} 
	else if (document.all) document.all[ID].innerHTML = sText;
} 


function change(id, newClass){
	identity=document.getElementById(id);
	identity.className=newClass;
}
