function Contato()
{
	var frmContato = "#frmContato";
	
	if($(frmContato).length > 0)
	{
		$("#txtTelefoneContato").mask("(99) 9999-9999");
		
		$("#selPaisContato").change(function()
		{
			if($(this).val().length > 0)
			{
				var PaisID = parseInt($(this).val());
				
				
			
				if(PaisID != 1)
				{
					$("#selEstadoContato").html('<option value="">Selecione...</option>').attr("disabled",true);
					$("#selEstadoContato").parent().prev().empty();
					$("#selCidadeContato").html('<option value="">Selecione...</option>').parent().parent().hide();
					$("#txtOutroMunicipioContato").parent().parent().show();
					$("#txtTelefoneContato").unmask();
				}
				else
				{
					$("#selEstadoContato").attr("disabled",false);
					if($("#selEstadoContato").parent().prev().html() == 0) $("#selEstadoContato").parent().prev().html("*");
					$("#selCidadeContato").parent().parent().show();
					$("#txtOutroMunicipioContato").val("").parent().parent().hide();
					$("#txtTelefoneContato").unmask().mask("(99) 9999-9999");
				}
				
				$("#selEstadoContato").empty();
				$("#selEstadoContato").append('<option value="">Carregando...</option>');
				
				$.ajax(
				{
					type: "POST",
					url: "acao/UnidadeFederativa.php",
					data: {"acao":"CarregarUnidadeFederativa","PaisID":PaisID},
					dataType: "json",
					complete: function(resposta,status)
					{
						var retorno = eval(resposta.responseText)[0];
						
						$("#selEstadoContato").empty();
						$("#selEstadoContato").append('<option value="">Selecione...</option>');
						
						if(!retorno.erro)
						{
							$(retorno.unidadefederativa).each(function(indice)
							{
								$("#selEstadoContato").append('<option value="'+retorno.unidadefederativa[indice].id+'">'+unescape(retorno.unidadefederativa[indice].nome)+'</option>');
							});
						}
					}
				});
			}
		});
		
		$("#selEstadoContato").change(function()
		{
			if($(this).val().length > 0)
			{
				var UnidadeFederativaID = $(this).val();
				
				$("#selCidadeContato").empty();
				$("#selCidadeContato").append('<option value="">Carregando...</option>');
				
				$.ajax(
				{
					type: "POST",
					url: "acao/Municipio.php",
					data: {"acao":"CarregarMunicipio","UnidadeFederativaID":UnidadeFederativaID},
					dataType: "json",
					complete: function(resposta,status)
					{
						var retorno = eval(resposta.responseText)[0];
						
						$("#selCidadeContato").empty();
						$("#selCidadeContato").append('<option value="">Selecione...</option>');
						
						if(!retorno.erro)
						{
							$(retorno.municipios).each(function(indice)
							{
								$("#selCidadeContato").append('<option value="'+retorno.municipios[indice].id+'">'+unescape(retorno.municipios[indice].nome)+'</option>');
							});
						}
					}
				});
			}
		});
		
		$(frmContato).validate
		(
		 	{
		 		submitHandler: function()
		 		{
		 			$.ajax(
					{
						type: "POST",
						url: "acao/Contato.php",
						data: $(frmContato).serializeEncode(),
						dataType: "json",
						complete: function(resposta,status)
						{
							var retorno = eval(resposta.responseText)[0];
							
							if(!retorno.erro)
							{
								$("input:text,textarea",frmContato).val("");
								$("select option:eq(0)",frmContato).attr("selected",true);
								
								$("#selEstadoContato").attr("disabled",false).html('<option value="">Selecione...</option>');
								if($("#selEstadoContato").parent().prev().html() == 0) $("#selEstadoContato").parent().prev().html("*");
								$("#selCidadeContato").html('<option value="">Selecione...</option>').parent().parent().show();
								$("#txtOutroMunicipioContato").val("").parent().parent().hide();
								$("#txtTelefoneContato").unmask().mask("(99) 9999-9999");
							}
						}
					});
		 		},
				errorPlacement: function(error, element) 
				{
					if('<label class="msg-erro" for="txtNomeContato" generated="true">'+error.html()+'</label>' != $("#msg-erro").html()) $("#msg-erro").html('<label class="msg-erro" for="txtNomeContato" generated="true">'+error.html()+'</label>');
				},			
				errorClass: "msg-erro",
				errorElement: "label",
				rules:
				{
					txtNomeContato:
					{
						required: true
					},
					txtEmailContato:
					{
						required: true,
						email: true
					},
					txtTelefoneContato:
					{
						required: true
					},
					selPaisContato:
					{
						required: true
					},
					selEstadoContato:
					{
						required: true
					},
					selCidadeContato:
					{
						required: function()
						{
							return $("#txtOutroMunicipioContato").val() == 0;
						}
					},
					txtOutroMunicipioContato:
					{
						required: function()
						{
							return $("#selEstadoContato").is(":disabled");
						}
					},
					txaMensagemContato:
					{
						required: true
					}
				},
				messages:
				{
					txtNomeContato:
					{
						required: MSG04
					},
					txtEmailContato:
					{
						required: MSG04,
						email: MSG27.replace("{CAMPO}","E-mail")
					},
					txtTelefoneContato:
					{
						required: MSG04
					},
					selPaisContato:
					{
						required: MSG04
					},
					selEstadoContato:
					{
						required: MSG04
					},
					selCidadeContato:
					{
						required: MSG04
					},
					txtOutroMunicipioContato:
					{
						required: MSG04
					},
					txaMensagemContato:
					{
						required: MSG04
					}
				}
			}
		);
	}
}