
function addOrModifyCommunicationsContact(id, type, firstName, lastName, email, phone, fax, line1, line2, city, state, zip, notes)
{
	$$("span.error").each(
		function(el) {
			el.className = "hidden";
		}
	);
	
	Modalbox.deactivate();
    new Ajax.Request(
        "/patient/communications/modify-contact.html?id="+ id,
        {
            method: "post",
            parameters: {
                id: id,
                type: type,
                firstName: firstName,
                lastName: lastName,
                email: email,
                phone: phone,
                fax: fax,
                line1: line1,
                line2: line2,
                city: city,
                state: state,
                zip: zip,
                notes: notes
            },
            onSuccess: function(response) {
            	var data = JSON.parse(response.responseText);
            	if (data.success == true) {
                	Modalbox.hide();
                	location.href = location.pathname;
                }
                else {
                	if (data.typeError == true) $("typeError").className = "error";
                	if (data.firstNameError == true) $("firstNameError").className = "error";
                	if (data.lastNameError == true) $("lastNameError").className = "error";
                	if (data.emailError == true) $("emailError").className = "error";
                	Modalbox.activate();
                }
            },
            onFailure: function() {
            	alert("Save Error:" + response.status);
                Modalbox.hide();
            }
        }
    );
}

function deleteContact(id) {
	new Ajax.Request('/patient/communications/delete-contact.html', {
		method: 'post',
		parameters: {
			contactId: id
		},
		onSuccess: function(response) {
			location.href = location.pathname;
		},
		onFailure: function(response) {
			alert("Delete Error: " + response.status);
		}
	});
}

function deleteAlert(id) {
	new Ajax.Request('/patient/communications/delete-alert.html', {
		method: 'post',
		parameters: {
			alertId: id
		},
		onSuccess: function(response) {
			location.href = location.pathname;
		},
		onFailure: function(response) {
			alert("Delete Error: " + response.status);
		}
	});
}

function deleteSentItem(id) {
	new Ajax.Request('/patient/communications/delete-sent-item.html', {
		method: 'post',
		parameters: {
			itemId: id
		},
		onSuccess: function(response) {
			location.href = location.pathname;
		},
		onFailure: function(response) {
			alert("Delete Error: " + response.status);
		}
	});
}