// JavaScript Document

// When the document is ready (i.e. done loading), we'll fetch each of the modules and load them individually
$(document).ready(function(){
    $('#invite').jqm({ajax: '/admission/TellAFriend/index.cfm', trigger: 'a.inviteTrigger'});
});

// Used to send an e-mail invite to the student's friend from the modal panel
function sendInvite() {
	if (document.invitation.YourName.value == '') {
		alert('You must type your name.');
		document.invitation.YourName.focus();
	}
	else if (validEmail(document.invitation.YourEmail,true) != 'Valid') {
		alert('There was a problem with your email address. Please verify you typed it correctly.');
		document.invitation.YourEmail.focus();
		document.invitation.YourEmail.select();
	}
	else if (document.invitation.FriendName.value == '') {
		alert('You must type your friend\'s name.');
		document.invitation.FriendName.focus();
	}
	else if (validEmail(document.invitation.FriendEmail,true) != 'Valid') {
		alert('There was a problem with your friend\'s email address. Please verify you typed it correctly.');
		document.invitation.FriendEmail.focus();
		document.invitation.FriendEmail.select();
	}
	else {
	$.post('/admission/TellAFriend/sendEmail.cfm', {
		YourName: $("#YourName").val(),
		YourEmail: $("#YourEmail").val(),
		FriendName: $("#FriendName").val(),
		FriendEmail: $("#FriendEmail").val()
	}, function() {
		alert('Your message has been sent.');
		$('#invite').jqmclose();
	});
	}
};
function updateMessage(theForm) {
	if($("#FriendMessage").val() == "") {
		$("#FriendMessage").html($("#FriendName").val() + ", your friend thought you might be interested in Central College. Check us out at <a href='http://www.central.edu'>http://www.central.edu</a> or request more info here - <a href='https://www.central.edu/admission/forms/info.cfm'>https://www.central.edu/admission/forms/info.cfm</a>");
	}
}