$(document).ready(function() {
	$(".dm_form input, .dm_form select, .dm_form textarea").focus(
		function() {
			$(this).addClass("field-focus");
		}).blur(
		function() {
			$(this).removeClass("field-focus");
		});
	$(".dm_form").submit(function(){
			$(".dm_form .error :input").each(function(){
				if($(this).val() != "") $(this).parents('label').addClass('mandatory').removeClass('error');
			});
			$(".dm_form .mandatory :input").each(function(){
				if($(this).val() == "") $(this).parents('label').removeClass('mandatory').addClass('error');
			});
			$(".dm_form .error :input").each(function(){
				$(this).blur(function(){
					  if($(this).val() != "") $(this).parents('label').addClass('mandatory').removeClass('error');
					});
			});
			if ($(".dm_form .error :input").size() != 0)
			{
				alert("Antes de enviar é necessário preencher todos os campos obrigatórios (destacados em vermelho).");
				return false;
			}
		});
});

function popup(url)
{
	window.open(url,'popup','width=450,height=450');		
}

/** visibilidade **/
var obj_visivel = "";

function visivel(objeto) {
	if(obj_visivel != "" && obj_visivel != objeto){
		document.getElementById(obj_visivel).style.display = "none";
	}
	
	var obj = document.getElementById(objeto);
	
	if (obj.style.display == 'block'){
		obj.style.display = 'none';
	}
	else {
		obj.style.display = 'block';
	}
	
	obj_visivel = objeto;
}

function delFoto(usuaId)
{	
	var $check = $(usuaId);
	
	$.ajax({
		type: "POST",
		url: "comunidade.php?c=del_foto&idfoto="+usuaId,
		data: "cd_usua=" + usuaId,
		success: function(retorno)
		{
			$(".container-img").hide('slow', function() {
				$(".container-img").html("<img src=\"_arquivos/usuarios/noimg.jpg\" alt=\"\" class=\"imgPerfil floatLeft\" />");
				$(".container-img").show('slow');
			});
			if (retorno == "Erro!")
			{
				alert("Ocorreu um problema na requisição, por favor tente novamente.");
			}
		}
	});
}


function ucn(){
	window.open('http://sistema.ucn.com.br/1/mtc/E13515-964', 'UCN', 'width=790,height=580');
}
