// JavaScript Document
<!--

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();
		}	
}

-->