// Copyright (C) 2009 - 2012 Dwain Blazej

// ========================================
// Globals to customize.

// Where to send payment forms.
//var paymentSubmitURL='https://www.sandbox.paypal.com/cgi-bin/webscr';
var paymentSubmitURL='https://www.paypal.com/cgi-bin/webscr';

var paypalReturnUrl='http://lapedsoc.org/form/paypal_return.html';
//var paypalReturnUrl='http://lapedsoc.org/form/parmelee-_paypal_return.html';

// "Date()" month is ZERO based, so May is "4".
var lateRegistrationDate=new Date(2012,1,15 + 1); // + 1 for first day of lateness.
var lateFeeDollars=20

// ----------------------------------------
// Globals that don't need customization.

var paymentSend='payment@';
// Anti-Spambot crawler.
paymentSend+='lap' + 'edsoc' + '.org';

// Where to email bugs.
var problemReportEmail='lapedsoc+bug@';
// Anti-Spambot crawler.
problemReportEmail += 'gmail.com';

var currentDate=new Date();
// Debug:
// var currentDate=new Date(2012,1,16,0,1);
var isLate=false;
if (currentDate.valueOf() >= lateRegistrationDate.valueOf()) {
	isLate=true;
}

var colorForProblem='#fdff89';

// ========================================
// Begin: Lib


// ....................
// User special variable "onerror" to customize error handler.
// onerror=handleError;  // Function in lib.js

// Array of getElementById that are highlighted as problems.
var arrayProblemHighlight = new Array();



function debugMessage(msg) {
	// var x = document.getElementById('idDebug')
	// x.innerHTML = x.innerHTML + msg;
	// document.getElementById('idDebug').innerHTML += '<div bgcolor="#fdff89">' + msg + '</div><br />';
	document.getElementById('idDebug').style.backgroundColor='#fdff89';
	document.getElementById('idDebug').innerHTML += '<div>' + msg + '</div>';
}

function validateForm(eltMessageArea, funcValidateForm) {
	resetCorrectionFeedback(eltMessageArea);
	if (funcValidateForm != undefined) {
		if (typeof funcValidateForm == 'function') {
			funcValidateForm();
		} else {
			throw('validateForm: Function expected for funcValidateForm.');
		}
	}

	var issue;
	if (correctionMessages.length > 0) {
		if (correctionMessages.length == 1) {
			issue = 'issue';
		} else {
			issue = 'issues';
		}
		var msgHeading = 'Please address the following ' + issue + ' then try again:';
		// debugMessage('Correctionmessages length is ' + correctionMessages.length);
		var listOfCorrections = '<ul>';
		for(var i=0; i<correctionMessages.length; i++) {
			listOfCorrections += '<li class="problem">' + correctionMessages[i] + '</li>';
		}
		listOfCorrections += '</ul>';

		// var elt = document.getElementById('correctionMessageID');
		var elt = eltMessageArea;
		highlightProblem(eltMessageArea);
		// Using table instead of iframe because table has better browser support.
		elt.innerHTML = '<p><table width="100%" class="problem"><tr><td align="center" valign="top" rowspan="2"><img src="../images/alert.gif" alt="[Alert]"></td><th align="left">' +  msgHeading + '</th></tr><tr><td>' + listOfCorrections + '</td></tr></table></p>';
		document.location.href='#' + eltMessageArea.id;
		return false;
	} else {
		// Clean current page.
		resetCorrectionFeedback(eltMessageArea);
		return true;
	}		
}


function processForm(form, eltMessageArea, funcCustomizeForm, funcValidateForm) {
	if (! form) {
		throw('processForm: Form undefined.');
	}

	if ( validateForm(eltMessageArea, funcValidateForm) 
		 && formConfigure(form, funcCustomizeForm)
	   ) {
		return true;
	} else {
		// Form needs corrections.
		return false;
	}

}
// object	form
// string	name, value
// string	id: Optional.
function addHiddenInputToForm(form,name,value,id) {
	var new_element = document.createElement('input');
	new_element.setAttribute('type', 'hidden');
	new_element.setAttribute('name', name);
	new_element.setAttribute('value', value);
	if (id) {
		new_element.setAttribute('id', id);
	}
	// document.forms['form_name'].appendChild(new_element); 
	if (! form.appendChild(new_element)) {
		throw('addHiddenInputToForm: failed to append to form name=' + name + ' value=' + value);
	} else {
		// debugMessage('Added name=' + new_element.name + ' value=' + new_element.value);
	}
}


// eltMessageArea string
function resetCorrectionFeedback(eltMessageArea) {
	// var elt = document.getElementById(eltMessageArea);
	var elt = eltMessageArea;
	elt.style.backgroundColor='';
	elt.innerHTML = '';

	for(var i=0; i<arrayProblemHighlight.length; i++) {
		// document.getElementById(eltToHighlight).bgColor='';
		//document.getElementById(i).style.backgroundColor='';
		// document.getElementById(arrayProblemHighlight[i]).style.backgroundColor='';
		arrayProblemHighlight[i].style.backgroundColor='';
	}
	arrayProblemHighlight = [];
	correctionMessages = [];
}

// eltToHighlight: element to highlight.
function highlightProblem(eltToHighlight) {
	arrayProblemHighlight.push(eltToHighlight);
	// document.getElementById(eltToHighlight).bgColor=;
	//document.getElementById(eltToHighlight).className += 'problem';
	// document.getElementById(eltToHighlight).style.backgroundColor=colorForProblem;
	eltToHighlight.style.backgroundColor=colorForProblem;
}

/*
message string: Verbose correction message to show user.
* string: DOM elements to highlight.
*/
function userCorrectionRequired(message) {
	if(! message) throw('userCorrectionRequired: expected correction message');

	correctionMessages.push(message);
	// Skip the first argument, a text message to the user.
	var highlightObj;
	for (var i=1; i < arguments.length; i++) {
		highlightObj = document.getElementById(arguments[i]);
		if (! highlightObj) {
			throw('userCorrectionRequired: element id at argument index ' + i + ' is unknown: ' + arguments[i]);
		} else {
			highlightProblem(highlightObj);
		}
	}
	isValid=false;  // Usually in call scope.
}
function userCorrectionRequiredByClass(message,className) {
	if(! message) throw('userCorrectionRequiredByClass: expected correction message');

	correctionMessages.push(message);
	// Skip the first argument, a text message to the user.
	var highlightObj;
	var elts=getElementsByClassName(className);
	for (var i=0; i < elts.length; i++) {
		highlightProblem(elts[i]);
	}
	isValid=false;  // Usually in call scope.
}

// 



// End: Lib
// ========================================


// ----------------------------------------
// Begin: Helper functions.


function formConfigure(form, funcCustomizeForm) {
	// Validate assertion before making changes. Run the funcCustomizeForm last to override defaults.
	if (! funcCustomizeForm) {
		throw('formConfigure: Form not customized.');
		return false;
	} else if (typeof funcCustomizeForm != 'function') {
		throw('formConfigure: Form not customization not given a function.');
		return false;
	}

	// While the document is in "get" mode, IE v6  creates a URL for all the name value pairs.  The URL gets truncated when long.  To get around this limitation, change form method from "get" to "post" before making other additions to the form.
	form.method='post';


	// For information about the PayPal values, see "Website Payments Standard":
	// https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

	// These values customized.
	// addHiddenInputToForm(form,'item_name','');  // Max 127 chars.
	// addHiddenInputToForm(form,'item_number','');  // Max 127 chars.
	// addHiddenInputToForm(form,'amount','');

	// addHiddenInputToForm(form,'on0','');	 // "Optional Field Name", max 64 chars.

	/* "Optional Field Setting", max 200 chars, with these caveats:
		each new line is represented by a ^M^J sequence.
		when the variable is displayed in the cart during checkout and in the seller's order details, multiple new lines are compressed to one space.
		all 200 chars can be retrieved by using the download report feature.
	*/
	// addHiddenInputToForm(form,'os0','');	 


	// Form customization function needs to specify the 'cmd'.
	// addHiddenInputToForm(form,'cmd','');	// "_xclick" = Buy Now, "_cart"= Add to, view, or upload cart.

	// Use with add to cart.
	// addHiddenInputToForm(form,'add','1');
	// Use with view cart.
	// addHiddenInputToForm(form,'display','1');


	addHiddenInputToForm(form,'business', paymentSend);
	addHiddenInputToForm(form,'return',paypalReturnUrl);
	addHiddenInputToForm(form,'cbt_shipping','Return to Los Angeles Pediatric Society');
	addHiddenInputToForm(form,'cancel_return','http://lapedsoc.org/form/paypal_cancel.html');  // Max 60 chars.
	addHiddenInputToForm(form,'shipping','0.00');
	addHiddenInputToForm(form,'no_shipping','0');
	addHiddenInputToForm(form,'no_note','0'); // "0" (default) payer is prompted to include a note, 1 no note.  Max note length is 255 chars.
	addHiddenInputToForm(form,'cn','Leave any special instructions.'); // Label above payer's leave a note text box..  Max 40 chars.  Default "Add Instructions to Seller"

	addHiddenInputToForm(form,'currency_code','USD');
	addHiddenInputToForm(form,'tax','0.00');
	addHiddenInputToForm(form,'lc','US'); // Language for PayPal login page.
	addHiddenInputToForm(form,'cpp_headerback_color','d7c9c9'); // Optional: background color for the header of the payment page.

	addHiddenInputToForm(form,'cpp_headerborder_color','bda0a0');


	// If no existing window called paypal, a new window will be created.
	// Note: if this not set PayPal cart will *not* display the "contiune shopping" button.  Clicking the "contiune shopping" button simply closes the cart window, exposing the item window.
	// form.target='paypal';

	form.action = paymentSubmitURL;

	// Run the funcCustomizeForm last to override defaults.
	funcCustomizeForm();
	return true;
}

// End: Helper functions.
// ----------------------------------------


// ========================================
// Begin: Interative buttons

// ----------------------------------------
// Preload Alert icon next to correction text.
var imageButtonAddDonationNormal = new Image();
imageButtonAddDonationNormal.src = '../images/alert.gif';


// ----------------------------------------
// Begin: Interative 'Enroll Now' buttons
var imageEnrollOut = new Image();
imageEnrollOut.src = '../images/btn_enrollBrown_LG.gif';
function enrollOut(obj) {
	obj.src = imageEnrollOut.src;
}

var imageEnrollOver = new Image();
imageEnrollOver.src = '../images/btn_enroll_LG.gif';
function enrollOver(obj) {
	obj.src = imageEnrollOver.src;
}

var imageEnrollDown = new Image();
imageEnrollDown.src = '../images/btn_enroll_LG_down.gif';
function enrollDown(obj) {
	obj.src = imageEnrollDown.src;
}

var imagePleaseWait = new Image();
imagePleaseWait.src = '../images/interface/button/please wait - disabled.png';
function pleaseWait(obj) {
	obj.src = imagePleaseWait.src;
}

function enrollUp(obj) {
	enrollOut(obj);
}

// End: Interative buttons
// ========================================


/* ========================================
	Form Submission
*/
// form object required: 
// str_idMessageArea string required: place to display the form feedback messages.
// idInputHighlight string: optional. If only one element has need of highlight name it here.  If more than one, just go ahead and hard code the element's ID into the submitForm function.
function submitForm(form, str_idMessageArea, str_idInputHighlight) {
	// This "true" code path is for unsupported browser using the unmodified form.action
	if (! supportedBrowser()) { return true; } else { form.action='#'; }

	if (! str_idMessageArea) {
		throw('processForm: str_idMessageArea undefined.');
	}
	var eltMessageArea = document.getElementById(str_idMessageArea);
	if (! eltMessageArea) {
		throw('processForm: eltMessageArea undefined.');
	}

	switch(form.name)	{
	case 'nameFormViewCart':
		var funcCustomizeForm = function() {
			addHiddenInputToForm(form,'cmd','_cart');
			addHiddenInputToForm(form,'display','1');
			form.target='paypal';
		}
		return processForm(form, eltMessageArea, funcCustomizeForm);

	case 'formParmelee':
		var registrationChoiceRadios=document.getElementsByName('registrationChoice');
		var registrationChoiceIds;
		var registrationChoice=false;
		// var dinnerChoiceRequired=false;
		var dinnerChoiceRequired=true;  // For 2012 a meal choice is mandatory.
		for(var i=0;i <registrationChoiceRadios.length; i++) {
			if(registrationChoiceRadios[i].checked) {
				registrationChoice=registrationChoiceRadios[i].value;
			}				
		}
		if (registrationChoice && (registrationChoice.search(/-LectureBanquet$/) >= 0)) {
			dinnerChoiceRequired=true;
		}

		var dinnerChoiceRadios=document.getElementsByName('dinnerChoice');
		var dinnerChoiceSelected=false;
		for(var i=0;i <dinnerChoiceRadios.length; i++) {
			if(dinnerChoiceRadios[i].checked) {
				dinnerChoiceSelected=dinnerChoiceRadios[i].value;
			}				
		}

		if (!dinnerChoiceRequired) {
			dinnerChoiceSelected="none";
		}

		var registrantName=trimExtraSpaces(document.getElementById('idRegistrantName').value);

		var validationFunc = function() {
			var isOkay = true;
			if (!registrationChoice) {
				// userCorrectionRequiredByClass('Select either a &ldquo;Lecture Only&rdquo; or &ldquo;Lecture &amp; Banquet&rdquo; Tuition Type.', 'parmeleeSelector');
				userCorrectionRequiredByClass('Select a &ldquo;Lecture &amp; Banquet&rdquo; Tuition Type.', 'parmeleeSelector');
				if (dinnerChoiceRadios.focus) dinnerChoiceRadios.focus();
				isOkay =  false;
			}
			if (dinnerChoiceRequired && (! dinnerChoiceSelected)) {
				userCorrectionRequired('Select the type of dinner you wish to eat.','idDinnerChoiceCorrectionHighlight');
				if (dinnerChoiceRadios.focus) dinnerChoiceRadios.focus();
				isOkay =  false;
			}

			if (registrantName == ''){
				userCorrectionRequired('You must enter the name of the person you are registering (probably your own name).','idRegistrantNameHighlight');
				if (document.getElementById('idRegistrantName').focus) document.getElementById('idRegistrantName').focus();
				isOkay =  false;
			}

			return isOkay;
		}

		var funcCustomizeForm = function() {
			switch(registrationChoice) {
			case 'physicianMember-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for LAPS member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-10_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'physicianMember-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for LAPS member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','40.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-15_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'emeritusMember-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for physician emeritus with LAPS.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-20_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'emeritusMember-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for physician emeritus with LAPS.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','35.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-25_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'physicianNonmember-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for non-member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-30_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'physicianNonmember-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for non-member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','55.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-35_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'physicianNonmemberAddingMembership-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for non-member physician upgrading to member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-130_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'physicianNonmemberAddingMembership-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for non-member physician upgrading to member physician.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','105.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-135_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'emeritusNonmember-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for non-member emeritus.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-37_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'emeritusNonmember-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for non-member emeritus.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','45.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-39_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'alliedHealth-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for allied health personnel and others.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-40_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'alliedHealth-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for allied health personnel and others.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','40.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-45_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'resident-Lecture':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition for pediatric resident.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','error','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-50_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			case 'resident-LectureBanquet':
				addHiddenInputToForm(form,'item_name','2012 Annual Meeting and Parmelee Meeting: Tuition and banquet for pediatric resident.');  // Max 127 chars.
				addHiddenInputToForm(form,'amount','20.00','idPaypalAmount');
				addHiddenInputToForm(form,'item_number','2012_Parmelee-55_10','idPaypalItemNumber');  // Max 127 chars.
				break;
			default:
				throw('submitForm: Unexpected dues type "' + duesType + '"');
				return false;
			}

			if (isLate) {
				// Add late fee.
				var elt = document.getElementById('idPaypalAmount');
				elt.setAttribute('value', lateFeeDollars + parseFloat(elt.getAttribute('value')));
				// Change item_number to show it is a late item.
				elt = document.getElementById('idPaypalItemNumber');
				elt.setAttribute('value', elt.getAttribute('value').replace(/_10$/i, '_20'));
			}

			addHiddenInputToForm(form,'on0', 'Registrant');
			addHiddenInputToForm(form,'os0', registrantName);

			addHiddenInputToForm(form,'on1', 'Banquet');
			var os1 = dinnerChoiceSelected;
			// Paypal will not report the value of on1 if os1 is not used as well.  Include the text 'none' do give context to an otherwise meaningless option field "Customization".
			if (os1 == '') {
				os1 += 'none';
			}
			addHiddenInputToForm(form,'os1', os1);

			addHiddenInputToForm(form,'cmd','_xclick');
			return true;
		}
		return(processForm(form, eltMessageArea, funcCustomizeForm, validationFunc));

	default:
		throw('submitForm: Unexpected form name "' + form.name + '"');
		return(false);
	}
}

// ----------------------------------------
// End: Form submit entry points.

/* ========================================
	Form interaction
*/

// Also need to update the fields in: funcCustomizeForm = function
function parmeleeFees() {
		document.getElementById('parmeleeFeeHeader').innerHTML = 'Fee';
		// document.getElementById('physicianMember-Lecture-fee').innerHTML = '';
		document.getElementById('physicianMember-LectureBanquet-fee').innerHTML = '40';
		// document.getElementById('emeritusMember-Lecture-fee').innerHTML = '';
		document.getElementById('emeritusMember-LectureBanquet-fee').innerHTML = '35';
		// document.getElementById('physicianNonmember-Lecture-fee').innerHTML = '';
		document.getElementById('physicianNonmember-LectureBanquet-fee').innerHTML = '55';
		// document.getElementById('physicianNonmemberAddingMembership-Lecture-fee').innerHTML = '';
		document.getElementById('physicianNonmemberAddingMembership-LectureBanquet-fee').innerHTML = '105';
		// document.getElementById('emeritusNonmember-Lecture-fee').innerHTML = '';
		document.getElementById('emeritusNonmember-LectureBanquet-fee').innerHTML = '45';
		// document.getElementById('alliedHealth-Lecture-fee').innerHTML = '';
		document.getElementById('alliedHealth-LectureBanquet-fee').innerHTML = '40';
		// document.getElementById('resident-Lecture-fee').innerHTML = '';
		document.getElementById('resident-LectureBanquet-fee').innerHTML = '20';
	if (isLate) {
		document.getElementById('parmeleeFeeHeader').innerHTML = 'Fee (including $' + lateFeeDollars + ' late fee)';
		// document.getElementById('physicianMember-Lecture-fee').innerHTML = parseInt(lateFeeDollars + document.getElementById('physicianMember-Lecture-fee').innerHTML);
		document.getElementById('physicianMember-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('physicianMember-LectureBanquet-fee').innerHTML);
		// document.getElementById('emeritusMember-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('emeritusMember-Lecture-fee').innerHTML);
		document.getElementById('emeritusMember-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('emeritusMember-LectureBanquet-fee').innerHTML);
		// document.getElementById('physicianNonmember-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('physicianNonmember-Lecture-fee').innerHTML);
		document.getElementById('physicianNonmember-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt( document.getElementById('physicianNonmember-LectureBanquet-fee').innerHTML);
		// document.getElementById('physicianNonmemberAddingMembership-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('physicianNonmemberAddingMembership-Lecture-fee').innerHTML);
		document.getElementById('physicianNonmemberAddingMembership-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt( document.getElementById('physicianNonmemberAddingMembership-LectureBanquet-fee').innerHTML);
		// document.getElementById('emeritusNonmember-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('emeritusNonmember-Lecture-fee').innerHTML);
		document.getElementById('emeritusNonmember-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('emeritusNonmember-LectureBanquet-fee').innerHTML);
		// document.getElementById('alliedHealth-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('alliedHealth-Lecture-fee').innerHTML);
		document.getElementById('alliedHealth-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('alliedHealth-LectureBanquet-fee').innerHTML);
		// document.getElementById('resident-Lecture-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('resident-Lecture-fee').innerHTML);
		document.getElementById('resident-LectureBanquet-fee').innerHTML = lateFeeDollars + parseInt(document.getElementById('resident-LectureBanquet-fee').innerHTML);
	}
}

// Enable or Disable the dinner UI choices, useful for when the user selects a lecture only (no meal) choice.
function dinnerChoiceFunc(set) {
	var dinnerChoice=document.getElementsByName('dinnerChoice');
	for(var i=0;i <dinnerChoice.length; i++) {
		dinnerChoice[i].disabled = ! set;
	}
}


