// funçoes utilitárias

function popup(url, w, h, name){
	if(name == 'randon'){
		var timestamp = new Date();
		name = 'random' + timestamp.getTime();
	}
	//alert("URL: " + url + "\nWidth: " + w + "\nHeight: " + h);
	window.open( url, name, "width=" + w + ",height=" + h + ",scrollbars=no" );	
}
function popups(url, w, h){
	window.open( url, "popup", "width=" + w + ",height=" + h + ",scrollbars=yes" );	
}

// adicione string em elemento nomeado como "debug"
function debug(msg){
	if(debugin){
		document.getElementById('debug').innerHTML = document.getElementById('debug').innerHTML + "<br>" + msg;
	}
}

// invoca url baseado em resposta positiva
function question(msg, urlok){
	var z = confirm(msg);
	if (z == true){
		location.href = urlok;
	}
}

// permite apenas numero no objeto
function onlynumbers(obj, e){
	var tecla = parseInt(eval( ( (navigator.appName == "Netscape")?"e.which":"e.keyCode" ) ))
	if (!(tecla>47 && tecla<58 || tecla == 8 || tecla == 0 || tecla == 13)) return false;	
}
function onlymoney(obj, e){
	var tecla = parseInt(eval( ( (navigator.appName == "Netscape")?"e.which":"e.keyCode" ) ))
	if (!(tecla>47 && tecla<58 || tecla == 44 || tecla == 8 || tecla == 0 || tecla == 13)) return false;	
}
// permite apenas os caracteres especificados no objeto
function onlychars(obj, e, caracteres){
	var tecla = parseInt(eval( ( (navigator.appName == "Netscape")?"e.which":"e.keyCode" ) ));
	var char = String.fromCharCode(tecla);
	if( !(InStr(caracteres, char) || tecla == 16 || tecla == 8 || tecla == 0 || tecla == 13) ){
		debug("Bloqueado: " + tecla + "(" + char + ")");
		return false;
	}
}

// colocar string em barra de status

function setstatus(msg){
	self.status=msg;
}

function cleanstatus(msg){
	self.status='';
}
