function in_array (needle, haystack, argStrict) {
    var key = '', strict = !!argStrict;
     if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
    return false;
}

function checaMesmoDia() {
	var arr_dias_escolhidos = new Array;
	
	$('form input[type=checkbox]:checked').each(function() {
		if (!in_array($(this).attr('data'), arr_dias_escolhidos)) {
			arr_dias_escolhidos.push($(this).attr('data'));
		} else {
			$(this).attr('checked', false);
			$('.t-'+$(this).attr('class')).toggleClass('ativo');
			alert('Você já escolheu um congresso ou palestra para o mesmo dia.');
		}
	});
	
}

$(document).ready(function() {
	$('form input[type=checkbox]').click(function() {
		$('.t-'+$(this).attr('class')).toggleClass('ativo');
		checaMesmoDia();
	});

	$('form input[type=checkbox]:checked').each(function() {
		$('.t-'+$(this).attr('class')).toggleClass('ativo');
	});
});
