var xmlhttp = null;
// Conexão via XmlHttp
try {
	xmlhttp = new XMLHttpRequest();
} catch(ee) {
	try {
    	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
    	try {
        	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    	} catch(E) {
        	xmlhttp = false;
    	}
	}
}
	
function mostraConteudo(url, div) {
	// Seleciona objeto
	obj_div = document.getElementById(div);
   	// Verifica se existe xmlhttp
   	if (xmlhttp) {	
   		if(xmlhttp.readyState != 1){	
			xmlhttp.open("GET", url, true);
			xmlhttp.onreadystatechange = function() {
			   	// Verifica estado da requisição
			    if (xmlhttp.readyState == 1) {
			    	obj_div.innerHTML = "Aguarde ...";
			    } else if (xmlhttp.readyState == 4) {
			    	// Verifica status da requisição
					if (xmlhttp.status == 200) {
						obj_div.innerHTML = xmlhttp.responseText;
					} else {
						obj_div.innerHTML = "Erro ao carregar ...";
					}
				}
			}
   		}
   	}
   	xmlhttp.send(null);
}

function abrePopup(url,titulo,largura,altura){
	window.open(url,titulo,'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,width='+largura+',height='+altura+',resizable=0');
}

function abrePopupWScroll(url,titulo,largura,altura){
	window.open(url,titulo,'toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,width='+largura+',height='+altura+',resizable=0');
}

function editarLegenda(legendaAtual,idfoto){
	var legendaNova = prompt('Legenda:',legendaAtual);
	if(legendaNova == null) return false;
	document.editarleg.idFoto.value = idfoto;
	document.editarleg.legenda.value = legendaNova;
	document.editarleg.submit();
}