function formataNumero(numero, casasdecimais) {
	var numberTest = new NumberFormat(numero, '.');
	numberTest.setCommas(false);
	numberTest.setPlaces(casasdecimais);					
	return numberTest.toFormatted();
}
		
function MostraEsconde(obj, id_Table)
{

    obj1=document.getElementById(id_Table);
    var NomeImagem=obj.src;
    var img=NomeImagem.substr(NomeImagem.lastIndexOf('/')+1, NomeImagem.length);
    
    if(img=='icn_maximizar.gif')
    {
        obj.src='../../imagens/icn_minimizar.gif';
        obj1.style.display='block';
    }
    else
    {
        obj.src='../../imagens/icn_maximizar.gif';
        obj1.style.display='none';
    }
}

function ActualizaPai()
{       
window.opener.location.href = window.opener.location.href;
window.close();
}

function openWin( windowURL, windowName, width, height ) {

	topoJanela=(screen.height/2)-(200/2);
	esquerdaJanela=(screen.width/2)-(400/2);

	largura=0
	altura=0
	if (!document.all){
		largura=window.innerWidth
		altura=window.innerHeight
	}else{
		largura=screen.width
		altura=screen.height
	}
	esquerda=(largura/2)-(width/2)
	topo=(altura/2)-(height/2)

	comScroll="1"

	windowFeatures="width="+width+",height="+height+",left="+esquerda+",top="+topo+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars="+comScroll+",resizable=0"
	
	var janela = window.open(windowURL,windowName,windowFeatures);
	janela.focus();
}


function MostraAlerta(Texto, Tipo, Altura,Comprimento) 
{
	var MyArgs = new Array(Texto);

	var WinSettings = 'center:yes;resizable:no;scroll:off;dialogHeight:'+Altura+'px;dialogWidth:'+Comprimento+'px;status:off;help:no';
	var url='../paginas/Alerta.aspx?TP='+Tipo;
	var MyArgs1 = window.showModalDialog(url, MyArgs, WinSettings); 
	if (Tipo == 'P') {
		if (MyArgs1 != null) { 
			if (MyArgs1[0].toString() == 'S') {
				return true;
			} else { 
				return false; 
			}
		}
	}	
} 


function SeparadorDecimalCliente() {

	var separador = '';
	try {
		var ValorTeste = 1.234567;	
		var valorTesteComRegSettingsCliente = ValorTeste.toLocaleString();
		for (i=0; valorTesteComRegSettingsCliente.length - 1; i++) {
			caracter = valorTesteComRegSettingsCliente.substring(i, i+1);
			intValue=parseInt(caracter);
			if (isNaN(intValue)) {
				separador = caracter;
				break;
			}
		}	
	} catch(error) {
		separador = ',' // Valor por defeito
	}
	return separador;
}

function abreVentanaSin(url) {
	window.open(url,'_child','location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, tittlebar=no, toolbar=no');
}

//---------------TOOLTIP------------------


function popup(msg,cx,cy)
{ 
	var content="<TABLE class='ToolTip' CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center>"+msg+"</TD></TR></TABLE>"; 
	yyy=Yoffset; 
	xxx=Xoffset; 
	if(ns4)
	{ 
		skn.document.write(content); 
		skn.document.close(); 
		skn.visibility="visible"
	} 
	if(ns6){ document.getElementById("dek").innerHTML=content;skn.display=''} 
	if(ie4){ document.all("dek").innerHTML=content;skn.display=''}
} 
function get_mouse(e)
{ 
	var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft; skn.left=x+Xoffset+xxx; 
	var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop; skn.top=y+yyy;} 
	
	function kill()
	{ 
		yyy=-1000; 
		if(ns4){skn.visibility="hidden";} 
		else 
		if (ns6||ie4) skn.display="none"
	}
//------------TOOLTIP FIM

//---------------AGUARDE

var progress_outMsg = "";
var progress_i = 0;
var progress_timerDM=null;
var progress_msg = " ";

var progress_ScreenLine = "";
//var ScreenLine = "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||";
var progress_msgNum = progress_ScreenLine.length;
var progress_typeSpeed = 100;
var progress_delay=progress_typeSpeed;

progress_msg = progress_ScreenLine;




function switchDiv(strDivName,bolVisible){
	objElement = document.getElementById(strDivName);
	//set the visibility
	if(!bolVisible){
		objElement.style.display = 'none';	
		objElement.style.visibility = "hidden";
	} else {
		objElement.style.display = 'block';	
		objElement.style.visibility = "visible";
	}
	return;
}

function switchDivPParent(strDivName,bolVisible){
	objElement = parent.document.getElementById(strDivName);
	//set the visibility
	if(!bolVisible){
		objElement.style.display = 'none';	
		objElement.style.visibility = "hidden";
	} else {
		objElement.style.display = 'block';	
		objElement.style.visibility = "visible";
	}
	return;
}

function DisplayMsg() {
	switchDiv("tblCorpo",false);
	switchDivPParent("tblAguarde",true);
	if(progress_outMsg.length==progress_msgNum)
	{
		progress_outMsg = "";
		progress_msg = progress_ScreenLine;
		progress_i=0;
	}
	progress_outMsg = progress_outMsg + progress_msg.charAt(progress_i);
	progress_i++; 
	progress_delay = progress_typeSpeed;
	parent.document.getElementById('progress').value=progress_outMsg;
	progress_timerDM = setTimeout("DisplayMsg()",progress_delay);
}

function showPage(bCorpo)
{
	objElement = document.getElementById("tblCorpo");
	if (objElement) {
		if (bCorpo) {
			switchDivPParent("tblAguarde",false);
			switchDiv("tblCorpo",true);
			clearTimeout(progress_timerDM);
		}
		else {
			switchDiv("tblCorpo",false);
			switchDivPParent("tblAguarde",true);
			DisplayMsg();
		}
	}
}
//--------------AGUARDE FIM


function volverAtras(num)
{
  history.go(num);
}



