function prepare_elements() {
	
		//alert ("preparing elements...");
	
//	Include the other necessary Javascript files
//	This works, but we'll have to come back to implement it later when there's time to do it correctly ~Muxlow
	//include_js_file (path+'__framework/javascript/test.js');
	
	
	
	
//	Assign an ID to any element with a name but no ID
	var divs = document.getElementsByTagName('div');
			
		/* FOR TESTING ONLY */ //alert ('divs = ' + divs);
	
	for (var i=0; i<divs.length; i++) {
		
		if (divs[i].name != '' && divs[i].id == '') {
			
				/* FOR TESTING ONLY */ //alert ('name = ' + divs[i].name);
			
			divs[i].id = divs[i].name;
		}
	}
			
	var forms = document.getElementsByTagName('form');
			
		/* FOR TESTING ONLY */ //alert ('forms = ' + forms);
	
	for (var i=0; i<forms.length; i++) {
		
		if (forms[i].name != '' && forms[i].id == '') {
			
			forms[i].id = forms[i].name;
			
				/* FOR TESTING ONLY */ //alert ('name = ' + forms[i].name);
		}
	}
			
	var inputs = document.getElementsByTagName('input');
			
		/* FOR TESTING ONLY */ //alert ('inputs = ' + inputs);
	
	for (var i=0; i<inputs.length; i++) {
		
		if (inputs[i].name != '' && inputs[i].id == '') {
			
				/* FOR TESTING ONLY */ //alert ('name = ' + inputs[i].name);
			
			inputs[i].id = inputs[i].name;
		}
	}
			
	var textareas = document.getElementsByTagName('textarea');
			
		/* FOR TESTING ONLY */ //alert ('textareas = ' + textareas);
	
	for (var i=0; i<textareas.length; i++) {
		
		if (textareas[i].name != '' && textareas[i].id == '') {
			
				/* FOR TESTING ONLY */ //alert ('name = ' + textareas[i].name);
			
			textareas[i].id = textareas[i].name;
		}
	}
			
	var selects = document.getElementsByTagName('select');
			
		/* FOR TESTING ONLY */ //alert ('selects = ' + selects);
	
	for (var i=0; i<selects.length; i++) {
		
		if (selects[i].name != '' && selects[i].id == '') {
			
				/* FOR TESTING ONLY */ //alert ('name = ' + selects[i].name);
			
			selects[i].id = selects[i].name;
		}
	}
	
	
	
//	Wire any get_report forms
	if (getCorrectId('form_get_report')) {
		
			/* FOR TESTING ONLY */ //alert('got the get_report form');
		
		var the_form = getCorrectId('form_get_report');
		
	//	On submit...
		the_form.onsubmit = function () {
			
				/* FOR TESTING ONLY */ //alert ("submitting get_report form");
			
		//	Validate the User Record form before submitting
			return validate_form_get_report ();
		}
	}

	
	
	
	
//	Attach popup functionality to link with a popup CLASS (popup IDs are handled below)
	var links = document.getElementsByTagName("a");
	
	var classes;
	
	for (var i=0; i<links.length; i++) {
		
		if (links[i].getAttribute("class") == "popup" || links[i].getAttribute("className") == "popup") {
			
			links[i].onclick = function () {
				
				popup(this,'popup','650','500','scrollbars=auto,resizable=yes');
				
				return false;
			}
		}
		
		if (String(links[i].getAttribute("class")).match("popup_annual_meeting_talk") || String(links[i].getAttribute("className")).match("popup_annual_meeting_talk")) {
			
				/* FOR TESTING ONLY */ //alert ('got a meeting link');
			
			links[i].onclick = function () {
				
				StartViewer(this, SfRequestVariables.ViewerModeDefault, true); // This function is part of the javascript_mediasite.js file
				
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_gallery" || links[i].getAttribute("className") == "popup_gallery") {
			
			links[i].onclick = function () {
				
				popup(this,'popup','800','580','scrollbars=yes,resizable=yes');
				
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat" || links[i].getAttribute("className") == "popup_pat") {
			links[i].onclick = function () {
 				popup(this,'popup','600','750','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
				return false; 
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat_1999_slides" || links[i].getAttribute("className") == "popup_pat_1999_slides") {

			links[i].onclick = function () {
				popup(this,'popup','650','700','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat_2000_slides" || links[i].getAttribute("className") == "popup_pat_2000_slides") {
			links[i].onclick = function () {
				popup(this,'popup','650','700','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat_2001_slides" || links[i].getAttribute("className") == "popup_pat_2001_slides") {
			links[i].onclick = function () {
				popup(this,'popup','650','580','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat_2002_slides" || links[i].getAttribute("className") == "popup_pat_2002_slides") {
			links[i].onclick = function () {
				popup(this,'popup','625','550','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_pat_2003_slides" || links[i].getAttribute("className") == "popup_pat_2003_slides") {
			links[i].onclick = function () {
				popup(this,'popup','675','580','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_payment_receipt" || links[i].getAttribute("className") == "popup_payment_receipt") {
			
				/* FOR TESTING ONLY */ //alert ('got a payment receipt link');
			
			links[i].onclick = function () {
				popup(this,'popup','675','580','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_photo_upload_instructions" || links[i].getAttribute("className") == "popup_photo_upload_instructions") {
			links[i].onclick = function () {
				popup(this,'popup','700','600','scrollbars=yes,resizable=yes');
				return false;
			}
		}
		
		if (links[i].getAttribute("class") == "popup_retinatimes_video" || links[i].getAttribute("className") == "popup_retinatimes_video") {
			links[i].onclick = function () {
				popup(this,'popup','700','540','scrollbars=yes,resizable=yes');
				return false;
			}
		}
	}
		
		/* FOR TESTING ONLY */ //alert ("classes = " + classes);
	
//	Attach popup code to the RetinaTalk link in the nav
	if (getCorrectId('nav_link_retinatalk')) {
		
		getCorrectId('nav_link_retinatalk').onclick = function () {
			
				/* FOR TESTING ONLY */ //alert ('click');
			
			popup (this, 'nav_link_retinatalk', '650','500','scrollbars=auto,resizable=yes');
			
			return false;
		}
	}
	
	
//	Attach clear field functionality to text fields
	var fields = getElementsByClass('input', 'clear_on_focus');
	
	for (var i=0; i<fields.length; i++) {
		
		fields[i].onclick = function () {
			
			clear_field(this);
		}
		
		fields[i].onfocus = fields[i].onclick;
	}
	
//	Attach popup functionality to the abstract and register links in the Meetings nav
	
	if (getCorrectId('popup_abstracts')) { // Since this only appears on one page, we have to make sure it's present, else the script will break and stop preparing elements
		getCorrectId('popup_abstracts').onclick = function () {
			popup(this,'abstracts','660','524','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no');
			return false;
		}
	}
	
	if (getCorrectId('popup_register')) { // Since this only appears in the Meetings section's nav, we have to make sure they're present, else the script will break and stop preparing elements
		getCorrectId('popup_register').onclick = function () {
			popup(this,'register','660','524','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes');
			return false;
		}
	}
	
	if (getCorrectId('popup_register2')) { // Since this only appears in the Meetings section's nav, we have to make sure they're present, else the script will break and stop preparing elements
		getCorrectId('popup_register2').onclick = function () {
			popup(this,'register','660','524','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes');
			return false;
		}
	}
	
	if (getCorrectId('group_tours_nav_link')) { // Since this only appears in the Meetings section's nav, we have to make sure they're present, else the script will break and stop preparing elements
		
		getCorrectId('group_tours_nav_link').onclick = function () {
			
			window.open('group_tours.pdf');
			
			location.href='index.php';
			
			return false;
		}
	}
	
//	Attach rollover & popup functionality to the login button & greeting links

	var login_links = getElementsByClass('a', 'login_link');
	
	for (var i=0; i < login_links.length; i++) {
	 	
	 	login_links[i].onclick = function () {
	 		
			toggle('button','none');
			toggle('greeting','block');
			
			return false;
		}
	}
	
	 var logout_links = getElementsByClass('a', 'logout_link');
	 
	 for (var i=0; i < logout_links.length; i++) {
	 	
	 	logout_links[i].onclick = function () {
	 		
			toggle('greeting','none');
			toggle('button','block');
		}
	}

	if (getCorrectId('login_close')){
		
		getCorrectId('login_close').onclick = function () {
			
			toggle('greeting','none');
			toggle('button','block');
			
			return false;
		}
	}
	
	
	
	
//	SPECIAL FUNCTIONS FUNCTIONALITY PREPARATION
	
	//if (getCorrectId('special_features')) { // the <body> tag is ID'd as special_features in the special features section
		
			//alert ("We're in the Special Features section");
		
		
//	USER MANAGEMENT
		
		
	//	Ideally, this list would come from the DB (get unique country codes from the States table) and be printed here by PHP
		var state_pulldowns	= new Array('AU','CA','UK','US');
		
		
	//	MAIN COUNTRY
		
	//	If the main country pulldown exists...	
		if (getCorrectId('location_0_address_country_code_iso2')) { 
		
		//	Add functionality to the Main country pulldown...
			getCorrectId('location_0_address_country_code_iso2').onchange = function () {
				
				location_0_country_func(this.value);
			}
			
			location_0_country_func(getCorrectId('location_0_address_country_code_iso2').options[getCorrectId('location_0_address_country_code_iso2').selectedIndex].value);
			
		} // END MAIN COUNTRY
		
		
		
		
	//	MAILING COUNTRY
	
		if (getCorrectId('location_1_address_country_code_iso2')) { 
			
		//	Find the mailing address radio buttons	
			getCorrectId('location_1_Y').onclick = function () {
				
					//alert ("you clicked " + this.name);
				
				getCorrectId('row_location_1_address_country_code_iso2').className 	= '';
				getCorrectId(    'location_1_address_country_code_iso2').disabled 	= false;
				
				location_1_country_func(getCorrectId('location_1_address_country_code_iso2').options[getCorrectId('location_1_address_country_code_iso2').selectedIndex].value);					
			}
			
			getCorrectId('location_1_N').onclick = function () {
				
					//alert ("you clicked " + this.name + ' which is checked (' + this.checked + ')');
					
			//	Turn EVERYTHING off...
				getCorrectId('row_location_1_address_country_code_iso2').className	= 'hidden';
				getCorrectId(    'location_1_address_country_code_iso2').disabled	= true;
				
				getCorrectId('row_location_1_address_streets').className			= 'hidden';
				getCorrectId(    'location_1_address_street_1').disabled			= true;
				getCorrectId(    'location_1_address_street_2').disabled			= true;
				
				getCorrectId('row_location_1_address_city').className				= 'hidden';
				getCorrectId(    'location_1_address_city').disabled				= true;
				
				getCorrectId('row_location_1_address_zip_code').className			= 'hidden';
				getCorrectId(    'location_1_address_zip_code').disabled			= true;
				
				getCorrectId('row_location_1_address_postal_code').className		= 'hidden';
				getCorrectId(    'location_1_address_postal_code').disabled			= true;
				
				getCorrectId('row_location_1_address_zip_postal_code').className	= 'hidden';
				getCorrectId(    'location_1_address_zip_postal_code').disabled		= true;
				
				for (var i=0; i<state_pulldowns.length; i++) {
				
					getCorrectId('row_location_1_address_state_prov_ter_' + state_pulldowns[i].toLowerCase()).className	= 'hidden';
					getCorrectId(    'location_1_address_state_prov_ter_' + state_pulldowns[i]).disabled 				= true;
				}
					
				getCorrectId('row_location_1_address_state_prov_ter_yy').className	= 'hidden';
				getCorrectId(    'location_1_address_state_prov_ter_YY').disabled	= true;
			}
			
		//	Then add the functionality to the Mailing country pulldown
			getCorrectId('location_1_address_country_code_iso2').onchange = function () {
				location_1_country_func(this.value);
			}
			
		//	Run the script if we're coming back to the page w/ an address	
			if (getCorrectId('location_1_Y').checked) {
				
				getCorrectId('row_location_1_address_country_code_iso2').className	= '';
				getCorrectId(    'location_1_address_country_code_iso2').disabled 	= false;
				
				location_1_country_func(getCorrectId('location_1_address_country_code_iso2').options[getCorrectId('location_1_address_country_code_iso2').selectedIndex].value);					
			}
			
		} // END MAILING COUNTRY
		
		
		
		
	//	USER STATUS
		
		if (getCorrectId('status')) {
			
				//alert ("Got status...");
			
			getCorrectId('status').onchange = function () {
			
					//alert ("User Status = " + this.value);
				
				adapt_user_edit(this.value);
			}
			
		} // END USER STATUS
		
		
			
	
	//	SEARCH RESULTS
		
		if (getCorrectId('search_results')) {
			
		//	Disable the preview buttons
			var form_inputs = document.getElementsByTagName('input'); 
			
			for (var i=0; i<form_inputs.length; i++) {
				
					//alert ('i = ' + i);
				
				if (form_inputs[i].type == 'radio') {
					
						//alert ('form_input = ' + form_inputs[i]);
					
					form_inputs[i].onclick = function () {
						
							//alert ('changing');
						
						getCorrectId('preview1').disabled = false;
						getCorrectId('preview2').disabled = false;
					}
					
				} //else { alert ('bah = ' + form_inputs[i].type); }
			}
			
		} // END SEARCH RESULTS
		
		
		
	//	ADDITIONAL LOCATION
	
	//	Loop through the additional locations
		for (var i=0; i<10; i++) { // NOTE : We're limiting the add locs to 10...
		
			if (getCorrectId('additional_location_' + i + '_Y')) { 
				
				var btn_y = getCorrectId('additional_location_' + i + '_Y');
				var btn_n = getCorrectId('additional_location_' + i + '_N');
				var pld_c = getCorrectId('additional_location_' + i + '_address_country_code_iso2');
				
			//	Find the Add Loc radio buttons	
				btn_y.onclick = function () {
					
						//alert ('click ' + this.value);
					
					var i = this.name.charAt(this.name.length - 1);
					
					additional_location_btn_y_func(i);
				}
				
				btn_n.onclick = function () {
					
						//alert ('click ' + this.value);
					
					var i = this.name.charAt(this.name.length - 1);
					
					additional_location_btn_n_func(i,this.checked);
				}
				
				
			//	Find the Add Loc country pulldown
				pld_c.onchange = function () {
					
					var i = this.name.charAt(20); // the X will be the 20th character in additional_location_X_country
					
					additional_location_country_func (i, this.value);
				}
				
			//	Run the Y / N script as soon as the page loads so we open the Add Loc form if we're coming from the preview
				if (btn_y.checked) {
					
						//alert ('opening form : '); // + getCorrectId('additional_location_' + i).id);
					
					var i = btn_y.name.charAt(20); // the X will be the 20th character in "additional_location_X"
					
					additional_location_func (i, btn_y.value);
				}
				
			} // END ADDITIONAL LOCATION
			
		} // END LOOP THROUGH ADDITIONAL LOCATIONS
		
		
		
		
		
		
					
	//	If this is the form on the user / approvals / index page
		if (getCorrectId('approve_new_and_updated_user_records')) {
			
		//	Disable the preview buttons
			if (getCorrectId('preview1')) { getCorrectId('preview1').disabled = true; }
			if (getCorrectId('preview2')) { getCorrectId('preview2').disabled = true; }
			
			var form_inputs = document.getElementsByTagName('input'); 
			
			for (var i=0; i<form_inputs.length; i++) {
				
				if (form_inputs[i].type == 'radio') {
					
					form_inputs[i].onclick = function () {
			
						if (getCorrectId('preview1')) { getCorrectId('preview1').disabled = false; }
						if (getCorrectId('preview2')) { getCorrectId('preview2').disabled = false; }
					}
				}
			}
			
		} // END If this is the form on the user / approvals / index page
		
		
			/* FOR TESTING ONLY */ //alert ("user_status = " + user_status);
		
		
	//	If this is the Admin's Edit User Record page...
		if (getCorrectId('status') && (getCorrectId('edit_user_record') || getCorrectId('approve_user_record'))) {
			
				/* FOR TESTING ONLY */ //alert ('User Status = ' + getCorrectId('status').value);
			
		//	Display the correct for fields for the User Status of the User Record being created / edited
			adapt_user_edit(getCorrectId('status').value);
		
		
		
	//..otherwise, if this is the Manage Your Account page...
		} else if (getCorrectId('new_guest_account')) {
			
				/* FOR TESTING ONLY */ //alert ("Got the guest account reg form and the User Status is " + getCorrectId('status').options[getCorrectId('status').selectedIndex].value);
				
		//	Display the correct for fields for the User Status of the User Record being previewed
			adapt_user_edit(getCorrectId('status').options[getCorrectId('status').selectedIndex].value);
		
		
		
	//..otherwise, if this is the Manage Your Account page...
		} else if (getCorrectId('tbl_user_record_edit_main')) {
			
				/* FOR TESTING ONLY */ //alert ("User Status = " );
				
		//	Display the correct for fields for the User Status of the User Record being previewed
			adapt_user_edit(user_status);
		
		
		
	//..otherwise, if this is the User Record preview page...
		} else if (getCorrectId('tbl_user_record_preview_main')) {
			
				/* FOR TESTING ONLY */ //alert ('tbl_user_record_preview_main exists');
			
		//	Display the correct for fields for the User Status of the User Record being previewed
			if (getCorrectId('status')) {
				
				adapt_user_preview (getCorrectId('status').value);
				
			} else {
				
				adapt_user_preview (user_status);
			}
		}
		
		
		
		
		
	//	If this page contains an Edit User Record form...
		if (
				getCorrectId('new_guest_account') // /meetings/asrs_annual_meeting/register/guest_register.php
				
					||
					
				getCorrectId('asrs_record_update') // /meetings/asrs_annual_meeting/register/asrs_record_edit.php
				
					||
					
				getCorrectId('new_user_record') // /special_features/user/new
				
					||
					
				getCorrectId('edit_user_record') // /admin/user/edit
				
					||
				
				getCorrectId('approve_user_record') // /admin/user/approvals
		) {
			
				/* FOR TESTING ONLY */ //alert('got a form');
			
			if (getCorrectId('new_guest_account')) {
				
					//alert('got a guest form');
				
				var the_form = getCorrectId('new_guest_account');
			
			} else if (getCorrectId('asrs_record_update')) {
				
					//alert('got the asrs_record_update form');
				
				var the_form = getCorrectId('asrs_record_update');
				
			} else if (getCorrectId('new_user_record')) {
				
				var the_form = getCorrectId('new_user_record');
			
			} else if (getCorrectId('edit_user_record')) {
				
					/* FOR TESTING ONLY */ //alert('got the edit_user_record form');
				
				var the_form = getCorrectId('edit_user_record');
				
			} else if (getCorrectId('approve_user_record')) {
				
					/* FOR TESTING ONLY */ //alert('got the approve_user_record form');
				
				var the_form = getCorrectId('approve_user_record');
			}
			
		//	On submit...
			the_form.onsubmit = function () {
				
					//alert ("submitting form");
				
			//	Select all the degrees in the Selected degrees box
				selectAllOptions(getCorrectId('degrees[]'));
				
			//	Validate the User Record form before submitting
				return validate_user_edit ();
			}
		}
		
		
		
	//	If this is a meeting registration admin tool...
		if (
			
			getCorrectId('frm_admin_meeting_registration_new') ||
			getCorrectId('frm_admin_meeting_registration_edit')
		
		) {
			
				/* FOR TESTING ONLY */ //alert ("Got the admin meeting registration new form");
			
			var types = new Array (
				
				'member_reg_',
				
				'guest_reg_0_',
				'guest_reg_1_',
				'guest_reg_2_',
				'guest_reg_3_',
				'guest_reg_4_',
				'guest_reg_5_',
				
				'tennis_0_',
				'tennis_1_',
				
				'tennis_wait_list_0_',
				
				'film_0_',
				'film_1_',
				
				'gala_0_',
				'gala_1_',
				'gala_2_',
				'gala_3_',
				'gala_4_',
				'gala_5_',
				
				'museum_0_',
				'museum_1_',
				'museum_2_',
				'museum_3_',
				'museum_4_',
				'museum_5_'
			);
			
			for (var i=0; i<types.length; i++) {
				
				wire_billing_elements (types[i]);
			}
			
		} // END frm_admin_meeting_registration_new
		
	
		
		
	//	THIS IS ALL DEPRECATED??? /////////////////////////////////////////////
	//	THIS IS ALL DEPRECATED??? /////////////////////////////////////////////
	//	THIS IS ALL DEPRECATED??? /////////////////////////////////////////////
		
	//	If this is the meeting registration admin tool...
		if (getCorrectId('frm_meeting_registration_update')) {
			
				/* FOR TESTING ONLY */ //alert ("Got the meeting registration admin form");
			
			var the_form = getCorrectId('frm_meeting_registration_update');
			
			//	NOTE: We don't use the var declaration because this needs to be a global var so the following functions can see it
				the_amount 	= getCorrectId('transaction_amount');
				
				/* FOR TESTING ONLY */ //alert ("the_form = " + the_form);
				/* FOR TESTING ONLY */ //alert ("the_amount = " + the_amount);
			
			
			
			if (getCorrectId('cancel_registration')) {
				
				getCorrectId('cancel_registration').onclick = function () {
					
						/* FOR TESTING ONLY */ //alert ("click = " + this.value + ' - ' + the_amount.value);
					
					if (this.checked == true) {
						
					//	Delete the amount charged for the meeting registration
						the_amount.value = parseInt(the_amount.value) - parseInt(this.value);
						
					//	Loop through the guests
						for (var i=0; i<6; i++) {
							
								/* FOR TESTING ONLY */ //alert (parseInt(getCorrectId('frmAdultGuests'+i+'Status').options[getCorrectId('frmAdultGuests'+i+'Status').selectedIndex].getAttribute('cost')));
							
							getCorrectId('frmAdultGuests'+i+'Name').disabled = true;
							getCorrectId('frmAdultGuests'+i+'Status').disabled = true;
							
						//	If there's a delete button (i.e.: this was an existing guest)...
							if (getCorrectId('frmAdultGuests'+i+'Delete')) { 
							
							//..mark the guest as deleted
								getCorrectId('frmAdultGuests'+i+'Delete').checked = true; 
								
							//..call the delete button's onchange function, which will update the_amount
								getCorrectId('frmAdultGuests'+i+'Delete').onchange();
								
							//..disable the delete button so the guest can't be turned back on
								getCorrectId('frmAdultGuests'+i+'Delete').disabled = true;
							
							} else {
								
							//	Delete the amount set for this guest
								the_amount.value = parseInt(the_amount.value) - parseInt(getCorrectId('frmAdultGuests'+i+'Status').options[getCorrectId('frmAdultGuests'+i+'Status').selectedIndex].getAttribute('cost'));
							}
						}
						
						if (getCorrectId('frmGolf')) {
							
							getCorrectId('frmGolf').disabled = true;
							
							// No need to adjust the total as golf packages are non-refundable
						}
						
					} else if (this.checked == false) {
						
						the_amount.value = parseInt(the_amount.value) + parseInt(this.value);
						
						for (var i=0; i<6; i++) {
							
							getCorrectId('frmAdultGuests'+i+'Name').disabled = false;
							getCorrectId('frmAdultGuests'+i+'Status').disabled = false;
							
							if (getCorrectId('frmAdultGuests'+i+'Delete')) { 
								getCorrectId('frmAdultGuests'+i+'Delete').disabled = false;
								getCorrectId('frmAdultGuests'+i+'Delete').checked = false; 
								getCorrectId('frmAdultGuests'+i+'Delete').onchange(); 
							
							} else {
								
							//	Delete the amount set for this guest
								the_amount.value = parseInt(the_amount.value) + parseInt(getCorrectId('frmAdultGuests'+i+'Status').options[getCorrectId('frmAdultGuests'+i+'Status').selectedIndex].getAttribute('cost'));
							}
						}
						
						if (getCorrectId('frmGolf')) {
							
							getCorrectId('frmGolf').disabled = false;
							
							// No need to adjust the total as golf packages are non-refundable
						}
					}
				}
			}
			
			
			
			
		//	Note the original value of this pulldown so we can calculate the right amount to + / - from the total when it (the pulldown) is changed
		//	We don't use the var declaration because this needs to be a global var so the following onchange function can see it
			
		//	If you can figure out how to create var name dynamically, these call all be wrappped in a nice for loop. ~ Muxlow
			
			if (getCorrectId('frmAdultGuests0Status')) {
				guest_0 = getCorrectId('frmAdultGuests0Status');
				orig_guest_0_cost = parseInt(guest_0.options[guest_0.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests0Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_0_cost;
					orig_guest_0_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests0Delete')) {
					getCorrectId('frmAdultGuests0Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_0.options[guest_0.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests0Name').disabled = true;
							getCorrectId('frmAdultGuests0Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_0.options[guest_0.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests0Name').disabled = false;
							getCorrectId('frmAdultGuests0Status').disabled = false;
						}
					}
				}
			}
			
			if (getCorrectId('frmAdultGuests1Status')) {
				guest_1 = getCorrectId('frmAdultGuests1Status');
				orig_guest_1_cost = parseInt(guest_1.options[guest_1.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests1Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_1_cost;
					orig_guest_1_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests1Delete')) {
					getCorrectId('frmAdultGuests1Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_1.options[guest_1.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests1Name').disabled = true;
							getCorrectId('frmAdultGuests1Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_1.options[guest_1.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests1Name').disabled = false;
							getCorrectId('frmAdultGuests1Status').disabled = false;
						}
					}
				}
			}
			
			if (getCorrectId('frmAdultGuests2Status')) {
				guest_2 = getCorrectId('frmAdultGuests2Status');
				orig_guest_2_cost = parseInt(guest_2.options[guest_2.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests2Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_2_cost;
					orig_guest_2_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests2Delete')) {
					getCorrectId('frmAdultGuests2Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_2.options[guest_2.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests2Name').disabled = true;
							getCorrectId('frmAdultGuests2Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_2.options[guest_2.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests2Name').disabled = false;
							getCorrectId('frmAdultGuests2Status').disabled = false;
						}
					}
				}
			}
			
			if (getCorrectId('frmAdultGuests3Status')) {
				guest_3 = getCorrectId('frmAdultGuests3Status');
				orig_guest_3_cost = parseInt(guest_3.options[guest_3.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests3Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_3_cost;
					orig_guest_3_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests3Delete')) {
					getCorrectId('frmAdultGuests3Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_3.options[guest_3.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests3Name').disabled = true;
							getCorrectId('frmAdultGuests3Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_3.options[guest_3.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests3Name').disabled = false;
							getCorrectId('frmAdultGuests3Status').disabled = false;
						}
					}
				}
			}
			
			if (getCorrectId('frmAdultGuests4Status')) {
				guest_4 = getCorrectId('frmAdultGuests4Status');
				orig_guest_4_cost = parseInt(guest_4.options[guest_4.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests4Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_4_cost;
					orig_guest_4_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests4Delete')) {
					getCorrectId('frmAdultGuests4Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_4.options[guest_4.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests4Name').disabled = true;
							getCorrectId('frmAdultGuests4Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_4.options[guest_4.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests4Name').disabled = false;
							getCorrectId('frmAdultGuests4Status').disabled = false;
						}
					}
				}
			}
			
			if (getCorrectId('frmAdultGuests5Status')) {
				guest_5 = getCorrectId('frmAdultGuests5Status');
				orig_guest_5_cost = parseInt(guest_5.options[guest_5.selectedIndex].getAttribute('cost'));
				getCorrectId('frmAdultGuests5Status').onchange = function () {
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - orig_guest_5_cost;
					orig_guest_5_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
				if (getCorrectId('frmAdultGuests5Delete')) {
					getCorrectId('frmAdultGuests5Delete').onchange = function () {
						if (this.checked == true) {
							the_amount.value = parseInt(the_amount.value) - parseInt(guest_5.options[guest_5.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests5Name').disabled = true;
							getCorrectId('frmAdultGuests5Status').disabled = true;
						} else if (this.checked == false) {
							the_amount.value = parseInt(the_amount.value) + parseInt(guest_5.options[guest_5.selectedIndex].getAttribute('cost'));
							getCorrectId('frmAdultGuests5Name').disabled = false;
							getCorrectId('frmAdultGuests5Status').disabled = false;
						}
					}
				}
			}
			
			
			if (getCorrectId('frmGolf')) {
				
				var the_golf = getCorrectId('frmGolf');
				
					/* FOR TESTING ONLY */ //alert ("the_golf = " + the_golf.options[the_golf.selectedIndex].value);
				
			//	Note the original value of this pulldown so we can calculate the right amount to + / - from the total when it (the pulldown) is changed
			//	We don't use the var declaration because this needs to be a global var so the following onchange function can see it
				the_golf_orig_cost = parseInt(the_golf.options[the_golf.selectedIndex].getAttribute('cost'));
							
				the_golf.onchange = function () {
						
						/* FOR TESTING ONLY */ //alert ("change = " + the_amount.value + ' + ' + this.options[this.selectedIndex].getAttribute('cost') + ' - ' + the_golf_orig_cost);
						
					the_amount.value = parseInt(the_amount.value) + parseInt(this.options[this.selectedIndex].getAttribute('cost')) - the_golf_orig_cost;
					
				//	We need to reset this so the next time onchange is called, we can calculate the right amount to + / - from the total
				//	The attribute 'cost' is where we stuck the dollar amount for that number (i.e.: the option's value) of packages in edit.php
					the_golf_orig_cost = parseInt(this.options[this.selectedIndex].getAttribute('cost'));
				}
			}
		}
		
	//	END DEPRECATED /////////////////////////////////////////////
	//	END DEPRECATED /////////////////////////////////////////////
	//	END DEPRECATED /////////////////////////////////////////////
		
		
		
		
		if (getCorrectId('photo_forget') && getCorrectId('photo')) {
			
			getCorrectId('photo_forget').onclick = function() {
				
				if (this.checked) {
					
					getCorrectId('photo').disabled = true;
					
				} else {
					
					getCorrectId('photo').disabled = false;
				}
			}
		}
		
		
		
		
	//	Add validation to the forms that include the payment method form
	//	If you can figure out a way to get the ID of any <form> encasing the payment method form, we won't have to specify them individually...
		if (getCorrectId('frm_user_dues')) {
			getCorrectId('frm_user_dues').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_admin_billing_payment_new')) {
			getCorrectId('frm_admin_billing_payment_new').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_admin_billing_payment_edit')) {
			getCorrectId('frm_admin_billing_payment_edit').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_annual_meeting_registration')) {
			getCorrectId('frm_annual_meeting_registration').onsubmit = function () {
				if (validate_form_annual_meeting_registration()) {
					return validate_payment_method_form();
				} else {
					return false;
				}
			}
		}
		if (getCorrectId('frm_admin_meeting_registration_new')) {
			getCorrectId('frm_admin_meeting_registration_new').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_admin_meeting_registration_edit')) {
			getCorrectId('frm_admin_meeting_registration_edit').onsubmit = function () {
				
				if (
					
					getCorrectId('member_reg_rate_id').value  != '' ||
					
					getCorrectId('guest_reg_0_rate_id').value != '' ||
					getCorrectId('guest_reg_1_rate_id').value != '' ||
					getCorrectId('guest_reg_2_rate_id').value != '' ||
					getCorrectId('guest_reg_3_rate_id').value != '' ||
					getCorrectId('guest_reg_4_rate_id').value != '' ||
					getCorrectId('guest_reg_5_rate_id').value != '' ||
					
					getCorrectId('golf_0_rate_id').value != '' ||
					getCorrectId('golf_1_rate_id').value != '' ||
					getCorrectId('golf_2_rate_id').value != '' ||
					getCorrectId('golf_3_rate_id').value != '' ||
					getCorrectId('golf_4_rate_id').value != '' ||
					getCorrectId('golf_5_rate_id').value != '' ||
					
					getCorrectId('luau_0_rate_id').value != '' ||
					getCorrectId('luau_1_rate_id').value != '' ||
					getCorrectId('luau_2_rate_id').value != '' ||
					getCorrectId('luau_3_rate_id').value != '' ||
					getCorrectId('luau_4_rate_id').value != '' ||
					getCorrectId('luau_5_rate_id').value != '' ||
					
					getCorrectId('film_0_rate_id').value != '' ||
					getCorrectId('film_1_rate_id').value != ''
					
				) {
					
					return validate_payment_method_form();
				}
			}
		}
		if (getCorrectId('frm_admin_meeting_corporate_supporter_new')) {
			getCorrectId('frm_admin_meeting_corporate_supporter_new').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_admin_meeting_corporate_supporter_edit')) {
			getCorrectId('frm_admin_meeting_corporate_supporter_edit').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_corporate_supporter_billing')) {
			getCorrectId('frm_corporate_supporter_billing').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		if (getCorrectId('frm_admin_user_dues_process_payment')) {
			getCorrectId('frm_admin_user_dues_process_payment').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		
		
	//	WIRE ANY BILLING ELEMENTS
	//	This will wire any we use anywhere
		var selects = document.getElementsByTagName('select');
		
		for (var i=0; i<selects.length; i++) {
			
			if (selects[i].name.indexOf('_rate_id')) {
				
				var s = selects[i].name.replace('rate_id','');

				wire_billing_elements(s);
			}
		}
		
	//	Validate the Dues payment form
		if (getCorrectId('admin_user_dues_process_payment')) {
			getCorrectId('admin_user_dues_process_payment').onsubmit = function () {
				return validate_payment_method_form();
			}
		}
		
		
			
		if (getCorrectId('payment_method') && getCorrectId('payment_method').type == 'select-one') {
			
			/* FOR TESTING ONLY */ //alert ("payment method is a "+getCorrectId('payment_method').type);
			
		//	Handle the selection of a payment method
			getCorrectId('payment_method').onchange = function () {
				
					/* FOR TESTING ONLY */ //alert ('method pulldown selection: ' + this.options[this.selectedIndex].value);
				
				if (
					this.options[this.selectedIndex].value == "credit_card" ||
					this.options[this.selectedIndex].value == "terminal"
				) {
					
					if (this.options[this.selectedIndex].value == "credit_card") {
						
						getCorrectId('row_payment_method_credit_card_number').className		= '';
						getCorrectId('row_payment_method_credit_card_cvv').className		= '';
						
						getCorrectId('row_payment_method_credit_card_number_4').className		= 'hidden';
						getCorrectId('row_payment_method_terminal_invoice_number').className	= 'hidden';
						getCorrectId('row_payment_method_terminal_approval_code').className		= 'hidden';
					}
					
					if (this.options[this.selectedIndex].value == "terminal") {
						
						getCorrectId('row_payment_method_credit_card_number').className		= 'hidden';
						getCorrectId('row_payment_method_credit_card_cvv').className		= 'hidden';
						
						getCorrectId('row_payment_method_credit_card_number_4').className		= '';
						getCorrectId('row_payment_method_terminal_invoice_number').className	= '';
						getCorrectId('row_payment_method_terminal_approval_code').className		= '';
					}
					
					getCorrectId('row_payment_method_name').className 					= '';	
					getCorrectId( 'th_payment_method_name_cash').className 				= 'hidden';
					getCorrectId(  'p_payment_method_name_cash_note').className 		= 'hidden';
					getCorrectId( 'th_payment_method_name_check').className 			= 'hidden';
					getCorrectId( 'th_payment_method_name_credit_card').className		= '';
					
					getCorrectId('row_payment_method_check_number').className 			= 'hidden';
					
					getCorrectId('row_payment_method_credit_card_brand').className 				= '';
					getCorrectId('row_payment_method_credit_card_expiration_date').className	= '';
					
					getCorrectId('row_payment_method_address1').className 				= '';
					getCorrectId('row_payment_method_address2').className 				= '';
					getCorrectId('row_payment_method_city').className 					= '';
					getCorrectId('row_payment_method_state').className 					= '';
					getCorrectId('row_payment_method_zip').className 					= '';
					getCorrectId('row_payment_method_country').className 				= '';
					
					if (getCorrectId('payment_method_check_number')) {
						
						getCorrectId('payment_method_check_number').disabled 				= true;
						
						getCorrectId('payment_method_credit_card_brand_MC').disabled 		= false;
						getCorrectId('payment_method_credit_card_brand_AMEX').disabled 		= false;
						getCorrectId('payment_method_credit_card_brand_VISA').disabled 		= false;
						getCorrectId('payment_method_credit_card_number').disabled 			= false;
						getCorrectId('payment_method_credit_card_cvv').disabled 			= false;
						getCorrectId('payment_method_credit_card_expiration_date').disabled	= false;
						
						getCorrectId('payment_method_address1').disabled				= false;
						getCorrectId('payment_method_address2').disabled				= false;
						getCorrectId('payment_method_city').disabled 					= false;
						getCorrectId('payment_method_state').disabled 					= false;
						getCorrectId('payment_method_zip').disabled 					= false;
						getCorrectId('payment_method_country').disabled 				= false;
					}
					
				} else if (this.options[this.selectedIndex].value == "check") {
					
					getCorrectId('row_payment_method_name').className 					= '';
					getCorrectId( 'th_payment_method_name_cash').className 				= 'hidden';
					getCorrectId(  'p_payment_method_name_cash_note').className 		= 'hidden';
					getCorrectId( 'th_payment_method_name_check').className 			= '';
					getCorrectId( 'th_payment_method_name_credit_card').className		= 'hidden';
					
					getCorrectId('row_payment_method_check_number').className 			= '';
					
					getCorrectId('row_payment_method_credit_card_brand').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_number').className 			= 'hidden';
					getCorrectId('row_payment_method_credit_card_number_4').className			= 'hidden';
					getCorrectId('row_payment_method_credit_card_cvv').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_expiration_date').className	= 'hidden';
					
					getCorrectId('row_payment_method_terminal_invoice_number').className	= 'hidden';
					getCorrectId('row_payment_method_terminal_approval_code').className		= 'hidden';
					
					getCorrectId('row_payment_method_address1').className 				= '';
					getCorrectId('row_payment_method_address2').className 				= '';
					getCorrectId('row_payment_method_city').className 					= '';
					getCorrectId('row_payment_method_state').className 					= '';
					getCorrectId('row_payment_method_zip').className 					= '';
					getCorrectId('row_payment_method_country').className 				= '';
					
					if (getCorrectId('payment_method_check_number')) {
							
						getCorrectId('payment_method_check_number').disabled 			= false;
						
						getCorrectId('payment_method_credit_card_brand_MC').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_AMEX').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_VISA').disabled 		= true;
						getCorrectId('payment_method_credit_card_number').disabled 			= true;
						getCorrectId('payment_method_credit_card_cvv').disabled 			= true;
						getCorrectId('payment_method_credit_card_expiration_date').disabled	= true;
						
						getCorrectId('payment_method_address1').disabled				= false;
						getCorrectId('payment_method_address2').disabled				= false;
						getCorrectId('payment_method_city').disabled 					= false;
						getCorrectId('payment_method_state').disabled 					= false;
						getCorrectId('payment_method_zip').disabled 					= false;
						getCorrectId('payment_method_country').disabled 				= false;
						
					}
					
				} else if (this.options[this.selectedIndex].value == "cash") {
					
					getCorrectId('row_payment_method_name').className 					= '';
					getCorrectId( 'th_payment_method_name_cash').className 				= '';
					getCorrectId(  'p_payment_method_name_cash_note').className 		= '';
					getCorrectId( 'th_payment_method_name_check').className 			= 'hidden';
					getCorrectId( 'th_payment_method_name_credit_card').className		= 'hidden';
						
					getCorrectId('row_payment_method_check_number').className 			= 'hidden';
					
					getCorrectId('row_payment_method_credit_card_brand').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_number').className 			= 'hidden';
					getCorrectId('row_payment_method_credit_card_number_4').className			= 'hidden';
					getCorrectId('row_payment_method_credit_card_cvv').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_expiration_date').className	= 'hidden';
					
					getCorrectId('row_payment_method_terminal_invoice_number').className		= 'hidden';
					getCorrectId('row_payment_method_terminal_approval_code').className			= 'hidden';
					
					getCorrectId('row_payment_method_address1').className 				= 'hidden';
					getCorrectId('row_payment_method_address2').className 				= 'hidden';
					getCorrectId('row_payment_method_city').className 					= 'hidden';
					getCorrectId('row_payment_method_state').className 					= 'hidden';
					getCorrectId('row_payment_method_zip').className 					= 'hidden';
					getCorrectId('row_payment_method_country').className 				= 'hidden';
					
					if (getCorrectId('payment_method_check_number')) {
							
						getCorrectId('payment_method_check_number').disabled 				= true;
						
						getCorrectId('payment_method_credit_card_brand_MC').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_AMEX').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_VISA').disabled 		= true;
						getCorrectId('payment_method_credit_card_number').disabled 			= true;
						getCorrectId('payment_method_credit_card_cvv').disabled 			= true;
						getCorrectId('payment_method_credit_card_expiration_date').disabled	= true;
						
						getCorrectId('payment_method_address1').disabled				= true;
						getCorrectId('payment_method_address2').disabled				= true;
						getCorrectId('payment_method_city').disabled 					= true;
						getCorrectId('payment_method_state').disabled 					= true;
						getCorrectId('payment_method_zip').disabled 					= true;
						getCorrectId('payment_method_country').disabled 				= true;
						
					}
					
				} else {
					
					getCorrectId('row_payment_method_name').className 					= 'hidden';
					getCorrectId( 'th_payment_method_name_cash').className 				= 'hidden';
					getCorrectId(  'p_payment_method_name_cash_note').className 		= 'hidden';
					getCorrectId( 'th_payment_method_name_check').className 			= 'hidden';
					getCorrectId( 'th_payment_method_name_credit_card').className		= 'hidden';
					
					getCorrectId('row_payment_method_check_number').className			= 'hidden';
					
					getCorrectId('row_payment_method_credit_card_brand').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_number').className 			= 'hidden';
					getCorrectId('row_payment_method_credit_card_number_4').className			= 'hidden';
					getCorrectId('row_payment_method_credit_card_cvv').className 				= 'hidden';
					getCorrectId('row_payment_method_credit_card_expiration_date').className	= 'hidden';
					
					getCorrectId('row_payment_method_terminal_invoice_number').className		= 'hidden';
					getCorrectId('row_payment_method_terminal_approval_code').className			= 'hidden';
					
					getCorrectId('row_payment_method_address1').className	 			= 'hidden';
					getCorrectId('row_payment_method_address2').className 				= 'hidden';
					getCorrectId('row_payment_method_city').className 					= 'hidden';
					getCorrectId('row_payment_method_state').className 					= 'hidden';
					getCorrectId('row_payment_method_zip').className 					= 'hidden';
					getCorrectId('row_payment_method_country').className 				= 'hidden';
					
					if (getCorrectId('payment_method_check_number')) {
							
						getCorrectId('payment_method_check_number').disabled 				= true;
						
						getCorrectId('payment_method_credit_card_brand_MC').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_AMEX').disabled 		= true;
						getCorrectId('payment_method_credit_card_brand_VISA').disabled 		= true;
						getCorrectId('payment_method_credit_card_number').disabled 			= true;
						getCorrectId('payment_method_credit_card_cvv').disabled 			= true;
						getCorrectId('payment_method_credit_card_expiration_date').disabled	= true;
						
						getCorrectId('payment_method_address1').disabled				= true;
						getCorrectId('payment_method_address2').disabled				= true;
						getCorrectId('payment_method_city').disabled 					= true;
						getCorrectId('payment_method_state').disabled 					= true;
						getCorrectId('payment_method_zip').disabled 					= true;
						getCorrectId('payment_method_country').disabled 				= true;
					}
				}
			}
			
		//	Call the onchange function to reveal any pre-filled values
			getCorrectId('payment_method').onchange();
			
		//	Wire up the Advanced buttons
			if (getCorrectId('payment_show_advanced')) {
				
					//alert ('got payment show advanced button');
				
				getCorrectId('payment_show_advanced').onchange = function () {
					
						//alert('click');
					
					if (this.checked) {
					
						getCorrectId('row_payment_discount').style.display			= '';
						getCorrectId('payment_discount').disabled 					= false;
						getCorrectId('payment_show_discount_notes').disabled		= false;
						
						if (getCorrectId('payment_show_discount_notes').checked) {
							
							getCorrectId('payment_discount_notes').style.display	= 'inline';
							getCorrectId('payment_discount_notes').disabled 		= false;
							
						} else {
							
							getCorrectId('payment_discount_notes').style.display	= 'none';
							getCorrectId('payment_discount_notes').disabled 		= true;
						}
						
						getCorrectId('row_payment_surcharge').style.display 		= '';
						getCorrectId('payment_surcharge').disabled 					= false;
						getCorrectId('payment_show_surcharge_notes').disabled		= false;
						
						if (getCorrectId('payment_show_surcharge_notes').checked) {
							
							getCorrectId('payment_surcharge_notes').style.display	= 'inline';
							getCorrectId('payment_surcharge_notes').disabled 		= false;
							
						} else {
							
							getCorrectId('payment_surcharge_notes').style.display	= 'none';
							getCorrectId('payment_surcharge_notes').disabled 		= true;
						}
						
						getCorrectId('row_payment_notes').style.display				= '';
						getCorrectId('payment_notes').disabled 						= false;
						
					} else {
						
						getCorrectId('row_payment_discount').style.display 			= 'none';
						getCorrectId('payment_discount').disabled 					= true;
						getCorrectId('payment_show_discount_notes').disabled		= true;
						
						getCorrectId('row_payment_surcharge').style.display 		= 'none';
						getCorrectId('payment_surcharge').disabled 					= true;
						getCorrectId('payment_show_surcharge_notes').disabled		= true;
						
						getCorrectId('row_payment_notes').style.display 			= 'none';
						getCorrectId('payment_notes').disabled 						= true;
					}
				}
				
				getCorrectId('payment_show_advanced').onchange();
			}
			
			if (getCorrectId('payment_show_discount_notes')) {
				
				getCorrectId('payment_show_discount_notes').onchange = function () {
					
					if (this.checked) {
						
						getCorrectId('payment_discount_notes').style.display 	= '';
						getCorrectId('payment_discount_notes').disabled 		= false;
						
					} else {
						
						getCorrectId('payment_discount_notes').style.display 	= 'none';
						getCorrectId('payment_discount_notes').disabled 		= true;
					}
				}
				
				getCorrectId('payment_show_discount_notes').onchange();
			}
			
			if (getCorrectId('payment_show_surcharge_notes')) {
				
				getCorrectId('payment_show_surcharge_notes').onchange = function () {

					if (this.checked) {
						
						getCorrectId('payment_surcharge_notes').style.display	= '';
						getCorrectId('payment_surcharge_notes').disabled 		= false;
						
					} else {
						
						getCorrectId('payment_surcharge_notes').style.display	= 'none';
						getCorrectId('payment_surcharge_notes').disabled 		= true;
					}
				}
				
				getCorrectId('payment_show_surcharge_notes').onchange();
			}
		}
		
		
		
		
	//	Handle the toggle checkbox on Corporate Supporters
		if (getCorrectId('btn_show_web_info')){
			
				/* FOR TESTING ONLY */ //alert('got btn_show_web_info');
				
		/*
			getCorrectId('btn_show_web_info').onclick = function () {
				
					/* FOR TESTING ONLY */ //alert('click');
		/*
				
				if (getCorrectId('web_info').className	== 'hidden') {
					
					getCorrectId('web_info').className	= '';
					
				} else {
					
					getCorrectId('web_info').className	= 'hidden';
				}
			}
		*/
			
		//	If the post on site button is checked, the web info must be displayed
			if (getCorrectId('btn_post_on_site').checked == true) {
				
				getCorrectId('btn_show_web_info').checked == true;
			}				
			
		//	If the web info button was checked, we have to reveal the web form
			if (getCorrectId('btn_show_web_info').checked == true) {
				
				getCorrectId('btn_show_web_info').onclick();
			}
		}
		
		
	//	Scripts for the Corporate Supporters Representative Registration Form
		if (getCorrectId('frm_corp_supp_rep_reg')) {
			
				/* FOR TESTING ONLY */ //alert ("Got the Corp Supp Rep Reg form...");
			
		//	Make the payment_amount field read-only so only the javascript can alter it
			if (getCorrectId('payment_amount')) {
				
					/* FOR TESTING ONLY */ //alert ("Got the payment_amount field...");
				
				getCorrectId('payment_amount').readOnly = 'readonly';
				getCorrectId('payment_amount').value = 0;
			}
			
		//	This is the function we'll call to update payment_amount
			recalculate_payment_amount = function() {
				
					/* FOR TESTING ONLY */ //alert ("Recalculating the payment amount");
				
			//	Handle the "free" values...
				
				if (getCorrectId('corporate_supporter_representative_fee').options[getCorrectId('corporate_supporter_representative_fee').selectedIndex].value == 'FREE') 	{ var corporate_supporter_representative_fee = '0'; } else { var corporate_supporter_representative_fee = getCorrectId('corporate_supporter_representative_fee').options[getCorrectId('corporate_supporter_representative_fee').selectedIndex].value; }
				if (getCorrectId('guest_adult_fee').options[getCorrectId('guest_adult_fee').selectedIndex].value == 'FREE') 													{ var guest_adult_fee = '0'; } else { var guest_adult_fee = getCorrectId('guest_adult_fee').options[getCorrectId('guest_adult_fee').selectedIndex].value; }
				if (getCorrectId('guest_child_fee').options[getCorrectId('guest_child_fee').selectedIndex].value == 'FREE') 													{ var guest_child_fee = '0'; } else { var guest_child_fee = getCorrectId('guest_child_fee').options[getCorrectId('guest_child_fee').selectedIndex].value; }
				
				getCorrectId('payment_amount').value = (
					
					  (getCorrectId('corporate_supporter_representative_num').value	* corporate_supporter_representative_fee)
					+ (getCorrectId('guest_adult_num').value	* guest_adult_fee)
					+ (getCorrectId('guest_child_num').value	* guest_child_fee)
					+ (getCorrectId('golf_num').value			* getCorrectId('golf_fee').value)
				);
			}
			
		//	Run the calculation to populate the field
			recalculate_payment_amount();
			
			if (getCorrectId('corporate_supporter_representative_num')) {
				getCorrectId('corporate_supporter_representative_num').onkeyup = function () {
					recalculate_payment_amount();	
				}
			}
			
			if (getCorrectId('corporate_supporter_representative_fee')) {
				getCorrectId('corporate_supporter_representative_fee').onchange = function () {
					recalculate_payment_amount();	
				}
			}
			
			if (getCorrectId('guest_adult_num')) {
				getCorrectId('guest_adult_num').onkeyup = function () {
					recalculate_payment_amount();	
				}
			}
			
			if (getCorrectId('guest_adult_fee')) {
				getCorrectId('guest_adult_fee').onchange = function () {
					recalculate_payment_amount();	
				}
			}
			
			if (getCorrectId('guest_child_num')) {
				getCorrectId('guest_child_num').onkeyup = function () {
					recalculate_payment_amount();	
				}
			}
			
			
			if (getCorrectId('guest_child_fee')) {
				getCorrectId('guest_child_fee').onchange = function () {
					recalculate_payment_amount();	
				}
			}
			
			if (getCorrectId('golf_num')) {
				getCorrectId('golf_num').onkeyup = function () {
					recalculate_payment_amount();	
				}
			}
		}
		
//	END MEETING MANAGEMENT		
		
		
		
//	SITE MANAGEMENT
		
	//	PERMISSIONS
		
	//	Wire the target type pulldown to reveal the proper tables
		if (getCorrectId('frm_new_permission_target')) {
			
				/* FOR TESTING ONLY */ //alert ('!!!' + getCorrectId('target_is_a'));
			
		//	Wire the special feature checkbox...
			getCorrectId('target_special').onclick = function () {
				
				var value = getCorrectId('target_is_a').options[getCorrectId('target_is_a').selectedIndex].value;
				
				if (value == 'fnc') {
									
					if (getCorrectId('target_special').checked == true) {
						
						getCorrectId('row_target_info_special_feature_enabled').style.display 	= '';
						getCorrectId('target_special_enabled').disabled							= false;
						
					} else {
					
						getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
						getCorrectId('target_special_enabled').disabled 						= true;
					}
					
				} else {
					
					if (getCorrectId('target_special').checked == true) {
						
						getCorrectId('row_target_info_name').style.display 						= '';
						getCorrectId('row_target_info_description').style.display 				= '';
						getCorrectId('row_target_info_group').style.display 					= '';
						getCorrectId('row_target_info_special_feature_enabled').style.display 	= '';
						
						getCorrectId('target_name').disabled 			= false;
						getCorrectId('target_description').disabled 	= false;
						getCorrectId('target_group').disabled 			= false;
						getCorrectId('target_special_enabled').disabled = false;
						
					} else {
					
						getCorrectId('row_target_info_name').style.display 						= 'none';
						getCorrectId('row_target_info_description').style.display 				= 'none';
						getCorrectId('row_target_info_group').style.display 					= 'none';
						getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
						
						getCorrectId('target_name').disabled 			= true;
						getCorrectId('target_description').disabled 	= true;
						getCorrectId('target_group').disabled 			= true;
						getCorrectId('target_special_enabled').disabled	= true;
					}
				}
				
			} // End wiring the special feature checkbox
			
			
			
		//	Wire the target_is_a select...
			getCorrectId('target_is_a').onchange = function () {
				
				var value = getCorrectId('target_is_a').options[getCorrectId('target_is_a').selectedIndex].value;
				
				if (value == '') {
					
					getCorrectId('tbl_target_perms_u').style.display	= 'none';
					getCorrectId('tbl_target_perms_us').style.display	= 'none';
					getCorrectId('tbl_target_perms_usg').style.display	= 'none';
					
				} else {
					
					getCorrectId('tbl_target_perms_u').style.display	= 'block';
					getCorrectId('tbl_target_perms_us').style.display	= 'table';
					getCorrectId('tbl_target_perms_usg').style.display	= 'table';
				}
				if (value == '') {
					
					getCorrectId('row_target_info_url').style.display 						= 'none';
					getCorrectId('row_target_info_popup').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature').style.display 			= 'none';
					getCorrectId('row_target_info_name').style.display 						= 'none';
					getCorrectId('row_target_info_description').style.display 				= 'none';
					getCorrectId('row_target_info_group').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature').style.display 			= 'none';
					getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
					
					getCorrectId('target_url').disabled	 					= true;
					getCorrectId('target_popup').disabled 					= true;
					getCorrectId('target_special').disabled 			= true;
					getCorrectId('target_name').disabled 					= true;
					getCorrectId('target_description').disabled 				= true;
					getCorrectId('target_group').disabled 					= true;
					getCorrectId('target_special').disabled 			= true;
					getCorrectId('target_special_enabled').disabled 	= true;
					
				} else if (value == 'dir') {
					
					getCorrectId('row_target_info_url').style.display 						= '';
					getCorrectId('row_target_info_popup').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature').style.display 			= '';
					getCorrectId('row_target_info_name').style.display 						= 'none';
					getCorrectId('row_target_info_description').style.display 				= 'none';
					getCorrectId('row_target_info_group').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
					
					getCorrectId('target_url').disabled	 					= false;
					getCorrectId('target_popup').disabled 					= true;
					getCorrectId('target_special').disabled 			= false;
					getCorrectId('target_name').disabled 					= true;
					getCorrectId('target_description').disabled 				= true;
					getCorrectId('target_group').disabled 					= true;
					getCorrectId('target_special_enabled').disabled 	= true;
					
				} else if (value == 'fil') {
				
					getCorrectId('row_target_info_url').style.display 						= '';
					getCorrectId('row_target_info_popup').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature').style.display 			= '';
					getCorrectId('row_target_info_name').style.display 						= 'none';
					getCorrectId('row_target_info_description').style.display 				= 'none';
					getCorrectId('row_target_info_group').style.display 						= 'none';
					getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
					
					getCorrectId('target_url').disabled	 					= false;
					getCorrectId('target_popup').disabled 					= true;
					getCorrectId('target_special').disabled 			= false;
					getCorrectId('target_name').disabled 					= true;
					getCorrectId('target_description').disabled 				= true;
					getCorrectId('target_group').disabled 					= true;
					getCorrectId('target_special_enabled').disabled 	= true;
					
				} else if (value == 'fnc') {
				
					getCorrectId('row_target_info_url').style.display 						= 'none';
					getCorrectId('row_target_info_popup').style.display 					= 'none';
					getCorrectId('row_target_info_special_feature').style.display 			= '';
					getCorrectId('row_target_info_name').style.display 						= '';
					getCorrectId('row_target_info_description').style.display 				= '';
					getCorrectId('row_target_info_group').style.display 					= '';
					getCorrectId('row_target_info_special_feature_enabled').style.display 	= 'none';
					
					getCorrectId('target_url').disabled	 			= true;
					getCorrectId('target_popup').disabled 			= true;
					getCorrectId('target_special').disabled 		= false;
					getCorrectId('target_name').disabled 			= false;
					getCorrectId('target_description').disabled 	= false;
					getCorrectId('target_group').disabled 			= false;
					getCorrectId('target_special_enabled').disabled	= true;
				}
				
				getCorrectId('target_special').onclick();
				
			} // End wiring the target_is_a select
			
			getCorrectId('target_special').onclick();
			
			getCorrectId('target_is_a').disabled = false;
			
			getCorrectId('target_is_a').onchange();
			
		} // End check for the new permission target form
		
	//	END PERMISSIONS
	
//	END SITE MANAGEMENT
		
		
		
	//} // END SPECIAL FEATURES FUNCTIONALITY PREPARATION
	
	
	
	
//	If this is meetings/asrs_annual_meeting/abstracts/popup/photo.php...
	if (getCorrectId('frm_photo_upload')) {
			
			//alert ("Got the photo upload form");
			
		getCorrectId('frm_photo_upload').onsubmit = function () {
			
			if (
					getCorrectId('uploadedfile').value.substr(-3, 3) != 'jpg'  &&
					getCorrectId('uploadedfile').value.substr(-4, 4) != 'jpeg' &&
					getCorrectId('uploadedfile').value.substr(-3, 3) != 'gif'  &&
					getCorrectId('uploadedfile').value.substr(-3, 3) != 'png'
			) {	
			
				alert ("This form can only accepts .jpg, .jpeg, .gif and .png files. Please convert you photo to one of those file types and try again.");
				
				return false;
			}
		}
	}
	
	
	
	
//	If this is meetings/asrs_annual_meeting/abstracts/popup/photo.php...
	if (getCorrectId('frm_registration_preview')) {
			
			//alert ("Got the registration preview form");
			
		getCorrectId('frm_registration_preview').onsubmit = function () {
			
				//alert ("Submitting the registration preview form");
			
			getCorrectId('btn_submit').disabled = true;
		}
	}
	
	
	
	
//	If this is the PAT Survey Confirmation page...
	if (getCorrectId('pat_survey_disclaimer')) {
		
		getCorrectId('pat_survey_disclaimer').onsubmit = function () {
			
				/* FOR TESTING ONLY */ //alert ('Submitting the form...');
			
			if (getCorrectId('a2_disagree').checked == true) {
				
				alert ("You must acknowledge that you have read the PAT Survey Policies and Guidelines in order to view the PAT Survey.");
				
				return false;
				
			} else {
				
				location.href="main.php?poll_id=<?=$_GET['poll_id'];?>";
			}
		}
	}
	
	
	
//	PAT Survey survey pages...
//	Move this to the Poll Engine. Why fight it? REWRITE ~Muxlow
	if (getCorrectId('pat_survey') || getCorrectId('poll')) {
		
			/* FOR TESTING ONLY */ //alert ("got the pat survey");
		
	//	If there is a  / are clear answer button / buttons...
		var clear_answer_buttons = getElementsByClass('input', 'clear_answer');
			
			/* FOR TESTING ONLY */ //alert ("clear_answer_buttons = " + clear_answer_buttons);
		
		for (var q=0; q<clear_answer_buttons.length; q++) {
			
		//if (getCorrectId('clear_answers')){
			
				/* FOR TESTING ONLY */ //alert ("Found the button");
			
			clear_answer_buttons[q].onclick = function () {
				
					/* FOR TESTING ONLY */ //alert ("click");
				
			//	This is a bit hacky...
			//	To uncheck any checked radio buttons, there's a hidden, valueless radio that we select instead.
			//	The ID of that radio button is stored in a an attribute we made up and stored in this Clear Answers button's tag.
			//	Why I didn't just loop through all available radio buttons for this question and turn them off, I dont' know.
			//	Probably didn't have time, but this seems awful convoluted to be a time-saver.
				getCorrectId(this.getAttribute('target_name') + '_clear').checked = true;
				
			//	Clear buttons also show up on the Admin's Submit Entry tools but WITHOUT poll_question forms wrapped around each question.
			//	We don't want it to submit answers for every check, so we yanked the individual forms.
			//	That means we now have to sniff for the poll_question form's very existence, lest our javascript break.
				//Don't do this here; do it in the poll engine //if (getCorrectId('poll_question')) { getCorrectId('poll_question').submit(); }
			}
		}
		
	//	Get the tabs
		var tabs = getElementsByClass('img', 'tab');
		
			/* FOR TESTING ONLY */ //alert ("tabs = " + tabs);
		
		if (tabs.length>0) {
				
				/* FOR TESTING ONLY */ //alert ("got tabs");
				
		//	Grab the year we're working with the from header.php file
			var survey_year = document.getElementById('survey_year').value;
			
					/* FOR TESTING ONLY */ //alert ("survey year = " + survey_year);
				
			for (var j=0; j<tabs.length; j++) {
			
					/* FOR TESTING ONLY */ //alert (tabs[j]);
				
				tabs[j].onmouseover = function () {
					
						/* FOR TESTING ONLY */ //alert ("mouseover");
					
					this.src = '/___media/home/communicate_and_educate/pat_survey/surveys/'+survey_year+'/_header/' + this.id + '_over.gif';
				}
				
				tabs[j].onmouseout = function () {
					
						/* FOR TESTING ONLY */ //alert ("mouseout");
					
					this.src = '/___media/home/communicate_and_educate/pat_survey/surveys/'+survey_year+'/_header/' + this.id + '.gif';
				}
			}
		}
		
	} // END PAT SURVEY PAGES
	
	
	
	
		/* FOR TESTING ONLY */ //alert ("Elements Prepared");
	}