// application javascript goes here
$(document).ready(function(){
	
	// auto populate badge name:
	var updateBadgeName = function(){
		val = jQuery.trim(jQuery.trim($('#registration_first_name').val()) + ' ' + jQuery.trim($('#registration_last_name').val()));
		$('#registration_badge_name').val(val);
	};
	
	$('#registration_first_name, #registration_last_name').change(updateBadgeName);
	
	// mask numeric inputs:
	$('#registration_phone_number').mask('(999) 999-9999');
	$('#registration_fax_number').mask('(999) 999-9999');
	$('#registration_zipcode').mask('99999');
	
	// hide/show the single day selection:
	function toggleSingleDay() {
		if ($('#registration_type_4').attr('checked') == true) {
			$('#select_single_day').fadeIn(300);
		} else {
			$('#select_single_day').fadeOut(300);
		}
	}
	
	$('#packages :radio').change(function(){
		toggleSingleDay();
	});
	$('#packages :radio').click(function(){
		toggleSingleDay();
	});
	
	// - creates auto striping tables
	$('table.zebra').each(function() {
		$(this.getElementsByTagName("tbody")[0].getElementsByTagName("tr")).each(function(i) {
			$(this).mouseover(function(){$(this).addClass('ruled')});
			$(this).mouseout(function(){$(this).removeClass('ruled')});
			if(i%2==1) { 
				$(this).addClass('even');
			}
		});
	});
});