
// escreve datas de bate papo //
// o objeto "config" esta no arquivo script-config.js importado no template //
function writeChats()
{
  var list = document.getElementById("batepapo").getElementsByTagName("ul")[0];
  for(var i=0;i<config.batepapo.length;i++)
  {
    var item = document.createElement("li");
    if (config.batepapo[i].link!=null&&config.batepapo[i].link!="")
    {
      var link = document.createElement("a");
      link.target = (config.batepapo[i].target!=null&&config.batepapo[i].target!="")?config.batepapo[i].target:"_top";
      link.href = config.batepapo[i].link;
      item.appendChild(link);
      item=link
    }
    var text = document.createTextNode(config.batepapo[i].texto);
    item.appendChild(text);
    list.appendChild(item);
  }
}
writeChats();

// posiciona elementos //
bFs = (document.getElementById('barrauol')) ? document.getElementById('barrauol').offsetWidth/98.8 : 0 ;

function findPos(bId, sum) {
	obj = document.getElementById(bId);
	var curtop = 0;
	if (obj.offsetParent) {
	while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) curtop += obj.y;
	return curtop;
}		

// equaliza colunas //
function getHeight(id) {
	if (document.getElementById(id)) return document.getElementById(id).offsetHeight + findPos(id);
	else return 0;
}
		
function getMaxHeight(args) {
	maxHeight = getHeight(args[0]);
	for(i=0;i<args.length;i++)	
	maxHeight = Math.max(maxHeight, getHeight(args[i]))
	return maxHeight;
}
		
function setHeight() {
	maxHeight = getMaxHeight(arguments) 
	for(i=0;i<arguments.length;i++)
		if (document.getElementById(arguments[i]) && maxHeight != 0 && bFs != 0){
			document.getElementById(arguments[i]).style.height = (maxHeight - findPos(arguments[i]))/bFs  +'em';
			if (document.getElementById('gastronomia-col-dir')) {
				document.getElementById('gastronomia-col-dir').style.height = (maxHeight - findPos('gastronomia-col-dir'))/bFs - 1 +'em';
			}
			if (document.getElementById('gastronomia-receitas-ervas')) {
				document.getElementById('gastronomia-receitas-ervas').style.height = (maxHeight - findPos('gastronomia-receitas-ervas'))/bFs - 3 +'em';
			}
			if (document.getElementById('gastronomia-receitas-acompanhamentos')) {
				document.getElementById('gastronomia-receitas-acompanhamentos').style.height = (maxHeight - findPos('gastronomia-receitas-acompanhamentos'))/bFs - 3 +'em';
			}
			if (document.getElementById('gastronomia-receitas-item')) {
				document.getElementById('gastronomia-receitas-item').style.height = (maxHeight - findPos('gastronomia-receitas-item'))/bFs - 3 +'em';
			}
		}
}
		
// adicionar aqui os IDs das colunas que deseja equalizar 
// estes elementos devem ser DIVs de estruturação, não devem conter padding ou margin
setHeight("col-esquerda","centro");


