// JavaScript Document
function checkContact()
{	
	check = new Array();
	check[0] = new Array(document.getElementById('contact'), "- select a department to contact\n", "dropdown");
	check[1] = new Array(document.getElementById('fullname'), "- fullname\n", "");
	check[2] = new Array(document.getElementById('email'), "- email\n", "email");
	check[3] = new Array(document.getElementById('nearbystore'), "- nearest store\n", "dropdown");
	check[4] = new Array(document.getElementById('comments'), "- comments\n", "");	
	
	error = "";
	for(var i=0;i<check.length;i++)
	{
		eField = check[i][0];
		if(check[i][2] == ""){
			eValue = eField.value;
			if(eValue != null){
				eValue = eValue.trim();
				if(eValue.length == 0) error += check[i][1];
			}else{
				error += check[i][1];
			}
		}else if(check[i][2] == 'email'){
			eValue = eField.value;		
			if(eValue.indexOf("@") == -1 || eValue.length <= 3) error += check[i][1];
		}else if(check[i][2] == 'dropdown'){
			if(eField.selectedIndex == 0) error += check[i][1];
		}
	}
	if(error != ""){
		error = "The following fields are required:\n" + error;
		alert(error)
		return false;
	}else{
		return true;
	}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

function checkServices()
{	
	check = new Array();
	check[0] = new Array(document.getElementById('firstname'), "- firstname\n", "");
	check[1] = new Array(document.getElementById('lastname'), "- lastname\n", "");
	check[2] = new Array(document.getElementById('email'), "- email\n", "email");
	check[3] = new Array(document.getElementById('nearbystore'), "- nearest store\n", "dropdown");
	
	error = "";
	for(var i=0;i<check.length;i++)
	{
		eField = check[i][0];
		if(check[i][2] == ""){
			eValue = eField.value;
			if(eValue != null){
				eValue = eValue.trim();
				if(eValue.length == 0) error += check[i][1];
			}else{
				error += check[i][1];
			}
		}else if(check[i][2] == 'email'){
			eValue = eField.value;		
			if(eValue.indexOf("@") == -1 || eValue.length <= 3) error += check[i][1];
		}else if(check[i][2] == 'dropdown'){
			if(eField.selectedIndex == 0) error += check[i][1];
		}
	}
	if(error != ""){
		error = "The following fields are required:\n" + error;
		alert(error)
		return false;
	}else{
		return true;
	}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

// JavaScript Document
function checkDonation()
{	
var firstemail = document.getElementById('firstemail').value;
var secondemail = document.getElementById('verifyemail').value;

	check = new Array();
	check[0] = new Array(document.getElementById('organization'), "- Organization Name\n", "");
	check[1] = new Array(document.getElementById('eventdate'), "- Date of Event\n", "");
	check[2] = new Array(document.getElementById('donationneeded'), "- Date Donation Needed\n", "");
	check[3] = new Array(document.getElementById('firstname'), "- First Name\n", "");
	check[4] = new Array(document.getElementById('lastname'), "- Last Name\n", "");
	check[5] = new Array(document.getElementById('firstemail'), "- Email\n", "email");
	check[6] = new Array(document.getElementById('verifyemail'), "- Verify Email\n", "");	
	check[7] = new Array(document.getElementById('phone_ac'), "- Phone Area Code\n", "");	
	check[8] = new Array(document.getElementById('phone_pre'), "- Phone Prefix\n", "");	
	check[9] = new Array(document.getElementById('phone_last'), "- Phone Number\n", "");	
	check[10] = new Array(document.getElementById('address1'), "- Address\n", "");	
	check[11] = new Array(document.getElementById('city'), "- City\n", "");	
	check[12] = new Array(document.getElementById('state'), "- State\n", "");	
	check[13] = new Array(document.getElementById('zip'), "- Zipcode\n", "");

error = "";
	for(var i=0;i<check.length;i++)
	{
		eField = check[i][0];
		if(check[i][2] == ""){
			eValue = eField.value;
			if(eValue != null){
				eValue = eValue.trim();
				if(eValue.length == 0) error += check[i][1];
			}else{
				error += check[i][1];
			}
		}else if(check[i][2] == 'email'){
			eValue = eField.value;		
			if(eValue.indexOf("@") == -1 || eValue.length <= 3) error += check[i][1];
		}else if(check[i][2] == 'dropdown'){
			if(eField.selectedIndex == 0) error += check[i][1];
		}
	}
	if(error != ""){
		error = "The following fields are required:\n" + error;
		if (firstemail != secondemail) {
			error = error + "\nThe email addresses do not match.";
		}
		alert(error)
		return false;
	}else{
		return true;
	}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

function checkGarden()
{	
var firstemail = document.getElementById('firstemail').value;
var secondemail = document.getElementById('verifyemail').value;

	check = new Array();
	check[0] = new Array(document.getElementById('firstname'), "- First Name\n", "");
	check[1] = new Array(document.getElementById('lastname'), "- Last Name\n", "");
	check[2] = new Array(document.getElementById('firstemail'), "- Email\n", "email");
	check[3] = new Array(document.getElementById('verifyemail'), "- Verify Email\n", "");	
	check[4] = new Array(document.getElementById('phone_ac'), "- Phone Area Code\n", "");	
	check[5] = new Array(document.getElementById('phone_pre'), "- Phone Prefix\n", "");	
	check[6] = new Array(document.getElementById('phone_last'), "- Phone Number\n", "");	

error = "";
	for(var i=0;i<check.length;i++)
	{
		eField = check[i][0];
		if(check[i][2] == ""){
			eValue = eField.value;
			if(eValue != null){
				eValue = eValue.trim();
				if(eValue.length == 0) error += check[i][1];
			}else{
				error += check[i][1];
			}
		}else if(check[i][2] == 'email'){
			eValue = eField.value;		
			if(eValue.indexOf("@") == -1 || eValue.length <= 3) error += check[i][1];
		}else if(check[i][2] == 'dropdown'){
			if(eField.selectedIndex == 0) error += check[i][1];
		}
	}
	if(error != ""){
		error = "The following fields are required:\n" + error;
		if (firstemail != secondemail) {
			error = error + "\nThe email addresses do not match.";
		}
		alert(error)
		return false;
	}else{
		return true;
	}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}