function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
}

function fadeIn(id, time) {
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}


function esqueceu_senha(TIPO) {

	window.open("senha.php?tipo=" + TIPO, "JANELA", "height = 200 , width = 400, scrollbars = yes, menubar = no, toolbar = no");

}

function esqueceu_senha2() {

	window.open("senha.php?tipo=empresa", "JANELA", "height = 200 , width = 400, scrollbars = yes, menubar = no, toolbar = no");

}

function apagar_usuario(id,titulo){
	var agree=confirm("Tem certeza que deseja excluir o usuário: " + titulo + "?");
	if (agree){
		window.location = "usuarios.php?acao=apagar&id=" + id;
	}else{
		return false;
	}
}
function apagar_empresa(id,titulo){
	var agree=confirm("Tem certeza que deseja excluir a empresa: " + titulo + "?");
	if (agree){
		window.location = "empresas.php?acao=apagar&id=" + id;
	}else{
		return false;
	}
}
function apagar_conteudo(pagina,id,tipo,titulo){
	var agree=confirm("Tem certeza que deseja excluir o conteúdo: " + titulo + "?");
	if (agree){
		window.location = "paginas.php?acao=" + tipo + "_apagar&pagina=" + pagina + "&subpagina=" + id;
	}else{
		return false;
	}
}
function apagar_foto(pagina,id,tipo,titulo){
	var agree=confirm("Tem certeza que deseja excluir a foto: " + titulo + "?");
	if (agree){
		window.location = "paginas.php?acao=" + tipo + "_apagar&pagina=" + pagina + "&subpagina=" + id;
	}else{
		return false;
	}
}
function apagar_produtos(pagina,id,tipo,titulo){
	var agree=confirm("Tem certeza que deseja excluir o conteúdo: " + titulo + "?");
	if (agree){
		window.location = "produtos.php?acao=" + tipo + "_apagar&pagina=" + pagina + "&subpagina=" + id;
	}else{
		return false;
	}
}
function form_CadastroVaga() {

	if (document.form.motivo_a.value == "") {
	alert("Você deve informar um motivo válido!");
	document.form.motivo_a.focus();
	return (false);
	}

}
function form_CadastraConfiguracoes() {

	if (document.form.titulo_a.value == "") {
	alert("Você deve informar um nome válido!");
	document.form.titulo_a.focus();
	return (false);
	}

}
function form_CadastraFoto() {

	if (document.form.titulo_a.value == "") {
	alert("Você deve informar um título válido!");
	document.form.titulo_a.focus();
	return (false);
	}

	if (document.form.imagem) {
	if (document.form.imagem.value == "") {
	alert("Você não deve selecionar um arquivo de imagem!");
	document.form.imagem.focus();
	return (false);
	}
	}

	if (document.form.data_a.value == "") {
	alert("Você deve informar uma data!");
	document.form.data_a.focus();
	return (false);
	}
}
function form_CadastraConteudo() {

	if (document.form.titulo_a.value == "") {
	alert("Você deve informar um título válido!");
	document.form.titulo_a.focus();
	return (false);
	}

	if (document.form.data_a.value == "") {
	alert("Você deve informar uma data!");
	document.form.data_a.focus();
	return (false);
	}

	
}
function form_CadastroUsuario()
{

	if (document.form.ds_email_a.value == "") {
	alert("Você deve informar um email válido!");
	document.form.ds_email_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.ds_senha_a.value == "") {
	alert("Você deve informar uma senha válida!");
	document.form.ds_senha_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.nm_usuario_a.value == "") {
	alert("Você deve informar um nome válido!");
	document.form.nm_usuario_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.ds_login_a.value == "") {
	alert("Você deve informar um login válido!");
	document.form.ds_login_a.focus();
	var erro = "sim";
	return (false);
	}
	
}

function janela(PAGINA, LAR, ALT)
{
	window.open(PAGINA, "JANELA", "height = " + ALT + " , width = " + LAR + ", scrollbars = yes, menubar = no, toolbar = no, resizable = true");
}
function Data(){
    		var diasemana = new Array()
        diasemana[0] = "Domingo"
        diasemana[1] = "Segunda-feira"
        diasemana[2] = "Terça-feira"
        diasemana[3] = "Quarta-feira"
        diasemana[4] = "Quinta-feira"
        diasemana[5] = "Sexta-feira"
        diasemana[6] = "Sábado"


    var mesnome = new Array();
        mesnome[0] = "janeiro";
        mesnome[1] = "fevereiro";
        mesnome[2] = "março";
        mesnome[3] = "abril";
        mesnome[4] = "maio";
        mesnome[5] = "junho";
        mesnome[6] = "julho";
        mesnome[7] = "agosto";
        mesnome[8] = "setembro";
        mesnome[9] = "outubro";
        mesnome[10] = "novembro";
        mesnome[11] = "dezembro";


    var hoje = new Date()
    var ano = hoje.getYear()
    if (ano<2000){ano = 1900+ano;}
    var mes = hoje.getMonth()
    var dia = hoje.getDate()
    var diasem = hoje.getDay()


    var str = ""+diasemana[diasem]+", "+dia+" de "+mesnome[mes]+" de "+ano;
    document.write(str);

}

function formata(src, mask)
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida)
  {
	src.value += texto.substring(0,1);
  }
}

VerifiqueTAB=true;
function Mostra(quem, tammax) {
if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
var i=0,j=0, indice=-1;
for (i=0; i<document.forms.length; i++) {
for (j=0; j<document.forms[i].elements.length; j++) {
if (document.forms[i].elements[j].name == quem.name) {
indice=i;
break;
}
}
if (indice != -1) break;
}
for (i=0; i<=document.forms[indice].elements.length; i++) {
if (document.forms[indice].elements[i].name == quem.name) {
while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
(i < document.forms[indice].elements.length) ) {
i++;
}
document.forms[indice].elements[(i+1)].focus();
VerifiqueTAB=false;
break;
}
}
}
}

function PararTAB(quem) { VerifiqueTAB=false; }
function ChecarTAB() { VerifiqueTAB=true; }


function isNum( caractere ) {

var strValidos = "0123456789"

if ( strValidos.indexOf( caractere ) == -1 )

return false;

return true;

}

function validaTecla(campo, event)

{

var BACKSPACE= 8;

var key;

var tecla;



CheckTAB=true;

if(navigator.appName.indexOf("Netscape")!= -1)

tecla= event.which;

else

tecla= event.keyCode;



key = String.fromCharCode( tecla);

//alert( 'key: ' + tecla + ' -> campo: ' + campo.value);



if ( tecla == 13 )

return false;

if ( tecla == BACKSPACE )

return true;

return ( isNum(key));

}


function Limpar(valor, validos) { 
// retira caracteres invalidos da string 
var result = ""; 
var aux; 
for (var i=0; i < valor.length; i++) { 
aux = validos.indexOf(valor.substring(i, i+1)); 
if (aux>=0) { 
result += aux; 
} 
} 
return result; 
} 

//Formata número tipo moeda usando o evento onKeyDown 

function Formata(campo,tammax,teclapres,decimal) { 
var tecla = teclapres.keyCode; 
vr = Limpar(campo.value,"0123456789"); 
tam = vr.length; 
dec=decimal 

if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; } 

if (tecla == 8 ) 
{ tam = tam - 1 ; } 

if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) 
{ 

if ( tam <= dec ) 
{ campo.value = vr ; } 

if ( (tam > dec) && (tam <= 5) ){ 
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 6) && (tam <= 8) ){ 
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
} 
if ( (tam >= 9) && (tam <= 11) ){ 
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 12) && (tam <= 14) ){ 
campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 15) && (tam <= 17) ){ 
campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;} 
} 

} 

function trocar_string(velho,novo,texto) {  
    for (var i=0; i<texto.length; i++) {  
               texto = texto.replace(velho,novo); 
        }  
     return texto;  
}  

function add_favoritos(URL,TITULO)
{
	var browsName = navigator.appName; 
	if (browsName == 'Microsoft Internet Explorer') { 
		window.external.AddFavorite(URL,TITULO);
	} else if (browsName == 'Netscape') { 
		alert ('Para adicionar este site aos favoritos pressione CTRL+D'); 
	}
}

function FormularioTrabalhe()
{

	if (document.form.nome_a.value == "") {
	alert("Você deve informar um nome válido!");
	document.form.nome_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.telefone_a.value == "") {
	alert("Você deve informar um telefone válido!");
	document.form.telefone_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.email_a.value == "") {
	alert("Você deve informar um email válido!");
	document.form.email_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.curriculo_a.value == "") {
	alert("Você não pode cadastrar um currículo em branco!");
	document.form.curriculo_a.focus();
	var erro = "sim";
	return (false);
	}
	
}

function FormularioContato()
{

	if (document.form.nome_a.value == "") {
	alert("Você deve informar um nome válido!");
	document.form.nome_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.telefone_a.value == "") {
	alert("Você deve informar um telefone válido!");
	document.form.telefone_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.email_a.value == "") {
	alert("Você deve informar um email válido!");
	document.form.email_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.mensagem_a.value == "") {
	alert("Você não pode enviar uma mensagem em branco!");
	document.form.mensagem_a.focus();
	var erro = "sim";
	return (false);
	}
	
}

function FormularioIndique()
{

	if (document.form.nome_a.value == "") {
	alert("Você deve informar um nome válido!");
	document.form.nome_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.nome2_a.value == "") {
	alert("Você deve informar um nome de amigo(a) válido!");
	document.form.nome2_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.email_a.value == "") {
	alert("Você deve informar um email válido!");
	document.form.email_a.focus();
	var erro = "sim";
	return (false);
	}

	if (document.form.email2_a.value == "") {
	alert("Você deve informar um email de amigo(a) válido!");
	document.form.email2_a.focus();
	var erro = "sim";
	return (false);
	}
	
	if (document.form.mensagem_a.value == "") {
	alert("Você não pode enviar uma mensagem em branco!");
	document.form.mensagem_a.focus();
	var erro = "sim";
	return (false);
	}
}
