
function formataValor(numero){
	nu = new String(numero)
	posPonto = nu.indexOf(".")
	if(posPonto == -1){
		nu = nu + ",000000000000000"
	}else{
		nu = nu.replace(".",",") + "00000000000000000"
	}
	posVirg = nu.indexOf(",")
	return nu.substr(0, posVirg + 3)
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function selecionarTodos(name) {
	var obj = getObj(name);
	if (obj != null) {
		var selTodos = getCheckedValue(getObj("selTodos"));
		if (obj.length) {
			for (i = 0; i < obj.length; i++) {
				if (selTodos == 'todos') {
					obj[i].checked = true;
				} else {
					obj[i].checked = false;
				}
			}
		} else {
			if (selTodos == 'todos') {
				obj.checked = true;
			} else {
				obj.checked = false;
			}
		}
	}
}

function getObj(n,d){
	var p,i,x;
	if (!d) {
		d = document;
	}
	if ( (p = n.indexOf("?") ) >0 && parent.frames.length ){
		if( n.substring(p+1) != "" && n.substring(p+1) != null && parent.frames[n.substring(p+1)]) {
			d=parent.frames[n.substring(p+1)].document;
			n=n.substring(0,p);
		}
	}
	if(!(x=d[n])&&d.all){
		x=d.all[n];
	}
	for(i=0;!x&&i<d.forms.length;i++){
		x=d.forms[i][n];
	}
	for(i=0;!x&&d.layers&&i<d.layers.length;i++){
		x=getObj(n,d.layers[i].document);
	}
	if(!x&&d.getElementById){
		x=d.getElementById(n);
	}
	return x;
}
