$(document).ready(function() {
	$('input[name="x\:search_group"]').autocomplete('/teams/search_teams', {
	delay: 500,
	autoFill: true,
	scrollHeight: 200,
	selectFirst: false
	}).result(function(event, data, formatted) {
		cb_JoinLinkFoxee(this, formatted);
	}).bind('keyup', function() {
		cb_JoinLinkFoxee(this, $(this).val());
	});
	
	$('input[name="x\:team"]').bind('blur', function() {
		$('#error-msg').remove();
		var team = $(this);
		if( $(team).val() == '' ) return false;
		$.ajax({
			url: '/teams/check-title',
			data: {q: $(team).val()},
			success: function(data) {
				if( $.trim(data) == "yes" ) {
					clearGroup();
					$('#team-name').after('<tr id="error-msg"><td colspan="2" align="right">Team Name already taken. Please choose another.</td></tr>');
				}
				else
					cb_JoinLinkFoxee(this, $(team).val());
			}
		});
	});
	
	jQuery('input.fc_checkbox').bind('click', function() {
		var field = jQuery(this);
		jQuery('input[name="'+field.attr('name')+'"]').removeAttr('checked');
		field.attr('checked', 'checked');
	});
		jQuery('input[name="fund_goal"]').bind('keyup', function() {
			var val = jQuery(this).val().replace(/[^0-9\.]+/, '');
			jQuery(this).val(val);
		});
});
