var numeros = "0123456789";
function sonumeros(obj,tipo)
{
	if(tipo=='data')
    {
		numeros = "0123456789/";
	}
	else
	{
		numeros = "0123456789";
	}
    str = obj.value;
    tamanho = str.length;
    retorno = "";
    for ( i=0; i<tamanho; i++ ){
    	letra = str.substr(i,1);
    	indexof = numeros.lastIndexOf(letra);
    	if ( indexof > -1 ){ 
    		retorno = retorno + letra; 
    	}
    }
    obj.value = retorno;
}

function contextmenu(str,show,e)
{
	if(!e) e = event;
	if(!document.getElementById('contextmenudiv'))
	{
		div = document.createElement("div");
		div.setAttribute('id','contextmenudiv');
		document.body.appendChild(div);
	}
	if (e.pageX || e.pageY)
    {
      mousex = e.pageX;
      mousey = e.pageY;
    }
    else if (e.clientX || e.clientY)
    { 
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
    }  
	var varleft = mousex - 10;
	var vartop = mousey + 23;
	document.getElementById('contextmenudiv').innerHTML = escape(str);
	document.getElementById('contextmenudiv').style.position = 'absolute';
	document.getElementById('contextmenudiv').style.padding = '3px';
	document.getElementById('contextmenudiv').style.border = '1px solid #000000';
	document.getElementById('contextmenudiv').style.backgroundColor = '#0091DE';
	document.getElementById('contextmenudiv').style.color = '#FFFFFF';
	document.getElementById('contextmenudiv').style.top = vartop + 'px';
	document.getElementById('contextmenudiv').style.left = varleft + 'px';
	
	if(show == 'off')
	{
		document.getElementById('contextmenudiv').style.display = 'none';
	}
	if(show == 'on')
	{
		document.getElementById('contextmenudiv').style.display = 'inline';
	}
}

function abrirPopup(url,nome,largura,altura)
{
	largura = largura + 40;
	altura = altura + 40;
	
	var topo = (screen.height - altura) / 2;
	var esquerda = (screen.width - largura) / 2;
	
	winConfig = 'height='+altura+',width='+largura+',top='+topo+',left='+esquerda+',scrollbars=yes,statusbars=yes';
	win = window.open(url,nome,winConfig);
}
