//Setup the form with show/hide
function setForm() {
	$('#content form li').each(function (i) {
		if (($(this).children('input:checked').hasClass('.trigger')) || ($(this).children('select').children('option:selected').hasClass('.trigger'))) {
			$(this).children('.other').show();
			//Check if the ".other" input is required and add ".required" class for validation
			if ($(this).children('.other').hasClass('.reqd')) {
				$(this).children('.other').addClass('required');
			}
		} else {
			$(this).children('.other').removeClass('required').hide();
		}
	});
}

$(document).ready(function() {
	//Check form to see what needs to be shown or hidden
	setForm();
	
	//Distinguish empty select options from regular choices
	$('select option', $('#content')).each(function (i) {
		var value = $(this).val();
		if (value == "") {$(this).addClass('empty');}
	});
	
	//Set the currently selected form item to active
	$('#content input, #content textarea, #content select').focus(function() {
		$('form li').removeClass('active');
		$(this).parent('li').addClass('active');
	});
	
	//When a radio/checkbox input is clicked, check to see if items need to be shown or hidden
	$('input:radio, input:checkbox').click(function() {
		setForm();
	});
	
	//When a select input is changes, check to see if items need to be shown or hidden
	$('select', $('#content')).change(function() {
		setForm();
	});
	
	//Make form action buttons appear to have a "click" effect for IE6
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version<=6)) {
			$('.actions input', $('#content')).hover(function() {
			$(this).addClass('hover');
		}, function() { 
			$(this).removeClass('hover');
		});
		$('.actions input', $('#content')).click(function() {
			$(this).addClass('active');
		}, function() { 
			$(this).removeClass('active');
		});

}

});