// JavaScript Document
<!--
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;
                }
        }
}

//--->Função para verificar se o valor digitado é número...<---
function digitos(event){
        if (window.event) {
                // IE
                key = event.keyCode;
        } else if ( event.which ) {
                // netscape
                key = event.which;
        }
        if ( key != 8 || key != 13 || key < 48 || key > 57 )
                return ( ( ( key > 47 ) && ( key < 58 ) ) || ( key == 8 ) || ( key == 13 ) );
        return true;
}



function open_window(URL) { eval("page=window.open(URL,'','scrollbars=0,resizable=0,width=530,height=373,left = 300,top = 300');");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function resizeWindow(largura,altura){
	resizeTo(largura,altura);
	window.moveTo(550,480); 
}

function Valida(form){
var ok = false;
var form = document.form.Cod_Mod;
    if (form.checked) { 
        ok = true; 
    }
if (!ok) {
    alert ("É obrigatório selecionar o item 'Concordo com os termos do Contrato' para continuar!");
    return false;
    }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- O campo '+nm+' precisa conter um e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- O campo '+nm+' precisa conter números.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- O campo '+nm+' é de preenchimento obrigatório\n'; }
  } if (errors) alert('Desculpe, mas:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function fechar(){
	window.close();
}

function fone(){
if (document.form.telefone.value.length == 0){
document.form.telefone.value = "(" + document.form.telefone.value; }
if (document.form.telefone.value.length == 3){
document.form.telefone.value = document.form.telefone.value + ") "; }
if (document.form.telefone.value.length == 9){
document.form.telefone.value = document.form.telefone.value + "-";}
}

function fone2(){
if (document.form.fax.value.length == 0){
document.form.fax.value = "(" + document.form.fax.value; }
if (document.form.fax.value.length == 3){
document.form.fax.value = document.form.fax.value + ") "; }
if (document.form.fax.value.length == 9){
document.form.fax.value = document.form.fax.value + "-";}
}

function postal(){
if (document.form.cep.value.length == 2){
document.form.cep.value = document.form.cep.value + "."; }
if (document.form.cep.value.length == 6){
document.form.cep.value = document.form.cep.value + "-"; }
}

function doc(){
if (document.form.rg.value.length == 2){
document.form.rg.value = document.form.rg.value + "."; }
if (document.form.rg.value.length == 6){
document.form.rg.value = document.form.rg.value + "."; }
if (document.form.rg.value.length == 10){
document.form.rg.value = document.form.rg.value + "-"; }
}

function doc2(){
if (document.form.cpf.value.length == 3){
document.form.cpf.value = document.form.cpf.value + "."; }
if (document.form.cpf.value.length == 7){
document.form.cpf.value = document.form.cpf.value + "."; }
if (document.form.cpf.value.length == 11){
document.form.cpf.value = document.form.cpf.value + "-"; }
}

function doc3(){
if (document.form.cnpj.value.length == 3){
document.form.cnpj.value = document.form.cnpj.value + "."; }
if (document.form.cnpj.value.length == 7){
document.form.cnpj.value = document.form.cnpj.value + "."; }
if (document.form.cnpj.value.length == 11){
document.form.cnpj.value = document.form.cnpj.value + "/"; }
if (document.form.cnpj.value.length == 16){
document.form.cnpj.value = document.form.cnpj.value + "-"; }
}

var vlSub=0; //GLobal
						

function somenteNumero(e,id_element){
	var key
	if(window.event) {
		key = e.keyCode; 
		if (( key < 47 )||( key > 58 )) {
				window.event.returnValue = null; 
				return;
		}		
	}
	else if (e.which) {
			key = e.which;
			if (( key < 47 )||( key > 58 )) {
					e.preventDefault();
					return ; 
			}		
	}

}
var boolClicado = false;

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 enviaform(){
	erro='';
	focar='';
	bln_fnc=1; 
	formulario=document.form;
	tamx=formulario.tipo_pessoa;
	for (x=0; x<tamx.length;x++){
		if(document.form.tipo_pessoa[x].checked==true){
			var tpPessoa=document.form.tipo_pessoa[x].value;
		}
	}
	
	if(document.form.nome.value==''){
		erro+='Nome (obrigatório)\n';
		if(focar==''){focar='nome'};
	}
	
	if(document.form.telefone.value==''){
		erro+='Telefone (DDD obrigatório)\n';
		if(focar==''){focar='telefone'};
	}
	if(document.form.email.value==''){
		erro+='E-mail (obrigatório)\n';
		if(focar==''){focar='email'};
	} 

	if (erro!=''){
		alert('Favor preencher corretamente os seguintes campos : \n\n'+erro);
		nFoco=$(focar);
		nFoco.focus();
	}

	else{
		shErro=0;
		if(shErro==0){
				mail=document.form.email.value;
				if(!verifica_mail(mail)){
					bln_fnc=0;
					shErro=1;
					return false;
				}
		}
		
			formulario.submit();
		}	
}


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], 'orange');
                                               legenda=document.getElementById(nome);
                                               legenda.style.color="orange";
                                               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;
}
-->