<!--

function CY_findObj(n, d) {
  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=CY_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function CY_validaForm() {
  var i,p,q,nm,test,num,min,max,errors='',args=CY_validaForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=CY_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+' deve conter apenas 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+' precisa ser preenchido.\n'; }
  } if (errors) alert(' A T E N Ç Ã O !!!\n Para que o formulário seja enviado corrija \n o(s) seguinte(s) erro(s):\n\n'+errors);
  document.CY_returnValue = (errors == '');
}

function openWinSenha(url){
  popupWin12 = window.open(url,'Senha',
  'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=100,top=115,width=250,height=130');
  popupWin12.focus();
}


function openWinPrint(url,name) {
popupWin = window.open(url, 'Impressao',
'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=4,top=20,width=700,height=500');
popupWin.focus();
}

function openWinTutorial(url,name) {
popupWin = window.open(url, 'Tutorial',
'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=15,top=15,width=770,height=500');
popupWin.focus();
}


function openWinBoletim(url){
    popupWin = window.open(url, 'Boletim', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=390,top=102,width=400,height=420');
    popupWin.focus();
}

function openWinCasos(url){
    popupWin = window.open(url, 'Casos', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=700,height=500');
    popupWin.focus();
}

// contador de textarea
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
<!-- textCounter() parameters are:  text field, the count field, max length -->
//fim contador


function openWinEnquete(url){
    popupWin = window.open(url, 'Enquete', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=160,top=10,width=450,height=550');
    popupWin.focus();
}

function valida_enquete() {
	var resp,errors='';
	for(i=0; i < document.enquete.resposta.length; i++){
		if(document.enquete.resposta[i].checked){
			resp = 1;
		}
	}
    	if(resp != '1'){
        errors +='Responda a pesquisa!\n';
        }

   if (errors) alert(' A T E N Ç Ã O !!!\n Para que o formulário seja enviado corrija \n o(s) seguinte(s) erro(s):\n\n'+errors);
  document.CY_returnValue = (errors == '');

}

// Usado para abertura da pop-up de Cadastro
function openWinCadastro(url){
  popupWin12 = window.open(url,'Cadastro',
  'toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,screenX=0,screenY=0,left=150,top=20,width=600,height=500');
  popupWin12.focus();
}

// Usado para abertura da pop-up de Certificados
function openWinCertificado(url){
  popupWin12 = window.open(url,'Certificado',
  'toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,screenX=0,screenY=0,left=50,top=10,width=700,height=560');
  popupWin12.focus();
}

// Usado para abertura da pop-up de Boleto on line
function openWinBoleto(url){
  popupWin12 = window.open(url,'Cadastro',
  'toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,screenX=0,screenY=0,left=150,top=20,width=700,height=580');
  popupWin12.focus();
}

//-->
