function MascaraCPF(pObjeto)
{
	var valorCPF = pObjeto.value.replace(/\D/g, '');
	var cpfFormatado = valorCPF;
	if (valorCPF != '' && valorCPF.length == 11)
	{
		pObjeto.maxLength = 14;
	    cpfFormatado = valorCPF.substr(0, 3) + '.' + valorCPF.substr(3, 3) + '.' + valorCPF.substr(6, 3) + '-' + valorCPF.substr(9, 2);
	}
	pObjeto.value = cpfFormatado;
}

function SomenteNumero(pObjeto)
{
	pObjeto.value = pObjeto.value.replace(/\D/g, '');
}

function MascaraData(pObjeto)
{	
	var valorData = pObjeto.value.replace(/\D/g, '');
	if (valorData != '')
	{
		var dia = valorData.substr(0, 2);
		var mes = valorData.substr(2, 2);
		var ano = valorData.substr(4, 4);
		if (ano.length > 1)
		{
			if (ano.length != 4)
			{
				ano = (ano < 30 ? '20' : '19') + ano.toString().substr(0, 2);
			}
			pObjeto.maxLength = 10;
			pObjeto.value = dia + '/' +  mes + '/' + ano;
		}
	}
}

function SomenteNumeros(e)
{
	if (!e) e = window.event;
	var teclaPressionada = (e.keyCode) ? e.keyCode : e.which;	 
	if (!VerificarTeclasPossiveis(teclaPressionada, e))
	{
		if (window.event)
			e.returnValue = false;
		else
			e.preventDefault();
	}
}

function VerificarTeclasPossiveis(pTeclaPressionada, e)
{
	// Verifica as teclas possíveis.
	if ((pTeclaPressionada >= 48 && pTeclaPressionada <= 57) || e.altKey || e.ctrlKey) // Bot?es de 0...9, alt e control.
		return true;	
		
	switch (pTeclaPressionada)
	{
		case 8: // Backspace.
		case 9: // Tab.
		case 13: // Enter.
		case 35: // End.
		case 36: // Home.
		case 37: // Seta para Esquerda.
		case 39: // Seta para Direita.
		case 46: // Delete.
			return true;
		default:
			return false;
	}
}	

function ShowWait()
{
	try
	{                   
		var objMenu = document.getElementById("Menu_menuBarLeft");
		if((objMenu) && (objMenu != "undefined"))
		{        
			HandleMenuBar(objMenu);
		}
	}
	catch(e){}      
	
	try
	{       
		var div2 = document.getElementById("divWait");
		div2.style.visibility = "";
	}
	catch(e){}
}

function OpenWindow(pUrl, pLargura, pAltura)
{
	var left = (screen.availWidth / 2) - (pLargura / 2);
	var top = (screen.availHeight /2) - (pAltura / 2);
	return window.open(pUrl, 'janelaModal', 'width=' + pLargura + ', height=' + pAltura + ', location=0, menubar=0, resizable=no, toolbar=0, scrollbars=0, left=' + left + ', top=' + top);
}

function RedirectPage(pUrl)
{
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		window.location.href = pUrl;
	}
	else
	{
		window.open(pUrl, target = '_self');
	}
}

