// JavaScript Document
function limitaTamanho(textArea, maxLength, countField){
	if(textArea.value.length > maxLength) {
		textArea.value = textArea.value.substring(0, maxLength);
	}
	countField.value = maxLength - textArea.value.length;
	return true;
}
function fixHeight(one,two) {
	var el1 = document.getElementById(one);
	var el2 = document.getElementById(two);
	if (el1) {
		var lh=el1.offsetHeight;
		var rh=el2.offsetHeight;
		var nh = Math.max(lh, rh);
		el1.style.height=nh+"px";
		el2.style.height=nh+"px";
	}
}

function sortNum(a,b) {
	return b - a;
}
function fixHeight2(one,two,three) {
	if (document.getElementById(one)) {
		var obj=new Array(3);
		var option=[one,two,three];
		for(var i=0; i<option.length; i++) {
			document.getElementById(option[i]).style.height="auto";
			obj[i]=document.getElementById(option[i]).offsetHeight;	
			nh=obj.sort(sortNum);
		}
		nh1=nh.splice(1,2);
		for(var i=0; i<option.length; i++) {
			document.getElementById(option[i]).style.height= nh+"px";
		}
	}
}
function alteraAltura(div, deltaY) {
	var elemento = document.getElementById(div);
	var altura = deltaY + elemento.offsetHeight;
	elemento.style.height = (altura)+"px";
}
function igualaAlturas(idContainer){
	var childs = document.getElementById(idContainer).childNodes;
	var blocos = new Array();
	for(i=0; i<childs.length;i++){
		if(childs[i].tagName == 'DIV') {
			blocos.push(childs[i]);
		}
	}
	var i = 0;
	while(blocos.length > i+1) {
		fixHeight(blocos[i].id, blocos[i+1].id);
		i = i + 2;
	}
		
}
function getEvent(e){
  if(window.event != null) {
    return event;
  }
  return e;
}
function setBkColor(e, bkColor){
 e = getEvent(e);
 var src =  e.srcElement || e.target;
 if(src != null) {
   src.style.bkColor = src.style.backgroundColor;
   src.style.backgroundColor = bkColor;
 }
}
function reSetBKColor(e){
 e = getEvent(e);
 var src =  e.srcElement || e.target;
 if(src != null) {
   src.style.backgroundColor = src.style.bkColor;
 }
}
function changeDisplay(element) {
	if (element.style.display == "none") {
		element.style.display= "";
	} else {
		element.style.display = "none";
	}
}