// JavaScript Document
var ultimo = new Array(2);
ultimo[0] = -1;

var ultimoCBO = "";


/*****************************************************************************************************
*****								  	 ÁREA ADMINISTRATIVA									 *****
*****************************************************************************************************/
function salvarTexto(obj)
{	obj.txttexto.value = document.getElementById('field_body').contentWindow.document.body.innerHTML;
	return true;
}

function editarTexto()
{	var rte = document.getElementById('field_body');
	var conteudo = document.getElementById('txttexto').value;
	
	rte.contentWindow.document.body.innerHTML = conteudo
}


/*****************************************************************************************************
*****								  	 		AJAX											 *****
*****************************************************************************************************/
function apagarFoto(tabfoto, chk)
{	var tabelas = document.getElementsByTagName("table")

	for (x = 0; x <= tabelas.length - 1; x++)
	{	with (tabelas[x])
		{	if (id == "datalistfotos__ctl" + tabfoto + "_tabela" + tabfoto ||
				id == "datalistfotos__ctl" + tabfoto + "_tabfoto")
			{	if (chk.checked)
				{	className = className + "-sele"; }
				else
				{	className = "tabela-foto"; }
			}
		}
	}
}

function apagar(foto)
{	var resposta = func_ajax.apagarFoto(foto).value;
	
	if (resposta)
	{	location.reload(true); } //setInterval("location.href = location.href;", 500);	}
	else
	{	alert("Ocorreu um erro ao tentar apagar esta imagem.");	}
}


/*****************************************************************************************************
*****									 		 FOTOS											 *****
*****************************************************************************************************/
function verFoto(foto)
{	var w = 500;
	var h = 375;
	var pic = window.open('','','width=' + w + ',height=' + h);
	var fotoStr = '';

	if (foto.src.indexOf("aspx") > 0)
	{	var inicio = foto.src.indexOf("=") + 1;
		var fim = foto.src.indexOf("&");
		foto = foto.src.substr(inicio, fim - inicio)
		fotoStr = '<img src="../thumb.aspx?foto=' + foto + '&w=' + w + '&h=' + h + '" border="0" alt="Fechar Janela">';
	}
	else
	{	fotoStr = '<img src="' + foto.src.replace('mini/','') + '" border="0" alt="Fechar Janela">';	}
	
	pic.document.write('<html><body topmargin=0 leftmargin=0>');
	pic.document.write('<a href="javascript:window.close()">');
	pic.document.write(fotoStr);
	pic.document.write('</a></body></html>');
}

