function tamanho(xmsg)
{
	var xtam=0;
	xtam = xmsg.length;
	return(xtam);
}

function wincentro(pagina, nomedajanela, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=yes,location=no,status=no,scrollbars=yes,resizable=no,menubar=no'
win = window.open(pagina, nomedajanela, winprops)
win.window.focus(); 
}

function wincentro2(pagina, nomedajanela, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=yes,location=no,status=no,scrollbars=no,resizable=no,menubar=no'
win = window.open(pagina, nomedajanela, winprops)
win.window.focus(); 
}

function line_over()
	{
		var tr,td;
		tr = event.srcElement.parentElement;
		if (tr.tagName != "TR") tr = tr.parentElement;		
		for(i=0;i<tr.children.length;i++){
			 td = tr.children[i];			
			 td.style.backgroundColor='#77DF4A'; //#5A6BC6
			 td.style.color = 'white';//#00336F#80FF2E
			 td.style.cursor='hand';		
		 }
	}
	function line_out(){
		var tr,td;
		tr = event.srcElement.parentElement;
		if (tr.tagName != "TR") tr = tr.parentElement;		
		for(i=0;i<tr.children.length;i++){
			td = tr.children[i];			
			td.style.backgroundColor='#EAF4F4';
			td.style.color=000;
		}
	}


function textCounter(field, countfield, maxlimit)
{
if(field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
else
	countfield.value = maxlimit - field.value.length;
}

<!--

// ------------------------------------------------------------------------------------------ //
// Acrescenta algumas propriedades aos controles:
// .Indice			: indica o índice na tela para o controle
// .IndiceAnterior	: indica o índice do controle anterior
// .IndicePosterior	: indica o índice para o controle posterior
// .Tam				: tamanho máximo para digitação
// .AutoSkip		: indica se pula para o próximo campo após completar o tamanho do campo
// .Tipo			: indica o tipo de dado
//						'D' -> só dígitos de 0(zero) a 9(nove)
//						'T' -> só dígitos de 0(zero) a 9(nove) e /
//						'N' -> dígitos de 0(zero) a 9(nove), "."(ponto) e ","(vírgula)
//						'C' -> caracteres de 'a' até 'z' e de 'A' até 'Z'
//						outro -> qualquer caracter entre ascii 32 e ascii 127
// .Saltar			: (reservado) indica o momento de saltar de campo
// ------------------------------------------------------------------------------------------ //

// Carrega índices para o próximo controle e controle anterior
function InicializarIndices()
{
	if (document.CargaInicial==null)
	{
		document.CargaInicial=false;		// Seta para só fazer uma vez por documento
		var ctrlAnterior=null;
		var IndAnt=0;
		for ( var i=0; i<document.forms[0].elements.length;i++)
		{
			var e=document.forms[0].elements[i];
			if ( e.type!="hidden" && e.type!="image" )		
			{
				if ( ctrlAnterior != null )
					ctrlAnterior.IndicePosterior=i;
				ctrlAnterior=e;
				e.Indice=i;
				e.IndiceAnterior=IndAnt;
			}
		}
		//if ( ctrlAnterior!=null )
		//{
		//	ctrlAnterior.IndicePosterior=i-1;
		//}
	}
}

// Colocar o foco em determinado campo
function SetarFoco ( ind )
	{
	InicializarIndices();
	if ( isNaN(ind) && document.forms[0].elements[ind].type!="hidden" )
		document.forms[0].elements[ind].focus();
	else
		for (;ind<document.forms[0].elements.length;ind++)
			if ( document.forms[0].elements[ind].type!="hidden" )
				break;
		if ( ind<=document.forms[0].elements.length )
			document.forms[0].elements[ind].focus();
	}

// Limpar o conteúdo do(s) campo(s)
function LimparCampo ( ind )
	// Para -1, limpa todos os elementos
	{
	if (isNaN(ind))			// Limpa pelo nome
		document.forms[0].elements[ind].value="";
	else if (ind != -1 )	// Limpa o elemento "ind" ( só considera "text" e "password" )
		for ( var i=ind; i < document.forms[0].elements.length;i++ )
			if ( document.forms[0].elements[i].type=="text" || document.forms[0].elements[i].type=="password")		// Só limpa campo "text"
				{
				document.forms[0].elements[i].value="";
				break;
				}
	else					// Limpa todos os elementos "text" e "password"
		for ( var i=0; i < document.forms[0].elements.length; i++ )
			if ( document.forms[0].elements[i].type=="text" || document.forms[0].elements[i].type=="password" )
				document.forms[0].elements[i].value="";
		
	}

// Verificar qual navegador
function QualNavegador() 
{
	var s = navigator.appName;
	if ( s == "Microsoft Internet Explorer" )
		return "IE";
	else if ( s == "Netscape" )
		return "NE";
	else
		return "";
}

// Verificar qual a versão do navegador
function QualVersao()
{
	var s = navigator.appVersion;
	if ( QualNavegador() == "IE" )
	{
		var i = s.search("MSIE");
		s=s.substring(i+5);
		i=s.search(".");
		return parseInt(s.substring(0,i+1));
	}
	else if ( QualNavegador() == "NE" )
		return parseInt(s.substring(0,1));
	else
		return 0;
}


// Setar o evento
function se(ctrl, Tam, Tipo, AutoSkip )
{
	// Filtra navegadores conhecidos
	var s = QualNavegador();
	if ( s.length==0 )
		return;
	if ( s=="IE" && QualVersao()>5 )
		return;
	if ( s=="NE" && QualVersao()>4 )
		return;

	if (ctrl.onkeypress==null)
	{
		if (AutoSkip==null)
			AutoSkip=true;
		if (Tipo!=null)
			Tipo.toUpperCase();
		ctrl.Tam=Tam;
		ctrl.Tipo=Tipo;
		ctrl.AutoSkip=true;
		ctrl.Saltar=false;
		InicializarIndices();
		ctrl.onkeypress=ValidarTecla;
		if (QualNavegador()=="IE" && QualVersao()==5)
			ctrl.onkeyup=SaltarCampo;
	}
}

function SaltarCampo(ctrl)
{
	if (ctrl==null)
		ctrl=this;
	if ( ctrl.AutoSkip && ctrl.Saltar)
		if (ctrl.Saltar)
		{
			ctrl.Saltar=false;
			if ( ctrl.IndicePosterior != null )
				SetarFoco(ctrl.IndicePosterior);
		}
}

// Fazer o salto de campo
function ValidarTecla (evnt)
{
	var tk;
    var c;
	// Recebe a tela pressionada
	tk = ( (QualNavegador()=="IE") ? event.keyCode : evnt.which);
    c=String.fromCharCode(tk);
	c=c.toUpperCase();

	// -- Este trecho faz com que o <Enter> tenha a função de <Tab>, mas acho inviável, pois não é possível
	//       colocar o foco em campos do Tipo "image", e, neste caso, nunca seria possível fazer a submissão
	//       do formulário
	// if ( tk == 13 )
	// {
	//	this.Saltar=true;
	//	SaltarCampo(this);
	//	return false;
	// }
	
	// Só aceita teclas alfanuméricas. Não aceita teclas de controle
	if ( tk < 32 )
		return true;

	// Aceita também caracteres acentuados
	if ( ((tk>127) && (tk<192)) || (tk>252) )
		return false;

	// Não aceita o apostrofo
	if ( c == "'")
		return false;

	switch ( this.Tipo )
	{
	case "T":
		if (( c<"0" || c>"9") && c!="/")
			return false;
		break;
	case "D":
		if ( c<"0" || c>"9" )
			return false;
		break;
	case "N":
		if ( (c<"0" || c>"9") && (c!="." && c!=",") )
			return false;
		if ( (c==",") && ((this.value.search(",")>-1) || (this.value.length==0)) )
			return false;
		if ( (c==".") && (this.value.length==0) )
			return false;
		break;
	case "C":
		if ( c<"A" || c>"Z" )
			return false;
		break;
	default:
		break;
	}

	this.Saltar=(this.value.length==this.Tam-1);
	if ( ((QualNavegador()=="IE") && QualVersao()<5) || (QualNavegador()!="IE") )
		SaltarCampo(this);

	return true;
}


function jumpTo(s) {
  if (s.selectedIndex >= 0) top.location.href = s.options[s.selectedIndex].value;return 1;
}


var savedobj=false;
var zera=false;
function show(target){
  if (savedobj) savedobj.style.display='none';
  obj=(document.all) ? document.all[target] : document.getElementById(target);

  if (savedobj==obj){
    if (zera)
    {
     obj.style.display='inline';
     zera=false;
    }
    else
    {
     obj.style.display='none';
     zera=true;
    }
  }
  else
    obj.style.display='inline';
    
  savedobj=obj;
}

function CallPrint(strid) 
{   
  var prtContent = document.getElementById(strid);   
  var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0,location=0'); 
  WinPrint.document.write(prtContent.innerHTML); 
  WinPrint.document.close(); 
  WinPrint.focus(); 
  WinPrint.print(); 
  WinPrint.close(); 
  prtContent.innerHTML=strOldOne; 
} 

function cancelBack()
  {
    if (event.keyCode == 8 && event.srcElement.form == null)
    {
      event.cancelBubble = true;
      event.returnValue = false;
    }
  }

    function encerraSessao()
    {
        wincentro2("mensagem.aspx", "Agradecimento", 550,325);
    }
    
    function ajustaJanela()
    {
        return window.screen.availHeight;
    }

    function resize(objName, objId)
    {
        document.getElementById(objName).height=""; // required for Moz, value can be "", null, or integer
        document.getElementById(objId).height=window.frames[objName].document.body.scrollHeight;
    }
    
    function resize2(objName, objId)
    {
        browser = detectaBrowser();
        alert(navigator.appName);
        //document.getElementById(objName).height=""; // required for Moz, value can be "", null, or integer
        if (browser == "firefox") {
            document.getElementById(objId).height=window.frames[objName].document.body.scrollHeight+"px";
        }else{
            document.getElementById(objId).height=window.frames[objName].document.body.scrollHeight;
        }
        
    }
    
    function mudastatus()
    {
        window.status = "Hotbill";
    }

    function detectaBrowser() {
        if (navigator.appName.toLowerCase().indexOf("microsoft internet explorer") > -1)
            return("ie");
        else
            if (navigator.appName.toLowerCase().indexOf("netscape") > -1)
                return("firefox");
    }

//    function ajustaIframe() {
//        browser = detectaBrowser();
//        alert(browser);
//        if (browser == "firefox") {
//            var tamanho = parent.document.getElementById("ifr").contentDocument.body.scrollHeight;
//            parent.document.getElementById("ifr").style.height = (tamanho+10)+"px";
//            parent.document.getElementById("Div_Menu").style.height = (tamanho+60)+"px";
//        } else {
//            if (browser == "ie") {
//                var tamanho = document.getElementById("container").offsetHeight;
//                parent.document.getElementById("ifr").style.height = tamanho+30;
//                parent.document.getElementById("Div_Menu").style.height = tamanho+70;
//            }
//        }
//    }
	
