



function validate_donation_request(f) {
	var e = new Errors();
	if(f.what_are_you_requesting_.selectedIndex <= 0) e.adderror("Please specify what you are requesting.");
	if(!f.organization_name.value) e.adderror("Please enter your organization name.");
	if(!f.contact_first_name.value) e.adderror("Please enter your first name.");
	if(!f.contact_last_name.value) e.adderror("Please enter your last name.");

	if(!f.street_address_1.value) e.adderror("Please enter your address.");
	if(!f.city.value) e.adderror("Please enter your city.");
	if(f.state.selectedIndex <= 0) e.adderror("Please select your state.");
	if(!f.zip.value) e.adderror("Please enter your zip code.");
	if(!f.telephone.value) e.adderror("Please enter your telephone.");
	if(!validate_email(f.email.value)) e.adderror("Sorry, Invalid Email Address!");
	
	if(valButton(f.are_you_registered_no_profit_organization_)==null) e.adderror("Please specify if you are registered non-profit organization or not.");
	if(valButton(f.are_you_registered_no_profit_organization_)==1 && !f.tax_id_number.value) e.adderror("Please specify 501c3 Tax Id number.");
	if(valButton(f.are_you_state_tax_exempt_)==null) e.adderror("Please specify if you are State tax exempt or not.");	
	if(valButton(f.has_chateau_julien_contributed_to_your_organizatio)==null) e.adderror("Please specify if Chateau Julien has contributed to your organization before.");	
	if(valButton(f.are_you_a_chateau_julien_customer_)==null) e.adderror("Please specify if you are a Chateau Julien customer.");	



	if(!f.event_name.value) e.adderror("Please enter the event name.");
	if(f.date_of_event_month.selectedIndex <= 0 || f.date_of_event_day.selectedIndex <= 0 || f.date_of_event_year.selectedIndex <= 0) e.adderror("Please specify the event date.");	
	if(!f.event_location.value) e.adderror("Please enter the event location.");
	if(f.type.selectedIndex <= 0) e.adderror("Please specify the event type.");
	if(!f.expected_number_of_attendees.value) e.adderror("Please enter expected number of attendees.");
	
	
	if(!f.what_tpe_of_donor_acknowledgment_will_you_offer_.value) e.adderror("Please specify the type of donor acknowledgment you will offer.");


	return e.alert() ? false : true;
}


// error class
function Errors() {
	this.errors = new Array();

	this.adderror = function(msg) {
		this.errors[this.errors.length] = msg;
	}
	this.alert = function() {
		if(!this.errors.length) return false;

		var msg = '';

		for(var i=0; i<this.errors.length; ++i) {
			msg += '*  ' + this.errors[i];
			if(i < this.errors.length - 1) msg += '\n\n';
		}

		alert(msg);
		return true;
	}
}


function validate_email(email) {
	if(email.length <= 5) return false;
	if(email.indexOf('@', 0) == -1) return false;
	return true;
}

function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}




