
function Ajax(url,destino)
{
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
	destino.innerHTML = "<img src='./estilo/img/loading.gif' alt='carregando'/> <span class='texto'>Carregando...</span>";
	xmlhttp.open("GET", url ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4){
			destino.innerHTML = xmlhttp.responseText;
		}
	}

xmlhttp.send(null);
}

function SubMenu(id_categoria)
{
	if(document.getElementById("submenu"+id_categoria).style.display=="none")
	{
		document.getElementById("submenu"+id_categoria).style.display = 'inline';
		Ajax("./include/funcoes.php?id_categoria=" + id_categoria,document.getElementById("submenu"+id_categoria)); 
	}
	else 
	{
		document.getElementById("submenu"+id_categoria).style.display = 'none';
	}
}

function valida_piada(){
	if (document.form_piada.id_categoria.value=="") 
	{
		alert('Selecione uma categoria.');
		return;
	}
	else if (document.form_piada.piadaTitulo.value=="")
	{
		alert('Digite um titulo.');
		return;
	}
	else if (document.form_piada.piadaTexto.value=="") 
	{
		alert('Digite a Piada neh... Deeeerr...');
		return;
	}
	else
	document.form_piada.action="grava.php";
	document.form_piada.submit();
}

function valida_video(){
	if (document.all.id_categoria.value=="") {
		alert('Selecione uma categoria.');
		return;
	}
	else if (document.all.videoTitulo.value=="")
	{
		alert('Digite um titulo.');
		return;
	}
	else if (document.all.videoTexto.value=="") 
	{
		alert('Digite a video neh... Deeeerr...');
		return;
	}
	else
	document.form_video.action="grava_video.php";
	document.form_video.submit();
}
function SubMenuv(id_categoria)
{
	if(document.getElementById("submenu"+id_categoria).style.display=="none")
	{
		document.getElementById("submenu"+id_categoria).style.display = 'inline';
		Ajax("./include/funcoes.php?id_categoriav=" + id_categoria,document.getElementById("submenu"+id_categoria)); 
	}
	else 
	{
		document.getElementById("submenu"+id_categoria).style.display = 'none';
	}
}

function abre_piada(id,tipo){
	if(tipo=='0')
		location='http://www.opiadeiro.com/?p='+id;
	else {
		Ajax("./include/funcoes.php?id_piada="+id ,document.getElementById(tipo));
	}
	
}

function ajax_login()
{

	//Ajax();
//	alert("./include/funcoes.php?login=1&usuario_Login=" + $("#usuario_Login").val() + "&usuario_Senha=" + $("#usuario_Senha").val());
	
	$.getJSON("./include/funcoes.php?login=1&usuario_Login=" + $("#usuario_Login").val() + "&usuario_Senha=" + $("#usuario_Senha").val(),
		function(data){
			///alert("xxxxxxxx" );
			if(data.result == 1)
			{
				$(".login_box").html("<span> Seja bem vindo " + data.usuario +"</span>");
				//$(".login_box").hide();
				
			}
			else
			{
				alert('Login ou senha Inválidos.');
			}
		}
	);
	
}
	
	