// JavaScript Document

function validaCriaComunidade()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
	
	if(document.novaComunidade.nome.value=="" || document.novaComunidade.nome.value.length < 3)
	{
		alert( "Preencha campo NOME corretamente! (Mínimo 3 Caracteres)" );
			document.novaComunidade.nome.focus();
			document.novaComunidade.nome.style.backgroundColor = corErro;
				return false;
	}
	document.novaComunidade.nome.style.backgroundColor = corOk;
	
	if(document.novaComunidade.descricao.value=="" || document.novaComunidade.descricao.value.length < 15)
	{
		alert( "A comunidade deve ter uma breve descrição! (Mínimo 15 Caracteres)" );
			document.novaComunidade.descricao.focus();
			document.novaComunidade.descricao.style.backgroundColor = corErro;
				return false;
	}
	document.novaComunidade.descricao.style.backgroundColor = corOk;
	
	return true;
}


function tamTextArea(txarea, total) 
{
	//total = 100; 
	tam = txarea.value.length; 
	str=""; 
	str=str+tam; 
	Digitado.innerHTML = str; 
	Restante.innerHTML = total - str; 
	
	if (tam > total){ 
		aux = txarea.value; 
		txarea.value = aux.substring(0,total); 
		Digitado.innerHTML = total 
		Restante.innerHTML = 0 
	} 
} 

function geraBoletoWeb(idBoleto, idProfessor)
{
	window.open("../gerenciar/gerenciador/boleto/boletoWeb.php?id_boleto="+idBoleto+"&id_professor="+idProfessor,null,"top=50,left=50,height=600,width=778,status=no,toolbar=no,menubar=yes,location=no,resizable=yes");
}

function mostraDiv(id) {
      if (document.getElementById) 
	  {
		var theitem = document.getElementById(id);
		theitem.style.display = 'block';
	  }
}

function escondeDiv(id) {
      if (document.getElementById) 
	  {
		var theitem = document.getElementById(id);
		theitem.style.display = 'none';
	  }
}

function validaPesquisa()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
	
	if(document.formPesquisa.busca.value=="" || document.formPesquisa.busca.value.length < 3)
	{
		alert( "Preencha campo BUSCA corretamente! (Mínimo 3 Caracteres)" );
			document.formPesquisa.busca.focus();
			document.formPesquisa.busca.style.backgroundColor = corErro;
				return false;
	}
	document.formPesquisa.busca.style.backgroundColor = corOk;	
}

function validaPesquisa2()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
	
	if(document.formPesquisa2.busca.value=="" || document.formPesquisa2.busca.value.length < 3)
	{
		alert( "Preencha campo BUSCA corretamente (Mínimo 3 Caracteres)!" );
			document.formPesquisa2.busca.focus();
			document.formPesquisa2.busca.style.backgroundColor = corErro;
				return false;
	}
	document.formPesquisa2.busca.style.backgroundColor = corOk;	
}

function validaContatoArquivo()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
	
	if(document.contatoArquivo.nome.value=="" || document.contatoArquivo.nome.value.length < 3)
	{
		alert( "Preencha campo NOME corretamente! (Mínimo 3 Caracteres)" );
			document.contatoArquivo.nome.focus();
			document.contatoArquivo.nome.style.backgroundColor = corErro;
				return false;
	}
	document.contatoArquivo.nome.style.backgroundColor = corOk;
		
	if( document.contatoArquivo.email.value=="" || document.contatoArquivo.email.value.indexOf('@')==-1 || document.contatoArquivo.email.value.indexOf('.')==-1 )
	{
		alert( "Preencha campo E-MAIL corretamente!" );
			document.contatoArquivo.email.focus();
			document.contatoArquivo.email.style.backgroundColor = corErro;
				return false;
	}
	document.contatoArquivo.email.style.backgroundColor = corOk;
	
	
	if(document.contatoArquivo.texto.value=="" || document.contatoArquivo.texto.value.length < 10)
	{
		alert( "Preencha campo TEXTO corretamente! (Mínimo 10 caracteres)" );
			document.contatoArquivo.texto.focus();
			document.contatoArquivo.texto.style.backgroundColor = corErro;
				return false;
	}
	document.contatoArquivo.texto.style.backgroundColor = corOk;	
	
	return true;
}


function validaContato()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
	
	if(document.formContato.nome.value=="" || document.formContato.nome.value.length < 3)
	{
		alert( "Preencha campo NOME corretamente! (Mínimo 3 Caracteres)" );
			document.formContato.nome.focus();
			document.formContato.nome.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.nome.style.backgroundColor = corOk;
		
	if( document.formContato.email.value=="" || document.formContato.email.value.indexOf('@')==-1 || document.formContato.email.value.indexOf('.')==-1 )
	{
		alert( "Preencha campo E-MAIL corretamente!" );
			document.formContato.email.focus();
			document.formContato.email.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.email.style.backgroundColor = corOk;
	
	
	if(document.formContato.assunto.value=="")
	{
		alert( "Preencha campo ASSUNTO corretamente!" );
			document.formContato.assunto.focus();
			document.formContato.assunto.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.assunto.style.backgroundColor = corOk;
	
	if(document.formContato.texto.value=="" || document.formContato.texto.value.length < 10)
	{
		alert( "Preencha campo MENSAGEM corretamente! (Mínimo 10 caracteres)" );
			document.formContato.texto.focus();
			document.formContato.texto.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.texto.style.backgroundColor = corOk;	
	
	return true;
}

function validaContatoAdm()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
		
	if(document.formContato.assunto.value=="")
	{
		alert( "Preencha campo ASSUNTO corretamente!" );
			document.formContato.assunto.focus();
			document.formContato.assunto.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.assunto.style.backgroundColor = corOk;
	
	if(document.formContato.texto.value=="" || document.formContato.texto.value.length < 10)
	{
		alert( "Preencha campo TEXTO corretamente! (Mínimo 10 caracteres)" );
			document.formContato.texto.focus();
			document.formContato.texto.style.backgroundColor = corErro;
				return false;
	}
	document.formContato.texto.style.backgroundColor = corOk;	
	
	return true;
}

function validaEnvioArquivo()
{
	corOk = '#FFFFFF';
	corErro = '#FCD1D1';
		
	if(document.enviaArquivo.nome.value=="")
	{
		alert( "Preencha campo NOME corretamente!" );
			document.enviaArquivo.nome.focus();
			document.enviaArquivo.nome.style.backgroundColor = corErro;
				return false;
	}
	document.enviaArquivo.nome.style.backgroundColor = corOk;
	
	if( document.enviaArquivo.email.value=="" || document.enviaArquivo.email.value.indexOf('@')==-1 || document.enviaArquivo.email.value.indexOf('.')==-1 )
	{
		alert( "Preencha campo E-MAIL corretamente!" );
			document.enviaArquivo.email.focus();
			document.enviaArquivo.email.style.backgroundColor = corErro;
				return false;
	}
	document.enviaArquivo.email.style.backgroundColor = corOk;
	
	if(document.enviaArquivo.arquivo.value=="")
	{
		alert( "Preencha campo ARQUIVO corretamente!" );
			document.enviaArquivo.arquivo.focus();
			document.enviaArquivo.arquivo.style.backgroundColor = corErro;
				return false;
	}
	document.enviaArquivo.arquivo.style.backgroundColor = corOk;
	
	return true;
}
		
//Script para confirmação de exclusão
function deleta(msg)
{
	if (msg == '') 
	{
		if(confirm("Confirma Exclusão?")) {
			return true;
		} else {
			return false;
		}
	}
	else
	{
		if(confirm(msg)) {
			return true;
		} else {
			return false;
		}	
	}
}

//addSWF('Caminho e arquivo a ser chamado', Largura , altura , true ou false para transparente)
function addSWF   (URL, WIDTH, HEIGHT, TRANSPARENT)
{
document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');
document.write (' <param name="movie" value="'+ URL +'" />');
document.write (' <param name="quality" value="high" />');

if ( TRANSPARENT ) {
  document.write (' <param name="Wmode" value="Transparent" />');
}

document.write (' <embed src="'+ URL +'" quality="high" ');

if ( TRANSPARENT ) {
document.write (' Wmode = "transparent" ');
}

document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
document.write (' </object>');

}
