var submitForm = function(form_id){

	var myForm = $("#"+form_id)[0];

	$("#msg").fadeOut("fast");

	//clearUnusedFields();
	$.ajax({
		type: 'POST'
		, url: myForm.action
		, dataType: 'json'
		, data: $("input,select,textarea", myForm)
		, success: function(data){
			if(data.success){
				$("#msg").text(data.msg);
				$("#msg").fadeIn("fast");
				$("#msg").fadeOut(7500);
				if(data.other && data.other.url){ window.location = data.other.url; }
			} else {
				var msg = data.msg; //+ '<ul style="text-align:left">'; //UNCOMMENT TO SHOW SPECIFIC FIELD MESSAGES
				var fields = data.results;
				var cssField = null;
				for(x in fields){
					var showError = true;
					if(fields[x].error){
						if(!fields[x].required && $('#'+fields[x].name).length == 0){
							showError = false;
						}
						if(showError) {
							//msg += '<li>' + fields[x].error + '</li>'; //UNCOMMENT TO SHOW SPECIFIC FIELD MESSAGES
							cssField = (fields[x].type=="checkbox") ? "checkbox_" + fields[x].name : fields[x].name;
							$('#'+cssField).css({'background-color' : '#FFC0CB'});
							//alert(cssField);
						}
					} else {
						cssField = (fields[x].type=="checkbox") ? "checkbox_" + fields[x].name : fields[x].name;
						if(fields[x].type=="text" || fields[x].type=="select") { $('#'+cssField).css({'background-color' : 'white'}); }
						else if(fields[x].type=="checkbox") { $('#'+cssField).css({'background-color' : ''}); }
					}
				}
				msg += '</ul>';
				$("#notify").html(msg);
				$("#notify").fadeIn("fast");
				$("#notify").fadeOut(7500);
			}
		}
	});

	//initTextFields();
	return false;

};