// JavaScript Document

//FUNCOES CHAMAM O XML==============================================================
function lista_acomp(id)
{
	moving = true;
	$('#tb_lista').fadeOut(1000, function(){ moving = false; 
	getXmlAjax('paginas/acompanhamento.xml.php?id='+id,'ProcessaXMLAcomp','');
	//alert(id);
	});
}

//FUNCOES CARREGA DADOS GALERIA DO ACOMPANHAMENTO DE OBRAS==============================================================
function mostra_foto(i)
{
	img = imagens[i];
	
	legA = legalt[i];
	
	img = img.split('_t');
	
	o('thumb_maior').src = "admIN/upload/empr_obra_fotos/"+img[0]+img[1];
	o('legenda').innerHTML = legA;
}

function ProcessaXMLAcomp(obj)
{
	
	var lista_imagens = obj.getElementsByTagName("imagem");
	
	var ul=document.getElementById('tb_lista');
		
	ul.style.width=(110*lista_imagens.length) +"px";
	
	while (ul.firstChild) {
	ul.removeChild(ul.firstChild);
	}
	
	for(i=0;i<lista_imagens.length;i++)
	{
		
		
		list = lista_imagens[i];
		
		id = list.getElementsByTagName('imagem_id')[0].firstChild.nodeValue;
		
		foto = list.getElementsByTagName('foto_lnk')[0].firstChild.nodeValue;
		
		var legenda = list.getElementsByTagName('legenda')[0].firstChild.nodeValue;
		
		//crio o link
		var a = document.createElement('a');
		a.setAttribute('href',"javascript:mostra_foto("+i+")");
		a.setAttribute('title',legenda);
		
		//crio a img e add no link
		var img = document.createElement('img');
		img.setAttribute('src',"admIN/upload/empr_obra_fotos/"+foto);
		img.setAttribute('alt',legenda);
		
		//add img ao link
		a.appendChild(img);
		
		var li=document.createElement('li');
		
		li.appendChild(a);
		ul.appendChild(li);
		
	}
	
	imagens = new Array();
	legalt = new Array();
	
	for(i=0;i<lista_imagens.length;i++)
	{
		imagem = lista_imagens[i];
		imagens[i] = imagem.getElementsByTagName('foto_lnk')[0].firstChild.nodeValue;
		legalt[i] = imagem.getElementsByTagName('legenda')[0].firstChild.nodeValue;
	}
	
	ul.style.left=0;
	
	$(ul).fadeIn(1000);
	
	mostra_foto(0);
	
}