var x;
x=$(document);

function mostrarSobreMi(){
	//var capa=$("#div_acerca");
	//capa.css("heigth","100px");
	var flag=document.getElementById("flag_div_sobremi").value;
	//alert(flag);
	if(flag=='1'){
	document.getElementById("flag_div_sobremi").value='0'; 
	document.getElementById("div_acerca").style.height='40px';
	document.getElementById("div_acerca").style.border='1px solid white';
	document.getElementById("div_acerca").style.top='1px';
	document.getElementById("maximiza_1").className ='minimiza_style';
	//document.getElementById("div_acerca").style.background-image ='url(images/flecha_oculta.png)';

	} else {
		document.getElementById("flag_div_sobremi").value='1';
		document.getElementById("div_acerca").style.height='auto';
		document.getElementById("div_acerca").style.border='0px solid white';
		document.getElementById("maximiza_1").className ='maximiza_style';
	}
	//capa.html(data);
	//cargarFotos();

}

function mostrarSobreBusco(){
	var flag=document.getElementById("flag_div_sobrePersona").value;
	//alert(flag);
	if(flag=='1'){
	document.getElementById("flag_div_sobrePersona").value='0'; 
	document.getElementById("div_sobre").style.height='30px';
	document.getElementById("div_sobre").style.border='1px solid white';
	document.getElementById("div_sobre").style.top='1px';
	document.getElementById("maximiza_2").className ='minimiza_style';
	//document.getElementById("div_acerca").style.background-image ='url(images/flecha_oculta.png)';

	} else {
		document.getElementById("flag_div_sobrePersona").value='1';
		document.getElementById("div_sobre").style.height='auto';
		document.getElementById("div_sobre").style.border='0px solid white';
		document.getElementById("maximiza_2").className ='maximiza_style';
	}

}

function mostrarComo(){
	var flag=document.getElementById("flag_div_como").value;
	//alert(flag);
	if(flag=='1'){
	document.getElementById("flag_div_como").value='0'; 
	document.getElementById("div_meConsidero").style.height='35px';
	document.getElementById("div_meConsidero").style.border='1px solid white';
	document.getElementById("div_meConsidero").style.top='1px';
	document.getElementById("maximiza_3").className ='minimiza_style';
	//document.getElementById("div_acerca").style.background-image ='url(images/flecha_oculta.png)';

	} else {
		document.getElementById("flag_div_como").value='1';
		document.getElementById("div_meConsidero").style.height='auto';
		document.getElementById("div_meConsidero").style.border='0px solid white';
		document.getElementById("maximiza_3").className ='maximiza_style';
	}

}

function guardarComentarioFoto(){
	var jfoto=document.getElementById("id_foto").value; //alert(foto);
	var jcomentario=document.getElementById("txt_comentario").value; // alert(comentario);
	var jmiembro=document.getElementById("id_usuario").value; //alert(comentario);
	//var capa=$("#msg_comentario_foto");
	//capa.css("display","block");
	var jaleat=aleatorio(1000000000,9999999999);
	//capa.load("librerias/guardar_coment_foto.php?cod_foto="+jfoto+"&miembro="+jmiembro+"&comentario='"+jcomentario+"'&aleat="+jaleat);
	$.get("librerias/guardar_coment_foto.php",{cod_foto:jfoto,miembro:jmiembro,comentario:jcomentario,aleat:jaleat},recibir_registro_foto); 

}

function recibir_registro_foto(data){
	var capa=$("#msg_comentario_foto");
	capa.css("display","block");
	capa.html(data);
	cargarFotos();
}

function cerrarComentario(){
	document.getElementById('div_comentario_foto').style.display = 'none';
	document.getElementById("id_foto").value='';
	document.getElementById("txt_comentario").value='';
	var capa=$("#msg_comentario_foto");
	capa.html("");
	capa.css("display","none");

}

function editComentario(codigo){
	document.getElementById("id_foto").value=codigo;
	var a=$("#div_comentario_foto");
	a.css("display","block");
	var comentario=	document.getElementById("coment_"+codigo).value;
	document.getElementById("txt_comentario").value=comentario;
}


function refresca_usuario_enlinea(id_usuario,j_ubicacion){
	//alert(id_usuario);	
	$.post("librerias/actualiza_usuario_online.php",{usuario:id_usuario,ubicacion:j_ubicacion},''); 

}

function desbloquearAmigo(id_amigo){
	
	//var id_desde=$("#abuso_desde").attr("value"); 
	var id_desde=$("#cod_miembro").attr("value");
	//alert(id_amigo); alert(id_desde);
	var j_accion="desbloquear_amigo";
	$.post("includes/miembros.php",{accion:j_accion,desde:id_desde,para:id_amigo},retornarDesbloqueoAmigos); 
	
}

function retornarDesbloqueoAmigos(data){
		//var capa=$("#div_accion");
		//capa.css("display","block");
		var bloqueado=data;
		//capa.html(data);
		window.location="misAmigos.php?result=desbloquearAmigoOk&idAmigo="+bloqueado+"";
}
function bloquearAmigo(id_amigo){
	
	var id_desde=$("#cod_miembro").attr("value");
	
}
function desbloquearAmigo(id_amigo){
	
	var id_desde=$("#cod_miembro").attr("value");
	
}
function retornarBloqueoAmigos(data){
		//var capa=$("#div_accion");
		//capa.css("display","block");
		var bloqueado=data;
		//capa.html(data);
		window.location="misAmigos.php?result=bloquearAmigoOk&idAmigo="+bloqueado+"";
}

function eliminarAmigo(id_amigo){
	
	//var id_desde=$("#abuso_desde").attr("value"); 
	var id_desde=$("#cod_miembro").attr("value");
	//alert(id_amigo); alert(id_desde);
	var j_accion="eliminar_amigo";
	$.post("includes/miembros.php",{accion:j_accion,desde:id_desde,para:id_amigo},retornarAmigos); 
	
}

function retornarAmigos(data){
		//var capa=$("#div_accion");
		//capa.css("display","block");
		var eliminado=data;
		//capa.html(data);
		window.location="misAmigos.php?result=borrarAmigoOk&idAmigo="+eliminado+"";
}

function mostrarIconos(id){
	document.getElementById('div-fotos-'+id).style.display = 'block';
	document.getElementById('div-mensaje-'+id).style.display = 'block';
	document.getElementById('div-borrar-'+id).style.display = 'block';

}

function ocultarIconos(id){
	document.getElementById('div-fotos-'+id).style.display = 'none';
	document.getElementById('div-mensaje-'+id).style.display = 'none';
	document.getElementById('div-borrar-'+id).style.display = 'none';
	
}

function boxMsg(vista){
	if(vista=='abrir'){
		document.getElementById('div_envia_mensaje').style.display = 'block';
		document.getElementById('div_form_mensaje').style.display = 'block';
		document.getElementById('div_rpta_mensaje').style.display = 'none';
		document.getElementById("txt_asunto_para").value="";
	 	document.getElementById("txt_msj_para").value="";
	}
	if(vista=='cerrar') document.getElementById('div_envia_mensaje').style.display = 'none';
}

function sendboxMsg(t_id_destino){
	
	var t_asunto	=document.getElementById("txt_asunto_para").value;
	var t_mensaje	=document.getElementById("txt_msj_para").value;
	var t_accion	="enviar_mensaje";	
	
	if(!t_asunto || t_asunto==''){
		alert("Debes ingresar el Asunto de tu mensaje!");
		document.getElementById("txt_asunto_para").focus();
	} else if(!t_mensaje || t_mensaje==''){
			alert("Debes ingresar tu mensaje!");
			document.getElementById("txt_msj_para").focus();
			} else { 
				$.post("librerias/lb_mensajes.php",{accion:t_accion,id_destino:t_id_destino,asunto:t_asunto, mensaje:t_mensaje},
				function(data){
					var div_rpta=$("#div_rpta_mensaje");
					div_rpta.html(data);
					document.getElementById('div_form_mensaje').style.display = 'none';
					document.getElementById('div_rpta_mensaje').style.display = 'block';
					document.getElementById("txt_asunto_para").value="";
					document.getElementById("txt_msj_para").value="";
				}																																 ); 
			}	
			
}

function reportarAbuso(){
	//var id_desde=$("#abuso_desde").attr("value"); 
	//var x=$("#div_abuso");
//	x.css("display","block");
	document.getElementById('div_abuso').style.display = 'block';
	//var id_para=$("#abuso_para").attr("value");

}

function seleccionarMotivo(valor){
	document.getElementById("motivo").value=valor;	
	if(valor=="razon_otro"){
		var capa=$("#div_abuso_otro");
		capa.css("display","block");
	} else { 
			var capa=$("#div_abuso_otro");
			capa.css("display","none");
		}
}

function validar_abuso(){
	indicador=true;
	var razon=document.getElementById("motivo").value;
	if(razon==''){ indicador=false; }
		else {
				if(razon=="razon_otro"){ 
					var texto_motivo=document.getElementById("txt_motivo").value;
					if(texto_motivo==''){
						indicador=false;	
						}
				} 
			}
	if(!(indicador)){ alert("Por favor, seleccione el motivo del reporte de abuso!") }
	return indicador;

}

function buscar_desde_index(){
	var x=$("#div_cargando");
	x.css("display","block");
	document.form_busqueda.submit();	
}

function buscar_desde_perfil(){
	var x=$("#div_cargando");
	x.css("display","block");
	document.form_busqueda_desde_perfil.submit();	
}

function buscar_desde_buscador(){
	var x=$("#div_cargando");
	x.css("display","block");
	document.form_busqueda_desde_busk.submit();	
}

function cerrarAviso(){
	//x.css("display","none");
	var usuario=document.getElementById("miembro_id").value;//window.alert(usuario);
	
	if(navigator.userAgent.indexOf("MSIE")>=0) navegador=0;
		else navegador=1;
		/* **** */
			if(navegador==0)
				{
				var no_mostrar=document.getElementById("mostrarAviso").value; //alert(mostrar);
				} else { 
				var no_mostrar=document.getElementById("mostrarAviso").value; //alert(mostrar);
				//var no_mostrar=document.getElementById("chkMostrarAviso").value; //alert(mostrar);
				}
				
//var no_mostrar=document.getElementById("chkMostrarAviso").checked; //alert(mostrar);

	if(no_mostrar==1) { 
		var mostrar_valor="ocultar";
		var jaccion="ocultar_aviso";
		var x=$("#root");
		$.post("includes/miembros.php",{accion:jaccion,id_usuario:usuario,valor:mostrar_valor},ocultarAviso); 
//		alert("No mostrar "); 
		} else { 
				var x=$("#fondo_alpha");
				x.css("display","none");
			}
}

function ocultarAviso(datos){
		var x=$("#fondo_alpha");
		//x.html(datos);
		x.css("display","none");
	
}

function editar_campo(contenedorCapa,nombreCapa,jcampo,jusername,ancho)
{

  //var cod_miembro=$("#cod_miembro").attr("value");
	var capa=$("#"+contenedorCapa);
	  //capa.text("cargando..."); return false;

	//alert(contenedorCapa);return;
  //capa.html('<table width="250" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF"><form id="form1" name="form1" method="post" action=""><tr><td class="cont_2"><textarea name="textarea"></textarea></td></tr><tr><td class="cont_2"><input type="button" name="Submit" value="Guardar" /> <a href="#">Cancelar</a></td></tr></form></table>');
  //$.get("lista_eventos.php",{mes:v},llegadaDatos); 
  //return false;
  //var activado=$("#hidden_"+nombreCapa).attr("value"); //alert(activado);
  	//if(activado!=1){
	capa.load("librerias/valores_editar.php?campo="+jcampo+"&username="+jusername+"&capa="+nombreCapa+"&contenedor="+contenedorCapa+"&ancho="+ancho);
	//}
	//document.getElementById("hidden_"+nombreCapa).value="1";
	//alert("hola");
	//document.getElementById("txtValor_"+jcampo+"").focus();
}

function carga_valor(contenedorCapa,nombreCapa,jcampo,jusername,ancho){
	
	 //var cod_miembro=$("#cod_miembro").attr("value");
	var capa=$("#"+contenedorCapa);
	capa.load("librerias/valores_cargar.php?campo="+jcampo+"&username="+jusername+"&capa="+nombreCapa+"&contenedor="+contenedorCapa+"&ancho="+ancho);

	//$.get("../librerias/carga_valores.php",{campo:jcampo,username:jusername},mostrarFotos); 
}

function cancel_edit(contenedorCapa,nombreCapa,jcampo,jusername,ancho)
{
	//var capa=$("#"+nombreCapa);  	
	//capa.load("librerias/carga_valores.php?campo="+jcampo+"&username="+jusername+"&capa="+nombreCapa);
	//document.getElementById("hidden_"+nombreCapa).value="0";
  var capa=$("#"+contenedorCapa);
  capa.load("librerias/valores_cargar.php?campo="+jcampo+"&username="+jusername+"&capa="+nombreCapa+"&contenedor="+contenedorCapa+"&ancho="+ancho);

}

function actualiza_valor(contenedorCapa,nombreCapa,jcampo,jusername,anchoCelda)
{	
	//var texto=$("#txtValor").attr("value");
	//var texto=document.getElementById("txtValor_"+jcampo+"").value;
	
	var n="txtValor_"+jcampo+""; 
	
	if(contenedorCapa=='cont_comosoy'){
		var getDocument = document.getElementById("wysiwyg" + n).contentWindow.document;
		var browserName = navigator.appName;
		
		// View Source for IE 	 
		if (browserName == "Microsoft Internet Explorer") {
			var iHTML = getDocument.body.innerHTML;
		}
	  // View Source for Mozilla/Netscape
		else {
			var html = document.createTextNode(getDocument.body.innerHTML);
		}	
		var texto=iHTML;
	} else {
			var browserName = navigator.appName;
			// for IE 	 
			if (browserName == "Microsoft Internet Explorer") {
				var texto=document.getElementById('txtValor_'+jcampo).value;
			}
		  // for Mozilla/Netscape
			else {
				var texto=document.getElementById('txtValor_'+jcampo).value;
			}
	}
	

  	var capa=$("#"+contenedorCapa);
	capa.html("Guardando...");
	$.get("librerias/valores_actualizar.php",{contenedor:contenedorCapa,capa:nombreCapa,campo:jcampo,username:jusername,cadena:texto,ancho:anchoCelda},retorna_valor); 
 	//capa.load("librerias/actualiza_valores.php?campo="+jcampo+"&username="+jusername+"&capa="+nombreCapa+"&contenedor="+contenedorCapa+"&cadena="+texto);

}

function retorna_valor(string){
	//window.alert(string);
	var cadena=string;
	var pos_ini=cadena.indexOf("START"); //alert(pos_ini);
	var pos_fin=cadena.indexOf("END"); //alert(pos_fin);
	var contenedor=(cadena.substring(pos_ini+5,pos_fin)); 
	//alert(cadena.length);
	var longitud=(cadena.length);
	cadena=cadena.substring(pos_fin+3,longitud);
	//var pos_ini='1';
	//alert(cadena.indexOf("START"));return;

	var x=$("#"+contenedor);
	x.html("Guardando...");
 	x.html(cadena);
	
}

function mostrarAcerca(){
	//alert("editar");return;
  var capa=$("#div_acerca");
  capa.text("Cargando informacion...");
  capa.load("mostrar_acerca.php");

}

function editarAcerca(){
	//alert("editar");return;
	document.getElementById("div_acerca").style.height='auto';
  var capa=$("#div_acerca");
  capa.text("Cargando formulario...");
  capa.load("editar_acerca.php");

}

function editarSobre(){
	document.getElementById("div_sobre").style.height='auto';
	//alert("editar");return;
	var capa=$("#div_sobre");
	capa.text("Cargando formulario...");
	capa.load("editar_sobre.php");

}

function cargarEditorWysywyn(){
  var capa=$("#div_meConsidero");
  capa.text("Cargando formulario...");
  capa.load("area-w.php");
	//document.getElementById("miarea").value="valores";	
}

function editarMeConsidero(){
	document.getElementById("div_meConsidero").style.height='auto';
	//alert("editar");return;
  var capa=$("#div_meConsidero");
  capa.text("Cargando formulario...");
  capa.load("editar_meConsidero.php");

}

function textoLimite(objeto,maximo){
	var nombre=objeto.id;
	var caracteres=(objeto.value).length;
	if(caracteres>maximo) {
		objeto.value = objeto.value.substring(0,maximo);		
	}	

}

function textoLimite2(objeto,maximo){
	var nombre=objeto.id;
	var caracteres=(objeto.value).length;
	if(caracteres>maximo) {
		objeto.value = objeto.value.substring(0,maximo);		
	}	
	
	var x=$("#div_"+nombre);
	x.css("display","block");
	
	disponible=400-caracteres;
	x.text(disponible);

}

function ocultarLimite(objeto){
	var x=$("#div_"+objeto);
	//disponible=400-caracteres;
	x.css("display","none");


}

function aleatorio(inferior,superior){ 
    numPosibilidades = superior - inferior ;
    aleat = Math.random() * numPosibilidades; 
    aleat = Math.round(aleat) ;
    return parseInt(inferior) + aleat ;
} 


function cargarFotos(){
	//window.alert("cancelar");
		var cod_miembro=$("#id_usuario").attr("value"); 
		//alert(cod_miembro);
		//ajax=nuevoAjax(); 
        //ajax.open("GET", "ajax_cache_2.php?accion=mostrar&aleatorio="+aleatorio,
		var aleat=aleatorio(100000,999999);
		$.get("librerias/cargar_fotos.php",{userid:cod_miembro,paraletorio:aleat},mostrarFotos); 
	//	return false;
}

function cargarFotosAmigo(){
	//window.alert("cancelar");
		var cod_miembro=$("#cod_amigo").attr("value"); 
		//alert(id_auto);
		
		$.get("librerias/cargar_fotos_amigo.php",{userid:cod_miembro},mostrarFotos); 
		return false;
}


function eliminaFotos(fotoURL){
	//window.alert("cancelar");
		var j_url=fotoURL;
		var cod_miembro=$("#id_usuario").attr("value"); 
		//var x=$("#divFotos");
		$.get("librerias/eliminar_fotos.php",{userid:cod_miembro,url:j_url},mostrarFotos); 
		//return false;
		var aleat=aleatorio(1000000000,9999999999);
		var capa=$("#div_avatar");
		capa.load("librerias/recargar_avatar.php?userid="+cod_miembro+"&aleatorio="+aleat);
}

function actualizaFotos(fotoURL){
	//window.alert("cancelar");
		var j_url=fotoURL;
		var cod_miembro=$("#id_usuario").attr("value"); 
		//var x=$("#divFotos");
		var aleat=aleatorio(1000000000,9999999999);
		
		$.get("librerias/cargar_fotos.php",{userid:cod_miembro,url:j_url,al:aleat},mostrarFotos); 
		var capa=$("#div_avatar");
		//capa.text("Cargando...");
		//window.alert(cod_miembro);
		  
		capa.load("librerias/cargar_avatar.php?userid="+cod_miembro+"&aleatorio="+aleat+"&url="+j_url);

		//return false;
}

function mostrarFotos(fotos){
	//window.alert("cancelar");
	var x=$("#divFotos");
	x.text("Cargando fotos...");
 	x.html(fotos);
	
	
}

function invitacion(idusuario,idamigo,opcion){
	//window.alert("cancelar");
	var x=$("#divFotos");
 	x.html(fotos);
	
}

function seleccionarCheck(valor){
	//window.alert(valor);
	//if(valor){}
	var num_select=document.getElementById("seleccionados").value;
	document.getElementById("seleccionados").value="";
	if(valor){
		var nuevo=parseInt(num_select)+1;
	document.getElementById("seleccionados").value=nuevo;
		} else {
		var nuevo=parseInt(num_select)-1;
	document.getElementById("seleccionados").value=nuevo;
		}
	//document.getElementById("accion").value="eliminarMensajes";
	//document.getElementById("form_eliminarMensajes").submit;
	//return true
}
function todos(chkbox)
{

var count=0;
for (var i=0;i < document.form_eliminarMensajes.elements.length;i++)
	{
	
	var elemento = document.form_eliminarMensajes.elements[i];
	
	if (elemento.type == "checkbox")
		{
		elemento.checked = chkbox.checked;
		count++;
		}
	}
document.getElementById("seleccionados").value=(count-1);

	var check_todos=document.getElementById("arr_todos").checked; 
	if(check_todos==false){
		document.getElementById("seleccionados").value=0;
	}

}

function todos_postal(chkbox)
{

var count=0;
for (var i=0;i < document.form_enviar_postales.elements.length;i++)
	{
	
	var elemento = document.form_enviar_postales.elements[i];
	
	if (elemento.type == "checkbox")
		{
		elemento.checked = chkbox.checked;
		count++;
		}
	}
document.getElementById("seleccionados").value=(count-1);

	var check_todos=document.getElementById("arr_todos").checked; 
	if(check_todos==false){
		document.getElementById("seleccionados").value=0;
	}

}

function eliminarMensajes(){
	var seleccionados=document.getElementById("seleccionados").value;
	if(seleccionados>0)  {
		document.getElementById("accionMSG").value="eliminarMensajes"; //return false;
		document.form_eliminarMensajes.submit(); 
		//window.alert("Eliminando mensajes...");		
		} else {
			window.alert("Debes seleccionar al menos un mensaje para eliminar!");
		}
}



function bloquearUsuarios(){
	var seleccionados=document.getElementById("seleccionados").value;
	if(seleccionados>0)  {
		document.getElementById("accionMSG").value="bloquearUsuarios"; //return false;
		document.form_eliminarMensajes.submit(); 
		//window.alert("Eliminando mensajes...");		
		} else {
			window.alert("Debes seleccionar al menos un mensaje para bloquear usuario!");
		}
}

function responderMensaje(){
	//var seleccionados=document.getElementById("seleccionados").value;
	//if(seleccionados>0)  {
		document.getElementById("accionMSG").value="eliminarMensajes"; //return false;
		document.form_eliminarMensajes.submit(); 
		//window.alert("Eliminando mensajes...");		
}

function responderMensaje(){
	//var seleccionados=document.getElementById("seleccionados").value;
	//if(seleccionados>0)  {
		document.getElementById("accionMSG").value="eliminarMensajes"; //return false;
		document.form_eliminarMensajes.submit(); 
		//window.alert("Eliminando mensajes...");		
}

function eliminarMensaje(){
	//var seleccionados=document.getElementById("seleccionados").value;
	//if(seleccionados>0)  {
		//document.getElementById("accionMSG").value="eliminarMensajes"; //return false;
		document.form_eliminarMensaje.submit(); 
		//window.alert("Eliminando mensajes...");		
}

function SelectArtilugio(valor){
		//alert(valor);
		document.getElementById("flagArtilugio").value=valor; //return false;

}

function bloquearUsuario(){
		//window.alert("bloquear");
		var j_accion="bloquear_usuario";
		var user=$("#id_para").attr("value"); ;
		var user_bloqueado=$("#id_desde").attr("value"); 
		//var x=$("#divFotos");
		
		$.post("includes/miembros.php",{accion:j_accion, id_desde:user,id_para:user_bloqueado},mostrarBloqueo); 
		//return false;
}

function mostrarBloqueo(bloqueo){
	//window.alert("cancelar");
	var x=$("#div_bloquearUser");
	x.text("Bloqueando...");
 	x.html(bloqueo);
	//window.refresh();
	
}

function desbloquearUsuario(id_bloqueado){
		//window.alert("bloquear");
		var j_accion="desbloquear_usuario";
		var user=$("#id_usuario").attr("value"); ;
		var user_bloqueado=id_bloqueado; 
		//var x=$("#divFotos");
		
		$.post("includes/miembros.php",{accion:j_accion, id_desde:user,id_para:user_bloqueado},mostrarDesbloqueo); 
		//return false;
}

function mostrarDesbloqueo(desbloqueo){
	//window.alert(desbloqueo); return false;
	var id=desbloqueo;
	var x=$("#div_desbloq_"+id+"");
	x.text("desbloqueando...");
 	x.html('Desbloqueado');
	//window.refresh();
	
}

function desbloquearUsuarios(){
	var seleccionados=document.getElementById("seleccionados").value;
	if(seleccionados>0)  {
		document.getElementById("accionMSG").value="desbloquearUsuarios"; //return false;
		document.form_bloqueados.submit(); 
		//window.alert("Eliminando mensajes...");		
		} else {
			window.alert("Debes seleccionar al menos un usuario para desbloquear!");
		}
}
function cargar_lista_online(){

		var cod_miembro=$("#miembro_id").attr("value"); 
		var aleat=aleatorio(1000000000,9999999999);
		var capa=$("#div_amigos_online2");
		//capa.html("Cargando lista...");
		capa.load("librerias/amigos_online.php?userid="+cod_miembro+"&aleatorio="+aleat);


}

	function playSound() {
	  document.all.sound.src = "sounds/dop.wav"
	}

function chat_pendientes(){

		//var cod_miembro=$("#miembro_id").attr("value"); 
		var cod_miembro=document.getElementById("miembro_id").value; 
		var aleat=aleatorio(1000000000,9999999999);
		//var capa=$("#div_amigos_online2");
		//capa.html("Cargando lista...");
		//capa.load("librerias/amigos_online.php?userid="+cod_miembro+"&aleatorio="+aleat);
		$.get("librerias/chat_pendientes.php?aleatorio="+aleat+"",{id_desde:cod_miembro,randon:aleat},recibir_chat_pendientes); 
}

function recibir_chat_pendientes(dataPendientes){
	//alert(dataPendientes);
	var cadena=dataPendientes;
	if(cadena!=''){
		trozos = cadena.split ("-"); 
		nuevos=trozos.length;
		if(trozos[0]=='bandera'){
			//alert(nuevos);
			for( var a = 1; a < nuevos; a++){
				var codigo=trozos[a];
				//alert(codigo);
				window.open('ChatMMN/iniciarChat.php?codigo='+codigo+'&estado=online&estilo=2', '_blank', 'width = 500px, height = 550px, resizable=no,  scrollbars=no, top=100, left=200');
				//window.open("","","");
				//playSound();
			}
		}
	}
}

function enviar_invitacion_chat(){
		var desde=document.getElementById("id_desde").value; 
		//$("#id_desde").attr("value"); 
		var para=document.getElementById("id_para").value; 
		//alert(cod_miembro);
		//ajax=nuevoAjax(); 
        //ajax.open("GET", "ajax_cache_2.php?accion=mostrar&aleatorio="+aleatorio,
		var aleat=aleatorio(100000,999999);
		$.get("../librerias/invitacion_chat.php",{iddesde:desde,idpara:para},recibir_chat); 
	//	return false;
}

function recibir_chat(data_chat){
			var capa=$("#div_respuesta_chat");
			capa.html(data_chat);
}


