// JavaScript Document
function FrameLoad(){
	window.location=("../principal.php");
}

function confirma_boleto(id){
	if(confirm('Confirma exclusã¯ do registro '+ id + '?')){
		window.location=("consulta.php?<?= $pagina ?>=<?= $valor ?>&acao=Excluir&excluir=" + id +"");
//		document.frm.submit();
	}
}

function confirma_voluntario(id){
	if(confirm('Confirma exclusã¯ do registro '+ id + '?')){
		window.location=("consulta.php?<?= $pagina ?>=<?= $valor ?>&acao=Excluir&excluir=" + id +"");
//		document.frm.submit();
	}
}

function open_janela(m,d){
		window.open('includes/ocorrencias.php?codigo_alu=' + m + '&diames=' + d + '','modelo1','resizable=no,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=no,width=580,height=270');
	}

function openJanelaBoleto(cli,bol){
		window.open('boleto_real.php?idcli=' + cli + '&idboleto=' + bol + '','Boleto','resizable=no,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width=700,height=460');
}



function viewCalendario(){
		window.open('includes/calendario.php','modelo1','resizable=no,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width=800,height=600');
}

function excluir(id){
	if(confirm("Confirma a exclusã¯¿"))
		window.location.href="consulta.php?excluir=1&id="+id;
}
function excluirConteudoPA(id,detalhar){
	if(confirm("Confirma a exclusã¯¿"))
		window.location.href="?detalhar="+detalhar+"&excluir_conteudo="+id;
}

function editarConteudo(id){
	window.location.href="conteudoplanoaula.php?detalhar="+id;
}

function consulta(){
	window.location=("consulta.php");
}

function verificaResumo(){
	if(vazio(document.formu.descricao.value,"Descriç£¯"));
		return;

	document.formu.submit();
}

function somente_numero(campo){
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function so_numero(campo){
	var digits="0123456789,";
    var campo_temp
    for (var i=0;i<campo.value.length;i++){
      campo_temp=campo.value.substring(i,i+1)
      if (digits.indexOf(campo_temp)==-1){
            campo.value = campo.value.substring(0,i);
            break;
       }
    }
	return campo.value;
}

function formatar(src, mask){
  if(somente_numero(src));
  var src_temp = src.value;
//  if(src.value!=1 && src.value<10) src.value= "0"+src_temp;
  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);
  }
}

function verifica(){
	if(!vazio(document.formu.login.value,"Login")){
	   document.formu.login.focus();
       return false;
	}
	if(!vazio(document.formu.senha.value,"Senha")){
   	   document.formu.senha.focus();
	   return false;
	}else{
       return true;
	}
}

function verificaCliente(){
	if(!vazio(document.formu.nome.value,"Nome")){
	   document.formu.nome.focus();
       return false;
	}else if(!vazio(document.formu.cidade.value,"Cidade")){
   	   document.formu.cidade.focus();
	   return false;
	}else if(!vazio(document.formu.estado.value,"Estado")){
   	   document.formu.estado.focus();
	   return false;
	}else if(!email(1) || !vazio(document.formu.email.value,"Email")){
   	   document.formu.email.focus();
	   return false;
	}else if(!vazio(document.formu.valor.value,"Valor da doaç£¯")){
   	   document.formu.valor.focus();
	   return false;
	}else{
       document.formu.submit();
	}
}

function verificaVoluntario(){
	if(!vazio(document.formu.nome.value,"Nome")){
	   document.formu.nome.focus();
       return false;
	}
	if(!vazio(document.formu.endereco.value,"Endereco")){
	   document.formu.endereco.focus();
       return false;
	}
	if(!vazio(document.formu.cidade.value,"Cidade")){
	   document.formu.cidade.focus();
       return false;
	}
	if(!vazio(document.formu.telefone1.value,"Telefone1")){
	   document.formu.telefone1.focus();
       return false;
	}
	if(!email(1) || !vazio(document.formu.email.value,"E-mail")){
	   document.formu.email.focus();
       return false;
	}else{
       document.formu.submit();
	}
}

function ValidaCadCli(){
	if(!vazio(document.form1.razao.value,"Razã¯ Social da empresa")){
	   document.form1.razao.focus();
       return false;
	}else if(!vazio(document.form1.fantasia.value,"Fantasia")){
   	   document.form1.fantasia.focus();
	   return false;
	}else if(!vazio(document.form1.telefone1.value,"Telefone1")){
   	   document.form1.telefone1.focus();
	   return false;
	}/*else if(!numero(document.form1.telefone1.value,"Telefone1")){
	   document.form1.telefone1.value="";
	   document.form1.telefone1.focus();
	   return false;
	}*/else{
       document.form1.submit();
	}
}

function ValidaCadTipo(){
	if(!vazio(document.form3.tipo.value,"Tipo de Aparelho")){
   	   document.form3.tipo.focus();
	   return false;
	}else{
       document.form3.submit();
	}
}

function ValidaCadStatus(){
	if(!vazio(document.form3.nome.value,"Nome do Status do Aparelho")){
   	   document.form3.nome.focus();
	   return false;
	}else{
       document.form3.submit();
	}
}

function ValidaCadFonecedor(){
	if(!vazio(document.form1.nome.value,"Nome")){
	   document.form1.nome.focus();
       return false;
	}else if(!vazio(document.form1.telefone1.value,"Telefone1")){
   	   document.form1.telefone1.focus();
	   return false;
	}else if(!numero(document.form1.telefone1.value,"Telefone1")){
	   document.form1.telefone1.value="";
	   document.form1.telefone1.focus();
	   return false;
	}else{
       document.form1.submit();
	}
}

function ValidaCadAparelho(){
	if(!parado(document.form1.idtipo,"Tipo de Aparelho")){
	   document.form1.idtipo.focus();
       return false;
	}else if(!vazio(document.form1.modelo.value,"Modelo")){
	   document.form1.modelo.focus();
       return false;
	}else if(!vazio(document.form1.numero.value,"N?")){
   	   document.form1.numero.focus();
	   return false;
	}else{
       document.form1.submit();
	}
}

function ValidaCadAcessorios(){
	if(!vazio(document.form2.pass.value,"Permissã¯ chave")){
		document.form2.pass.focus();
		return false;
	}else if(confirm("Confirma atualizar a quantidade de acessó²©¯s no estoque?")){
       document.form2.submit();
	}else{
		return false;
	}
}

function ValidaFinalizarPedido(pedido){
	if(confirm("Confirma finalizar este pedido?")){
		if(confirm("Deseja efetuar baixa dos equipamentos deste pedido?"))
			window.location=("?finalizar="+pedido);
	}
}

function ValidaImprimirPedido(pedido){
	window.open('imprimir.php?pedido=' + pedido + '','Imprimir','resizable=no,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width=700,height=450');
}

function VarreCheckBox(documento){
	var x=0;
	for(i=0;i<documento.length;i++){
		if(documento[i].type=="checkbox"){
			if(documento[i].checked==true) x=1;
		}
	}
	if(x==1){
		return true ;
	}else{
		return false;
	}
}

function ValidaCadPedido(){
	if(!parado(document.form1.cliente,"Empresa")){
	   document.form1.cliente.focus();
       return false;
	}if(!vazio(document.form1.nproposta.value,"Proposta n?")){
	   document.form1.nproposta.focus();
       return false;
	}if(!vazio(document.form1.contato.value,"Contato")){
	   document.form1.contato.focus();
       return false;
	}else if(parseInt(document.form1.base.value) > parseInt(document.form1.tmp_base.value)){
		MensagemPadrao(1,"Base");
		document.form1.base.focus();
		return false;
	}else if(parseInt(document.form1.fonte.value) > parseInt(document.form1.tmp_fonte.value)){
		MensagemPadrao(1,"Fonte");
		document.form1.fonte.focus();
		return false;
	}else if(parseInt(document.form1.fone.value) > parseInt(document.form1.tmp_fone.value)){
		MensagemPadrao(1,"Fone");
		document.form1.fone.focus();
		return false;
	}else if(parseInt(document.form1.antena.value) > parseInt(document.form1.tmp_antena.value)){
		MensagemPadrao(1,"Antena");
		document.form1.antena.focus();
		return false;
	}else if(parseInt(document.form1.suporte.value) > parseInt(document.form1.tmp_suporte.value)){
		MensagemPadrao(1,"Suporte");
		document.form1.suporte.focus();
		return false;
	}else if(parseInt(document.form1.bateria.value) > parseInt(document.form1.tmp_bateria.value)){
		MensagemPadrao(1,"Bateria");
		document.form1.bateria.focus();
		return false;
	}else if(parseInt(document.form1.clip.value) > parseInt(document.form1.tmp_clip.value)){
		MensagemPadrao(1,"Clip");
		document.form1.clip.focus();
		return false;
	}else if(parseInt(document.form1.regua.value) > parseInt(document.form1.tmp_regua.value)){
		MensagemPadrao(1,"Ré§µa");
		document.form1.regua.focus();
		return false;
	}else if(parseInt(document.form1.anatel.value) > parseInt(document.form1.tmp_anatel.value)){
		MensagemPadrao(1,"Anatel");
		document.form1.anatel.focus();
		return false;
	}else if(parseInt(document.form1.mala.value) > parseInt(document.form1.tmp_mala.value)){
		MensagemPadrao(1,"Mala");
		document.form1.mala.focus();
		return false;
	}else if(parseInt(document.form1.ncase.value) > parseInt(document.form1.tmp_case.value)){
		MensagemPadrao(1,"Case");
		document.form1.ncase.focus();
		return false;
	}else if(parseInt(document.form1.sacola.value) > parseInt(document.form1.tmp_sacola.value)){
		MensagemPadrao(1,"Sacola");
		document.form1.sacola.focus();
		return false;
	}else if(!VarreCheckBox(document.form1)){
	   alert("Seleç£¯ mí®©ma de 1 aparelho por pedido!");
	   return false;
	}else{
       document.form1.submit();
	}
}

function MensagemPadrao(tipo,label){
	if(tipo==1){
		alert("A quantidade disponí¶¥l em estoque inferior para "+label+"!");
	}
}

function parado(campo,label){
	if(campo.selectedIndex==0){
		alert("Selecione algo no campo "+label+"!");
		return false;
	}
	else{
		return true;
	}
}

function vazio(campo,nome){
	if(campo.length == 0){
		alert("Favor preencher o campo " + nome + " !");
		return false;
	}else{
		if(campo.substring(0,1)==" "){
			if (campo.substring(0,1)==" " && campo.substring(1,2)!=" "){
				alert("O campo " + nome + " nã¯ pode começ¡² com o espaç¯¡");
			}
			else{
				alert("Favor preencher o campo " + nome + " !");
				return false;
			}
		}
		else{
			return true;
		}
	}
}

function email(tipo){
	if(tipo==1) var url=document.formu.email.value;
	a = url.lastIndexOf("@");
	b = url.lastIndexOf(".");
	c = url.indexOf(":");
	d = url.indexOf("/");
			e = url.substring(0,a);
			f = e.indexOf("@");
			g = url.substring(a+1,url.length);
			h = g.indexOf("[");
			i = g.indexOf("]");
			j = g.indexOf("<");
			k = g.indexOf(">");
			l = url.substring(a+1,b);
			m = url.substring(b+1,url.length);
			n = url.substring(0,a);
			o = 0;
			if (a > b) {o++};
			if (c != -1) {o++};
			if (d != -1) {o++};
			if (c != -1) {o++};
			if (d != -1) {o++};
			if (f != -1) {o++};
			if (h != -1) {o++};
			if (i != -1) {o++};
			if (j != -1) {o++};
			if (k != -1) {o++};
			if (l.length < 3) {o++};
			if (m.length < 2) {o++};
			if (n.length < 1) {o++};

	if (o == 0) return true
	else {
			alert("Email no formato incorreto");
			return false;
	}
}

// valida formulá²©o para campos nã¯ numé²©cos.
function numero(n,campo){
	ns="0123456789";
	k=n.length;
	i=0;
	pos=0;
	erro=0;
	for(i=0;i<k;i++)
		pos=ns.indexOf(n.substring(i,i+1));
		if (pos==-1 && erro!=1)
			erro=1;
	if(erro==1){
		alert("Utilize somente n?s no campo '" + campo + "'!")
		return false;
	}
	else
		return true;
}


//Variá¶¥is globais
var _loadTimer	= setInterval(__loadAnima,1);
var _loadPos	= 0;
var _loadDir	= 2;
var _loadLen	= 0;

//Anima a barra de progresso
function __loadAnima(){
	var elem = document.getElementById("barra_progresso");
	if(elem != null){
		if (_loadPos==0) _loadLen += _loadDir;
		if (_loadLen>32 || _loadPos>79) _loadPos += _loadDir;
		if (_loadPos>79) _loadLen -= _loadDir;
		if (_loadPos>79 && _loadLen==0) _loadPos=0;
		elem.style.left		= _loadPos;
		elem.style.width	= _loadLen;
	}
}

//Esconde o carregador
function __loadEsconde(){
	this.clearInterval(_loadTimer);
	var objLoader				= document.getElementById("carregador_pai");
	objLoader.style.display		="none";
	objLoader.style.visibility	="hidden";
}

function getHour(){
	var currentTime = new Date();
	return (currentTime.getHours());
}

function doGreeting(){
	var hour=getHour();
	var greeting="";
	if (hour>0 && hour<12) greeting="bom dia";
	else if(hour>=12 && hour<19) greeting="boa tarde";
	else greeting="boa noite";
	return ("Olá¬ "+greeting+"!");
}


function ExibeFlash(w,h,wmode,movie) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="wmode" value="'+wmode+'"/>');
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="'+wmode+'" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}

// FORMATA CAMPO COM M?CARA

function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	if(document.all) { // Internet Explorer
		nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
		nTecla = evtKeyPress.which;
	} else {
		nTecla = evtKeyPress.which;
		if (nTecla == 8) {
			return true;
		}
	}

    sValue = objeto.value;

    // Limpa todos os caracteres de formataç£¯ que
    // já ¥stiverem no campo.
    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( ":", "" );
    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++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas n?s...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
}


function SomenteNumeros(input)
	{
	if ((event.keyCode<48)||(event.keyCode>57))
		event.returnValue = false;
	}
//-------------------------------

// ex: <INPUT onkeypress=SomenteNumeros(this) onkeyup=FormataValor(this,13,event) tabIndex=18 maxLength=13 size=13 name=VR_RENDIMENTO>

function FormataValor(campo,tammax,teclapres) {

	var tecla = teclapres.keyCode;
	var vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	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 <= 2 ){
	 		campo.value = vr ; }
	 	tam = tam - 1;
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, 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 - 2, 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 - 2, 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 ) ;}
	}
}

<!-- Menu -->
nChoose = 1;
   menu1on = new Image(); menu1off = new Image(); menu1on.src = "img/menu1on.gif"; menu1off.src = "img/menu1off.gif";
   menu2on = new Image(); menu2off = new Image(); menu2on.src = "img/menu2on.gif"; menu2off.src = "img/menu2off.gif";
   menu3on = new Image(); menu3off = new Image(); menu3on.src = "img/menu3on.gif"; menu3off.src = "img/menu3off.gif";
   menu4on = new Image(); menu4off = new Image(); menu4on.src = "img/menu4on.gif"; menu4off.src = "img/menu4off.gif";
   menu5on = new Image(); menu5off = new Image(); menu5on.src = "img/menu5on.gif"; menu5off.src = "img/menu5off.gif";
   menu6on = new Image(); menu6off = new Image(); menu6on.src = "img/menu6on.gif"; menu6off.src = "img/menu6off.gif";
   menu7on = new Image(); menu7off = new Image(); menu7on.src = "img/menu7on.gif"; menu7off.src = "img/menu7off.gif";
   menu8on = new Image(); menu8off = new Image(); menu8on.src = "img/menu8on.gif"; menu8off.src = "img/menu8off.gif";
   menu9on = new Image(); menu9off = new Image(); menu9on.src = "img/menu9on.gif"; menu9off.src = "img/menu9off.gif";
   menu10on = new Image(); menu10off = new Image(); menu10on.src = "img/menu10on.gif"; menu10off.src = "img/menu10off.gif";
   menu11on = new Image(); menu11off = new Image(); menu11on.src = "img/menu11on.gif"; menu11off.src = "img/menu11off.gif";
   menu12on = new Image(); menu12off = new Image(); menu12on.src = "img/menu12on.gif"; menu12off.src = "img/menu12off.gif";
   menu13on = new Image(); menu13off = new Image(); menu13on.src = "img/menu13on.gif"; menu13off.src = "img/menu13off.gif";
   menu14on = new Image(); menu14off = new Image(); menu14on.src = "img/menu14on.gif"; menu14off.src = "img/menu14off.gif";
   menu15on = new Image(); menu15off = new Image(); menu15on.src = "img/menu15on.gif"; menu15off.src = "img/menu15off.gif";


   function MOv(C) {
   //alert("MOV="+eval("menu"+C+"_on.src"));
     document.images["menu"+C].src = eval("menu"+C+"on.src");
   }

   function MOu(C) {
   //alert("MOU="+eval("menu"+C+"_off.src"));
     document.images["menu"+C].src = eval("menu"+C+"off.src");
   }

	function open_janela(m){
		window.open(m + '','modelo1','resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width=797,height=695');
	}


<!-- ABAS -->
	function stAba(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}

	var arAbas = new Array();
	arAbas[0] = new stAba('td_cadastro','div_cadastro');
	arAbas[1] = new stAba('td_consulta','div_consulta');
	//arAbas[2] = new stAba('td_manutencao','div_manutencao');

	function AlternarAbas(menu,conteudo)
	{
		for (i=0;i<arAbas.length;i++)
		{
			var m = document.getElementById(arAbas[i].menu);
			m.className = 'menu';
			var c = document.getElementById(arAbas[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
		//c.src = c.src;
		//c.parent.contentWindow.location.reload(true);
	}

	function AlternarAbas2(menu,conteudo)
	{
		for (i=0;i<arAbas.length;i++)
		{
			var m = document.getElementById(arAbas[i].menu);
			m.className = 'menu';
			var c = document.getElementById(arAbas[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
		c.src = c.src;
		//c.parent.contentWindow.location.reload(true);
	}

	function Reload () {
		var f = document.getElementById('iframe1');
		f.src = f.src;
	}

function chamaSWF(w,h,wmode,movie) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="wmode" value="'+wmode+'"/>');
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="'+wmode+'" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}
