// ---------------------------  Pop-ups e Mensagens  ---------------------------  //
var popUpWin=0;

// função para abrir popups aleatorios
function popup(URLStr, width, height){
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+'';
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
	popUpWin = window.open(URLStr, 'popUpWin', styleStr);
}

// função para abrir popups centralizados pelas medidas
function popup_centralizado(URLStr, width, height){
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'';
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
	popUpWin = window.open(URLStr, 'popUpWin', styleStr);
}

// função para abrir popup centralizado específicos para mensagens com 2 tamanhos fixos, so q com rolagem caso necessário
function popup_t1(URLStr){
	var width = 450;
	var height = 320;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'';
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
	popUpWin = window.open(URLStr, 'popUpWin', styleStr);
}

function popup_t2(URLStr, width, height){
	var width = 625;
	var height = 430;
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'';
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
	popUpWin = window.open(URLStr, 'popUpWin', styleStr);
}

// função para abrir popup com propriedades especificas
function popup_tipo(URLStr,width,height,tipotools,tipomenu,tiposcroll,tiporesize,tipofullscreen){
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var tipotools = tipotools != 1 ? 0 : 1;
	var tipomenu = tipomenu != 1 ? 0 : 1;
	var tiposcroll = tiposcroll != 1 ? 0 : 1;
	var tiporesize = tiporesize != 1 ? 0 : 1;
	var tipofullscreen = tipofullscreen != 1 ? 0 : 1;
	var styleStr = 'toolbar='+tipotools+',location=no,directories=no,status=no,menubar='+tipomenu+',scrollbars='+tiposcroll+',resizable='+tiporesize+',fullscreen='+tipofullscreen+',copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'';
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
	popUpWin = window.open(URLStr, 'popUpWin', styleStr);
}

// funcao para fechar um popup já existente
function popup_fecha(){
	if(popUpWin){ if(!popUpWin.closed) popUpWin.close(); }
}

// ----------------------------------------- Campo com letras maiúsculas
function maiuscula(obj){obj.value = obj.value.toUpperCase();} 

// ----------------------------------------- Campo com letras maiúsculas
function minuscula(obj){obj.value = obj.value.toLowerCase();}

// ----------------------------------------- Funcao para efetuar tab automatico
function autotab(atual,destinatino) {	if ((atual.getAttribute && atual.value.length) == atual.getAttribute("maxlength")) destinatino.focus(); } /* <input type="text" name="first" size=4 onKeyup="autotab(this, document.form1.second)" maxlength=3> */

// ----------------------------------------- Limitacao para campos textos e textareas
function limitechar(obj,limite){ if (obj.value.length>=limite)	return false; } /* <input type="text" size=15 onkeypress="return limitechar(this, 10)"><br /> */

// ----------------------------------------- Validação de formulário
<!--
function MM_validateForm() { //v4.0
  if (document.getElementById){
    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=document.getElementById(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+='- '+nm+' deve conter um endereço de e-mail.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' deve conter um número.\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+' deve conter um número entre '+min+' e '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é necessário.\n'; }
    } if (errors) alert('O(s) seguinte(s) erro(s) ocorreu(ram):\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->
