function ajaxInit() {
    var req
    try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
 try {
     req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(ex) {
     try {
   req = new XMLHttpRequest();
     } catch(exc) {	
   alert("Esse browser não tem recursos para uso do Ajax");
   req = null;
     }
 }
    }
    return req;
}

function busca(str, tipo){
	if (str.length==0){ 
		document.getElementById("livesearch"+tipo).innerHTML="";
		document.getElementById("livesearch"+tipo).style.border="0px";
		return;
	}
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			document.getElementById("livesearch"+tipo).innerHTML=xmlhttp.responseText;
			document.getElementById("carregando"+tipo).style.display="none";
		}
	}
	xmlhttp.open("GET","/rede/cadastro/search.php?t="+tipo+"&q="+str+"&n="+document.getElementById("nascimento").value,true);
	document.getElementById("carregando"+tipo).style.display="inline";
	xmlhttp.send();
}

function apaga_info(){
	document.getElementById("livesearch1").innerHTML="";
	document.getElementById("carregando1").style.display="none";
}
	
function coloca_valor(campo, valor, tipo){
	document.getElementById(campo).value = valor;
	document.getElementById("livesearch"+tipo).innerHTML="";
}

function lista_comentario(id, qtd, tipo){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			document.getElementById("mostra_coments").innerHTML=document.getElementById("mostra_coments").innerHTML+xmlhttp.responseText;
			document.getElementById("inicio").value=Number(document.getElementById("inicio").value)+Number(qtd);
			document.getElementById("carregando").style.display="none";
		}
	}
	xmlhttp.open("GET","/includes/ajax/comentario.php?tipo="+tipo+"&qtd="+qtd+"&inicio="+document.getElementById("inicio").value+"&id="+id,true);
	document.getElementById("carregando").style.display="inline";
	xmlhttp.send();
}

function monta_menu_categoria(tipo){
	//if(document.getElementById("carregando").class!="carregado"){
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				document.getElementById("categorias").innerHTML=xmlhttp.responseText;
				document.getElementById("carregando").style.display="none";
				//document.getElementById("carregando").class="carregado";
			}
		}
		xmlhttp.open("GET", "/includes/ajax/categoria.php?tipo="+tipo, true);
		document.getElementById("carregando").style.display="inline";
		xmlhttp.send();
	//}
}

function mostra_msg(qtd, id, tipo_mensagem, envio){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("more-msg").innerHTML="Sem mais mensagens.";
				document.getElementById("carregando").style.display="none";
			}else{
				document.getElementById("msg").innerHTML=document.getElementById("msg").innerHTML+xmlhttp.responseText;
				document.getElementById("inicio").value=Number(document.getElementById("inicio").value)+Number(qtd);
				document.getElementById("carregando").style.display="none";
			}
		}
	}
	xmlhttp.open("GET","/includes/ajax/mensagem.php?tipo_mensagem="+tipo_mensagem+"&qtd="+qtd+"&inicio="+document.getElementById("inicio").value+"&id="+id+"&envio="+envio,true);
	//xmlhttp.open("GET","/includes/ajax/mensagem.php", true);
	document.getElementById("carregando").style.display="inline";
	xmlhttp.send();
}

function mostra_extrato_geral(qtd){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("msg-mostra").innerHTML="Sem mais.";
				document.getElementById("carregando").style.display="none";
			}else{
				document.getElementById("mostrar_mais").innerHTML=document.getElementById("mostrar_mais").innerHTML+xmlhttp.responseText;
				document.getElementById("quantidade").value=Number(document.getElementById("quantidade").value)+Number(qtd);
				document.getElementById("carregando").style.display="none";
			}
		}
	}
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inico="+document.getElementById("quantidade").value,true);
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd,true);
	xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inicio="+document.getElementById("quantidade").value,true);
	document.getElementById("carregando").style.display="inline";
	xmlhttp.send();
}

function mostra_extrato_geral2(qtd){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("msg-mostra").innerHTML="Sem mais.";
				document.getElementById("carregando").style.display="none";
			}else{
				document.getElementById("mostrar_mais").innerHTML=document.getElementById("mostrar_mais").innerHTML+xmlhttp.responseText;
				document.getElementById("quantidade").value=Number(document.getElementById("quantidade").value)+Number(qtd);
				document.getElementById("carregando").style.display="none";
			}
		}
	}
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inico="+document.getElementById("quantidade").value,true);
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd,true);
	xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral2.php?qtd="+qtd+"&inicio="+document.getElementById("quantidade").value,true);
	document.getElementById("carregando").style.display="inline";
	xmlhttp.send();
}

function mostra_extrato1(qtd, id){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("msg-mostra1").innerHTML="Sem mais.";
				document.getElementById("carregando1").style.display="none";
			}else{
				document.getElementById("mostrar_mais1").innerHTML=document.getElementById("mostrar_mais1").innerHTML+xmlhttp.responseText;
				document.getElementById("quantidade1").value=Number(document.getElementById("quantidade1").value)+Number(qtd);
				document.getElementById("carregando1").style.display="none";
			}
		}
	}
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inico="+document.getElementById("quantidade").value,true);
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd,true);
	xmlhttp.open("GET","/includes/ajax/mostra_extrato1.php?qtd="+qtd+"&inicio="+document.getElementById("quantidade1").value+"&id="+id,true);
	document.getElementById("carregando1").style.display="inline";
	xmlhttp.send();
}

function mostra_extrato2(qtd, id){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("msg-mostra2").innerHTML="Sem mais.";
				document.getElementById("carregando2").style.display="none";
			}else{
				document.getElementById("mostrar_mais2").innerHTML=document.getElementById("mostrar_mais2").innerHTML+xmlhttp.responseText;
				document.getElementById("quantidade2").value=Number(document.getElementById("quantidade2").value)+Number(qtd);
				document.getElementById("carregando2").style.display="none";
			}
		}
	}
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inico="+document.getElementById("quantidade").value,true);
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd,true);
	xmlhttp.open("GET","/includes/ajax/mostra_extrato2.php?qtd="+qtd+"&inicio="+document.getElementById("quantidade2").value+"&id="+id,true);
	document.getElementById("carregando2").style.display="inline";
	xmlhttp.send();
}

function mostra_produtos(qtd, order, direction){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			if(xmlhttp.responseText == 0){
				document.getElementById("msg-mostra").innerHTML="Sem mais.";
				document.getElementById("carregando").style.display="none";
			}else{
				document.getElementById("mostrar_mais").innerHTML=document.getElementById("mostrar_mais").innerHTML+xmlhttp.responseText;
				document.getElementById("pagina").value=Number(document.getElementById("pagina").value)+Number(1);
				document.getElementById("carregando").style.display="none";
			}
		}
	}
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd+"&inico="+document.getElementById("quantidade").value,true);
	//xmlhttp.open("GET","/includes/ajax/mostra_extrato_geral.php?qtd="+qtd,true);
	xmlhttp.open("GET","/includes/ajax/mostra_produtos.php?qtd="+qtd+"&pag="+document.getElementById("pagina").value+"&o="+order+"&d="+direction,true);
	document.getElementById("carregando").style.display="inline";
	xmlhttp.send();
}
