function ValidateEmail(form2) {
  var missinginfo = "";
   if (isEmail(form2.email) == false) {   //Is email properly formated address?
   missinginfo += "Please enter a valid e-mail address.\n";
   }
   if (isEmailGov(form2.email) == false) {           //Is email filled as .gov?
   missinginfo += "Please enter a non government email address.\n";
   }
   if (isZipCode(form2.ZipCode) == false) {                //Is ZipCode filled?
   missinginfo += "\nPlease enter your zip code as xxxxx or xxxxx-xxxx.\n";
	}
  if (missinginfo != "") {
    alert(missinginfo);
    form2.email.focus();
    return false;
  }
  else return true;
}

// Check for proper e-mail address format
function isEmail(elm) {
   if ((elm.value != "") &&
       (elm.value != "email address"))
   {
     if (elm.value.indexOf("@") != "-1" &&
         elm.value.indexOf(".") != "-1" &&
         elm.value != "")
       return true;
     else
	   return false;
   }
   return false;
}
// Check for proper e-mail address domain
function isEmailGov(elm) {
    if ((elm.value.indexOf(".gov") != "-1") &&
        (elm.value != ""))
    return false;
    else return true;
}
// Check for no null field and an integer
function isNumber(elm) {
    var elmstr = elm.value + "";
    if (elmstr.length == 0) return false;
    for (var i = 0; i < elmstr.length; i++) {
        if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") return false;
    }
return true;
}

function CalculateAmount() {
    var amount = (document.epform.adults.value*35) + (document.epform.youth.value*10);
    document.epform.amount.value = amount + ".00";
return true;
}

function CalculateAmountGOTV() {
    var amount = 0;
	if (document.epform.lunch) {if (document.epform.lunch.checked==1) {amount=amount+20;}}
	if (document.epform.stickers) {if (document.epform.stickers.checked==1) {amount=amount+17;}}
	if (document.epform.stamps) {if (document.epform.stamps.checked==1) {amount=amount+37;}}
	if (document.epform.hangers) {if (document.epform.hangers.checked==1) {amount=amount+52;}}
	if (document.epform.postcards) {if (document.epform.postcards.checked==1) {amount=amount+90;}}
    if (document.epform.signs) {if (document.epform.signs.checked==1) {amount=amount+140;}}
    document.epform.amount.value = amount + ".00";
return true;
}

function CalculateAmountHybrid() {
    var amount = "";
	if (document.epform.amountradio)
	{ if (document.epform.amountradio[0].checked) {amount = "10.00";}
	  if (document.epform.amountradio[1].checked) {amount = "25.00";}
	  if (document.epform.amountradio[2].checked) {amount = "50.00";}
	  if (document.epform.amountradio[3].checked) {amount = "100.00";}
	  if (document.epform.amountradio[4].checked) {amount = "";}
	}

    document.epform.amount.value = amount;
return true;
}

function CalculateAmountMartins() {
    var amount = (document.epform.hostreception.value*1000) + (document.epform.mainevent.value*250);
    document.epform.amount.value = amount + ".00";
return true;
}

function CalculateAmountBreakfast() {
    var amount = (document.epform.tickets.value*100);
    document.epform.amount.value = amount + ".00";
return true;
}

function CalculateAmountOktober() {
    var amount = (document.epform.tickets.value*75);
    document.epform.amount.value = amount + ".00";
return true;
}

function CalculateAmount50() {
    var amount = (document.epform.tickets.value*50);
    document.epform.amount.value = amount + ".00";
return true;
}

// Check for proper zip code format
function isZipCode(elm) {
var elmstr = elm.value + "";
    if ((elmstr.length != 5) && (elmstr.length != 10)) { return false }
    for (i=0; i < elmstr.length; i++) {
        if ((elmstr.length == 10) && (i == 5)) {
        if (elmstr.charAt(i) != "-") { return false }
    } else {
        if ((elmstr.charAt(i) < "0") || (elmstr.charAt(i) > "9")) { return false }
        }
    }
return true;
}
// Check for null and empty fields
function isFilled(elm) {
    if (elm.value == "" ||
        elm.value == null)
    return false;
    else return true;
}
