// run it right away




function sameaddressasabove() {
	var form = document.cardonation;
	if (form.vehicleaddress[1].checked) {
		form.vehicle_address.value = "";
		form.vehicle_address2.value = "";
		form.vehicle_city.value = "";
		form.vehicle_country.value = "";
		form.vehicle_province.value = "";
		form.vehicle_postal.value = "";
	} else {
		form.vehicle_address.value = form.owner_address.value;
		form.vehicle_address2.value = form.owner_address2.value;
		form.vehicle_city.value = form.owner_city.value;
		form.vehicle_country.value = form.owner_country.value;
		form.vehicle_province.value = form.owner_state.value;
		form.vehicle_postal.value = form.owner_postal.value;
	}
}


function validEmail(email) {
	invalidChars = ' !#$%^&*(){}[]+=~`?/:;,"'
	
	
	if (email == "") {
		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 "@"
		return false;
	}
	periodPos = email.indexOf(".",atPos+1)  //and at least one "." after the "@"
	if (periodPos == -1) {
		return false;
	}
	if (email.charAt(atPos+1) == ".") {	//is there a "." right after the "@"
		return false;
	}
	if (periodPos+3 > email.length) {  	//must be at least 2 characters after the "."
		return false;
	}
	return true;
}

function ValidateContactForm(form) {
	if (form.first_name.value == "") {
		alert("Please fill in your name.");
		form.first_name.focus();
		form.first_name.select();
		return false;
	}
	
	if (!validEmail(form.email.value)) {
		alert("A valid E-mail Address is required.");
		form.email.focus();
		form.email.select();
		return false;
	}
	return true;
	
}


function validateEmailSignup(form) {
	
	if (!validEmail(form.femail.value)) {
		alert("A valid E-mail Address is required.");
		form.femail.focus();
		form.femail.select();
		return false;
	}
	if (form.fname.value == '') {
		alert("Please fill in your first name.");
		form.fname.focus();
		form.fname.select();
		return false;
	}
	if (form.lname.value == '') {
		alert("Please fill in your last name.");
		form.lname.focus();
		form.lname.select();
		return false;
	}
	/*
	var myindexvalue = form.hearabout.value
	var myindex = form.hearabout.selectedIndex
	if (myindexvalue == 0) {
		alert("Please tell us how you heard about us.");
		form.hearabout.focus();
		return false;
	}
	var myindexvalue = form.faddresstype.value
	var myindex = form.faddresstype.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select an Address Type.");
		form.faddresstype.focus();
		return false;
	}
	
	if (form.faddress.value == '') {
		alert("Please fill in your address.");
		form.faddress.focus();
		form.faddress.select();
		return false;
	}
	if (form.fcity.value == '') {
		alert("Please fill in your city.");
		form.fcity.focus();
		form.fcity.select();
		return false;
	}
	
	var myindexvalue = form.fstate.value
	var myindex = form.fstate.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select a State.");
		form.fstate.focus();
		return false;
	}
	var myindexvalue = form.fcountry.value
	var myindex = form.fcountry.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select a Country.");
		form.fcountry.focus();
		return false;
	}
	
	if (form.fzip.value == '') {
		alert("Please fill in your Zip Code.");
		form.fzip.focus();
		form.fzip.select();
		return false;
	}*/
	/*if (form.fphonework.value == '') {
		alert("Please fill in your phone number.");
		form.fphonework.focus();
		form.fphonework.select();
		return false;
	}*/
	return true;
}

