/*
 * Copyright Sentido Virtual - http://www.sentidovirtual.com.br
 * contato@sentidovirtual.com.br
 */
 
window.defaultStatus=".:..:: NOSSO LAR - www.capsnossolar.org.br ::..:."


// ********************************************************************************

function OpenUp(resenha, w, h)
{
	remote = window.open(resenha,'comentario','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+ w + ',height='+ h + '')
}


// ********************************************************************************

function go(pag)
{
	top.opener.top.location.href=pag;
	window.self.close();
}


// ********************************************************************************

function tabRoll(srv,vale)
{
srv.className=vale; 
}


// ********************************************************************************

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);


// ********************************************************************************

// função utilizada para aumentar / diminuir fonte da página.
var tgs = new Array( 'div' );

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 ];
	}
}


// ********************************************************************************

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;
}


// ********************************************************************************

// 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 entrada de formato moeda
function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}


// ********************************************************************************

// 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);
}


// ********************************************************************************
