function validate_payment_method_form () {
	
		/* FOR TESTING ONLY */ //alert ('Validating payment method form');
	
	var errors = Array();
	
	if (
			getCorrectId('payment_method').value == "credit_card" ||
			getCorrectId('payment_method').value == "terminal" ||
			getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "credit_card" ||
			getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "terminal"
	) {
		
	//	RULES FOR BOTH CC & TERMINAL
		if (
			
			(
				getCorrectId('payment_method_credit_card_brand_MC') &&
				getCorrectId('payment_method_credit_card_brand_AMEX') &&
				getCorrectId('payment_method_credit_card_brand_VISA') &&
				getCorrectId('payment_method_credit_card_brand_MC').checked == false &&
				getCorrectId('payment_method_credit_card_brand_AMEX').checked == false &&
				getCorrectId('payment_method_credit_card_brand_VISA').checked == false
			)
			
				||
			
			(
				getCorrectId('payment_method_credit_card_brand') &&
				getCorrectId('payment_method_credit_card_brand').options[getCorrectId('payment_method_credit_card_brand').selectedIndex].value == ''
			)
		) {
			
			getCorrectId('row_payment_method_credit_card_brand').className = 'error';
			errors.push("You must select a Credit Card Type.");
			
		} else {
			
			getCorrectId('row_payment_method_credit_card_brand').className = '';
		}
		
	//	RULES FOR JUST CC
		if (
				getCorrectId('payment_method').value == "credit_card" ||
				getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "credit_card"
		) {
			
			if (getCorrectId('payment_method_credit_card_number').value == '') {
				
				getCorrectId('row_payment_method_credit_card_number').className = 'error';
				errors.push ("You must provide a Credit Card Number.");
				
			} else {
				
				if (
					getCorrectId('payment_method_credit_card_number').value.substr(0,1) != '3' &&
					getCorrectId('payment_method_credit_card_number').value.substr(0,1) != '4' &&
					getCorrectId('payment_method_credit_card_number').value.substr(0,1) != '5'
				) {
					
					getCorrectId('row_payment_method_credit_card_number').className = 'error';
					errors.push ("The credit card number entered is not accepted by this registration system. Please enter an American Express, Visa or Master Card number.");
						
				} else if (
					(
						getCorrectId('payment_method_credit_card_number').value.substr(0,1) == '5'
							&&
						(
							(getCorrectId('payment_method_credit_card_brand_MC') && getCorrectId('payment_method_credit_card_brand_MC').checked != true) // Admin form
								||
							(getCorrectId('payment_method_credit_card_brand') && getCorrectId('payment_method_credit_card_brand').options[getCorrectId('payment_method_credit_card_brand').selectedIndex].value != "MC") // User form
						)
					)
						||
					(
						getCorrectId('payment_method_credit_card_number').value.substr(0,1) == '3'
							&&
						(
							(getCorrectId('payment_method_credit_card_brand_AMEX') && getCorrectId('payment_method_credit_card_brand_AMEX').checked != true) // Admin form
								||
							(getCorrectId('payment_method_credit_card_brand') && getCorrectId('payment_method_credit_card_brand').options[getCorrectId('payment_method_credit_card_brand').selectedIndex].value != "AMEX") // User form
						)
					)
						||
					(
						getCorrectId('payment_method_credit_card_number').value.substr(0,1) == '4'
							&&
						(
							(getCorrectId('payment_method_credit_card_brand_VISA') && getCorrectId('payment_method_credit_card_brand_VISA').checked != true) // Admin form
								||
							(getCorrectId('payment_method_credit_card_brand') && getCorrectId('payment_method_credit_card_brand').options[getCorrectId('payment_method_credit_card_brand').selectedIndex].value != "VISA") // User form
						)
					)
				) {
					
					getCorrectId('row_payment_method_credit_card_number').className = 'error';
					errors.push ("Credit card type selected does not match credit card number entered.");
						
				} else {
					
					getCorrectId('row_payment_method_credit_card_number').className = '';
				}
			}
			
			if (getCorrectId('payment_method_credit_card_expiration_date').value == '') {
				getCorrectId('row_payment_method_credit_card_expiration_date').className = 'error';
				errors.push ("You must provide an Expiration Date for your Credit Card.");
			} else {
				getCorrectId('row_payment_method_credit_card_expiration_date').className = '';
			}
			
			if (getCorrectId('payment_method_credit_card_cvv').value == '') {
				getCorrectId('row_payment_method_credit_card_cvv').className = 'error';
				errors.push ("You must provide a Security Code for your Credit Card.");
			} else {
				getCorrectId('row_payment_method_credit_card_cvv').className = '';
			}
			
			if (getCorrectId('payment_method_name').value == '') {
				getCorrectId('row_payment_method_name').className = 'divider error';
				errors.push ("You must provide a Cardholder's Name for your Credit Card.");
			} else {
				getCorrectId('row_payment_method_name').className = 'divider';
			}
			
			if (getCorrectId('payment_method_address1').value == '') {
				getCorrectId('row_payment_method_address1').className = 'error';
				errors.push ("You must provide an Address for your Credit Card.");
			} else {
				getCorrectId('row_payment_method_address1').className = '';
			}
			
			if (getCorrectId('payment_method_city').value == '') {
				getCorrectId('row_payment_method_city').className = 'error';
				errors.push ("You must provide a City for your Credit Card address.");
			} else {
				getCorrectId('row_payment_method_city').className = '';
			}
			
			if (getCorrectId('payment_method_state').value == '') {
				getCorrectId('row_payment_method_state').className = 'error';
				errors.push ("You must provide a State / Province for your Credit Card address.");
			} else {
				getCorrectId('row_payment_method_state').className = '';
			}
			
			if (getCorrectId('payment_method_zip').value == '') {
				getCorrectId('row_payment_method_zip').className = 'error';
				errors.push ("You must provide a Zip Code for your Credit Card address.");
			} else {
				getCorrectId('row_payment_method_zip').className = '';
			}
			
			if (getCorrectId('payment_method_country').value == '') {
				getCorrectId('row_payment_method_country').className = 'error';
				errors.push ("You must provide a country for your Credit Card address.");
			} else {
				getCorrectId('row_payment_method_country').className = '';
			}
		}
		
	//	RULES FOR JUST TERMINAL
		if (
				getCorrectId('payment_method').options && (
					getCorrectId('payment_method').value == "terminal" ||
					getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "terminal"
				)
		) {
			
			if (getCorrectId('payment_method_credit_card_number_4').value.length != '4') {
				
				getCorrectId('row_payment_method_credit_card_number_4').className = 'error';
				errors.push ("You must provide the last 4 digits of the Credit Card Number used.");
				
			} else {
				getCorrectId('row_payment_method_credit_card_number_4').className = '';
			}
		}
			
	} else if (
			getCorrectId('payment_method').value == "check" ||
			getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "check"
	) {
		
		//	Check rules go here
		
	} else if (
			getCorrectId('payment_method').value == "cash" ||
			getCorrectId('payment_method').options[getCorrectId('payment_method').selectedIndex].value == "cash"
	) {
		
		//	Cash rules go here
		
	} else {
		
		errors.push ("You must choose a Payment Type.");
	}
	
	if (errors.length > 0) {
		
		var msg = "There are problems with your payment information.\n\n";
		
		for (i=0; i<errors.length; i++) {
			
			msg += errors[i]+"\n\n";
		}
		
		alert(msg);
		
		return false;
		
	}
	
	return true;
}




function wire_billing_advanced_checkbox (name) {
		
			/* FOR TESTING ONLY */ //alert ('Sniffing for show_' + name + 'advanced checkbox...');

	if (getCorrectId('show_'+name+'advanced')) {
		
			/* FOR TESTING ONLY */ //alert ('Wiring ' + name + 'advanced checkbox...');
		
		getCorrectId('show_'+name+'advanced').onchange = function () {
			
				/* FOR TESTING ONLY */ //alert ('Revealing Advanced for ' + name + '...');
			
		//	Get the root of the name of this checkbox (i.e.: 'show_XXXX_advanced')
			var x = this.name.replace('show_','');
			var x = x.replace('advanced',''); // this is for the overall payment option which only have one _, which gets deleted by the first snip
			
			if (this.checked) {
			
				if (
					
					!getCorrectId(x+'rate_id') ||
					
					getCorrectId(x+'rate_id').options[getCorrectId(x+'rate_id').selectedIndex].value != '150'
					
				) {
					
					getCorrectId('row_'+x+'discount').style.display		= '';
					getCorrectId(x+'discount').disabled 				= false;
					getCorrectId('show_'+x+'discount_notes').disabled	= false;
					
					if (getCorrectId('show_'+x+'discount_notes').checked) {
						
						getCorrectId(x+'discount_notes').style.display	= 'inline';
						getCorrectId(x+'discount_notes').disabled 		= false;
						
					} else {
						
						getCorrectId(x+'discount_notes').style.display	= 'none';
						getCorrectId(x+'discount_notes').disabled 		= true;
					}
				}
				
				getCorrectId('row_'+x+'surcharge').style.display 	= '';
				getCorrectId(x+'surcharge').disabled 				= false;
				getCorrectId('show_'+x+'surcharge_notes').disabled	= false;
				
				if (getCorrectId('show_'+x+'surcharge_notes').checked) {
					
					getCorrectId(x+'surcharge_notes').style.display	= 'inline';
					getCorrectId(x+'surcharge_notes').disabled 		= false;
					
				} else {
					
					getCorrectId(x+'surcharge_notes').style.display	= 'none';
					getCorrectId(x+'surcharge_notes').disabled 		= true;
				}
				
				getCorrectId('row_'+x+'notes').style.display	= '';
				getCorrectId(x+'notes').disabled 				= false;
				
			} else {
				
				getCorrectId('row_'+x+'discount').style.display 	= 'none';
				getCorrectId(x+'discount').disabled 				= true;
				getCorrectId('show_'+x+'discount_notes').disabled	= true;
				
				getCorrectId('row_'+x+'surcharge').style.display 	= 'none';
				getCorrectId(x+'surcharge').disabled 				= true;
				getCorrectId('show_'+x+'surcharge_notes').disabled	= true;
				
				getCorrectId('row_'+x+'notes').style.display	= 'none';
				getCorrectId(x+'notes').disabled				= true;
			}
		}
		
		getCorrectId('show_'+name+'advanced').onchange();
		
		return true;
		
	} else { return false; }
}




function wire_billing_advanced_discount_notes (name) {
	
		/* FOR TESTING ONLY */ //alert ('Sniffing for ' + name + 'rate_id select...');
	
	if (getCorrectId('show_'+name+'discount_notes')) {
	
			/* FOR TESTING ONLY */ //alert ('Wiring ' + name + 'rate_id select...');
		
		getCorrectId('show_'+name+'discount_notes').onchange = function () {
			
			var x = this.name.replace('show_','');
			var x = x.replace('discount_notes',''); // this is for the overall payment option which only have one _, which gets deleted by the first snip
			
			if (this.checked) {
				
				getCorrectId(x+'discount_notes').style.display 	= '';
				getCorrectId(x+'discount_notes').disabled 		= false;
				
			} else {
				
				getCorrectId(x+'discount_notes').style.display 	= 'none';
				getCorrectId(x+'discount_notes').disabled 		= true;
			}
		}
		
		getCorrectId('show_'+name+'discount_notes').onchange();
		
		return true;
		
	} else { return false; }
}




function wire_billing_advanced_surcharge_notes (name) {
	
		/* FOR TESTING ONLY */ //alert ('Sniffing for ' + name + 'rate_id select...');
	
	if (getCorrectId('show_'+name+'surcharge_notes')) {
	
			/* FOR TESTING ONLY */ //alert ('Wiring ' + name + 'rate_id select...');
		
		getCorrectId('show_'+name+'surcharge_notes').onchange = function () {
			
			var x = this.name.replace('show_','');
			var x = x.replace('surcharge_notes',''); // this is for the overall payment option which only have one _, which gets deleted by the first snip
			
			if (this.checked) {
				
				getCorrectId(x+'surcharge_notes').style.display	= '';
				getCorrectId(x+'surcharge_notes').disabled 		= false;
				
			} else {
				
				getCorrectId(x+'surcharge_notes').style.display = 'none';
				getCorrectId(x+'surcharge_notes').disabled 		= true;
			}
		}
		
		getCorrectId('show_'+name+'surcharge_notes').onchange();
		
		return true;
		
	} else { return false; }
}




function wire_billing_elements (name) {
	
		/* FOR TESTING ONLY */ //alert ('Wiring Billing Elements for ' + name + '...');
	
	wire_billing_rate_id_select 			(name);
	wire_billing_advanced_checkbox 			(name);
	wire_billing_advanced_discount_notes	(name);
	wire_billing_advanced_surcharge_notes	(name);
}




function wire_billing_rate_id_select (name) {	
	
		/* FOR TESTING ONLY */ //alert ('Sniffing for ' + name + 'rate_id select...');
	
	if (getCorrectId(name+'rate_id')) {
	
			/* FOR TESTING ONLY */ //alert ('Wiring ' + name + 'rate_id select...');
		
		getCorrectId(name+'rate_id').onchange = function () {
			
			var x = this.name.replace('rate_id','');
			
				/* FOR TESTING ONLY */ //alert('You selected ' + this.value);
			
				/* FOR TESTING ONLY */ //alert ('row_' + x + '_discount' + ' = ' + getCorrectId('row_'+x+'discount'));
			
		//	FREE
			if (
				
				this.options[this.selectedIndex].value == '150'					// This is a straight Free rate pulldown
				
					||
				
				this.options[this.selectedIndex].value.indexOf('_150') != -1 	// This handles pulldowns where there are combination of product ID and Product Rate ID in the option value; for example: Admin > Meeting > Registrations > New > Guest pulldowns are built this way
				
			) {
				
					/* FOR TESTING ONLY */ //alert ('free');
				
				getCorrectId('row_'+x+'discount').style.display	= 'none';
				getCorrectId(x+'discount_notes').style.display	= 'none';
				
				getCorrectId(x+'discount').disabled 				= true;
				getCorrectId('show_'+x+'discount_notes').disabled	= true;
				getCorrectId(x+'discount_notes').disabled 			= true;
				
				
		//	NOT FREE
			} else {
					
						/* FOR TESTING ONLY */ //alert ('not free');
				
				if (getCorrectId('show_'+x+'advanced') && getCorrectId('show_'+x+'advanced').checked) {
					
						/* FOR TESTING ONLY */ //alert ('not free');
					
					getCorrectId('row_'+x+'discount').style.display 	= '';
					getCorrectId(x+'discount').disabled 				= false;
					getCorrectId('show_'+x+'discount_notes').disabled	= false;
					
					if (getCorrectId('show_'+x+'discount_notes').checked) {
						
						getCorrectId(x+'discount_notes').style.display	= 'inline';
						getCorrectId(x+'discount_notes').disabled 		= false;
						
					} else {
						
						getCorrectId(x+'discount_notes').style.display	= 'none';
						getCorrectId(x+'discount_notes').disabled 		= true;
					}
				}
			}
			
		//	CUSTOM
			if (getCorrectId('row_'+x+'custom') && getCorrectId(x+'custom')) {
				if (
					
					this.options[this.selectedIndex].value == '151'					// This is a straight custom rate pulldown
					
						||
					
					this.options[this.selectedIndex].value.indexOf('_151') != -1 	// This handles pulldowns where there are combination of Product ID and Product Rate ID in the option value; for example: Admin > Meeting > Registrations > New > Guest pulldowns are built this way
					
				) {
					
						/* FOR TESTING ONLY */ //alert (x + ' is custom');
					
					getCorrectId('row_'+x+'custom').style.display 	= '';
					getCorrectId(x+'custom').disabled 				= false;
					
				} else {
					
						/* FOR TESTING ONLY */ //alert (x + ' is not custom');
					
					getCorrectId(x+'custom').disabled 				= true;
					getCorrectId('row_'+x+'custom').style.display 	= 'none';
				}
			}
		}
		
		getCorrectId(name+'rate_id').onchange();
		
		return true;
		
	} else { return false; }
}