// donation.js
// Order Form processing code

function checkEmail(email)
{
	if(email.length > 0){
		if (email.indexOf(' ') >= 0)
			alert("Email addresses cannot have spaces in them!")
		else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1))
			alert("A valid email address must have an '@' and a '.' in it!")
		}
	}

function checkrequired(which){
	var pass=true
	var ThisForm = document.forms[0]
	var anon = document.CCBDonate.anonymous
	var news = document.CCBDonate.newsletter

	if (document.images){
		for (i=0;i<which.length;i++){
			var tempobj=which.elements[i]
			if (tempobj.name.substring(0,7)=="billing"){
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='') || (tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
					pass=false
					break
					}
				}
			}
		}

	if (!pass){
		alert("All Credit Card Billing fields are required. Please complete them, then submit again!")
		return false
		}
	else {
		ThisForm.grand_total.value = ThisForm.item_subtotal1.value
		if (anon.checked){
			ThisForm.comments.value = ThisForm.comments.value + " <ANONYMOUS: YES>"
			}
		else{
			ThisForm.comments.value = ThisForm.comments.value + " <ANONYMOUS: NO>"
			}
		if (news.checked){
			ThisForm.comments.value = ThisForm.comments.value + " <NEWSLETTER: YES>"
			}
		else{
			ThisForm.comments.value = ThisForm.comments.value + " <NEWSLETTER: NO>"
			}

		return true
		}
	}
