function validate_formSubmission (){
	
	var form = this,
		fields = $(":input", form),
		errors = [];
		
		
	for (var i=0, count=fields.length; i < count; i++){
		
		var curField = $(fields[i]);
		var fieldLabel = $(curField).siblings("label");
		var value = $(curField).val();
		var type = $(curField).attr("rel");
		var required = ($(curField).hasClass("required")) ? true : false;
	
		// If required field is left blank, show error
		if (required && value === "") errors.push({field: curField, message: $(fieldLabel).html() + " is required."});
		
		
		if (!required && value.length || required){
			// Validate Email addresses
			if (type === "email" && ! validateEmail(value)) errors.push({field: curField, message: $(fieldLabel).html() + " must be a valid email address (i.e., name@domain.com)."});
			
			// Validate URLs
			if (type === "url" && ! validateURL(value)) errors.push({field: curField, message: $(fieldLabel).html() + " must be a valid URL (i.e., http://www.domain.com)."});
			
			// Validate Zip Codes
			if (type === "zipcode" && ! validateZip(value)) errors.push({field: curField, message: $(fieldLabel).html() + " must be a valid zipcode (i.e., 12345-1234)."});
			
			// Validate Phone Numbers 
			if (type === "phone" && ! validatePhone(value)) errors.push({field: curField, message: $(fieldLabel).html() + " must be a valid phone number (i.e., 123-123-1234)."});
			
			// Validate Passwords
			if (type === "password" && ! validatePassword(value)) errors.push({field: curField, message: $(fieldLabel).html() + " must be at least 5 characters long."});
			
		}
		
	}
	
	
	// Display Errors 
	if (errors.length){
		var message = "";
		for (var i = 0; i < errors.length; i++){
			message += errors[i].message + "\r\n\r\n";
		}
		alert(message);
		return false;
	}
	
	
	// Submit Form
	return true;
	
}


function validatePassword(str){
	if (str.length < 5) return false;
	return true;
}


function validateEmail (str){	
	var regEx = /^([\w]+)(\.[\w]+)*@([\w\-]+)(\.[\w]{2,3}){1,2}$/;
	if (regEx.test(str)) return true;
	return false;
}

function validateURL (str){	
	var regEx = /^https?:\/\/(www\.)?([a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.[a-zA-Z]{2,3}(\.[a-zA-Z]{2})?\/?.*$/;
	if (regEx.test(str)) return true;
	return false;
}

function validatePhone (str){
	var regEx = /^(\(?[0-9]{3}\)?)(-|\.| )?([0-9]{3})(-|\.| )?([0-9]{4})$/;
	if (regEx.test(str)) return true;
	return false;
}


function validateZip (str) {
	var regEx = /^[0-9]{5}(-[0-9]{4})?$/;
	if (regEx.test(str)) return true;
	return false;

}
