function radioValue(radio) {
	var resp = "";
	for (var i=0; i < radio.length; i++) {
		if (radio[i].checked) { resp = radio[i].value; break; }		
	}
	return resp;
}

function selectValue(select) {
	var resp = "";
	for (var i=0; i < select.length; i++) {
		if (select[i].selected) { resp = select[i].value; break; }		
	}
	return resp;
}

function formataMoeda(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    if (obj.value.length == 0) {
    	obj.value = '0.0';
    } else {
    	valor = parseFloat(obj.value);
    	if (valor < 1) {
    		obj.value = obj.value.substr(2,1) + "." + obj.value.substr(3,1);
    	} else {
    		var partes = obj.value.split(".");
    		if (partes.length != 2) obj.value = '0.0';
    		else obj.value = partes[0] + partes[1].substr(0,1) + "." + partes[1].substr(1,1);
    	}
    }
   	return true;
}

function formataPeriodo(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
    if (obj.value.length == 2) obj.value += '/';
   	return true;
}

function soNumero(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    var key = String.fromCharCode(whichCode);
    if (strCheck.indexOf(key) == -1) return false;
   	return true;
}

function resetaNumeros(obj,e) {
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    switch (whichCode) {
    	case 8:	case 37: case 46: case 39:
    		obj.value = '';
    	break;
    }
}
