// JavaScript Document
/*______________________________________________________________________________________
[                                                                                       ]
[ by Sooners - Soluções em Tecnologia                                                   ]
[                                                                                       ]
[ http://www.sooners.com.br                                                             ]
[ sooners@sooners.com.br                                                                ]
[ Revisão: Fevereiro/2009                                                               ]
[_______________________________________________________________________________________]
*/

// #### Desabilite Click #### //
function click() 
{
  if (event.button==1||event.button==2||event.button==3) 
  {
    oncontextmenu='return false';
  }
}

function disableselect(e)
{
  return false
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")
document.onselectstart=new Function ("return false")

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


// #### Muda Cor Input #### //
function chgClass(n,c) {
	n.className = c;
}


// #### Máscara Telefone #### //
function TelefoneFormat(Campo, e) {
	var key = '';
	var len = 0;
	var strCheck = '0123456789';
	var aux = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13 || whichCode == 8 || whichCode == 0)
	{
		return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico
	}
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1){
		return false;  //NÃO E VALIDO
	}
	
	aux =  Telefone_Remove_Format(Campo.value);
	
	len = aux.length;
	if(len>=10)
	{
		return false;	//impede de digitar um telefone maior que 10
	}
	aux += key;
	
	Campo.value = Telefone_Mont_Format(aux);
	return false;
}

function  Telefone_Mont_Format(Telefone)
{
	var aux = len = '';
	
	len = Telefone.length;
	if(len<=9)
	{
		tmp = 5;
	}
	else
	{
		tmp = 6;
	}
	
	aux = '';
	for(i = 0; i < len; i++)
	{
		if(i==0)
		{
			aux = '(';
		}
		aux += Telefone.charAt(i);
		if(i+1==2)
		{
			aux += ')';
		}
		
		if(i+1==tmp)
		{
			aux += '-';
		}
	}
	return aux ;
}

function  Telefone_Remove_Format(Telefone)
{
	var strCheck = '0123456789';
	var len = i = aux = '';
	len = Telefone.length;
	for(i = 0; i < len; i++)
	{
		if (strCheck.indexOf(Telefone.charAt(i))!=-1)
		{
			aux += Telefone.charAt(i);
		}
	}
	return aux;
}


// #### Função CPF-CNPJ / CEP / EMAIL #### //
function validar(Form) {
	var invalid, s;
	invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var s;


// inicio de verificacao de cnpj ou cpf
	if (Form.cnpj.value.length == 0) {
		alert("O CNPJ/CPF é um campo obrigatório !");
		Form.cnpj.focus();
		return false;	}
		
	s = limpa_string(Form.cnpj.value);
	
	// checa se é cpf	
	if (s.length == 11) {
		if (valida_CPF(Form.cnpj.value) == false ) {
			alert("O CPF não é válido !");
			Form.cnpj.focus();
			return false;	}
     }
     
     // checa se é cgc
	else if (s.length == 14) {
		if (valida_CGC(Form.cnpj.value) == false ) {
			alert("O CNPJ não é válido !");
			Form.cnpj.focus();
			return false;	}
			}
		else {
			alert("O CPF/CNPJ não é válido !");
			Form.cnpj.focus();
			return false;
		}

// final da verificacao de cnpj ou cpf


	// verifica o cep
	// primeiro deixa somente numeros no cep
	// obs.:a chamada abaixo tambem pode ser utilizada para checar telefones
	
	s = limpa_string(Form.cep.value);
	if (s.length < 8) {
		alert("Digite corretamente o CEP: 99999-999 !");
		Form.cep.focus();
		return false; }


	// verifica se o email é válido
	if (Form.email.value.length == 0)	{
		alert("Digite corretamente seu E-mail por favor!");
		Form.email.focus();
		return false;	}

	if (invalid.test(document.cadastro.email.value) == false) {
		// caso o teste falhe, para mudar a cor do texto na caixa, mude na linha abaixo
		document.cadastro.email.style.color = "red";
		
		alert("Endereço de E-mail inválido !");
		Form.email.focus();
		return (false); }

     return true;
}
// fim da funcao validar()


function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}
// fim da funcao


function valida_CPF(s)	{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}                      

function mascara_cpf(cpf)
{    // Esta eh a function que formata o cpf.
  var mycpf = '';
  mycpf = mycpf + cpf;
  if (mycpf.length == 3)
  {
    mycpf = mycpf + '.';
    document.forms[0].cnpj.value = mycpf;
  }
  if (mycpf.length == 7)
  {
    mycpf = mycpf + '.';
    document.forms[0].cnpj.value = mycpf;
  }
  if (mycpf.length == 11)
  {
    mycpf = mycpf + '-';
    document.forms[0].cnpj.value = mycpf;
  }
  if (mycpf.length == 14)
  {
  }
}
		  
function mascara_cnpj(cnpj)
{    // Esta eh a function que formata o cnpj.
  var mycnpj = '';
  mycnpj = mycnpj + cnpj;
  if (mycnpj.length == 2)
  {
    mycnpj = mycnpj + '.';
    document.forms[0].cnpj.value = mycnpj;
  }
  if (mycnpj.length == 6)
  {
    mycnpj = mycnpj + '.';
    document.forms[0].cnpj.value = mycnpj;
  }
  if (mycnpj.length == 10)
  {
    mycnpj = mycnpj + '/';
    document.forms[0].cnpj.value = mycnpj;
  }
  if (mycnpj.length == 15)
  {
    mycnpj = mycnpj + '-';
    document.forms[0].cnpj.value = mycnpj;
  }
  if (mycnpj.length == 18)
  {
  }
}

//=============================== Formata Dinheiro =========================//
function formatamoney(c) {
    var t = this; if(c == undefined) c = 2;		
    var p, d = (t=t.split(","))[1].substr(0, c);
    for(p = (t=t[0]).length; (p-=3) >= 1;) {
	        t = t.substr(0,p) + "." + t.substr(p);
    }
    return t+","+d+Array(c+1-d.length).join(0);
}

String.prototype.formatCurrency=formatamoney

function demaskvalue(valor, currency){
/*
* Se currency é false, retorna o valor sem apenas com os números. Se é true, os dois últimos caracteres são considerados as 
* casas decimais
*/
var val2 = '';
var strCheck = '0123456789';
var len = valor.length;
	if (len== 0){
		return '0,00';
	}

	if (currency ==true){	
		/* Elimina os zeros à esquerda 
		* a variável  <i> passa a ser a localização do primeiro caractere após os zeros e 
		* val2 contém os caracteres (descontando os zeros à esquerda)
		*/
		
		for(var i = 0; i < len; i++)
			if ((valor.charAt(i) != '0') && (valor.charAt(i) != ',')) break;
		
		for(; i < len; i++){
			if (strCheck.indexOf(valor.charAt(i))!=-1) val2+= valor.charAt(i);
		}

		if(val2.length==0) return "0,00";
		if (val2.length==1)return "0,0" + val2;
		if (val2.length==2)return "0," + val2;
		
		var parte1 = val2.substring(0,val2.length-2);
		var parte2 = val2.substring(val2.length-2);
		var returnvalue = parte1 + "," + parte2;
		return returnvalue;
		
	}
	else{
			/* currency é false: retornamos os valores COM os zeros à esquerda, 
			* sem considerar os últimos 2 algarismos como casas decimais 
			*/
			val3 ="";
			for(var k=0; k < len; k++){
				if (strCheck.indexOf(valor.charAt(k))!=-1) val3+= valor.charAt(k);
			}			
	return val3;
	}
}

function reais(obj,event){

var whichCode = (window.Event) ? event.which : event.keyCode;
/*
Executa a formatação após o backspace nos navegadores !document.all
*/
if (whichCode == 8 && !documentall) {	
/*
Previne a ação padrão nos navegadores
*/
	if (event.preventDefault){ //standart browsers
			event.preventDefault();
		}else{ // internet explorer
			event.returnValue = false;
	}
	var valor = obj.value;
	var x = valor.substring(0,valor.length-1);
	obj.value= demaskvalue(x,true).formatCurrency();
	return false;
}
/*
Executa o Formata Reais e faz o format currency novamente após o backspace
*/
FormataReais(obj,'',',',event);
} // end reais


function backspace(obj,event){
/*
Essa função basicamente altera o  backspace nos input com máscara reais para os navegadores IE e opera.
O IE não detecta o keycode 8 no evento keypress, por isso, tratamos no keydown.
Como o opera suporta o infame document.all, tratamos dele na mesma parte do código.
*/

var whichCode = (window.Event) ? event.which : event.keyCode;
if (whichCode == 8 && documentall) {	
	var valor = obj.value;
	var x = valor.substring(0,valor.length-1);
	var y = demaskvalue(x,true).formatCurrency();

	obj.value =""; //necessário para o opera
	obj.value += y;
	
	if (event.preventDefault){ //standart browsers
			event.preventDefault();
		}else{ // internet explorer
			event.returnValue = false;
	}
	return false;

	}// end if		
}// end backspace

function FormataReais(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;

//if (whichCode == 8 ) return true; //backspace - estamos tratando disso em outra função no keydown
if (whichCode == 0 ) return true;
if (whichCode == 9 ) return true; //tecla tab
if (whichCode == 13) return true; //tecla enter
if (whichCode == 16) return true; //shift internet explorer
if (whichCode == 17) return true; //control no internet explorer
if (whichCode == 27 ) return true; //tecla esc
if (whichCode == 34 ) return true; //tecla end
if (whichCode == 35 ) return true;//tecla end
if (whichCode == 36 ) return true; //tecla home

/*
O trecho abaixo previne a ação padrão nos navegadores. Não estamos inserindo o caractere normalmente, mas via script
*/

if (e.preventDefault){ //standart browsers
		e.preventDefault()
	}else{ // internet explorer
		e.returnValue = false
}

var key = String.fromCharCode(whichCode);  // Valor para o código da Chave
if (strCheck.indexOf(key) == -1) return false;  // Chave inválida

/*
Concatenamos ao value o keycode de key, se esse for um número
*/
fld.value += key;

var len = fld.value.length;
var bodeaux = demaskvalue(fld.value,true).formatCurrency();
fld.value=bodeaux;

/*
Essa parte da função tão somente move o cursor para o final no opera. Atualmente não existe como movê-lo no konqueror.
*/
  if (fld.createTextRange) {
    var range = fld.createTextRange();
    range.collapse(false);
    range.select();
  }
  else if (fld.setSelectionRange) {
    fld.focus();
    var length = fld.value.length;
    fld.setSelectionRange(length, length);
  }
  return false;

}



function FormataValor(id,tammax,teclapres) {
    
        if(window.event) { // Internet Explorer
         var tecla = teclapres.keyCode; }
        else if(teclapres.which) { // Nestcape / firefox
         var tecla = teclapres.which;
        }
    

vr = document.getElementById(id).value;
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( ",", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().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 ){
document.getElementById(id).value = vr; }
if ( (tam > 2) && (tam <= 5) ){
document.getElementById(id).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
if ( (tam >= 6) && (tam <= 8) ){
document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
if ( (tam >= 9) && (tam <= 11) ){
document.getElementById(id).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) ){
document.getElementById(id).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) ){
document.getElementById(id).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 );}
}
}

function FormataValor2(id,tammax,teclapres) {
    
        if(window.event) { // Internet Explorer
         var tecla = teclapres.keyCode; }
        else if(teclapres.which) { // Nestcape / firefox
         var tecla = teclapres.which;
        }
    

vr = document.getElementById(id).value;
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( ",", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().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 ){
document.getElementById(id).value = vr; }
if ( (tam > 2) && (tam <= 5) ){
document.getElementById(id).value = vr.substr( 0, tam - 2 ) + '.' + vr.substr( tam - 2, tam ); }
if ( (tam >= 6) && (tam <= 8) ){
document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '' + vr.substr( tam - 5, 3 ) + '.' + vr.substr( tam - 2, tam ); }
if ( (tam >= 9) && (tam <= 11) ){
document.getElementById(id).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) ){
document.getElementById(id).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) ){
document.getElementById(id).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 );}
}
}

function Numero(e)
{
navegador = /msie/i.test(navigator.userAgent);
if (navegador)
var tecla = event.keyCode;
else
var tecla = e.which;

if(tecla > 47 && tecla < 58) // numeros de 0 a 9
return true;
else
{
if (tecla != 8) // backspace
return false;
else
return true;
}
}

//===============================

function mascara_data(data)
{ 
  var mydata = ''; 
  mydata = mydata + data; 
  if (mydata.length == 2)
  { 
    mydata = mydata + '/'; 
    document.forms[0].data.value = mydata; 
  } 
  if (mydata.length == 5)
  { 
    mydata = mydata + '/'; 
    document.forms[0].data.value = mydata; 
  }  
} 

function verifica_data()
{
  if(document.forms[0].data.value == '')
  {
    alert('Por favor, informe a data de Contratação.');
	document.forms[0].data.focus();
	return false;
  }

  var data2 = document.forms[0].data.value;
  
  mydate = new Date();
  myday = mydate.getDay();
  mymonth = mydate.getMonth()+1;
  myweekday= mydate.getDate();
  weekday= myweekday;
  myyear= mydate.getFullYear();
  year = myyear
  
  var data1 = (myweekday+'/'+mymonth+'/'+year);

  if ( parseInt( data2.split( "/" )[2].toString() + data2.split( "/" )[1].toString() + data2.split( "/" )[0].toString() ) < parseInt( data1.split( "/" )[2].toString() + data1.split( "/" )[1].toString() + data1.split( "/" )[0].toString() ) )
  {
    alert('A data não pode ser retroativa.');
	document.forms[0].data.focus();
	return false;
  }
  return true;
}

 function validar() {
 var dt = new Date();
 var dia = dt.getDate();
 var mes = dt.getMonth()+1;
 var ano = dt.getFullYear();
 if(dia > 0 && dia < 10) dia = "0" + dia;
 if(mes > 0 && mes < 10) mes = "0" + mes;
 var dataAtual = dia + "/" + mes + "/" + ano;
 var vDia = document.form1.data.value.substr(0,2);
 var vMes = document.form1.data.value.substr(3,2);
 var vAno = document.form1.data.value.substr(6,4);
 
 if (document.form1.data.value == '') 
 {
   alert("Preencha a data do Contrato.");
   document.form1.data.value = dataAtual;
   document.form1.data.focus();
   return false;
 }
 
 if (vAno+vMes+vDia < ano+mes+dia) 
 {
   alert("A data não pode ser retroativa.");
   document.form1.data.value = dataAtual;
   document.form1.data.focus();
   return false;
 }
 return true;
 }
 
//Testa Preenchiumento dos campos obrigatórios.
function verifica()
{
  if(document.form1.razao.value == '')
  {
    alert('Por favor, preencha o campo "Segurado".');
	document.form1.razao.focus();
	return false;
  }
  if(document.form1.fantasia.value == '')
  {
    alert('Por favor, preencha o campo "Nome Fantasia".');
	document.form1.fantasia.focus();
	return false;
  }
  if(document.form1.cnpj.value == '')
  {
    alert('Por favor, preencha o campo "CNPJ".');
	document.form1.cnpj.focus();
	return false;
  }
  if(document.form1.contato.value == '')
  {
    alert('Por favor, preencha o campo "Contato".');
	document.form1.contato.focus();
	return false;
  }
  if(document.form1.endereco.value == '')
  {
    alert('Por favor, preencha o campo "Endereço".');
	document.form1.endereco.focus();
	return false;
  }
  if(document.form1.bairro.value == '')
  {
    alert('Por favor, preencha o campo "Bairro".');
	document.form1.bairro.focus();
	return false;
  }
  if(document.form1.cidade.value == '')
  {
    alert('Por favor, preencha o campo "Cidade".');
	document.form1.cidade.focus();
	return false;
  }
  if(document.form1.uf.value == '')
  {
    alert('Por favor, preencha o campo "U.F.".');
	document.form1.uf.focus();
	return false;
  }
  if(document.form1.telefone.value == '')
  {
    alert('Por favor, preencha o campo "Telefone".');
	document.form1.telefone.focus();
	return false;
  }
  if(document.form1.email.value == '')
  {
    alert('Por favor, preencha o campo "E-mail".');
	document.form1.email.focus();
	return false;
  }
  if(document.form1.endereco_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "Endereço de Cobrança".');
	document.form1.endereco_cobranca.focus();
	return false;
  }
  if(document.form1.bairro_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "Bairro de Cobrança".');
	document.form1.bairro_cobranca.focus();
	return false;
  }
  if(document.form1.cep_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "CEP de Cobrança".');
	document.form1.cep_cobranca.focus();
	return false;
  }
  if(document.form1.cidade_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "Cidade de Cobrança".');
	document.form1.cidade_cobranca.focus();
	return false;
  }
  if(document.form1.uf_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "UF de Cobrança".');
	document.form1.uf_cobranca.focus();
	return false;
  }
  if(document.form1.telefone_cobranca.value == '')
  {
    alert('Por favor, preencha o campo "Telefone de Cobrança".');
	document.form1.telefone_cobranca.focus();
	return false;
  }
  if(document.form1.corretor.value == '')
  {
    alert('Por favor, preencha o campo "Corretor".');
	document.form1.corretor.focus();
	return false;
  }
  if(document.form1.fantasia_corretor.value == '')
  {
    alert('Por favor, preencha o campo "Nome fantasia do corretor".');
	document.form1.fantasia_corretor.focus();
	return false;
  }
  if(document.form1.cnpj_corretor.value == '')
  {
    alert('Por favor, preencha o campo "CNPJ do Corretor".');
	document.form1.cnpj_corretor.focus();
	return false;
  }
  
  
  if(document.form1.endereco_corretor.value == '')
  {
    alert('Por favor, preencha o campo "Endereço do Corretor".');
	document.form1.endereco_corretor.focus();
	return false;
  }
  if(document.form1.bairro_corretor.value == '')
  {
    alert('Por favor, preencha o campo "Bairro do Corretor".');
	document.form1.bairro_corretor.focus();
	return false;
  }
  if(document.form1.cep_corretor.value == '')
  {
    alert('Por favor, preencha o campo "CEP do Corretor".');
	document.form1.cep_corretor.focus();
	return false;
  }
  if(document.form1.cidade_corretor.value == '')
  {
    alert('Por favor, preencha o campo "Cidade do Corretor".');
	document.form1.cidade_corretor.focus();
	return false;
  }
  if(document.form1.uf_corretor.value == '')
  {
    alert('Por favor, preencha o campo "UF do Corretor".');
	document.form1.uf_corretor.focus();
	return false;
  }
  if(document.form1.telefone_corretor.value == '')
  {
    alert('Por favor, preencha o campo "Telefone do Corretor.');
	document.form1.telefone_corretor.focus();
	return false;
  }
  if(document.form1.sindicato.value == '')
  {
    alert('Por favor, informe o nome da entidade regional filiada a CBIC');
	document.form1.sindicato.focus();
	return false;
  }
  
  if(!confirm('É necessário imprimir a proposta antes de enviar. \n\A proposta já foi impressa?\n\n\Se você já imprimiu, clique em "OK". Se não imprimiu ainda, clique em "CANCELAR" e clique na opção Imprimir, no final desta página.'))
  {
    return false;
  }
  
  if(!confirm('Você está solicitando a emissão da apólice e dessa forma está de acordo com as condições do Transporte Nacional CBIC. \n\nDeseja continuar?'))
  {
    return false;
  }
  
  return true;
}

function preenche()
{
  if (document.form1.checkbox.checked == true)
  {
    document.form1.endereco_cobranca.value    = document.form1.endereco.value;
	document.form1.complemento_cobranca.value = document.form1.complemento.value;
	document.form1.bairro_cobranca.value      = document.form1.bairro.value;
	document.form1.cep_cobranca.value         = document.form1.cep.value;
	document.form1.cidade_cobranca.value      = document.form1.cidade.value;
	document.form1.uf_cobranca.value          = document.form1.uf.value;
	document.form1.telefone_cobranca.value    = document.form1.telefone.value;
	document.form1.email_cobranca.value       = document.form1.email.value;
  }
  else
  {
    document.form1.endereco_cobranca.value    = '';
	document.form1.complemento_cobranca.value = '';
	document.form1.bairro_cobranca.value      = '';
	document.form1.cep_cobranca.value         = '';
	document.form1.cidade_cobranca.value      = '';
	document.form1.uf_cobranca.value          = '';
	//document.form1.telefone_cobranca.value    = '';
	//document.form1.email_cobranca.value       = '';
  }
}
  
