// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function openActiveSubnav() {
	if (document.getElementsByClassName('active')) {
		var a = document.getElementsByClassName('active');
		if ((a.length == 1) && (a[0].childNodes.length > 3)) {
			for (i = 0; i != a.length; i++) {
				var li = a[i].childNodes[2];
				new Effect.Highlight(li, {startcolor:'#f5cdc3', endcolor:'#ffffff'});
			}
		}
	}
}

function toggleCheckboxContent(checkbox, el) {
	if ($(checkbox).checked == true) {
		Element.show(el);
	} else {
		Element.hide(el);
	}
}

function toggleCCFields() {
	var paymentSelect = $('registration_payment_method_id');
	var selectedValue = paymentSelect.options[paymentSelect.selectedIndex].value;
	if (selectedValue == '' || selectedValue == '1') {
		Element.hide('cc_info');
	} else {
		Element.show('cc_info');
	}
}

Event.observe(window, 'load', openActiveSubnav, false);