function cargaBandejaEntrada()
{
	var tabla = dojo.widget.byId("ResultadosTabla");
	tabla.addPropertyFunction("eliminar", function(){
				return "<center><img src='./admin/images/b_drop.png' alt='Eliminar' style='cursor:pointer' onclick='eliminarMensajeRecibido(\""+this.id_mensaje+"\")'/></center>";
	  });
	
	tabla.refresh();	
}

function eliminarMensajeRecibido(id)
{
	if (confirm("Seguro que desea eliminar este mensaje?"))
	{
		var url = "./admin/source/logic/json_deletemensaje.php?op=mensajes_recibidos&id="+id;		
		bind(url,function(result)
		{
			//if (result == "ok")
			{
				var tabla = dojo.widget.byId("ResultadosTabla");
				tabla.refresh();	
			}
		}
		,function(result){});
	}
}

function viewMessage(id)
{
	window.location="./recibido.php?value="+id;	
}

function Responder(id_from, id_to, yo, tu, enviado, fecha)
{
	var viejo_mensaje = document.getElementById("demo-show").innerHTML;
	var asunto = document.getElementById("asunto").value;
	var texto = document.getElementById("respuesta").value;
	if ((asunto == "") || (asunto == ""))
		alert("Complete los datos del mensaje que quiere enviar")
	else
	{
		var mensaje = "<H3>"+yo+", <span style=\"font-size:10px\">"+asunto+"</span></H3>";
		
		mensaje += "<DIV class=\"body_msg\">";		
		mensaje += "<img src=\"images/image.jpg\" align=\"left\">";
		mensaje += texto;
		mensaje += "<br><br>";
		mensaje += "<span class=\"fichaJuegos\">Enviado el: "+enviado+" </span>";
		mensaje += "</DIV>";

		var url = "./admin/source/logic/json_viewm.php?p="+id_to+"&s="+asunto+"&m="+mensaje+"&o="+viejo_mensaje+"&d="+id_from+"&da="+fecha+"";
		
		bind(url,function(result)
		{
			alert("Su mensaje ha sido enviado al usuario de manera satisfactoria.")
			window.location = "./recibidos.php";	
		},
		function(result)
		{
			alert("error "+result)
		});
		
		/*obj = new mensajes_recibidos();
		obj.new_mensajes_recibidos.call(0,id_to,asunto,mensaje+viejo_mensaje,id_from,fecha);
		obj.new_mensajes_recibidos.result = function(result)
		{			
			//Adicionar el nuevo mensaje enviado
			obj = new mensajes_enviados();
			obj.new_mensajes_enviados.call(0,id_from,asunto,mensaje,id_to,fecha);
			obj.new_mensajes_enviados.result = function(result)
			{
				
			}
		}*/
	}	
}

