function cargarMainOnline(idPerfil){
	mostrarListasAzar = false;
	new Ajax.Request('new_mainOnline.php',
			{
				onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('loginChanger').innerHTML=response;
				
				Event.observe('menuTopHome', 'click', cargarMenuPerfil.curry('miscosas', false, '', null), false);
				Event.observe('menuTopHome', 'click', cargarHomeOnline, false);
				Event.observe('menuTopBuscarle', 'click', cargarMenuPerfil.curry('', true), false);
				Event.observe('menuTopBuscarle', 'click', cargarBuscadorOnline, false);
				Event.observe('menuTopComerciales', 'click', cargarMenuPerfil.curry('', true), false);
				Event.observe('menuTopComerciales', 'click', cargarMiraComercialesOnline, false);
				Event.observe('menuTopTarjetas', 'click', cargarMenuPerfil.curry('', true), false);
				Event.observe('menuTopTarjetas', 'click', cargarEnviaTarjetasOnline, false);
				
				Event.observe('lnkCerrarSesion', 'click', cerrarSesion);
				//Event.observe('btnWidget', 'click', function(){$('btnWidget').href = "./instalar/";}, false);
				
				cargarDatosPerfilND();
				if(idPerfil > 0){
					recibirPerfilP(idPerfil, 'home', "");
				}
				else{
					if(typeof(entraPorSeccion) != 'undefined'){
							switch(entraPorSeccion){
								case 'tarjetas':
									cargarEnviaTarjetasOnline();
									break;
							}
							
					}else{
						cargarHomeOnline();
						//mostrarVideoPromoDiaDelAmigo();
					}
				}
			}
		});		
}

function cargarMenuPerfil(sopala, vaciar, textSolapa, funcion){
	textSolapa = (textSolapa)? textSolapa : '';
	if(vaciar){
		$('divMenuUsuario').innerHTML="<div style=\"height:30px;\"></div>";
	}else{
		new Ajax.Request('new_cargarMenuPerfil.php?solapa='+sopala+'&textsolapa='+textSolapa,
				{
					onSuccess: function(transport){
					var response = transport.responseText || "Se produjo un error en el servidor";
					$('divMenuUsuario').innerHTML=response;
					if(textSolapa == ''){
						Event.observe('MisCosas', 'click', cargarHomeOnline, false);
						Event.observe('MiPerfil', 'click', cargarMiPerfil, false);
						Event.observe('MisListas', 'click', cargarVerMisListas, false);
						Event.observe('MisLocales', 'click', cargarMisLocales,false);
						Event.observe('MisDatos', 'click', cargarMisDatos,false);
					}else{
						Event.observe('solapaCerrar', 'click', funcion, false);
					}
				}
			});
	}
}

function cargarDatosPerfilND(){
	new Ajax.Request('cargarDatosPerfil.php',
		{
			onSuccess: function(transport){
			var datos = transport.responseText.evalJSON();
			$("divLeftTitulo").innerHTML=unescape(encodeURIComponent(datos[0].divLeftTitulo));
			var divLeftTop="";
			if (datos[0].thumb=='NULL' || datos[0].thumb==''){
				divLeftTop+="<img src=\"img/silueta.jpg\" width=\"100\" height=\"100\" /><br>";
			}else{
				divLeftTop+="<img src=\"pics/"+datos[0].thumb+"\" width=\"100\" height=\"100\" /><br>";
			}
			var divLeftBottom="<a href=\"#\" id=\"lnkSolicitud\" class=\"enlacevc\">"+datos[0].solicitudes+" solicitud";
			if(datos[0].solicitudes!=1){
			divLeftBottom+="es";
			}
			divLeftBottom+=" de amigos</a><br>";
			//divLeftBottom+="<a href=\"#\" id=\"lnkLista\" class=\"enlacevc\">tengo "+datos[0].listas;
			//if(datos[0].listas>1){
			//	divLeftBottom+=" listas de regalos</a>";
			//}else{
			//	divLeftBottom+=" lista de regalos</a><br><br>";
			//}
			divLeftBottom+="<br><a href=\"#\" id=\"lnkBuscarAmigosP\" class=\"enlace\">Buscar amigos</a>";
			divLeftBottom+="<br><a href=\"#\" id=\"lnkEnviarAmigoP\" class=\"enlace\">Invitar amigos</a>";
			divLeftBottom+="<br><br><table cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"http://static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981\">&nbsp;</td><td valign=\"middle\"><a href=\#\" onclick=\"return fbs_click("+datos[0].usuario_id+")\" target=\"_blank\" class=\"enlace\">Compart&iacute; en Facebook</a></td></tr></table>";
			
			divLeftBottom+=datos[0].amigos;
			$("divLeftTop").innerHTML=unescape(encodeURIComponent(divLeftTop));
			$("divLeftBottom").innerHTML=unescape(encodeURIComponent(divLeftBottom));
			if(datos[0].solicitudes>0){
				Event.observe('lnkSolicitud', 'click', cargarSolicitudes);
			}
			Event.observe('lnkBuscarAmigosP', 'click', cargarBuscarListaOnline, false);
			Event.observe('lnkEnviarAmigoP', 'click', cargarInvitarAmigosRedOnline,false);
			
		}
	  });	
}


function cargarEnviarAmigoOnline(){
	cargarMenuPerfil('solapacerrar', false, 'Invitar amigos', cargarHomeOnline);
	
	new Ajax.Request('new_cargarEnviarAmigoP.php',{
			onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response;
				
				Event.observe('lnkEnviarMail', 'click', validarAmigosP);
		/*		
				switch(ubicacion){
					case 'registrarse':
//						$('lnkSaltear').innerHTML = "<img src=\"img/btn_siguiente.jpg\" border=\"0\"/>";
						break;
					case 'buscador':
						$('lnkSaltar').innerHTML = "<img src=\"img/btn_volver.jpg\" border=\"0\"/>";
						Event.observe('lnkSaltar', 'click', recibirBuscadorND.curry(param_url),false);
						break;
					default:
						$("lnkSaltear").style.display = "none";
						break;
				}*/
			}
		});
}


function cargarInvitarAmigosRedOnline(){
	switchMenuOnline(5);
	cargarMenuPerfil('solapacerrar', false, 'Invitar amigos', cargarHomeOnline);
	new Ajax.Request('new_cargarInvitarAmigosRedP.php',
	{
		onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$("divContenido").innerHTML = response;
			
				
			new Ajax.Request(' ./guiye/OpenInviter/exampleP.php',
			{
				method: 'get',
				onSuccess: function(transport){
					var response = transport.responseText || "Se produjo un error en el servidor";
					$("formInvitarContactos").innerHTML = response;
					
					Event.observe('btnImportarContactos', 'click', window.parent.cargarBuscarContactosRedOnline, false);
				}
			});
			
			//Event.observe('lnkSiguiente', 'click', cargarRegistracionSatisfactoria, false);
			Event.observe('enviarMailAmigo', 'click', cargarEnviarAmigoOnline, false);
		}
	});
}


function cargarBuscarContactosRedOnline(){
	valores = $("frmInviteFriends").serialize();
	if($("formInvitarContactos")){
		loading("formInvitarContactos", 100, 1);
	}
	//document.forms.openinviter.submit()	
	new Ajax.Request('./guiye/OpenInviter/exampleP.php',
	{
		parameters: valores,
		onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			new Ajax.Request('new_cargarInvitarAmigosRedResultadosP.php',
				{
					onSuccess: function(transport){
						var response2 = transport.responseText || "Se produjo un error en el servidor";
						$("divContenido").innerHTML = response2;
						$("divResultados").innerHTML = response;
						
						Event.observe('lnkVolver', 'click', cargarInvitarAmigosRedOnline);
						Event.observe('send', 'click', window.parent.cargarBuscarContactosRedOnline);
						Event.observe('send2', 'click', window.parent.cargarBuscarContactosRedOnline);
					}
				});
		}
	});
}

function cargarBuscarListaOnline(){
	switchMenuOnline(5);
	cargarMenuPerfil('solapacerrar', false, 'Buscar amigos', cargarHomeOnline);
	
	new Ajax.Request("new_cargarBuscarListaP.php", {
		onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$("divContenido").innerHTML=response;
			
			Event.observe('btnBuscarRegalos', 'click', validarBuscadorND.curry(true));
		}
	});
}


function cargarResultadosBuscadorListaOnline(datos, param_url){
	cargarMenuPerfil('solapacerrar', false, 'Buscar amigos', cargarHomeOnline);
	new Ajax.Request("new_cargarResultadosBuscadorListaP.php",{
		onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$("divContenido").innerHTML=response;
			
			// armo la estructura de los resultados
			htmlDatos = "";
			if(datos.length > 0 && datos[0].id > 0){
				
				mes = ['cero','enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
				
				for(i=0; i<datos.length; i++){
					htmlDatos += "<table width=\"500px\" bgcolor=\"#E3F2F2\" style=\"margin-top:10px;\">";
					htmlDatos += "	<tr>";
					htmlDatos += "		<td rowspan=\"3\" width=\"90px\"><a href=\"#\" id=\"lnkVerPerfil"+datos[i].id+"\">";
					htmlDatos += 			datos[i].thumb;
					htmlDatos += "		 </a></td>";
					htmlDatos += "		<td class=\"texto\">";
					htmlDatos += 			datos[i].nombre+" "+datos[i].apellido;
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "	 <tr>";
					htmlDatos += "		<td class=\"textopeque\">";
					
					fecha=datos[i].edad.split("-");
					htmlDatos += "			Mi cumplea&ntilde;os es el "+fecha[2]+" de "+mes[parseInt(fecha[1], 10)];
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "	 <tr>";
					htmlDatos += "		 <td align=\"right\">";
					htmlDatos += "			<a href=\"#\" id=\"lnkVerPerfil1"+datos[i].id+"\"><img src=\"img/btn_vermislistas_a.gif\" border=\"no\"/></a>";
					htmlDatos += "		<span id=\"spnEstado"+datos[i].id+"\" class=\"textopeque\">";
										switch(datos[i].seguime){
											case 0:
												htmlDatos+="<a href=\"#\" id=\"lnkSeguime"+datos[i].id+"\"><img src=\"img/seamosamigos.gif\" border=\"0\" /></a>";
												break;
											case 1:
												htmlDatos+="";
												//htmlDatos+="<a href=\"#\" id=\"lnkSeguime"+datos[i].id+"\"><img src=\"img/dejardeseramigo.png\" border=\"0\" /></a>";
												break;
											case 2:
												htmlDatos+="Amistad pendiente";
												break;
											default:
												htmlDatos+="";
										}
					htmlDatos += "		</span>";
//					htmlDatos += "			<img src=\"img/seamosamigos.png\" border=\"no\"/>";
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "</table>";
				}
			}
			
			$("divResultados").innerHTML = htmlDatos;
			
			if(datos[0].id!=0){
				for(i=0; i<datos.length; i++){
					id=datos[i].id;
					nombre=datos[i].nombre+" "+datos[i].apellido;
					Event.observe('lnkVerPerfil'+id, 'click', recibirPerfilP.curry(id, 'buscador', nombre, param_url), false);
					Event.observe('lnkVerPerfil1'+id, 'click', recibirPerfilP.curry(id, 'buscador', nombre, param_url), false);
					if(datos[i].seguime==0){
						Event.observe('lnkSeguime'+id, 'click', recibirSeguime.curry(id, ''), false);
					}
				}
			}
			
			Event.observe('lnkBuscador', 'click', cargarBuscadorOnline);
			Event.observe('lnkInvitarla', 'click', cargarInvitarAmigosRedOnline,false);
			
		}
	});
}
	



function cargarHomeOnline(){
	switchMenuOnline(1);
	cargarMenuPerfil('miscosas', false);
	new Ajax.Request('new_cargarHomeOnline.php',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
			cargarEventos();
			//cargarDatosPerfil();
			Event.observe('lnkEnviarPensamiento', 'click', recibirPensamientos);
		}
	  });	
}

function cargarMiPerfil(){
	cargarMenuPerfil('miperfil', false);
	new Ajax.Request('new_cargarUnPerfil.php?usr_id=0',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
			cargarMisEventos(0, true);
			cargarListas(0, 0);
			cargarLocales(0);
			
		}
	  });	
}


function cargarBuscadorOnline(){
	switchMenuOnline(2);
	new Ajax.Request('new_cargarBuscador.php',
			{
				onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response;
				Event.observe('btnBuscarUni', 'click', validarBuscarleND.curry(true));
			}
		});	
}

function cargarEstadisticasRegalosOnline(regalos, locales, param){
	new Ajax.Request("new_cargarEstadisticasRegalosP.php?"+param,
		{
			onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML = response;
				$('divRegalos').innerHTML = regalos;
				$('divLocales').innerHTML = locales;
				
				Event.observe('lnkVolver', 'click', cargarBuscadorOnline,false);
				Event.observe('lnkEnviarListaMail', 'click', cargarEnviarListaMailOnline.curry(param),false);
				Event.observe('lnkImprimir', 'click', cargarImprimirRegalosOnline.curry(param),false);
		}
	});

}


function cargarEnviarListaMailOnline(url){
	
	var hidden="";
	checkboxs = document.getElementsByName("check");
	for(index = 0; index < checkboxs.length; index++){
		if(checkboxs[index].checked){
			hidden+=checkboxs[index].value+"---";
		}
	}
	if(hidden != ""){
		new Ajax.Request('new_cargarEnviarListaMailP.php',
		{
			onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response
				$('hdnRegalos').value=hidden;
				Event.observe('lnkEnviarListaMail', 'click', validarListaMail);
				Event.observe('lnkVolver', 'click', recibirBuscarUniND.curry(url, true),false);
			}
		});
	}else{
		$("divError").innerHTML = "Ten&eacute;s que seleccionar los regalos de la lista";
	}
}


function cargarImprimirRegalosOnline(url){
	var hidden="";
	var regalos = new Array;
	indexRegalos = 0;
	checkboxs = document.getElementsByName("check");
	for(index = 0; index < checkboxs.length; index++){
		if(checkboxs[index].checked){
			regalos[indexRegalos] = checkboxs[index].value;
			indexRegalos++;
		}
	}
	if(indexRegalos > 0){
		new Ajax.Request('new_cargarImprimirP.php',
		{
			onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response
				
				html = "<table class='texto'>";
				for(index = 0;index < regalos.length;index++){
					html += "<tr><td>&bull;"+regalos[index]+"</td></tr>";
				}
				html += "</table>";
				$("divElegidos").innerHTML = html;
				//Event.observe('lnkEnviarListaMail', 'click', validarListaMail);
				Event.observe('lnkVolver', 'click', recibirBuscarUniND.curry(url, true));
			}
		});
	}else{
		$("divError").innerHTML = "Ten&eacute;s que seleccionar los regalos de la lista";
	}
}

//*////////////////////////////////////////////////////////////////*//
//* EDICION DE LISTAS

function cargarVerMisListas(){
	cargarMenuPerfil('mislistas', false);
	new Ajax.Request('new_cargarVerMisListas.php',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
			cargarEditarListas();
			Event.observe('btnAltaLista', 'click', validarListaP);
		}
	  });	
}

function cargarEditarListas(){
	new Ajax.Request('cargarEditarListas.php',
		{
			onSuccess: function(transport){
			//cargarDatosPerfil();
			var datos = transport.responseText.evalJSON() || "Se produjo un error en el servidor";
			
			html="<table cellpadding=\"0\" cellspacing=\"0\" width=\"235\">";
//			html+="<tr><td colspan=\"2\" background=\"img/barrab_up.png\" width=\"235\" height=\"10\" style=\"background-repeat:no-repeat;\"></td></tr>";
			for(i=0; i<datos.length; i++){
				if(datos[i].lista_id==0){
					html+="<tr><td height=\"30\" width=\"80%\" class=\"textob\" bgcolor=\"#B6DBE1\" align=\"left\">"
							"&nbsp;&nbsp;&bull;&nbsp;"+datos[i].nombre+"</td>"
							"<td bgcolor=\"#B6DBE1\" width=\"10%\">"
							"</td></tr>";
				}else{
					html+="<tr><td height=\"30px\" width=\"220px\" class=\"textob\" style=\"padding-left:10px;background-color:#B6DBE1;\" align=\"left\">"+
									"&bull;&nbsp;"+datos[i].nombre+
									"<div id=\"divConfirmarBorrar"+i+"\" style=\"display:none;\" class=\"error\">"+
									"&nbsp;&nbsp;&nbsp;&nbsp;&iquest;Vas a borrar tu lista?&nbsp;&nbsp;&nbsp;"+
									"<a href=\"#\" id=\"lnkSi"+i+"\" class=\"error\"><b>Si</b></a>&nbsp;&nbsp;&nbsp;"+
									"<a href=\"#\" id=\"lnkNo"+i+"\" class=\"error\"><b>No</b></a></div></td>"+
								"<td bgcolor=\"#B6DBE1\" width=\"70px;\" style=\"padding-right:5px;\">"+
									"<a href=\"#\" id=\"lnkLista"+i+"\" class=\"medianab\">"+
									"<img src=\"img/btn_editar.gif\" border=\"0\"></a>"+
									"<a href=\"#\" id=\"lnkBorrarLista"+i+"\" class=\"medianab\">"+
									"<img src=\"img/tacho_basuraa.gif\" border=\"0\" style=\"margin-left:3px;\"></a></td>"+
							"</tr>";
				}
			}
//			html+="<tr><td colspan=\"2\" background=\"img/barrab_down.png\" width=\"235\" height=\"10\" style=\"background-repeat:no-repeat;\"></td></tr>";
			html+="</table>";
			
			$('divEditarListas').innerHTML=html;
			
			for(i=0; i<datos.length; i++){
	//			Event.stopObserving('lnkLista'+i, 'click');
				Event.observe('lnkLista'+i, 'click', cargarAltaRegalosOnline.curry(datos[i].lista_id, datos[i].nombre), false);
				Event.observe('lnkBorrarLista'+i, 'click', cargarConfirmarBorrarLista.curry(datos[i].lista_id, i), false);
			}
		}
	  });	
}


function cargarConfirmarBorrarLista2(lista_id){
	new Ajax.Request('cargarFlotanteMensajeSINO.php', {
//		onLoading: showLoad,
		onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			mostrarVentanaFlotante(response);
			
			$('txtMensaje').innerHTML="Est&aacute;s seguro que quieres eliminar la lista?";
			
			Event.observe('btnSi', 'click', recibirBorrarLista2.curry(lista_id), false);
			Event.observe('btnSi', 'click', function(){ocultarVentanaFlotante();}, false);
			Event.observe('btnNo', 'click', function(){ocultarVentanaFlotante();}, false);
		}
	});
}

function recibirBorrarLista2(lista_id){
	new Ajax.Request('recibirBorrarLista.php?lista_id='+lista_id,
		{
			onSuccess: function(transport){
			cargarMiPerfil();
		}
	});	
}

function cargarConfirmarBorrarLista(lista_id, i){
	Effect.BlindDown('divConfirmarBorrar'+i);
	Event.observe('lnkSi'+i, 'click', recibirBorrarLista.curry(lista_id), false);
	Event.observe('lnkNo'+i, 'click', retraerConfirmarBorrarLista.curry(i), false);
}

function retraerConfirmarBorrarLista(i){
	Effect.BlindUp('divConfirmarBorrar'+i);
}

function recibirBorrarLista(lista_id){
	new Ajax.Request('recibirBorrarLista.php?lista_id='+lista_id,
		{
			onSuccess: function(transport){
			cargarVerMisListas();
	//		cargarDatosPerfil();
		}
	});	
}


function cargarIngresarItemPropio(){
	$("divIngresoItemPropio").style.display = "";
//	Effect.BlindDown('divIngresoItemPropio');
}

function retraerIngresarItemPropio(){
	$("divIngresoItemPropio").style.display = "none";
	//Effect.BlindUp('divIngresoItemPropio');
}


function cargarAltaRegalosOnline(id_lista, nombre_lista){
	cargarMenuPerfil('mislistas', false);
	new Ajax.Request('new_cargarAltaRegalosP.php?id_lista='+id_lista+"&nombre_lista="+nombre_lista,
			{
				onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response;
				$('nombreLista').innerHTML = nombre_lista;
				
				Event.observe("lnkAgregar", 'click', validarPalabras.curry('txtNombreItemPropio', 'spnErrorNombreItem', 0));
				Event.observe("lnkListo", 'click', cargarVerMisListas);
				
				cargarContenidoItemsAlta();
			}
		});	
}


/*
function cargarDesplegarItems(posicion, lista_id, nombre_lista){
	new Ajax.Request('cargarItems.php?lista_id='+lista_id,
	{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			if(posicion=="Registro"){
				$('divItems').innerHTML=response;
				$('divItems').innerHTML+=unescape(encodeURIComponent("<div class=\"error\" align=\"left\" style=\"color:#999;\">Si te equivocas al escribir un regalo, simplemente hac&eacute; click sobre el cesto de basura para borrarlo.</div>"));
				$("spnNombreLista").innerHTML="";
				cargarDesplegarItems2(lista_id);
			}else{
				$('divInnerListas').innerHTML=response;
				$('divConfirmar').innerHTML=unescape(encodeURIComponent("<div class=\"error\" align=\"left\" style=\"color:#999;\">Si te equivocas al escribir un regalo, simplemente hac&eacute; click sobre el cesto de basura para borrarlo.</div>"))+"<br><a href=\"#\" id=\"lnkConfirmar\"><img src=\"img/botonlisto.jpg\" border=\"0\"></a>";
				Event.observe('lnkConfirmar', 'click', recibirEventoItem.curry(lista_id), false);
				cargarDesplegarItems1(lista_id);
			}
			$('divNombreLista').innerHTML=nombre_lista;
		}
	});	
}

function cargarDesplegarItems2(lista_id){
new Ajax.Request('cargarDesplegarItems.php?lista_id='+lista_id,
	{
		onSuccess: function(transport){
			var datos = transport.responseText.evalJSON() || "Se produjo un error en el servidor";
			html="<table cellpadding=\"0\" cellspacing=\"0\" width=\"220\">";
			for(i=0; i<datos.length; i++){
				if(datos[i].nombre!="La lista no tiene items"){
				html+="<tr><td width=\"90%\" class=\"textob\">&nbsp;&bull;&nbsp;"+datos[i].nombre+"</td><td bgcolor=\"#b6dee6\" width=\"10%\"><a href=\"#\" id=\"lnkBorrarItem"+i+"\" class=\"medianab\"><img src=\"img/botoncesto.jpg\" height=\"31\" width=\"28\" border=\"0\"></a></td></tr>";
				}
			}
			html+="</table>";
			$('divMostrarItems').innerHTML=html;
			Event.stopObserving('txtNombreItem');
			new Ajax.Autocompleter("txtNombreItem", "txtAutocomplete", "items.php", {paramName:"caracteres"});
//			Event.observe('txtNombreItem', 'focus', activarCampo);
			activarCampo();
			Event.stopObserving('btnAltaItem', 'click');
			Event.observe('btnAltaItem', 'click', validarItem.curry(lista_id), false);
			for(i=0; i<datos.length; i++){
				Event.observe('lnkBorrarItem'+i, 'click', recibirBorrarItem.curry(datos[i].item_id, lista_id), false);
			}
		}
  });	
}

function cargarDesplegarItems1(lista_id){
	new Ajax.Request('cargarDesplegarItems.php?lista_id='+lista_id,
		{
			onSuccess: function(transport){
				var datos = transport.responseText.evalJSON() || "Se produjo un error en el servidor";
				html="<table cellpadding=\"0\" cellspacing=\"0\" width=\"220\">";
				for(i=0; i<datos.length; i++){
					if(datos[i].nombre!="La lista no tiene items"){
					html+="<tr><td width=\"90%\" class=\"textob\">&nbsp;&bull;&nbsp;"+datos[i].nombre+"</td><td bgcolor=\"#b6dee6\" width=\"10%\"><a href=\"#\" id=\"lnkBorrarItem"+i+"\" class=\"medianab\"><img src=\"img/botoncesto.jpg\" height=\"31\" width=\"28\" border=\"0\"></a></td></tr>";
					}
				}
				html+="</table>";
				$('divMostrarItems').innerHTML=html;
				Event.stopObserving('txtNombreItem');
				new Ajax.Autocompleter("txtNombreItem", "txtAutocomplete", "items.php", {paramName:"caracteres"});
	//			Event.observe('txtNombreItem', 'focus', activarCampo);
				activarCampo();
				Event.stopObserving('btnAltaItem', 'click');
				Event.observe('btnAltaItem', 'click', validarItemP.curry(lista_id), false);
				for(i=0; i<datos.length; i++){
					Event.observe('lnkBorrarItem'+i, 'click', recibirBorrarItem.curry(datos[i].item_id, lista_id), false);
				}
			}
	  });
}

function cargarAltaItemsP(transport){
	var datos = transport.responseText.evalJSON();
	cargarEditarListas();
	cargarDesplegarItems('', datos[0].id, datos[0].nombre);
}
*/
//*////////////////////////////////////////////////////////////////*/



//*///////////////////////////////////////////////////////////////////////
//*//////    MIS LOCALES


function cargarMisLocales(){
	cargarMenuPerfil('mislocales', false);
	new Ajax.Request('new_cargarMisLocales.php',
			{
				onSuccess: function(transport){
				var response = transport.responseText || "Se produjo un error en el servidor";
				$('divContenido').innerHTML=response;
				Event.observe('btnVolver', 'click', cargarHomeOnline);
				
				cargarMarcarMisLocales('xxxx');
			}
		});	
}


function cargarMarcarMisLocales(filtro){
new Ajax.Request('cargarMarcarLocales.php?filtro='+filtro.value,
{
	onSuccess: function(transport){
		var datos = transport.responseText.evalJSON();
		
		Event.stopObserving('lnkFiltrar');
		generarTablaMisLocales(datos, filtro);
	}
//	onFailure: function(){ alert('Se produjo un error en el servidor');} 
});
}


function generarTablaMisLocales(datos, filtro){
	var col=0;

	var html="<form id=\"frmMarcarLocales\" name=\"frmMarcarLocales\" style=\"margin-bottom:0px;\">";
	html+="<table cellpadding=\"0\" cellspacing=\"3\">";

	for(i=0; i<datos.length; i++){

		if(col==0){
			html+="<tr>";
		}
		html+="<td id=\"td"+datos[i].id+"\" background=\"pics/"+datos[i].thumb+"\" width=\"82\" align=\"right\" valign=\"bottom\" height=\"76\" title=\""+datos[i].nombre+"\" style=\"background-repeat:no-repeat;border: 1px solid #A7D6DE;\">";

		if(datos[i].selected!=0){
			html+="<img src=\"img/tick.jpg\" height=\"12\" width=\"12\" border=\"0\" />";
		}

		col++;
		if(col==6){
			html+="</td></tr>";
			col=0;
		}else{
			html+="</td>";
		}

	}

	html+="</table></form>";

	$("divMarcarLocales").innerHTML=html;
	html="";
	
	Event.stopObserving('txtFiltrarLocales');
	new Ajax.Autocompleter("txtFiltrarLocales", "txtAutocompleteLocales", "locales.php", {paramName:"caracteres"});
	
	if(filtro && filtro!='xxxx'){
		$("divNoFiltrar").innerHTML="<a href=\"#\" id=\"lnkNoFiltrar\" class=\"lnk_blanco\">ver todos</a>";
	}else{
		$("divNoFiltrar").innerHTML="";
	}

	
	var par_filtrar=cargarMarcarMisLocales.curry($('txtFiltrarLocales'));
	Event.stopObserving('lnkFiltrar');
	Event.observe('lnkFiltrar', 'click', par_filtrar);

	if(filtro && filtro!='xxxx'){
		Event.observe('lnkNoFiltrar', 'click', cargarMarcarMisLocales.curry(''), false);
	}
	
	for(i=0; i<datos.length; i++){
		var parametros=recibirMarcarLocalesND.curry(datos, filtro, i);
		Event.observe('td'+datos[i].id, 'click', parametros);
	}
}

//*//////////////////////////////////////////////////////////////////////



function cargarMisDatos(){
	cargarMenuPerfil('misdatos', false);
	new Ajax.Request('new_cargarMisDatos.php',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
			//mostrarImagenP();
			Event.observe('lnkSiguiente', 'click', validarEditar.curry('recibirEditarDatos'), false);
			Event.observe('lnkBorrarCuenta', 'click', cargarConfirmarBorrarCuenta);
		}
	  });	
}


function cargarConfirmarBorrarCuenta(){
	Effect.BlindDown('divConfirmarBorrar');
	Event.observe('lnkSi', 'click', recibirBorrarCuenta);
	Event.observe('lnkNo', 'click', retraerConfirmarBorrarCuenta);
}

function retraerConfirmarBorrarCuenta(){
	Effect.BlindUp('divConfirmarBorrar');
}

function recibirBorrarCuenta(){
new Ajax.Request('recibirBorrarCuenta.php',
	{
		onSuccess: function(transport){
		cerrarSesion();
	}
  });	
}


function cargarMiraComercialesOnline(){
	switchMenuOnline(3);
	new Ajax.Request('new_cargarMiraComercialesP.php',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
		}
	  });	
	
}


function cargarEnviaTarjetasOnline(){
	switchMenuOnline(4);
	new Ajax.Request('new_cargarEnviaTarjetasP.php',
		{
			onSuccess: function(transport){
			var response = transport.responseText || "Se produjo un error en el servidor";
			$('divContenido').innerHTML=response;
			
			Event.observe('lnkEnviar', 'click', enviarTarjeta,false);
		}
	  });	
	
}



function cargarSolicitudes(){
	switchMenuOnline(5);
	cargarMenuPerfil('solapacerrar', false, 'Solicitudes', cargarHomeOnline);
new Ajax.Request('cargarSolicitudes.php',
{
	onSuccess: function(transport){
		var datos = transport.responseText.evalJSON();
		var htmlDatos="<center>";	
		if(datos[0].id!=0){
			var fecha;
				
			mes = ['cero','enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
				
			for(i=0; i<datos.length; i++){
					htmlDatos += "<div style='margin-top:30px;padding-bottom:50px;'>";
					htmlDatos += "<table width=\"400px;\" cellpadding=\"5\" bgcolor=\"#E3F2F2\" style=\"margin-top:10px;margin-bottom:10px;\" id=\"trSolicitud"+datos[i].amigo_id+"\">";
					htmlDatos += "	<tr>";
					htmlDatos += "		<td rowspan=\"3\"><a href=\"#\" id=\"lnkVerPerfil"+datos[i].amigo_id+"\">";
					htmlDatos += 			datos[i].thumb;
					htmlDatos += "		 </a></td>";
					htmlDatos += "		<td class=\"texto\" width=\"90%\" style=\"padding-left:10px;\">";
					htmlDatos += 			datos[i].nombre+" "+datos[i].apellido;
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "	 <tr>";
					htmlDatos += "		<td class=\"textopeque\"  style=\"padding-left:10px;\">";
					
					fecha=datos[i].edad.split("-");
					htmlDatos += "			Mi cumplea&ntilde;os es el "+fecha[2]+" de "+mes[parseInt(fecha[1], 10)];
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "	 <tr>";
					htmlDatos += "		 <td align=\"right\">";
					htmlDatos += "			<a href=\"#\" id=\"lnkRechazarSolicitud"+datos[i].amigo_id+"\"><img src=\"img/btn_ignorar.gif\" border=\"0\"></a>";
					htmlDatos += "			<a href=\"#\" id=\"lnkAceptarSolicitud"+datos[i].amigo_id+"\"><img src=\"img/btn_confirmar.gif\" border=\"0\"></a>";
//					htmlDatos += "			<img src=\"img/seamosamigos.png\" border=\"no\"/>";
					htmlDatos += "		 </td>";
					htmlDatos += "	 </tr>";
					htmlDatos += "</table>";
					htmlDatos += "</div>";
		
			}
		}else{
			htmlDatos+="<table><tr><td style=\"padding-top:20px; padding-left:20px;width:300px;\" class=\"texto\">No ten&eacute;s m&aacute;s solicitudes pendientes</td></tr></table>";
		}

		htmlDatos+="</center>";
		$('divContenido').innerHTML=htmlDatos;
		var id=0;
		if(datos[0].id!=0){
			for(i=0; i<datos.length; i++){
				id=datos[i].amigo_id;
				nombre=datos[i].nombre+" "+datos[i].apellido;
				Event.observe('lnkVerPerfil'+id, 'click', recibirPerfilP.curry(id, 'solicitud', datos[i].nombre+" "+datos[i].apellido), false);
				Event.observe('lnkAceptarSolicitud'+datos[i].amigo_id, 'click', recibirAceptarSolicitud.curry(datos[i].amigo_id), false);
			}
		}
	}
});
}
