<!--
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 valida_busca() {
		  if(document.form2.palavra_chave.value == '') {
		    alert('O campo palavra_chave deve ser preenchido!');
			document.form2.palavra_chave.focus();
			return false;
		  }
		  if(document.form2.palavra_chave.value.length < 3 ) {
		    alert('Por favor, digite um conjunto de caracteres maior ou igual a 03 no campo palavra_chave!');
			document.form2.palavra_chave.focus();
            document.form2.palavra_chave.select();
			return false;
		  }
		  else {
		     return true; }
		}


//Utilizado para reload automatico de combobox de
//grupo/subgrupo de receita
function jumpMenu(targ,selObj,restore){ //v3.0
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}

// 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

//abertura de links úteis
function openWin(url,name) {
popupWin = window.open(url, 'WIN',
'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=4,top=20,width=786,height=450');
popupWin.focus();
}

//abertura de links úteis
function openWinElev(url,name) {
popupWin = window.open(url, 'WIN',
'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=200,top=0,width=400,height=570');
popupWin.focus();
}


// Usado Na pop-up DE CIDADES PARA ABRIR A INCLUSÃO
function openWinCid(url){
  popupWin = window.open(url, 'CID',
  'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=100,width=780,height=360');
  popupWin.focus();
}

// Usado Na pop-up DE Edição de Produtos
function openWinProd(url){
  popupWin = window.open(url, 'PROD',
  'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=80,top=100,width=630,height=360');
  popupWin.focus();
}

//-->
