// JavaScript Document
<!--
function fecharPop(){
	document.getElementById('popup').style.display = 'none';
}

function abreJanela(url,nome,pars) { //v2.0
  window.open(url,nome,pars);
}

function abre_janela(width, height, nome, scrollbar) {
var top; var left;
top = ( (screen.height/2) - (height/2) )
left = ( (screen.width/2) - (width/2) )
window.open('',nome,'width='+width+',height='+height+',scrollbars='+scrollbar+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);
}

function fechar(){
	window.close();
}

function open_window_novo(URL) { eval("page=window.open(URL,'','scrollbars=0,resizable=0,width=800,height=500,left = 50,top = 50');");
}

function pulaCasa(vl,qtd,prox){
	var tamanho=vl.length;
	var limite=qtd;
	//alert(tamanho+'#'+qtd+'#'+prox);
		if(tamanho==limite){
			$(prox).focus();
		}
}

function resizeWindow(largura,altura){
	resizeTo(largura,altura);
	window.moveTo(250,250); 
}

function validaCampoObrigatorio(form){
            var erro=0;
            var legenda;
            var obrigatorio;          
            for (i=0;i<form.length;i++){
                        obrigatorio = form[i].lang;
                        if (obrigatorio==1){
                                   if (form[i].value == ""){
                                               var nome = form[i].name;
                                               mudarCorCampo(form[i], '#66CCFF');
                                               legenda=document.getElementById(nome);
                                               legenda.style.color="#003366";
                                               erro++;
                                   }
                        }
            }
            if(erro>=1){
                        alert("Existe(m) " + erro + " campo(s) obrigatório(s) vazio(s)! ")
                        return false;
            } else
                        return true;
}
function mudarCorCampo(elemento, cor){
            elemento.style.backgroundColor=cor;
}

function somenteNumero(e,id_element){
	var key
	if(window.event) {
	// Atenter o IE
		key = e.keyCode; 
		if (( key < 47 )||( key > 58 )) {
				window.event.returnValue = null; 
				return;
		}		
	}
	else if (e.which) {
	//Atender NetScape.
			key = e.which;
			if (( key < 47 )||( key > 58 )) {
					e.preventDefault();
					return ; 
			}		
	}

}

function Mascara(tipo, campo, teclaPress) {
        if (window.event)
        {
                var tecla = teclaPress.keyCode;
        } else {
                tecla = teclaPress.which;
        }
 
        var s = new String(campo.value);
        // Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
        s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');
 
        tam = s.length + 1;
 
        if ( tecla != 9 && tecla != 8 ) {
                switch (tipo)
                {
                case 'CPF' :
                        if (tam > 3 && tam < 7)
                                campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
                        if (tam >= 7 && tam < 10)
                                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
                        if (tam >= 10 && tam < 12)
                                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
                break;
				
				case 'RG' :
                        if (tam > 2 && tam < 6)
                                campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
                        if (tam >= 6 && tam < 9)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
                        if (tam >= 9 && tam < 11)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '-' + s.substr(8,tam-8);
                break;
 
                case 'CNPJ' :
 
                        if (tam > 2 && tam < 6)
                                campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
                        if (tam >= 6 && tam < 9)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
                        if (tam >= 9 && tam < 13)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
                        if (tam >= 13 && tam < 15)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
                break;
 
                case 'TEL' :
                        if (tam > 2 && tam < 4)
                                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
                        if (tam >= 7 && tam < 11)
                                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
                break;
 
                case 'DATA' :
                        if (tam > 2 && tam < 4)
                                campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
                        if (tam > 4 && tam < 11)
                                campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
                break;
                
                case 'CEP' :
                        if (tam > 5 && tam < 7)
                                campo.value = s.substr(0,5) + '-' + s.substr(5, tam);
                break;
                }
        }
}

function verifica_mail(mail) {
mail=$('email');
  if (mail.value.length > 0) {
	if (!/^([a-zA-Z0-9_\-\\+\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/.test(mail.value)) {
		alert('E-mail incorreto.'); 
		mail.focus();
		return false;
	}
	return true;
  }
}

function getConvenios(v){
	var oXml = new PlaneStoneAjax("convenios.php?Token=" + v, null, true);
	oXml.typeReturn = "html";
	oXml.localCarregar = document.getElementById("resultados");
	oXml.exec();
}
-->
