
function getRadioValue(radioObject) {
	var value = null
	for (var i=0; i<radioObject.length; i++) {
		if (radioObject[i].checked) {
			value = radioObject[i].value
			break
		}
	}
	return value;

	}

function setForm(){
var emailto
var emailfrom
var emailsubject

document.formA.emailfrom.value = document.formA.email.value;

if(getRadioValue(document.formA.reqInfo) == "Show Dates"){
document.formA.hidden.value='Show Dates';document.formA['text'].disabled=true;
document.formA.hidden.value == "Show Dates";
document.formA.emailto.value = "shows@sarmite.com";
document.formA.emailsubject.value = "RE: Show Dates";	
document.formA.text.value = "";
}

if(getRadioValue(document.formA.reqInfo) == "Gallery Listings"){
document.formA.hidden.value='Gallery Listings';document.formA['text'].disabled=true;
document.formA.hidden.value == "Gallery Listings";
document.formA.emailto.value = "galleries@sarmite.com";
document.formA.text.value = "";
}

if(getRadioValue(document.formA.reqInfo) == "Order Information"){
document.formA.hidden.value='Order Information';document.formA['text'].disabled=false;
document.formA.hidden.value == "Order Information";
document.formA.emailto.value = "swa@sarmite.com"
document.formA.text.value = "";
}

if(getRadioValue(document.formA.reqInfo) == "Other Information"){
document.formA.hidden.value='Other Information';document.formA['text'].disabled=false;
document.formA.hidden.value == "Other Information";
document.formA.emailto.value = "swa@sarmite.com"
}

}

function validateForm(){

   if(document.formA.fName.value == ""){
   alert("Please fill in the First Name field.");
   document.formA.fName.focus();
   return false;
   }
   if(document.formA.lName.value == ""){
   alert("Please fill in the Last Name field.");
   document.formA.lName.focus();
   return false;
   }
    /*if(document.formA.strAdd.value == ""){
   alert("Please fill in the Street Address field.");
   document.formA.strAdd.focus();
   return false;
   }
      if(document.formA.city.value == ""){
   alert("Please fill in the City field.");
   document.formA.city.focus();
   return false;
   }
      if(document.formA.state.value == "0"){
   alert("Please select a State from the drop down list.");
   document.formA.state.focus();
   return false;
   }
 
	   if(document.formA.zipCode.value == ""){
   alert("Please fill in the Zip Code field.");
   document.formA.zipCode.focus();
   return false;
   }
 
	  if(document.formA.phone.value == ""){
   alert("Please fill in the Phone Number field.");
   document.formA.phone.focus();
   return false;
   }*/
     var email = document.formA.email.value;
var exclude=/[^@\-\.\w\']|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;

if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){
alert("The E-mail Address you have entered is not valid.");
document.formA.email.focus();
return false;
}

if(getRadioValue(document.formA.reqInfo) == null){
alert("Please select a radio button indicating what type of information you would like to receive.");
return false;
}

if((document.formA.hidden.value == "Order Information") && (document.formA.text.value== "")){
alert("Please tell us more about what type of Order Information you are interested in receiving.\nIf you are inquiring about a specific item you have seen in our Collections department, \nplease include the item number.");
document.formA.text.focus();
return false;
} 
if((document.formA.hidden.value == "Other Information") && (document.formA.value == "")){
alert("Please describe what Other Information you are interested in receiving.");
document.formA.text.focus();
return false;
}

var digits="0123456789-"
var tPhone//for phone
var tZip//for zip
for (var i=0;i<document.formA.zipCode.value.length;i++){
tZip=document.formA.zipCode.value.substring(i,i+1)
if (digits.indexOf(tZip)==-1){
alert("Please enter numerical values in the Zip Code Field")
document.formA.zipCode.focus();
return false;
  }
  }
  
for (var i=0;i<document.formA.phone.value.length;i++){
tPhone=document.formA.phone.value.substring(i,i+1)
if (digits.indexOf(tPhone)==-1){
alert("Please enter numerical values for the Phone Number in the following format.\n 000-000-0000")
document.formA.phone.focus();
return false;
  }
  }
  
  	document.formA.submitBut.disabled = true;
  
}

