function Inscricao()
{
	var frmInscricao = "#frmInscricao";
	
	if($(frmInscricao).length > 0)
	{
	
		// Campos numericos
		$("#txtNumero").numeric();
		
		
		// Exibe / Esconde campos 
		$("input[name='chkAreaInteresse[]'][value='9']").click(function()
		{
			if($(this).is(":checked"))
			{
				$(this).parent('li').next().show();
			}
			else
			{
				$(this).parent('li').next().hide();
			}
		});
		
		$("#selEvento").change(function()
		{
			if($(this).val() == "6")
			{
				$(this).parent('li').next().show();
			}
			else
			{
				$(this).parent('li').next().hide();
			}
		});
		
	
		$(frmInscricao).validate
		(
			{
				errorPlacement:function(error,element)
				{					
					if(error.html() != $("span.atencao").html()) $("span.atencao").html(error.html());					
				},
				highlight: function(element, errorClass)
				{
					$(element).addClass(errorClass);
				},		
				unhighlight: function(element, errorClass)
				{
					$(element).removeClass(errorClass);
					
					if($(".erro",frmInscricao).length == 0) $("span.atencao").html("");
				},
				errorClass: "erro",
				errorElement:"span",
				rules:
				{
					txtNome:{ required: true },
					txtEmail:{ required: true, email:true },
					txtEndereco:{ required: true },
					txtNumero:{ required: true },
					txtBairro:{ required: true },
					selPais:{ required: true },
					selEstado:
					{ 
						required: function()
						{
							return ($('#selPais').val() == 1);
						}
					},
					selCidade:
					{ 
						required: function()
						{
							return ($('#selPais').val() == 1);
						}
					},
					txtEstado:
					{ 
						required: function()
						{
							return ($('#selPais').val() > 1);
						}
					},
					txtCidade:
					{ 
						required: function()
						{
							return ($('#selPais').val() > 1);
						}
					},
					chkParticipouComo:
					{
						required: function()
						{
							return ($("#chkParticipou1").is(":checked"));
						}
					},
					"chkAreaInteresse[]": { required:true },
					txtAreaInteresseQual:
					{
						required: function()
						{
							return ($("input[name='chkAreaInteresse[]'][value='9']").is(":checked"));
						}
					},
					txtEventoQual:
					{
						required: function()
						{
							return ($('#selEvento').val() == 6);
						}
					}
				},
				messages:
				{
					txtNome:{ required: MSG04 },
					txtEmail:{ required: MSG04, email:MSG09 },
					txtEndereco:{ required: MSG04 },
					txtNumero:{ required: MSG04 },
					txtBairro:{ required: MSG04 },
					selPais:{ required: MSG04 },
					selEstado:{	required: MSG04	},
					selCidade:{ required: MSG04 },
					txtEstado:{ required: MSG04	},
					txtCidade:{ required: MSG04	},
					chkParticipou:{ required:MSG04 },
					"chkAreaInteresse[]": { required:MSG04 },
					txtAreaInteresseQual:{ required:MSG04 },
					txtEventoQual:{ required:MSG04 }
					
				}
			}
		);
		
		$("#selPais").change(function()
		{
			var paisID = $(this).val(); 
		
		
			$('#selEstado optgroup').empty();
			$('#selEstado optgroup').append('<option value="">Selecione</option>');
			$('#selCidade optgroup').empty();
			$('#selCidade optgroup').append('<option value="">Selecione</option>');			
		
			
			if(paisID == "1")
			{
				$("#txtTelefone").unmask().mask('(99) 9999-9999');
				
				$('#selEstado').parent('li').removeClass("hidden");
				$('#selCidade').parent('li').removeClass("hidden");
				$('#txtEstado').val('');
				$('#txtCidade').val('');
				$('#txtEstado').parent('li').addClass('hidden');
				$('#txtCidade').parent('li').addClass('hidden');
				
				$.ajax(
				{
					type: "POST",
					dataType: "json",
					data: "acao=carregar&paisID="+paisID,
					url: 'acao/unidadeFederativa.php',
					complete: function(resposta, status)
					{
						var retorno 		= new Array();
					   	var totalRegistros 	= 0;
					   	eval("retorno = "+resposta.responseText+";");
					   	
					   	if(retorno)
					   	{
							try
							{
								if(retorno.length > 0)
								{	
									totalRegistros = retorno.length;
									$('#selEstado').empty();
									$('#selEstado').append('<option value="">Selecione</option>');
									$('#selCidade').empty();
									$('#selCidade').append('<option value="">Selecione</option>');										
											
									for(var contador = 0; contador < totalRegistros; contador++)
									{
										$('#selEstado').append('<option value="'+retorno[contador].UnidadeFederativaID+'">'+retorno[contador].Nome+'</option>');										
									}
									
									$('#selEstado').unbind().change(function()
									{
									
										$('#selCidade').empty();
										$('#selCidade').append('<option value="">Selecione</option>');	
									
										if($(this).val() > 0)
										{
											var unidadeFederativaID = $(this).val(); 
										
											$.ajax(
											{
												type: "POST",
												dataType: "json",
												data: "acao=carregar&unidadeFederativaID="+unidadeFederativaID,
												url: 'acao/municipio.php',
												complete: function(resposta, status)
												{
													var retorno 		= new Array();
												   	var totalRegistros 	= 0;
												   	eval("retorno = "+resposta.responseText+";");
												   	
												   	if(retorno)
												   	{
														try
														{
															if(retorno.length > 0)
															{
																totalRegistros = retorno.length;
																$('#selCidade').empty();
																$('#selCidade').append('<option value="">Selecione</option>');
																		
																for(var contador = 0; contador < totalRegistros; contador++)
																{
																	$('#selCidade').append('<option value="'+retorno[contador].MunicipioID+'">'+retorno[contador].Nome+'</option>');										
																}
															}
														}
														catch(e)
														{}
													}
												}
											});				
										}
									});
									
								}
							}
							catch(e)
							{}
					   	}
					}
				});
			}
			else
			{
				$("#txtTelefone").unmask();
				$("#txtTelefone").numeric();
			
				$('#selEstado').parent('li').addClass("hidden");
				$('#selCidade').parent('li').addClass("hidden");
								
				$('#txtEstado').parent('li').removeClass('hidden');
				$('#txtCidade').parent('li').removeClass('hidden');
			}
		});
	}
}