caminhoBase = "http://www.estudioclick.com.br/cete"
//###################################################################################
function mostrahelp(linha,img) {
var linha = document.getElementById(linha);
  if (linha.style.display=='none') {
   linha.style.display='';
   if(img != null) {
      img.src = caminhoBase + 'imagens/layout/ball_glass_redS.gif';
   }
  } else {
   linha.style.display='none';
   if(img != null) {
      img.src = caminhoBase + 'imagens/layout/duvida.gif';
   }
  }
}

function FormataCampo(Campo,teclapres,mascara){ 
    strtext = Campo.value 
    tamtext = strtext.length 
    tammask = mascara.length 
    arrmask = new Array(tammask)     
    for (var i = 0 ; i < tammask; i++){ 
        arrmask[i] = mascara.slice(i,i+1) 
    } 
    //alert (teclapres.keyCode) 
    //começando o trabalho sujo 
    if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9"))))){ 
        if ((teclapres.keyCode >= 37 && teclapres.keyCode <= 40)||(teclapres.keyCode >= 48 && teclapres.keyCode <= 57)||(teclapres.keyCode >= 96 && teclapres.keyCode <= 105)||(teclapres.keyCode == 8)||(teclapres.keyCode == 9) ||(teclapres.keyCode == 46) ||(teclapres.keyCode == 13)){ 
            Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext)         
        } 
        else{ 
            Detona_Event(Campo,strtext) 
        } 
    } 
    else{
        if ((arrmask[tamtext] == "A"))    { 
            charupper = event.valueOf() 
            Detona_Event(Campo,strtext) 
            masktext = strtext + charupper 
            Campo.value = masktext 
        } 
    } 
} 
function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){ 
    if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){ 
        separador = arrpos 
        masktext = strtext + separador 
        Campo.value = masktext 
    } 
} 
function Detona_Event(Campo,strtext){ 
    event.returnValue = false 
    if (strtext != "") { 
        Campo.value = strtext 
    } 
}

//***************************************************************
//funcao p/ verificar cnpf
function validaCNPJ() {
                 CNPJ = document.frmCadastro.txtCnpj.value;
                 erro = new String;
                 //if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ! \n\n"; 
                 if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
                 //if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
                 }
                 //substituir os caracteres que não são números
               if(document.layers && parseInt(navigator.appVersion) == 4){
                       x = CNPJ.substring(0,2);
                       x += CNPJ. substring (3,6);
                       x += CNPJ. substring (7,10);
                       x += CNPJ. substring (11,15);
                       x += CNPJ. substring (16,18);
                       CNPJ = x; 
               } else {
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace ("-","");
                       CNPJ = CNPJ. replace ("/","");
               }
               var nonNumbers = /\D/;
               if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n"; 
               var a = [];
               var b = new Number;
               var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
               for (i=0; i<12; i++){
                       a[i] = CNPJ.charAt(i);
                       b += a[i] * c[i+1];
 }
               if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
               b = 0;
               for (y=0; y<13; y++) {
                       b += (a[y] * c[y]); 
               }
               if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
               if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
                       erro +="Dígito verificador com problema!";
               }
               if (erro.length > 0){
                       alert(erro);
					   document.frmCadastro.txtCnpj.focus();
                       return false;
               } else {
                       //alert("CNPJ valido!");
               }
               return true;
       }
//tratar campo cnpoj
function FormataCGC(Formulario, Campo, TeclaPres) 
  { 
    var tecla = TeclaPres.keyCode; 
    var strCampo; 
    var vr; 
    var tam; 
    var TamanhoMaximo = 14; 
  
    eval("strCampo = document." + Formulario + "." + Campo); 
  
    vr = strCampo.value; 
    vr = vr.replace("/", ""); 
    vr = vr.replace("/", ""); 
    vr = vr.replace("/", ""); 
    vr = vr.replace(",", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    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 < TamanhoMaximo && 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) 
      { 
        strCampo.value = vr; 
      } 
       if ((tam > 2) && (tam <= 6)) 
       { 
         strCampo.value = vr.substr(0, tam - 2) + '-' + vr.substr(tam - 2, tam); 
       } 
       if ((tam >= 7) && (tam <= 9)) 
       { 
         strCampo.value = vr.substr(0, tam - 6) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 10) && (tam <= 12)) 
       { 
         strCampo.value = vr.substr(0, tam - 9) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 13) && (tam <= 14)) 
       { 
         strCampo.value = vr.substr(0, tam - 12) + '.' + vr.substr(tam - 12, 3) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 15) && (tam <= 17)) 
       { 
         strCampo.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 Abre(url, width, height)
{
window.open(url,"_blank","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height);
}

////////////////////////////////////////
function EmailValidation(obj){
	var objValidation = new RegExp("^([\\w\\.\\-]{1,50})[@]([\\w\\.\\-]{1,125})([\\.]\\w{2,4})$");
	if(! objValidation.test(obj.value)){
		return false;
	}else{
		return true;
	}
}

////////////////////////////////////////
function PessoaFJ(){
	if(document.frmCadastro.rdbNatureza[0].checked){
		document.frmCadastro.txtCnpj.disabled = false;
		document.frmCadastro.txtCnpj.maxLength = "14"
		//document.getElementById("spnCnpj").style.display = 'inline';
		document.getElementById("spnCnpj").style.display = 'none';
		//document.getElementById("spnCpf").style.display = 'none';
		document.getElementById("spnCpf").style.display = 'inline';
		document.frmCadastro.txtEndereco.style.display = '';
	}else{
		document.frmCadastro.txtCpf.disabled = false;
		document.frmCadastro.txtCpf.maxLength = "11"
		//document.getElementById("spnCnpj").style.display = 'none';
		document.getElementById("spnCnpj").style.display = 'inline';
		//document.getElementById("spnCpf").style.display = 'inline';
		document.getElementById("spnCpf").style.display = 'none';
	}
}

////////////////////////////////////////
function Calendario(strOnde, strDestino, lngInicio, lngFim){
	if(document.all){
		var retorno = showModalDialog(strOnde + 'calendario.asp?txtInicio=' + lngInicio + '&txtFim=' + lngFim + '&txtDestino=' + strDestino, 'calendario', 'resizable: no; help: no; status: no; scroll: no;');
		if(retorno != null){
			window.document.getElementById(strDestino).value = retorno;
		}
		return false;
	}else{
		alert("Não foi possível abrir o calendário\nFavor informar a data no seguinte formato:\n01/12/2004.");
		var obj = window.document.getElementById(strDestino);
		obj.readOnly = false;
		obj.focus();
		obj.select();
		return false;
	}
}

////////////////////////////////////////
function link1()
{
if (document.radiolink.clique)
location='insc_cadastro.asp?id=1'            
}

////////////////////////////////////////
function FSNumeros(strPermissao){
    	var	KeyCode = event.keyCode;
	var strPermitido = " KeyCode != 46 && KeyCode != 37 && KeyCode != 39 && KeyCode != 8 && KeyCode != 9 ";
	if (strPermissao != ""){
		if (strPermissao.indexOf(",") != -1){
			strPermissao = strPermissao.split(",");
			for(i=0; i < strPermissao.length; i++){
				strPermitido += " && KeyCode!= " + parseInt(strPermissao[i]);
			}
		}else{
			strPermitido += " && KeyCode!= " + parseInt(strPermissao);
		}
		strPermitido = eval(strPermitido);
		if ((KeyCode < 48 || KeyCode > 57) && (KeyCode < 96 || KeyCode > 105) && (strPermitido)){
			event.cancelBubble;
			event.returnValue= false;
			return false;
		}
	}else{
		if ((KeyCode < 48 || KeyCode > 57) && (KeyCode < 96 || KeyCode > 105) && (eval(strPermitido))){
			event.cancelBubble;
			event.returnValue= false;
			return false;
		}
	}
	//Valores para AlfaNumerico, Numerico
	//Virgulas 188, 190
	//Pontos 190,194
}

//////////////////Dreamweaver//////////////////////
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

////////////////////////////////////////
function Focar(formulario, posicao){
	var obj = eval("document." + formulario);
	obj.elements[posicao].focus();
}

function EmailValidation(obj){
	var objValidation = new RegExp("^([\\w\\.\\-]{1,50})[@]([\\w\\.\\-]{1,125})([\\.]\\w{2,4})$");
	if(! objValidation.test(obj.value)){
		return false;
	}else{
		return true;
	}
}

////////////////////////////////////////#F0F2F9

function EnviarCadastro(){
	var objForm = document.frmCadastro;
	var i;
	var blnErro = false;
	for(i=0;i < objForm.length; i++){
		if(objForm.elements[i].value == "" && objForm.elements[i].disabled == false && (objForm.elements[i].name != "comercial" && objForm.elements[i].name != "celular" && objForm.elements[i].name != "email")){
			alert("Campo com preenchimento obrigatório.");
			objForm.elements[i].style.background="#F0F2F9";
			objForm.elements[i].focus();
			blnErro = true;

			break;
		}else{
			if(objForm.email.value != "" &&  ! EmailValidation(objForm.email)){
				alert("O e-mail informado é inválido.");
				objForm.email.style.background="#F0F2F9";
				objForm.email.style.background="#F0F2F9";
				objForm.email.focus();
				blnErro = true;
				break;
			}else{
				objForm.elements[i].style.background="#FFFFFF";
			}
		}					
	}
	if(! blnErro){
		objForm.submit();
	}
}

////////////////////////////////////////
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  visualizar = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
  //visualizar = window.open(theURL,winName,features);
  visualizar.focus();
  if (!visualizar.opener) visualizar.opener = self;
}

////////////////////////////////////////
function FaleConosco(){
	var objForm = document.frmFale;
	var i;
	var blnErro = false;
	for(i=0;i < objForm.length; i++){
		if(objForm.elements[i].value == "" && objForm.elements[i].disabled == false && (objForm.elements[i].name != "Destinatario" && objForm.elements[i].name != "Email")){
			alert("Campo com preenchimento obrigatório.");
			objForm.elements[i].style.background="#F0F2F9";
			objForm.elements[i].focus();
			blnErro = true;
			break;
		}
	}
	if(! blnErro){
		objForm.submit();
	}
}

function FaleConoscoIndex(){
	var objForm = document.frmFaleIndex;
	var i;
	var blnErro = false;
	for(i=0;i < objForm.length; i++){
		if(objForm.elements[i].value == "" && objForm.elements[i].disabled == false && (objForm.elements[i].name != "Destinatario" && objForm.elements[i].name != "Email")){
			alert("Campo com preenchimento obrigatório.");
			objForm.elements[i].style.background="#F0F2F9";
			objForm.elements[i].focus();
			blnErro = true;
			break;
		}					
	}
	if(! blnErro){
		objForm.submit();
	}
}

function FaleConoscoWeb(){
	var objForm = document.frmFaleWeb;
	var i;
	var blnErro = false;
	for(i=0;i < objForm.length; i++){
		if(objForm.elements[i].value == "" && objForm.elements[i].disabled == false && (objForm.elements[i].name != "Destinatario" && objForm.elements[i].name != "Email")){
			alert("Campo com preenchimento obrigatório.");
			objForm.elements[i].style.background="#F0F2F9";
			objForm.elements[i].focus();
			blnErro = true;
			break;
		}	
	}
	if(! blnErro){
		objForm.submit();
	}
}

/////////////////////////////////////////////////////////
function NavMOver(eItem){
	eItem.DefaultBgColor = eItem.style.backgroundColor;
	eItem.DefaultTxtColor = eItem.style.color;
	eItem.DefaultBorderColor = eItem.style.borderColor;
	eItem.DefaultBorderStyle = eItem.style.borderStyle;
	eItem.DefaultBorderWidth = eItem.style.borderWidth;
	
	eItem.style.backgroundColor = "#ADC2EB";
	
//	eItem.style.borderStyle = "solid";
//	eItem.style.borderColor = "#8C9DC0";
	//eItem.style.borderWidth = "2px";
	eItem.style.cursor="hand";
}
function NavMOut(eItem){
	eItem.style.backgroundColor = eItem.DefaultBgColor;
	eItem.style.borderStyle = eItem.DefaultBorderStyle;
	eItem.style.borderColor = eItem.DefaultBorderColor;
	eItem.style.borderWidth = eItem.DefaultBorderWidth;
}