
	if (document.images) {
	var OK = new Image(); OK.src = "check.gif";
	var excl = new Image(); excl.src = "excl.gif";
	var emp = new Image(); emp.src = "empty.gif";

	}

// in-line validation


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
  if (el.style) el.style.cssText = ""
}

function setOK(chkfield){
//span= chkfield.name+"Span.innerHTML='<img src=\"check.gif\" >'"
//eval(span)
document.images["i" + chkfield.name].src = OK.src
}

function setNotOK(chkfield){
//span= chkfield.name+"Span.innerHTML='<img src=\"excl.gif\" >'"
//eval(span)
document.images["i" + chkfield.name].src = excl.src
}

function checkblank(what,whatname) {
	// in-line check without alerts
	tocheck=what.value
	if (tocheck=="" ||tocheck.substring(0,5)=="Enter")	return false
	return true
}

function checkfield(chkfield) {

if (chkfield.name=="ZIP") {
	if(!checkblank(chkfield,"")){
		setNotOK(chkfield)
		return false
	}
	if (!checkZIP(chkfield)) {
		setNotOK(chkfield)
		alert("Please check your ZIP code. It should be formatted as 12345 or 12345-6789");
		return false }
		else setOK(chkfield)
}  // ZIP

if ((chkfield.name=="telephone") || (chkfield.name=="Fax") ) {

	tocheck=chkfield.value
	if (chkfield.name=="Fax" ) { // not required
		if (tocheck=="" ||tocheck.substring(0,2)=="123")	{ //empty fields
			// setOK(chkfield)
//		span= chkfield.name+"Span.innerHTML='<img src=\"empty.gif\" >'"
//		eval(span)
	document.images["i" + chkfield.name].src = emp.src


			return false 
		}
		else { // not empty fields
			if(!phoneformat(chkfield)){
			setNotOK(chkfield)
			alert("Please check your fax number.  \n It should be formatted as 123-456-7890 or 1234567890.");
			return false }
			else setOK(chkfield)
		}
	} // END of not required
	else { //  required - Tel1

		if (tocheck=="" ||tocheck.substring(0,2)=="123"){ //empty Tel1
				setNotOK(chkfield)
				return false }
	
		if(!phoneformat(chkfield)){
			setNotOK(chkfield)
			alert("Please check your telephone number.  \n It should be formatted as 123-456-7890 or 1234567890.");
			return false }
			else setOK(chkfield)
	
	} // end of  required - Tel1

}  // End of  - Telephone and Fax


if (chkfield.name=="Email") {
	if(chkfield.value==""){
//		span= chkfield.name+"Span.innerHTML='<img src=\"empty.gif\" >'"
//		eval(span)
	document.images["i" + chkfield.name].src = emp.src

		return false
		}
	else { // not empty
		if (!validEmail(chkfield.value)) {
			setNotOK(chkfield)
			return false }
			else setOK(chkfield)
		}
}  // Email

// everything else

if (!checkblank(chkfield,""))setNotOK(chkfield)
else  setOK(chkfield)
return true
}

function checkform() {

f=document.AddMember

what=f.FirstName

whatname="First Name"
if(!checkblank_sub(what,whatname)) return false


what=f.LastName
whatname="Last Name"
if(!checkblank_sub(what,whatname)) return false

what=f.Address1
whatname="Address1"
if(!checkblank_sub(what,whatname)) return false

what=f.City
whatname="City"
if(!checkblank_sub(what,whatname)) return false

what=f.State
if (what.value == "none") {
 alert("Please, select state")
  what.focus()
return false
}

what=f.ZIP
whatname="ZIP"
if(!checkblank_sub(what,whatname)) return false


if (!checkZIP(what)) {
s=prompt("Please, check your ZIP code. It should be formatted as 12345 or 12345-6789"," ")
what.value=s
 what.focus()
 return false

}

what=f.telephone
whatname="Telephone"
tocheck=what.value

if (tocheck=="" ||tocheck.substring(0,2)=="123"){
	alert("Please provide a telephone number")
	what.value=""
	what.focus()
	return false 
}

if(!phoneformat(what)) return false

what=f.Fax
if (what.value != "") {
	if(!phoneformat(what)) return false
}

what=f.Email
if (what.value != "") if (!validEmail(what.value)) return false

// check CC
what=f.CCNumber

if (what.value != "") {
//	if (!isCreditCard(what)) {
//	s=prompt("Please check your credit card number","")
//	what.value=s
//	what.focus()
//	return
//	}


what=f.CCtype

if (what.options[f.CCtype.selectedIndex].value =="") {
 alert("Please select credit card type")
  what.focus()
return false
}


// check on expiration
cMonth=f.CCMonth.options[f.CCMonth.selectedIndex].value
cYear=f.CCYear.options[f.CCYear.selectedIndex].value

   if (expired( cMonth, cYear )) {
   s=alert("Please check the credit card expiration date")
   f.CCMonth.focus()
return false
   }

}

what=f.UserName
	whatname="User"
	if(!checkblank_sub(what,whatname)) return false

	if (what.value.length <5) {
		alert("User Name: min length is 5 characters:")
		what.focus()
		return false
	}

	what=f.Password 
	whatname="password"
	if(!checkblank_sub(what,whatname)) return false

	if (what.value.length <5) {
		alert("Password: min length is 5 characters")
		what.focus()
		return false
	}
	if (what.value.length >8) {
		alert("Password: max length is 8 characters")
		what.focus()
		return false
	}

	if (!(f.Password.value  == f.ConfPassword.value)){
	alert("Password and Confirmed password are NOT the same")
	f.ConfPassword.focus()
	return false
	}

	what=f.Hint 
	whatname="Hint "
	if(!checkblank_sub(what,whatname)) return false

	what=f.HintAnswer 
	whatname="Hint Answer "
	if(!checkblank_sub(what,whatname)) return false

f.submit()
return true
}

function phoneBlur(i){
	if(i.value.length<5) i.value=""
	checkfield(i)
}

function phoneFocus(i){
  if (i.defaultValue==i.value) i.value = ""
  if (i.style) i.style.cssText = ""

   if((i.value=="")){
	i.value="("; i.focus(); i.select();
   } else { i.select(); }
}