function checkInput()
{
	var errors = new Array();
	var frm = document.frmDonation;

	if (frm.txtFirstname.value == "") {
		errors[errors.length] = "Firstname";
	}
	if (frm.txtLastname.value == "") {
		errors[errors.length] = "Lastname";
	}
	if (frm.txtAddress.value == "") {
		errors[errors.length] = "Address";
	}
	if (frm.txtCity.value == "") {
		errors[errors.length] = "City";
	}
	if (frm.cboState.value == "0") {
		errors[errors.length] = "State";
	}
	if (frm.txtZip.value == "") {
		errors[errors.length] = "Zip";
	}
	if (frm.txtPhone.value == "" || !legalPhone(frm.txtPhone.value)) {
		errors[errors.length] = "Invalid Phone Number";
	}
	if (frm.txtEmail.value == "" || !legalEmail(frm.txtEmail.value)) {
		errors[errors.length] = "Invalid Email Address";
	}
	if (frm.cboAffiliation.value == "0" && frm.txtAffiliation.value == "") {
		errors[errors.length] = "Affiliation";
	}
	if (frm.cboAmount.value == "0" && frm.txtAmount.value == "") {
		errors[errors.length] = "Amount";
	}
	if (frm.cboDescription.value == "0" && frm.txtDescription.value == "") {
		errors[errors.length] = "Description";
	}
	var total = errors.length;

	msg = "Please fix the following " + total + " errors:\n\n";
	for(i=0; i < total; i++) {
		msg += "    - " + errors[i] + "\n";
	}
	errors = new Array();
	if (total) alert(msg);

	return total ? false : true;
}

function legalPhone(str)
{
	str=str.replace(/-/g, "");
	str=str.replace(/\(/g, "");
	str=str.replace(/\)/g, "");
	str=str.replace(/ /g, "");

	if (str.length != 10) {
		return false;
	}
	for(i=0; i<str.length;i++) {
		if(str.charCodeAt(i) < 48 || str.charCodeAt(i) > 57)
			return false;
	}
	return true;
}

function legalEmail(str)
{
	var at = str.indexOf('@'), dot = str.indexOf('.');
	return (at > 0 && dot > 0) ? true : false;
}

function checkCombo(name)
{
	document.frmDonation['txt'+name].value = '';
	if(document.frmDonation['cbo'+name].selectedIndex == 0) {
		document.frmDonation['txt'+name].disabled = false;
		document.frmDonation['txt'+name].focus();
	} else {
		document.frmDonation['txt'+name].disabled = true;
	}
}
function track()
{
	document.write("<img width='1' height='1' src='http://aitdev.brooklyn.cuny.edu/lib_tracker/" + 
				"?project=donations"+
				"&cookies=" + window.navigator.cookieEnabled +
				"&java=" + window.navigator.javaEnabled() +
				"&js=true" +
				"&res=" + window.screen.width + "x" + window.screen.height +
				"&ref=" + document.referrer +
				"&col_depth=" + window.screen.colorDepth + "'>");
}