function TrocaTexto (texto,elemento) {
	document.getElementById(elemento).innerHTML = texto;
}

function Excluir(tipo,identificador) {
	if(confirm("Deseja realmente excluir este registro?"))
	{
		location = tipo+"_excluir.php?id="+identificador;
	}
}

function listar()
{
	location = "muralderecados_listar.php";
}

function Visualizar(url,page,w,h,sc) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
if(sc=="")
sc = "Yes";
win = window.open(url,page, 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+sc+',resizable=no')
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function validarNews()
{
	with(document.formNews)
	{
		if(nome.value=="")
		{
			alert("O campo NOME deve ser preenchido!");
			nome.focus();
			return false;
		}
		if (email.value=="")
		{
			alert ("O campo E-MAIL deve ser preenchido!");
		  	email.focus();
		   	return false;
		}
		if (email.value.indexOf ("@",0) == -1 || email.value.indexOf (".",0) == -1)
	    {
	    	alert("Por favor, preencha o campo E-MAIL corretamente!")
	        email.focus();
	        return false;
	    }
		return true;
	}
}

function RedimensionaIframe() {
	var ifr = document.getElementById('conteudo');
	var altura = ifr.contentWindow.document.body.scrollHeight;
	if(altura > 120) {
		ifr.style.height = altura;
	} else {
		ifr.style.height = 120;
	}
}

function validaForm( NomeForm )
{
	if (NomeForm == 'frmContato')
	{
		if (document.forms[NomeForm].elements['nome'].value == "")
		{
			alert("O campo NOME deve ser preenchido!");
			document.forms[NomeForm].elements['nome'].focus();
			return false;
		}
		
		if(document.forms[NomeForm].elements['email'].value == ""){
			alert("O campo E-MAIL deve ser preenchido!");
			document.forms[NomeForm].elements['email'].focus();
			return false;
		}else{
				if(!(validaEmail(document.forms[NomeForm].elements['email'].value))){
					alert("O campo E-MAIL não está com um e-mail válido!");
					document.forms[NomeForm].elements['email'].focus();
					return false;
				}
		}
		if (document.forms[NomeForm].elements['telefone'].value == "")
		{
			alert("O campo TELEFONE deve ser preenchido!");
			document.forms[NomeForm].elements['telefone'].focus();
			return false;
		}
		if (document.forms[NomeForm].elements['endereco'].value == "")
		{
			alert("O campo ENDERECO deve ser preenchido!");
			document.forms[NomeForm].elements['endereco'].focus();
			return false;
		}
		
		if (document.forms[NomeForm].elements['mensagem'].value == "")
		{
			alert("O campo MENSAGEM deve ser preenchido!");
			document.forms[NomeForm].elements['mensagem'].focus();
			return false;
		}
		return true;
	} //Fim frmContato
	
}

function validaEmail(email)
{
	if(email.length < 6)
	{
		return false;
	}
	var x=0;
	for(var c=0;c<email.length;c++)
	{
		if(email.substring(c,c+1)=='@')
		{
			x=c;
		}
	}
	var y=0;
	if(x > 0)
	{
		for(c=x;c<email.length;c++)
		{
			if(email.substring(c,c+1)=='.')
			{
				y=c;
				var valida=1;
			}
		}					
	}
	else
		{
			return false;
		}

	if(y<=x+2)
	{
		return false;
	}

	if(valida==1)
	{
		return true;
	}
	return true;
}