var checkbox_groups = {};

$(document).ready(function() {
	$("input:checkbox").each(function() {
		var fake = $(document.createElement("div"));
		fake.addClass('custom-checkbox');
		var original = this;
		fake.add($(this).next("label")).click(function() {
			original.checked = fake.toggleClass("checked").hasClass("checked");
		});
		if (this.checked) fake.addClass("checked");
		$(this).before(fake).css({display: 'none'});
	});
	
	$('#telefone').keyup(function(){
		maskFormat('NNNNNNNNNNN', document.getElementById('telefone'));
	});
	$('#cpf').keyup(function(){
		maskFormat('NNN.NNN.NNN-NN', document.getElementById('cpf'));
	});
	$('#cep').keyup(function(){
		maskFormat('NNNNN-NNN', document.getElementById('cep'));
	});

	$('#nome').focus(function(){
		if($.trim($(this).val()) == "nome"){
			$(this).val('');
		}
	});
	$('#nome').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('nome');
		}
	});
	$('#nome').click(function(){
		if($.trim($(this).val()) == "nome"){
			$(this).val('');
		}
	});
	
	$('#apelido').focus(function(){
		if($.trim($(this).val()) == "como gostaria de ser chamado(a)?"){
			$(this).val('');
		}
	});
	$('#apelido').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('como gostaria de ser chamado(a)?');
		}
	});
	$('#apelido').click(function(){
		if($.trim($(this).val()) == "como gostaria de ser chamado(a)?"){
			$(this).val('');
		}
	});
	
	$('#email').focus(function(){
		if($.trim($(this).val()) == "e-mail"){
			$(this).val('');
		}
	});
	$('#email').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('e-mail');
		}
	});
	$('#email').click(function(){
		if($.trim($(this).val()) == "e-mail"){
			$(this).val('');
		}
	});
	
	$('#telefone').focus(function(){
		if($.trim($(this).val()) == "telefone"){
			$(this).val('');
		}
	});
	$('#telefone').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('telefone');
		}
	});
	$('#telefone').click(function(){
		if($.trim($(this).val()) == "telefone"){
			$(this).val('');
		}
	});
	
	$('#rg').focus(function(){
		if($.trim($(this).val()) == "rg"){
			$(this).val('');
		}
	});
	$('#rg').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('rg');
		}
	});
	$('#rg').click(function(){
		if($.trim($(this).val()) == "rg"){
			$(this).val('');
		}
	});
	
	$('#cpf').focus(function(){
		if($.trim($(this).val()) == "cpf"){
			$(this).val('');
		}
	});
	$('#cpf').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('cpf');
		}
	});
	$('#cpf').click(function(){
		if($.trim($(this).val()) == "cpf"){
			$(this).val('');
		}
	});
	
	$('#endereco').focus(function(){
		if($.trim($(this).val()) == "endereço"){
			$(this).val('');
		}
	});
	$('#endereco').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('endereço');
		}
	});
	$('#endereco').click(function(){
		if($.trim($(this).val()) == "endereço"){
			$(this).val('');
		}
	});
	
	$('#complemento').focus(function(){
		if($.trim($(this).val()) == "complemento"){
			$(this).val('');
		}
	});
	$('#complemento').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('complemento');
		}
	});
	$('#complemento').click(function(){
		if($.trim($(this).val()) == "complemento"){
			$(this).val('');
		}
	});
	
	$('#bairro').focus(function(){
		if($.trim($(this).val()) == "bairro"){
			$(this).val('');
		}
	});
	$('#bairro').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('bairro');
		}
	});
	$('#bairro').click(function(){
		if($.trim($(this).val()) == "bairro"){
			$(this).val('');
		}
	});
	
	$('#cep').focus(function(){
		if($.trim($(this).val()) == "cep"){
			$(this).val('');
		}
	});
	$('#cep').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('cep');
		}
	});
	$('#cep').click(function(){
		if($.trim($(this).val()) == "cep"){
			$(this).val('');
		}
	});
	
	$('#cidade').focus(function(){
		if($.trim($(this).val()) == "cidade"){
			$(this).val('');
		}
	});
	$('#cidade').blur(function(){
		if($.trim($(this).val()) == ""){
			$(this).val('cidade');
		}
	});
	$('#cidade').click(function(){
		if($.trim($(this).val()) == "cidade"){
			$(this).val('');
		}
	});
});