var tempValue = null;

function aumentaRows(obj) {
	x = $(obj);
	x.rows = x.rows+2;
}

function diminuiRows(obj) {
	x = $(obj);
	x.rows = x.rows-2;
}

function setHiddenValue(hiddenId, valor) {
	x = $(hiddenId);
	x.value = valor;
}

function checkRadio(campoHiddenId, idRadio) {
	x = $(idRadio);
	x.checked = "true";
	
	y = $(campoHiddenId);
	y.value = x.id;
	
}


function naoPreenchido(campo) {
	x = $(campo);
	x.style.border=" 1px solid #FF8040";
}


function colorBorder(campo) {
	x = $(campo);
	x.style.border=" 1px solid red";
}

function colorLabel(id) {
	x = $(id);
	x.style.border="1px solid red";
	x.style.color="red";
}

function setValue(x) {
	tempValue = x;
}


function $(id) {
	return document.getElementById(id);	
}

function showHide(id) {
	x = $(id);
	x.style.display = (x.style.display == 'block') ? 'none' : 'block' ;
	
}

function findPosX(obj){
	
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;

	return curleft;
}

function findPosY(obj){
	
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function formatar(src, escape, mask) {
    y = event.keyCode; //8 = backspace

    var i = src.value.length;
    var saida = escape;
    var texto = mask.substring(i);

    if ( (texto.substring(0,1) != saida) && (y != 8) ) {
        if(texto.substring(0,1) == ' ') {
            tirar = src.value.substr(i-1,1);
            textoFull = src.value;

            lFix = src.value.charAt(i-1);
            src.value = textoFull.replace(src.value.charAt(i-1), ' ')+lFix;

        } else {
            src.value += texto.substring(0,1);
        }

    }
    if(y == 109) {
      return false;
    }
}