// javascript document`

var cfg_app_nomeDisplay = "Zilveti Sanden"

//*****************************************************************************************************************************
// FUNÇÕES OPERACIONAIS
//*****************************************************************************************************************************

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*   função para aceitar somente números
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function pecaOrcamento(prod){
	window.open('peca_orcamento.asp?'+ prod, 'educavirtual', 'statusbar=0, menubars=0, resizable=0, width=350, height=400');
}

function envieAmigo(){
	window.open('envie.asp', 'stormcorp', 'statusbar=1, menubars=0, resizable=1, width=450, height=300');
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*   função para abrir enquete
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function abre_enquete(url) {
	var strValue = window.open(''+url+'','Janela','scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,resizable=yes,height=280,width=300');
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*   função para ver curriculo do docente
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function verCurriculo(doc){
	window.open('curriculo.asp?'+ doc, 'educavirtual', 'statusbar=1, menubars=0, resizable=0, scrollbars=1, width=1004, height=500');
}


//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*   função para aceitar somente números
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function somenteNumero(){
	if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 8) {
		event.keyCode = 0;
		    return false;
	}
   return true;
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*   estruturando o campo conforme mask 
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function formataGeral(Object, Mask) {
   var i, nCount, sValue, fldLen, mskLen, bolMask, sCod, nTecla, sMask
	// definindo o source do keyPress para IE
	if(document.all) {
		nTecla = event.keyCode;
	}
	// definindo o source do keyPress para NS
	else if(document.layers) {
		nTecla = event.which;
	}

   sValue = document.getElementById(Object).value;
   sMask = Mask

   sValue = sValue.toString().replace('-','');
   sValue = sValue.toString().replace('.','');
   sValue = sValue.toString().replace('/','');
   sValue = sValue.toString().replace('(','');
   sValue = sValue.toString().replace(')','');
   sValue = sValue.toString().replace(' ','');
   sValue = sValue.toString().replace(':','');

   // é necessário checar duas vezes")
   sValue = sValue.toString().replace('-','');
   sValue = sValue.toString().replace('.','');
   sValue = sValue.toString().replace('/','');
   sValue = sValue.toString().replace('(','');
   sValue = sValue.toString().replace(')','');
   sValue = sValue.toString().replace(' ','');
   sValue = sValue.toString().replace(':','');

   fldLen = sValue.length;
   mskLen = sMask.length;
   i = 0;
   nCount = 0;
   sCod = '';
   mskLen = fldLen;

   while (i <= mskLen) {

	    bolMask = ((sMask.charAt(i) == '-') || (sMask.charAt(i) == ':') || (sMask.charAt(i) == '.') || (sMask.charAt(i) == '/'))
	    bolMask = bolMask || ((sMask.charAt(i) == '(') || (sMask.charAt(i) == ')') || (sMask.charAt(i) == ' '))

	    if (bolMask) {
		    sCod += sMask.charAt(i);
		    mskLen++;
	    } else {
		    sCod += sValue.charAt(nCount);
		    nCount++;
	    }
       i++;
   }

   // retornando a construção
   document.getElementById(Object).value = sCod;


   // verificando que tipo de tecla é pressionada
   if (nTecla != 8) { // se não for backspace

	    if (sMask.charAt(i - 1) == '9') { // se for somente números
		    return ((nTecla > 47) && (nTecla < 58));
	    } else { // se for qualquer caracter
		    return true;
 	    }

    } else {
 	    return true;
    }

    i = 0;
    nCount = 0;
    mskLen = '';
 }

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*    verificando se a data é válida      
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function verificaData(Object, tituloObj) {

var bissexto = 0;
var data = document.getElementById(Object).value; 
var tam = data.length; 

if(data != '') { 

	if (tam == 10) 
	{ 
	 var dia = data.substr(0, 2) 
	 var mes = data.substr(3, 2) 
	 var ano = data.substr(6, 40) 
		if (ano > 1900) 
		if (ano < 2100) 
		{ 
		 switch(mes) 
			{ 
				case '01': 
				case '03': 
				case '05': 
				case '07': 
				case '08': 
				case '10': 
				case '12': 

					if  (dia <= 31) { 
						return true; 
					} 
					break; 

				case '04': 
				case '06': 
				case '09': 
				case '11': 

					if  (dia <= 30) { 
						return true; 
					} 
					break; 

				case '02': // validando ano bissexto - mês fevereiro 

					if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) { 
						bissexto = 1; 
					} 

					if ((bissexto == 1) && (dia <= 29)) { 
						return true; 
					} 

					if ((bissexto != 1) && (dia <= 28)) { 
						return true; 
					} 
					break; 
			} 
		} 
	} 

	apresentaAlertas('5', tituloObj);
	document.getElementById(Object).focus(); 
	return(false);
	formReady = 0;
	
	} 
} 

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//*    função para validar e-mail     
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

function verificaEmail(Object) {
	var emailCheck = document.getElementById(Object).value; 
	
	if (emailCheck.indexOf('@', 0) == -1 || emailCheck.indexOf('.', 0) == -1){
		apresentaAlertas('8', 'O e-mail informado <strong>NÃO É UM E-MAIL VÁLIDO</strong>. Por favor verifique e tente novamente.');
		document.getElementById(Object).focus(); 
		return false;
	} else {
		return true;
	}
}


//*****************************************************************************************************************************
// FUNÇÕES PARA FORMULÁRIOS
//*****************************************************************************************************************************

// ****************************************************************************************************************
// função para LIMPAR campo de busca
// ****************************************************************************************************************
function clearSearch(act){
	if(document.getElementById){
		
		var iptSearch = document.getElementById("txtBuscaProduto");
		if(act == "in" && iptSearch.value == "Palavra-chave"){
			iptSearch.value = "";
		} else if(act == "out" && iptSearch.value == ""){
			iptSearch.value = "Palavra-chave";
		}
		
	}
}


// ****************************************************************************************************************
// função para VALIDAR campo de busca
// ****************************************************************************************************************
function checkSearch(){
	if(document.getElementById){
		
		var iptSearch = document.getElementById("txtBuscaProduto");
		if(iptSearch.value != "Palavra-chave" && iptSearch.value.length > 3){
			return (true);
		} else {
			
			if(iptSearch.value == "Palavra-chave"){
				alert('Por favor digite o que deseja buscar.');
			}
			
			if(iptSearch.value.length <= 3){
				alert('Por favor digite algo com mais de três letras.');
			}
			
			return false;
			
		}
		
	}
}



// ****************************************************************************************************************
// função para ocupar a status bar e nao deixar select
// ****************************************************************************************************************

function textoStatusBar() {
	window.status = cfg_app_nomeDisplay
	setTimeout("textoStatusBar()", 1)
}

textoStatusBar();

// document.onselectstart = new Function("return false");



// ****************************************************************************************************************
// função para bloquear botao direito do mouse
// ****************************************************************************************************************

// function click() {
//	if (event.button==2||event.button==3) {
//		oncontextmenu='return false';
//	}
// }

// document.onmousedown = click
// document.oncontextmenu = new Function("return false;")


// ****************************************************************************************************************
// função para apresentar erros e alertas
// ****************************************************************************************************************

function apresentaAlertas(erroTipo, objTarget) {
	if(document.getElementById) {
	
		var targetShow 		= document.getElementById("validacao_mensagem");
		var mensegemSaida	= ""
		
		if(erroTipo == 1) {
			mensegemSaida 	= "Atenção: Você precisa preencher o campo <strong>"+ objTarget +"</strong>. Preencha este campo e clique novamente em enviar.";
			
		} else if (erroTipo == 8) {
			mensegemSaida 	= objTarget;
			
		}
		
		targetShow.innerHTML = mensegemSaida;
	}
}


// ****************************************************************************************************************
// função para trocar imagens do rodapé
// ****************************************************************************************************************

function imgChange(imgT, imgI){
	
	if(imgT == 1){		
		document.images[imgI].src='images/layout/rodape_roll_'+ imgI +'_l.gif';
	} else if(imgT == 0){
		document.images[imgI].src='images/layout/rodape_roll_'+ imgI +'_d.gif';		
	}
	
}



// ****************************************************************************************************************
// função para controlar swf dentro de frames
// ****************************************************************************************************************

objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++){
	objects[i].outerHTML = objects[i].outerHTML;
}

//*****************************************************************************************************************************
// VALIDAÇÃO DE FORMULÁRIO
//*****************************************************************************************************************************


// ****************************************************************************************************************
// função para validar formulários de mais informações
// ****************************************************************************************************************

function validaFormMaisInformacoes() {
	
	if(document.getElementById("txtNome").value == "") {
		apresentaAlertas('1', 'Nome');
		document.getElementById("txtNome").focus();
		return(false);
	}
	
	if(document.getElementById("txtEmail").value == "") {
		apresentaAlertas('1', 'E-mail');
		document.getElementById("txtEmail").focus();
		return(false);
	}

	if(document.getElementById("txtTelefone").value == "") {
		apresentaAlertas('1', 'Telefone');
		document.getElementById("txtTelefone").focus();
		return(false);
	}
	
	if(document.getelementById("txtEscolaridade").value == "") {
		apresentaAlertas('1', 'Escolaridade');
		document.getElementById("txtEscolaridade").focus();
		return(false);
	}
	
	if(document.getElementById("txtMensagem").value == "") {
		apresentaAlertas('1', 'Mensagem');
		document.getElementById("txtMensagem").focus();
		return(false);
	}

}

// ****************************************************************************************************************
// função para validar formulários de compre agora
// ****************************************************************************************************************

function validaFormCompre() {
	
	if(document.getElementById("txtNome").value == "") {
		apresentaAlertas('1', 'Nome');
		document.getElementById("txtNome").focus();
		return(false);
	}
	
	if(document.getElementById("txtEndereco").value == "") {
		apresentaAlertas('1', 'Endereço');
		document.getElementById("txtEndereco").focus();
		return(false);
	}
	
	if(document.getElementById("txtEstado").value == "") {
		apresentaAlertas('1', 'Estado');
		document.getElementById("txtEstado").focus();
		return(false);
	}
	
	if(document.getElementById("txtCidade").value == "") {
		apresentaAlertas('1', 'Cidade');
		document.getElementById("txtCidade").focus();
		return(false);
	}
	
	if(document.getElementById("txtCEP").value == "") {
		apresentaAlertas('1', 'CEP');
		document.getElementById("txtCEP").focus();
		return(false);
	}
	
	if(document.getElementById("txtTelefone").value == "") {
		apresentaAlertas('1', 'Telefone');
		document.getElementById("txtTelefone").focus();
		return(false);
	}
	
	if(document.getElementById("txtCelular").value == "") {
		apresentaAlertas('1', 'Celular');
		document.getElementById("txtCelular").focus();
		return(false);
	}

	if(document.getElementById("txtEmail").value == "") {
		apresentaAlertas('1', 'E-mail');
		document.getElementById("txtEmail").focus();
		return(false);
	}
	
	if(document.getElementById("txtEstadoCivil").value == "") {
		apresentaAlertas('1', 'Estado Civil');
		document.getElementById("txtEstadoCivil").focus();
		return(false);
	}
	
	if(document.getElementById("txtDataNascimento").value == "") {
		apresentaAlertas('1', 'Data de Nascimento');
		document.getElementById("txtDataNascimento").focus();
		return(false);
	}
	
	if(document.getElementById("txtCPF").value == "") {
		apresentaAlertas('1', 'CPF');
		document.getElementById("txtCPF").focus();
		return(false);
	}
	
	if(document.getElementById("txtRG").value == "") {
		apresentaAlertas('1', 'RG');
		document.getElementById("txtRG").focus();
		return(false);
	}
	
	if(document.getElementById("txtNacionalidade").value == "") {
		apresentaAlertas('1', 'Nacionalidade');
		document.getElementById("txtNacionalidade").focus();
		return(false);
	}
	
	if(document.getElementById("txtNaturalidade").value == "") {
		apresentaAlertas('1', 'Naturalidade');
		document.getElementById("txtNaturalidade").focus();
		return(false);
	}
	
	if(document.getElementById("txtOrigemRecursos").value == "") {
		apresentaAlertas('1', 'Origem dos Recursos');
		document.getElementById("txtOrigemRecursos").focus();
		return(false);
	}
	
	if(document.getElementById("txtRendaFamiliar").value == "") {
		apresentaAlertas('1', 'Renda Familiar');
		document.getElementById("txtRendaFamiliar").focus();
		return(false);
	}
	
	if(document.getElementById("txtComoConheceu").value == "") {
		apresentaAlertas('1', 'Como conheceu o Educa Virtual');
		document.getElementById("txtComoConheceu").focus();
		return(false);
	}
	
	if(document.getElementById("txtTrabalha").value == "") {
		apresentaAlertas('1', 'Trabalha atualmente');
		document.getElementById("txtTrabalha").focus();
		return(false);
	}
	
	if(document.getElementById("txtInstituicaoGraduacao").value == "") {
		apresentaAlertas('1', 'Instituição de Ensino (Graduação)');
		document.getElementById("txtInstituicaoGraduacao").focus();
		return(false);
	}
	
	if(document.getElementById("txtCursoGraduacao").value == "") {
		apresentaAlertas('1', 'Curso (Graduação)');
		document.getElementById("txtCursoGraduacao").focus();
		return(false);
	}
	
	if(document.getElementById("termo_adesao").value == "") {
		apresentaAlertas('1', 'Termo de Adesão');
		document.getElementById("termo_adesao").focus();
		return(false);
	}

}

// ****************************************************************************************************************
// função para validar formulários de fale conosco
// ****************************************************************************************************************

function validaFormFaleConosco() {
	
	if(document.getElementById("txtNome").value == "") {
		apresentaAlertas('1', 'Nome');
		document.getElementById("txtNome").focus();
		return(false);
	}
	
	if(document.getElementById("txtEmail").value == "") {
		apresentaAlertas('1', 'Email');
		document.getElementById("txtEmail").focus();
		return(false);
	}
	
	if(document.getElementById("txtTelefone").value == "") {
		apresentaAlertas('1', 'Telefone');
		document.getElementById("txtTelefone").focus();
		return(false);
	}
	
	if(document.getElementById("txtComoConheceu").value == "") {
		apresentaAlertas('1', 'Como Conheceu');
		document.getElementById("txtComoConheceu").focus();
		return(false);
	}
	
	if(document.getElementById("txtMensagem").value == "") {
		apresentaAlertas('1', 'Mensagem');
		document.getElementById("txtMensagem").focus();
		return(false);
	}
	
}

// ****************************************************************************************************************
// função para validar formulários de trabalhe conosco
// ****************************************************************************************************************

function validaFormTrabalheConosco() {
	
	if(document.getElementById("txtNome").value == "") {
		apresentaAlertas('1', 'Nome');
		document.getElementById("txtNome").focus();
		return(false);
	}
	
	if(document.getElementById("txtEmail").value == "") {
		apresentaAlertas('1', 'Email');
		document.getElementById("txtEmail").focus();
		return(false);
	}
	
	if(document.getElementById("txtTelefone").value == "") {
		apresentaAlertas('1', 'Telefone');
		document.getElementById("txtTelefone").focus();
		return(false);
	}
	
	if(document.getElementById("txtSexo").value == "") {
		apresentaAlertas('1', 'Sexo');
		document.getElementById("txtSexo").focus();
		return(false);
	}
	
	if(document.getElementById("txtRg").value == "") {
		apresentaAlertas('1', 'RG');
		document.getElementById("txtRg").focus();
		return(false);
	}
	
	if(document.getElementById("txtCpf").value == "") {
		apresentaAlertas('1', 'CPF');
		document.getElementById("txtCpf").focus();
		return(false);
	}
	
	if(document.getElementById("txtNascimento").value == "") {
		apresentaAlertas('1', 'Data de Nascimento');
		document.getElementById("txtNascimento").focus();
		return(false);
	}
	
	if(document.getElementById("txtEstadoCivil").value == "") {
		apresentaAlertas('1', 'Estado Civil');
		document.getElementById("txtEstadoCivil").focus();
		return(false);
	}
	
	if(document.getElementById("txtNacionalidade").value == "") {
		apresentaAlertas('1', 'Nacionalidade');
		document.getElementById("txtNacionalidade").focus();
		return(false);
	}
	
	if(document.getElementById("txtFilhos").value == "") {
		apresentaAlertas('1', 'Número de Filhos');
		document.getElementById("txtFilhos").focus();
		return(false);
	}
	
	if(document.getElementById("txtMunicipio").value == "") {
		apresentaAlertas('1', 'Município');
		document.getElementById("txtMunicipio").focus();
		return(false);
	}
	
	if(document.getElementById("txtUf").value == "") {
		apresentaAlertas('1', 'UF');
		document.getElementById("txtUf").focus();
		return(false);
	}
	
	if(document.getElementById("txtCep").value == "") {
		apresentaAlertas('1', 'CEP');
		document.getElementById("txtCep").focus();
		return(false);
	}
	
	if(document.getElementById("txtEndereco").value == "") {
		apresentaAlertas('1', 'Endereço');
		document.getElementById("txtEndereco").focus();
		return(false);
	}
	
	if(document.getElementById("txtTelResidencial").value == "") {
		apresentaAlertas('1', 'Telefone Residencial');
		document.getElementById("txtTelResidencial").focus();
		return(false);
	}
	
	if(document.getElementById("txtTelComercial").value == "") {
		apresentaAlertas('1', 'Telefone Comercial');
		document.getElementById("txtTelComercial").focus();
		return(false);
	}
	
	if(document.getElementById("txtCelular").value == "") {
		apresentaAlertas('1', 'Telefone Celular');
		document.getElementById("txtCelular").focus();
		return(false);
	}
	
	if(document.getElementById("txtEscolaridade").value == "") {
		apresentaAlertas('1', 'Escolaridade');
		document.getElementById("txtEscolaridade").focus();
		return(false);
	}
		
	if(document.getElementById("txtAreas").value == "") {
		apresentaAlertas('1', 'Áreas de Interesse');
		document.getElementById("txtAreas").focus();
		return(false);
	}
	
	if(document.getElementById("txtFormacao").value == "") {
		apresentaAlertas('1', 'Formação Profissional');
		document.getElementById("txtFormacao").focus();
		return(false);
	}
	
	if(document.getElementById("txtExperiencia").value == "") {
		apresentaAlertas('1', 'Experiência Profissional');
		document.getElementById("txtExperiencia").focus();
		return(false);
	}
	
}

// ****************************************************************************************************************
// função para validar formulários de newsletter
// ****************************************************************************************************************

function validaFormNewsletter() {
	
	if(document.getElementById("txtNome").value == "") {
		//apresentaAlertas('1', 'Nome');
		document.getElementById("erroNome").innerHTML = '<span style=font color:red;>Preencha o Nome!<span>';
		document.getElementById("txtNome").focus();
		return(false);
	}
	
	if(document.getElementById("txtEmail").value == "") {
		//apresentaAlertas('1', 'Email');
		document.getElementById("erroEmail").innerHTML = '<span style=font color:red;>Preencha o Email!<span>';
		document.getElementById("txtEmail").focus();
		return(false);
	}

}

