//AJAX
function openAjaxXx() {
var AjaxXx;
try {AjaxXx = new XMLHttpRequest(); // XMLHttpRequest para browsers mais populares, como: Firefox, Safari, dentre outros.
}catch(ee){
try {AjaxXx = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
}catch(e){
try {AjaxXx = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
}catch(e){AjaxXx = false;}
}
}
return AjaxXx;
}

//Amplia FOTO
function atualizaComentarios(div, getURL) {
document.getElementById(div).style.display = "block";
if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
var exibeResultado = document.getElementById(div); // div que exibirá o resultado.
var AjaxXx = openAjaxXx(); // Inicia o Ajax.
AjaxXx.open("POST", getURL, true); // fazendo a requisição
AjaxXx.setRequestHeader("Content-type", "application/x-www-form-urlencoded");	// Setando Content-type
//Ajax.setRequestHeader("Content-length", div.length); // Comprimento do conteúdo=comprimento dos dados a enviar
//Função carregar
AjaxXx.onreadystatechange = function(){
if(AjaxXx.readyState == 1) { // Quando estiver carregando, exibe: carregando...
exibeResultado.innerHTML = "<div style='width:100%px; height:302px; background:url(_img/loader.gif) no-repeat center;'></div>";
}
if(AjaxXx.readyState == 4) { // Quando estiver tudo pronto.
if(AjaxXx.status == 200) {
var resultado = AjaxXx.responseText; // Coloca o retornado pelo Ajax nessa variável
resultado = resultado.replace(/\+/g,""); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
//resultado = resultado.replace(/ã/g,"a");
resultado = unescape(resultado); // Resolve o problema dos acentos
exibeResultado.innerHTML = resultado;
} else {
exibeResultado.innerHTML = "Por favor, tente novamente!";
}
}
}
AjaxXx.send(null); // submete
}
}

//Seleciona GO (Ir)
function SelGo(id, pagina){
	if(id != ""){
		window.open('?p='+pagina+'&nome='+id, '_parent');
	}
}

//Upload de Fotos
function uploadDeFoto(pag, img){
	window.open(pag+'img='+img,'','resizable=0,Menubar=no,toolbar=no,scrollbars=0,status=0,top=0,left=0,screenX='+window.screenLeft+',screenY='+window.screenTop+',width=800,height=500');
}

//Abre Radio
function abreRadio(){
    window.open('radio,ad,piedade.php','','resizable=0,Menubar=no,toolbar=no,scrollbars=no,status=0,top=0,left=0,screenX='+window.screenLeft+',screenY='+window.screenTop+',width=520,height=185');
}

//Abre Cultos
function abreTV(){
    window.open('tv,ad,piedade.php','','resizable=0,Menubar=no,toolbar=no,scrollbars=0,status=0,top=0,left=0,screenX='+window.screenLeft+',screenY='+window.screenTop+',width=770,height=520');
}

//ABRIR JANELA
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//SHOW
function show(id){
  caixa = document.getElementById(id);
  caixa.style.display = "";
}
//HIDE
function hide(id){
caixa = document.getElementById(id);
caixa.style.display = "none";
}

//Excluir
function Excluir(id, bd, pasta, img, pagina){
  if (confirm("Confirma a exclusão? (Isso será um ato irreversível!)")){
    window.location="_php/Excluir.php?Id="+id+"&Bd="+bd+"&Pasta="+pasta+"&Img="+img+"&Pagina="+pagina;
  }
}

//LIMPA CAMPO
function limparCampo(id, cont){
  var campo = document.getElementById(id);
  if (campo.value == cont){
    campo.value = '';
  }else if(campo.value == ''){
    campo.value = cont;
  }
}

function ValidaCod(dig){
  var d = dig;
  var ori = document.contato.cod_.value;
	if(d.length>5){
	    if(d == ori){
		   document.contato.bt.disabled = false;
		   document.getElementById('Result').innerHTML = "<font color='#060'>Código Correto!</font>";
	    }else{
		   document.contato.bt.disabled = true;
		   document.getElementById('Result').innerHTML = "<font color='#FF0000'>Código Errado!</font>";
	    }
	}else{
		document.getElementById('Result').innerHTML = "";
	}
}

//Escreve o Flash
function flash(largura, altura, arquivo){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	//document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><embed src="'+arquivo+'" quality="best" width="'+largura+'" height="'+altura+'" name="teste" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
