/*
 * Sentido Virtual - Soluções para Web
 * http://www.sentidovirtual.com.br
 * por: Renato Candia
 * contato@sentidovirtual.com.br
 */
 
window.defaultStatus="ABRAFORM - www.abraform.org.br ::..:."


function OpenUp(resenha, w, h)
{
	l = (screen.availWidth-w) / 3;
	t = (screen.availHeight-h) / 3;
	remote = window.open(resenha,'comentario','left='+l+',top='+t+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+ w + ',height='+ h + '')
}

// ********************************************************************************

// checa campo vazio
function isFieldBlank(theField)
{
	inStr = theField.value;
	inLen = inStr.length;
	for(var i = 0; i < inLen; i++)
	{
		var ch = inStr.substring(i, i+1)
		if (ch != " ")
		return false;   
	}
	theField.Value = "";
	return true;
}

// ********************************************************************************

// checa se é número
function isNumber(theNumber)
  {
  inStr = theNumber.value;
  inLen = inStr.length;
  for(var i = 0; i < inLen; i++)
    {
      var ch = inStr.substring(i, i+1)
      if ((ch < "0") || (ch > "9"))
        return false;
    }
  return true;
  }

// ********************************************************************************

function Verifica()
{
	var caract = new RegExp(/^[a-z 0-9 ç ã á ê é í ó ü ú]+$/i); 
	var caract = caract.test(String.fromCharCode(event.keyCode));

	if(!caract){
		//alert("Caracter inválido.\n" +String.fromCharCode(event.keyCode));
		event.keyCode=0;
		return;
	}
}

// ********************************************************************************

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);

// ********************************************************************************

// validação para entrada somente Números
function key()
{
	theKey = event.keyCode;
	if ((theKey < 48) ||
	(theKey > 57))
	event.returnValue = false;
}

// ********************************************************************************

function go(pag)
{
	top.opener.top.location.href=pag;
	window.self.close();
}

// ********************************************************************************

// Função utilizada para 'saltar' os campos quando o maxlength é atingido
function DFchangeField(o,e) {
	if(window.event)key=window.event.keyCode;
	else if(e)key=e.which;
	else return true;
	if (key==9||key==2||key==16) return false;
	// Vai
	if(o.value.length==o.maxLength){
  		for(var i=0;i<o.form.length;i++){
			if(o.form[i]==o && o.form[i+1]){
	    		if (!o.form[i+1].disabled && o.form[i+1].type != "hidden" && o.form[i+1].style.display != "none") {
					o.form[i+1].focus();
					return true;
				}else{
					return false;
				}
	    	}
		}
	}
	// Volta
	if(o.value.length == 0 && key == 8){
  		for(var i=0;i<o.form.length;i++){
    		if(o.form[i]==o && o.form[i-1]){
				if (!o.form[i-1].disabled && o.form[i-1].type != "hidden" && o.form[i+1].style.display != "none") {
					setTimeout("document." + o.form.name + "[" + (i-1) +"].focus()",10);
    				o.form[i-1].value = o.form[i-1].value;
    				return;
    			}else{
					return;
				}
			}
		}
	}
}

// ********************************************************************************

// função utilizada em formulário para aceitar somente entrada de números.
function soNumero(event)
{
	iKey = KeyStroke( event );
	if (!( ( iKey>47 && iKey<58 ) || iKey == 13 || iKey == 0 || iKey == 8 ) )
	{
		return false;
	}
	return true;
}

function KeyStroke( event )
{
	ikey = 0;
	if( event.which == undefined )
	{
		ikey = window.event.keyCode;
	}
	else
	{
		ikey = event.which;
	}
	return ikey;
}


// ********************************************************************************

// validação para qtd de caracters no campo
function minLen(txtField, minVal)
{
	strExp = txtField.value;
	l = strExp.length;
	if (l < minVal)
		return(true);
	else
		return(false);
}


// ********************************************************************************

// função utilizada para aumentar / diminuir fonte da página.
var tgs = new Array( 'div','table' );

var szs = new Array( 'xx-small','x-small','small','medium','large' );
var startSz = 2;

function ts( trgt,inc )
{
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 4 ) sz = 4;
	startSz = sz;
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0; i < tgs.length; i++ )
	{
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}


// ********************************************************************************
// ********************************************************************************
// ********************************************************************************
