/***** VARIAS ****/
function iSubmitEnter(oEvento, oFormulario){
     var iAscii;

     if (oEvento.keyCode)
         iAscii = oEvento.keyCode;
     else if (oEvento.which)
         iAscii = oEvento.which;
     else
         return false;

     if (iAscii == 13) oFormulario.submit();

     return true;
}

function cambiaProvincia(prov)
	{
	AjaxRequest("prov="+prov,'ajax/provincias.php', printprovinciasajax);
	}
	
function cambiaProvinciaSelect(prov)
	{
	AjaxRequest("prov="+prov+"&input_select=1",'ajax/provincias.php', printprovinciasajax);
	}
/***** VARIAS ****/
	
/***** USUARIOS *****/
/*
usuarios.php
*/

function parrillaUsuarios(limit,resultadosxpagina,orden,type,val,fotos,perfil,provincia,pais,genero,detallada,n,buscaDiasDisponibles,disponibilidad)
	{
	if(document.getElementById('paginador'))
		{
		document.getElementById('paginador').style.display='none';
		document.getElementById('cargando').style.display='block';
		}
	AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&orden=" + orden + "&type=" + type + "&val=" + val + "&fotos=" + fotos + "&perfil=" + perfil + "&provincia=" + provincia + "&pais=" + pais + "&genero=" + genero + "&detallada=" + detallada + "&n=" + n + "&buscaDiasDisponibles=" + buscaDiasDisponibles + "&disponibilidad=" + disponibilidad,'/ajax/usuarios.php', parrillausuariosajax);
	//$.getScript("js/usuarios.js");
	}

function parrillaUsuariosForm(limit,resultadosxpagina,orden,type,val,provincia,n)
	{
	if(document.filtroBuscadorUsuarios.detallada.checked) var detallada = 1; else var detallada = 0;
	if(document.filtroBuscadorUsuarios.fotos.checked) var fotos = 1; else var fotos = 0;
	if(document.filtroBuscadorUsuarios.perfil.checked) var perfil = 1; else var perfil = 0;
	
	if(document.filtroBuscadorUsuarios.pareja.checked) var pareja = 1; else var pareja = 0;
	if(document.filtroBuscadorUsuarios.chico.checked) var chico = 1; else var chico = 0;
	if(document.filtroBuscadorUsuarios.chica.checked) var chica = 1; else var chica = 0;
	if(!pareja && !chico && !chica){alert('Debes indicar que tipo de usuario buscas; parejas, chicos solos, etc...');return false;}	
	var genero = pareja+''+chico+''+chica;
	
	//Parche hasta poner en marcha DISPONIBILIDAD	
	if(document.filtroBuscadorUsuarios.disponible)
		{
		var buscaDiasDisponibles = document.filtroBuscadorUsuarios.buscaDiasDisponibles.value;
		if(document.filtroBuscadorUsuarios.disponible.checked) var disponible = 1; else var disponible = 0;
		
		//if(document.filtroBuscadorUsuarios.indeterminado.checked) var indeterminado = 1; else var indeterminado = 0; 
		//Forzado a 0, no buscar usuarios con esta opcion
		var indeterminado = 0;
		
		if(document.filtroBuscadorUsuarios.nodisponible.checked) var nodisponible = 1; else var nodisponible = 0;	
		if(!disponible && !indeterminado && !nodisponible && buscaDiasDisponibles!=''){alert('Si haces una busqueda en funcion de la disponibilidad del usuario, debes indicar si buscas usuarios con disponibilidad y/o disponibilidad sin determinar y/o sin disponibilidad');return false;}
		var disponibilidad = disponible+''+indeterminado+''+nodisponible;
		}
	
	var pais = document.filtroBuscadorUsuarios.pais.value;
	
	var provinciasform = '';
	for (i = 0; i < document.filtroBuscadorUsuarios.provincias.length; i++)
		{
		if (document.filtroBuscadorUsuarios.provincias[i].checked)
			{
			provinciasform += '#'+document.filtroBuscadorUsuarios.provincias[i].value;
			}
		}
		
	if(provinciasform != '') var provincia = provinciasform;
	
	document.getElementById('botonbuscar').style.display='none';
	document.getElementById('botoncargando').style.display='block';
		
	//Parche hasta poner en marcha DISPONIBILIDAD	
	if(document.filtroBuscadorUsuarios.disponible)
		{
		AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&orden=" + orden + "&type=" + type + "&val=" + val + "&fotos=" + fotos + "&perfil=" + perfil + "&provincia=" + provincia + "&pais=" + pais + "&genero=" + genero + "&detallada=" + detallada + "&n=" + n + "&buscaDiasDisponibles=" + buscaDiasDisponibles + "&disponibilidad=" + disponibilidad,'/ajax/usuarios.php', parrillausuariosajax);
		}
	else
		AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&orden=" + orden + "&type=" + type + "&val=" + val + "&fotos=" + fotos + "&perfil=" + perfil + "&provincia=" + provincia + "&pais=" + pais + "&genero=" + genero + "&detallada=" + detallada + "&n=" + n,'/ajax/usuarios.php', parrillausuariosajax);
	}
/***** USUARIOS *****/

/***** ANUNCIOS *****/
function parrillaAnuncios(limit,resultadosxpagina,type,val,fotos,interesadosen,provincia,pais,tags,identificador,referencia,n)
	{
	if(document.getElementById('paginador1'))
		{
		document.getElementById('paginador1').style.display='none';
		document.getElementById('cargando1').style.display='block';
		}
	if(document.getElementById('paginador2'))
		{
		document.getElementById('paginador2').style.display='none';
		document.getElementById('cargando2').style.display='block';
		}
		
	if(referencia)
		AjaxRequest("referencia=" + referencia,'/ajax/anuncios.php', parrillaanunciosajax);
	else
		AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&type=" + type + "&val=" + val + "&fotos=" + fotos + "&interesadosen=" + interesadosen + "&provincia=" + provincia + "&pais=" + pais + "&tags=" + tags + "&identificador=" + identificador + "&referencia=" + referencia + "&n=" + n,'/ajax/anuncios.php', parrillaanunciosajax);
	}

function parrillaAnunciosForm(limit,resultadosxpagina,provincia,n,marcador)
	{
	var identificador = document.find_a.identificador.value;
	var referencia = document.find_a.referencia.value;		
		
	if(marcador=='2')
		{	
		if(referencia==''){alert('Debes indicar una referencia');return}	
		AjaxRequest("referencia=" + referencia,'/ajax/anuncios.php', parrillaanunciosajax);
		return;
		}		
	
	if(marcador=='3')
		{
		if(identificador==''){alert('Debes indicar un nombre de usuario');return}
		AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&identificador=" + identificador + "&n=" + n,'/ajax/anuncios.php', parrillaanunciosajax);
		return;
		}		
		
	if(document.find_a.fotos.checked) var fotos = 1; else var fotos = 0;
	
	var detalles = '';
	
	var x_dias	= document.find_a.x_dias.value;
	var dia_x	= document.find_a.dia_x.value;
	var mes_x	= document.find_a.mes_x.value;	
	
	if(x_dias!='')
		{
		var type=1;
		var val=x_dias;
		}
	else if(dia_x!='')
		{
		var type=2;
		var val=dia_x;
		}
	else if(mes_x!='')
		{
		var type=4;
		var val=mes_x;
		}
	else
		{
		var type=1;
		var val=20;
		}	

	var pais = document.find_a.pais.value;
	var interesadosen = document.find_a.interesadosen.value;
	var tags = document.find_a.tags.value;
	
	var provinciasform = '';
	for (i = 0; i < document.find_a.provincias.length; i++)
		{
		if (document.find_a.provincias[i].checked)
			{
			provinciasform += '#'+document.find_a.provincias[i].value;
			}
		}
		
	if(provinciasform != '') var provincia = provinciasform;

	if(marcador)
		{
		switch(marcador)
			{
			case '1':
			document.getElementById('botonbuscar_1').style.display='none';
			document.getElementById('botoncargando_1').style.display='block';
			break;	
			
			case '2':
			document.getElementById('botonbuscar_2').style.display='none';
			document.getElementById('botoncargando_2').style.display='block';
			break;	

			case '3':
			document.getElementById('botonbuscar_3').style.display='none';
			document.getElementById('botoncargando_3').style.display='block';
			break;						
			}	
		}	
	
	AjaxRequest("limit=" + limit + "&resultadosxpagina=" + resultadosxpagina + "&type=" + type + "&val=" + val + "&fotos=" + fotos + "&interesadosen=" + interesadosen + "&provincia=" + provincia + "&pais=" + pais + "&tags=" + tags + "&n=" + n,'/ajax/anuncios.php', parrillaanunciosajax);
	}
/***** ANUNCIOS *****/

/***** MAILBOX *****/
function valida_nuevoMensajeMailbox(marcador) 
	{
	if(marcador)
		var nombreform = document.getElementById('nuevo_mensaje_mailbox'+marcador);
	else 
		var nombreform = document.getElementById('nuevo_mensaje_mailbox');
	
	if(nombreform.identificador.value == "" || nombreform.identificador.value == null) 
		{
		alert('Debes escribir el nombre de usuario de la cuenta a la que envias el mensaje');
		nombreform.identificador.focus();
		nombreform.identificador.style.background= '#556580';
		nombreform.identificador.style.color= '#FFF';		
		return;
		}
		
	if(nombreform.titulo.value == "" || nombreform.titulo.value == null) 
		{
		alert('No puedes dejar el campo ASUNTO vacio!');
		nombreform.titulo.focus();
		nombreform.titulo.style.background= '#556580';
		nombreform.titulo.style.color= '#FFF';			
		return;
		}
	
	if(nombreform.texto.value == "" || nombreform.texto.value == null) 
		{
		alert('Debes escribir un mensaje!');
		nombreform.texto.focus();
		nombreform.texto.style.background= '#556580';
		nombreform.texto.style.color= '#FFF';			
		return;
		}
	
	nombreform.submit();
	
	if(document.getElementById('status_email'))document.getElementById('status_email').style.display = 'none';
	if(document.getElementById('loading_email'))document.getElementById('loading_email').style.display = 'inline';
	}	
	
function compruebaIdentificadorOLD(marcador)
	{
	if(marcador)
		{
		//Version cuando hay varios formularios en la misma pagina
		var nombreform = 'nuevo_mensaje_mailbox'+marcador;
		var identificador = document.forms[nombreform].identificador.value;
		AjaxRequest("identificador=" + identificador + "&marcador=" + marcador + "&compruebaidentificador=true",'/ajax/mailbox.php', compruebaidentificadorajax);
		}
	else
		{
		var nombreform = 'nuevo_mensaje_mailbox'; 
		var identificador = document.forms[nombreform].identificador.value;
		AjaxRequest("identificador=" + identificador + "&compruebaidentificador=true",'/ajax/mailbox.php', compruebaidentificadorajax);
		}
	}
	
function compruebaIdentificador(marcador)
	{
	if(marcador)
		{
		//Version cuando hay varios formularios en la misma pagina
		var nombreform = document.getElementById('nuevo_mensaje_mailbox'+marcador);
		var identificador = nombreform.identificador.value;
		AjaxRequest("identificador=" + identificador + "&marcador=" + marcador + "&compruebaidentificador=true",'/ajax/mailbox.php', compruebaidentificadorajax);
		}
	else
		{
		var nombreform = document.getElementById('nuevo_mensaje_mailbox');
		var identificador = nombreform.identificador.value;
		AjaxRequest("identificador=" + identificador + "&compruebaidentificador=true",'/ajax/mailbox.php', compruebaidentificadorajax);
		}
	}	
	
function compruebaIdentificadorCoste(marcador)
	{
	if(marcador)
		//Version cuando hay varios formularios en la misma pagina
		var identificador = document.forms['nuevo_mensaje_mailbox'+marcador].identificador.value;
	else
		var identificador = document.forms['nuevo_mensaje_mailbox'].identificador.value;
	
	AjaxRequest("identificador=" + identificador + "&compruebaidentificadorcoste=true",'/ajax/mailbox.php', compruebaidentificadorcosteajax);
	}	
	
function cerrarConversacion(id_conversacion)
	{
	document.getElementById('label_conversacion_cerrando'+id_conversacion).style.display= 'block';
	document.getElementById('label_conversacion_abierta'+id_conversacion).style.display= 'none';
	AjaxRequest("id_conversacion=" + id_conversacion + "&cerrarconversacion=true",'ajax/mailbox.php', cerrarconversacionajax);
	}
	
function marcarComoLeido(id_mensaje,marcador,estado_in)
	{
	if(document.getElementById('gif_mensaje_nuevo'+marcador))document.getElementById('gif_mensaje_nuevo'+marcador).style.display= 'none';
	if(document.getElementById('gif_mensaje_nuevo_txt'+marcador))document.getElementById('gif_mensaje_nuevo_txt'+marcador).style.display= 'none';
	if(document.getElementById('gif_mensaje_antiguo'+marcador))document.getElementById('gif_mensaje_antiguo'+marcador).style.display= 'block';
	AjaxRequest("id_mensaje=" + id_mensaje + "&estado_in=" + estado_in + "&marcarcomoleido=true",'ajax/mailbox.php', marcarcomoleidoajax);
	}	
	
function moverConversacion(id_conversacion,estado_out,estado_in,estado_origen_destino,mensajes_no_leidos)
	{
	//estado_out -> estado al que va a pasar la conversacion
	//estado_in -> estado que tenia la conversacion. Se usa solo para restar una conversacion en columna derecha
	//estado_origen_destino -> En funcion de la conversacion, se modifica el estado_origen o estado_destino
	//mensajes_no_leidos -> El uso es similar a estado_in, solo para restar los mensajes
	AjaxRequest("id_conversacion=" + id_conversacion + "&estado_out=" + estado_out + "&estado_in=" + estado_in + "&mensajes_no_leidos=" + mensajes_no_leidos + "&estado_origen_destino=" + estado_origen_destino + "&moverconversacion=true",'ajax/mailbox.php', moverconversacionajax);
	}
/***** MAILBOX *****/	

/***** LOGIN ****/
function login_identificador()
	{
	var identificador = document.loginIdentificador.identificador.value;
	var email = document.loginIdentificador.email.value;
	var clave = document.loginIdentificador.clave.value;
	var referer = document.loginIdentificador.referer.value;
	
	if(document.loginIdentificador.recordar.checked)
	var recordar = 1; else var recordar = 0;
	
	document.getElementById('loading_login').style.display='block';
	if(document.getElementById('info_login'))document.getElementById('info_login').style.display='none';
	if(document.getElementById('container_login'))document.getElementById('container_login').style.display='none';
	
	AjaxRequest("identificador=" + identificador + "&email=" + email + "&clave=" + clave + "&recordar=" + recordar + "&referer=" + referer + "&loginidentificador=true",'/ajax/login.php', loginidentificadorajax);
	}
	
function login_identificador_header()
	{
	var identificador = document.getElementById('identificador_head').value;
	var email = document.getElementById('email_head').value;
	var clave = document.getElementById('clave_head').value;
	var referer = document.getElementById('referer_head').value;
	
	if(document.getElementById('recordar_head').checked)
	var recordar = 1; else var recordar = 0;
	
	document.getElementById('loading_login_header').style.display='block';
	if(document.getElementById('info_login_header'))document.getElementById('info_login_header').style.display='none';
	if(document.getElementById('container_login_header'))document.getElementById('container_login_header').style.display='none';
	
	AjaxRequest("identificador=" + identificador + "&email=" + email + "&clave=" + clave + "&recordar=" + recordar + "&referer=" + referer + "&loginidentificador=true",'/ajax/login.php', loginidentificadorheaderajax);
	}	
	
function emailValidacion()
	{
	var identificador = document.loginIdentificador.identificador.value;
	if(document.loginIdentificador.email) var email = document.loginIdentificador.email.value;
	var clave = document.loginIdentificador.clave.value;
	
	document.getElementById('loading_login').style.display='block';
	if(document.getElementById('info_login'))document.getElementById('info_login').style.display='none';
	if(document.getElementById('container_login'))document.getElementById('container_login').style.display='none';
	
	AjaxRequest("identificador=" + identificador + "&email=" + email + "&clave=" + clave + "&emailvalidacion=true",'/ajax/login.php', emailvalidacionajax);
	}	
	
function emailValidacion_header()
	{
	var identificador = document.loginIdentificador_header.identificador.value;
	if(document.loginIdentificador_header.email) var email = document.loginIdentificador_header.email.value;
	var clave = document.loginIdentificador_header.clave.value;
	
	document.getElementById('loading_login_header').style.display='block';
	if(document.getElementById('info_login_header'))document.getElementById('info_login_header').style.display='none';
	if(document.getElementById('container_login_header'))document.getElementById('container_login_header').style.display='none';
	
	AjaxRequest("identificador=" + identificador + "&email=" + email + "&clave=" + clave + "&emailvalidacion=true",'/ajax/login.php', emailvalidacionheaderajax);
	}	
/***** LOGIN ****/

/***** OPCIONES ADICIONALES ****/
function envio_sms()
	{
	var sms1 = document.gana_creditos.sms1.value;	
	var sms2 = document.gana_creditos.sms2.value;
	var sms3 = document.gana_creditos.sms3.value;
	var sms4 = document.gana_creditos.sms4.value;
	var sms5 = document.gana_creditos.sms5.value;
	
	if(sms1 == '' && sms2 == '' && sms3 == '' && sms4 == '' && sms5 == '')
		{
		alert('Debes introducir al menos, 1 codigo.');
		return false;
		}
	else 
		document.gana_creditos.submit();
	}

function envio_sms_mini_tarifa3()
	{
	var codigo = document.gana_creditos_tarifa.codigo.value;	
	
	if(codigo == '')
		{
		alert('Debes introducir al menos, 1 codigo.');
		return false;
		}
	else 
		AjaxRequest("codigo=" + codigo + "&minismstarifa3=true",'/ajax/comun.php', validasmsajax);
	}	
	
//Obsoleto con nueva tarificacion SMS 27/11/2009	
function envio_sms_mini()
	{
	var sms1 = document.gana_creditos_mini.sms1.value;	
	var sms2 = document.gana_creditos_mini.sms2.value;
	var sms3 = document.gana_creditos_mini.sms3.value;
	var sms4 = document.gana_creditos_mini.sms4.value;
	var sms5 = document.gana_creditos_mini.sms5.value;
	
	if(sms1 == '' && sms2 == '' && sms3 == '' && sms4 == '' && sms5 == '')
		{
		alert('Debes introducir al menos, 1 codigo.');
		return false;
		}
	else 
		AjaxRequest("sms1=" + sms1 + "&sms2=" + sms3 + "&sms3=" + sms3 + "&sms4=" + sms4 + "&sms5=" + sms5 + "&validasms=true",'/ajax/comun.php', validasmsajax);
	}

	
function ganaCreditos()
	{
	var acumula = 0;
	var inner = 0;
	var sms1 = document.gana_creditos.sms1.value;
	var sms2 = document.gana_creditos.sms2.value;
	var sms3 = document.gana_creditos.sms3.value;
	var sms4 = document.gana_creditos.sms4.value;
	var sms5 = document.gana_creditos.sms5.value;
	
	if(sms1 != "")acumula=acumula+1;
	if(sms2 != "")acumula=acumula+1;
	if(sms3 != "")acumula=acumula+1;
	if(sms4 != "")acumula=acumula+1;
	if(sms5 != "")acumula=acumula+1;
	
	if(acumula==1) inner = 10;
	else if (acumula==2) inner = 25;
	else if (acumula==3) inner = 40;
	else if (acumula==4) inner = 60;
	else if (acumula==5) inner = 90;
	else inner = 0;
	
	document.getElementById('creditos').innerHTML = inner;
	}

function ganaCreditos_mini()
	{
	var acumula = 0;
	var inner = 0;
	var sms1 = document.gana_creditos_mini.sms1.value;
	var sms2 = document.gana_creditos_mini.sms2.value;
	var sms3 = document.gana_creditos_mini.sms3.value;
	var sms4 = document.gana_creditos_mini.sms4.value;
	var sms5 = document.gana_creditos_mini.sms5.value;
	
	if(sms1 != "")acumula=acumula+1;
	if(sms2 != "")acumula=acumula+1;
	if(sms3 != "")acumula=acumula+1;
	if(sms4 != "")acumula=acumula+1;
	if(sms5 != "")acumula=acumula+1;
	
	if(acumula==1) inner = 10;
	else if (acumula==2) inner = 25;
	else if (acumula==3) inner = 40;
	else if (acumula==4) inner = 60;
	else if (acumula==5) inner = 90;
	else inner = 0;
	
	document.getElementById('creditos_mini').innerHTML = inner;
	}		
/***** OPCIONES ADICIONALES ****/		

/***** PERFIL DEL USUARIO ****/	
function submitVote(id_usuario_votado,id_usuario_votante,num)
	{	
	DoCallback_perfil("puntuaRanking=true&id_usuario_votado="+id_usuario_votado+"&id_usuario_votante="+id_usuario_votante+"&votacion="+num);
	document.getElementById('votacionRanking').style.display = 'none';
	document.getElementById('votacionRankingvotado').style.display = 'block';
	} 
	
function mensajeAmedida()
	{
	for (i=0; i<document.form_mensajesamedida.mensaje_id_mensaje.length; i++)
		{
		if(document.form_mensajesamedida.mensaje_id_mensaje[i].checked)
		var id_mensaje = document.form_mensajesamedida.mensaje_id_mensaje[i].value;
		}

	var id_usuario = document.form_mensajesamedida.mensajesamedida_idusuario.value;
	var id_destinatario = document.form_mensajesamedida.mensajesamedida_iddestinatario.value;
	
	document.getElementById('boton_enviando').style.display='none';	
	document.getElementById('display_enviando').style.display='block';	
	AjaxRequest("id_destinatario="+id_destinatario+"&id_usuario="+id_usuario+"&id_mensaje="+id_mensaje+"&mensajeAmedida=true",'/ajax/perfil.php', mensajeamedidaajax);
	}
	
function red(name_id_usuario,id_usuario,id_favorito)
	{
	var agree=confirm("Quieres enviar a "+name_id_usuario+" una solicitud para ser amigos?\n");
	if (agree)
	    {
		DoCallback_perfil("id_usuario="+id_usuario+"&id_favorito="+id_favorito+"&solicita=true");
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
		document.getElementById('confirm_red_div').style.top =  st+'px';	
		document.getElementById('confirm_red_div').style.visibility='visible'; 
		return;   
	    }
	else
		return;	
	}
function invitacionRed(id_usuario,id_favorito,upt)
	{
	if(!upt) var upt=0;
	if(document.getElementById('enlaceInvitacionOld'))document.getElementById('enlaceInvitacionOld').style.display = 'none';
	document.getElementById('enlaceInvitacionPre').style.display = 'none';
	document.getElementById('enlaceInvitacionSend').style.display = 'block';
	AjaxRequest("invitacionRed=true&id_usuario=" + id_usuario + "&id_favorito=" + id_favorito + "&upt=" + upt,'/ajax/perfil.php', invitacionredajax);
	}	
	
function visitarPerfil(identificador)
	{
	document.location.href=('/perfil/'+identificador);	
	}
/***** PERFIL DEL USUARIO ****/	
	
/***** MI ADMIN ****/	
function miadmininfo(val)
	{
	AjaxRequest("val=" + val + "&ventanainfo=true",'/ajax/miadmin.php', ventanainfoajax);
	}	

function parametros_adicionales()
	{
	var pa1 = document.parametrosadicionales.pa1.checked;
	var pa2 = document.parametrosadicionales.pa2.checked;
	var pa3 = document.parametrosadicionales.pa3.checked;
	var pa4 = document.parametrosadicionales.pa4.checked;
	var pa5 = document.parametrosadicionales.pa5.checked;
	var pa6 = document.parametrosadicionales.pa6.checked;
	//var pa7 = document.parametrosadicionales.pa7.checked;
	var id_usuario = document.parametrosadicionales.id_usuario.value;
	
	//DoCallback("actualizaParametrosAdicionales=true&pa1="+pa1+"&pa2="+pa2+"&pa3="+pa3+"&pa4="+pa4+"&pa5="+pa5+"&pa6="+pa6+"&pa7="+pa7+"&id_usuario="+id_usuario);	
	DoCallback("actualizaParametrosAdicionales=true&pa1="+pa1+"&pa2="+pa2+"&pa3="+pa3+"&pa4="+pa4+"&pa5="+pa5+"&pa6="+pa6+"&id_usuario="+id_usuario);	
	}

function configuracion_mailbox()
	{
	var mail_p1 = document.configuracionmailbox.mail_p1.value;
	var mail_p2 = document.configuracionmailbox.mail_p2.value;
	var mail_p3 = document.configuracionmailbox.mail_p3.value;
	var id_usuario = document.configuracionmailbox.id_usuario.value;
	
	DoCallback("actualizaConfiguracionMailbox=true&mail_p1="+mail_p1+"&mail_p2="+mail_p2+"&mail_p3="+mail_p3+"&id_usuario="+id_usuario);	
	}	
/***** MI ADMIN ****/

/***** CREAR ALBUM RED ****/
function envio_foto_album()
	{
	if (document.form_nuevafoto.foto.value == "" || document.form_nuevafoto.foto.value == null)
		{
		alert('Introduce una foto!');
		document.form_nuevafoto.foto.focus();
		return false;
		}
		
	document.getElementById('cargando').style.display='block';
	document.form_nuevafoto.submit();
	}
	
function displayNoneDiv(name)
	{
	document.getElementById(name).style.display =  'none';
	}	
	
function actualiza_foto_album(idfoto)
	{
	var nombreform = 'form_nuevafoto'+idfoto;
	document.getElementById('cargando'+idfoto).style.display='block';
	document.forms[nombreform].submit();
	}	

function verAlbum(idalbum)
	{
	document.forms['verAlbumRed'].id_album.value = idalbum;
	document.forms['verAlbumRed'].submit();	
	}

function sumaVisita(id_foto)
	{
	var contador = document.getElementById('contadorVisitas'+id_foto).innerHTML;
	document.getElementById('contadorVisitas'+id_foto).innerHTML = parseInt(contador)+1;
	AjaxRequest("sumaVisita=true&id_foto="+id_foto,'/ajax/red.php');
	}
/***** CREAR ALBUM RED ****/

function submitVotePic(id_foto,value,id_usuario_votado,id_usuario_votante)
	{
	document.getElementById('votacionRanking'+id_foto).style.display = 'none';
	AjaxRequest("enviaVoto=true&id_foto="+id_foto+"&value="+value+"&id_usuario_votado="+id_usuario_votado+"&id_usuario_votante="+id_usuario_votante,'/ajax/red.php',enviavotoajax);
	} 
	
	
function cargaDivInteraccion(id_usuario,datos_retorno)
	{
	if (window.XMLHttpRequest) 
		{
		reqObj = new XMLHttpRequest();
		reqObj.open("POST", "/ajax/perfil.php", false);
				reqObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				reqObj.send("cargaDivInteraccion=true&id_usuario="+id_usuario+"&datos_retorno="+encodeURIComponent(datos_retorno));
				if(document.getElementById('divInteraccion_'+id_usuario))document.getElementById('divInteraccion_'+id_usuario).innerHTML = reqObj.responseText;
		}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject) 
		{	
		reqObj = new ActiveXObject('Microsoft.XMLHTTP')
		if (reqObj) 
			{
			reqObj.open('POST', "/ajax/perfil.php", false);
			reqObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			reqObj.send("cargaDivInteraccion=true&id_usuario="+id_usuario+"&datos_retorno="+encodeURIComponent(datos_retorno));
			if(document.getElementById('divInteraccion_'+id_usuario))document.getElementById('divInteraccion_'+id_usuario).innerHTML = reqObj.responseText;
			}		
		}
	}

function cargaDivDisponibilidad(id_usuario)
	{
	if (window.XMLHttpRequest) 
		{
		reqObj = new XMLHttpRequest();
		reqObj.open("POST", "/ajax/perfil.php", false);
				reqObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				reqObj.send("cargaDivDisponibilidad=true&id_usuario="+id_usuario);
				if(document.getElementById('divDisponibilidad_'+id_usuario))document.getElementById('divDisponibilidad_'+id_usuario).innerHTML = reqObj.responseText;
		}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject) 
		{	
		reqObj = new ActiveXObject('Microsoft.XMLHTTP')
		if (reqObj) 
			{
			reqObj.open('POST', "/ajax/perfil.php", false);
			reqObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			reqObj.send("cargaDivDisponibilidad=true&id_usuario="+id_usuario);
			if(document.getElementById('divDisponibilidad_'+id_usuario))document.getElementById('divDisponibilidad_'+id_usuario).innerHTML = reqObj.responseText;
			}		
		}
	}	
	
function emoticonShow(id,id_destinatario)
	{
	var nombreform = 'form_emoticon_'+id_destinatario;
	for (n=0; n<15; n++)
		{
		document.getElementById('EM_normal_'+id_destinatario+'_'+n).style.display='block';
		document.getElementById('EM_click_'+id_destinatario+'_'+n).style.display='none';
		}
	document.getElementById('EM_normal_'+id_destinatario+'_'+id).style.display='none';
	document.getElementById('EM_click_'+id_destinatario+'_'+id).style.display='block';
	document.forms[nombreform].emoticon.value=id;
	}
	
function enviaEmoticon(id_destinatario)
	{
	var nombreform = 'form_emoticon_'+id_destinatario;
	var id_emoticon = document.forms[nombreform].emoticon.value;
	if(!id_emoticon){alert('Selecciona un icono gestual');return false;}
	var id_usuario = document.forms[nombreform].id_usuario.value;
	var id_destinatario = document.forms[nombreform].id_destinatario.value;
	document.getElementById('boton_enviando_'+id_destinatario).style.display='none';	
	document.getElementById('display_enviando_'+id_destinatario).style.display='block';	
	AjaxRequest("id_usuario="+id_usuario+"&id_destinatario="+id_destinatario+"&id_emoticon="+id_emoticon+"&enviaEmoticon=true",'/ajax/comun.php', enviaemoticonajax);	
	}	
	
function form_planes(datos,id,marca)
	{
	var values=datos.split("#");
	var html = "<div class='PLANES_desplega'><div style='position:absolute;top:2px;right:2px;width:40px;height:20px;'><a href='#' title='Cerrar ventana' onClick='"+id+".slideit();return false;'>cerrar</a></div><div class='PLANES_desplega_01'><span style='font-size:24px;font-weight:bold;'>"+values[0]+"</span><br/>"+values[1]+"<br/><span style='font-weight:bold;'>"+values[2]+"</span></div><div class='PLANES_desplega_02'><a href='#' title='Haz click para marcar como no disponible' class='boldlinknounder' style='color:red;' onClick='marcarDia(\""+marca+"#1\");return false;'>Marcar como d&iacute;a no disponible</a><br/><a href='#' title='Haz click para marcar d&iacute;a deseado para cita' class='boldlinknounder' style='color:#137C02;' onClick='marcarDia(\""+marca+"#2\");return false;'>Marcar como d&iacute;a deseado para cita</a><br/><a href='#' title='Haz click para marcar como d&iacute;a sin determinar' class='boldlinknounder' onClick='marcarDia(\""+marca+"#3\");return false;'>Marcar como d&iacute;a como sin determinar</div></div>";
	document.getElementById(id).innerHTML = html;
	}
	
function marcarDia(datos)
	{
	AjaxRequest("datos="+datos+"&cambiaPlan=true",'/ajax/comun.php', cambiaplanajax);	
	}
	
function marcaDiaFormDisponibilidad(dia,mes,ano,backcolor)
	{
	var newvalues = '';
	var existe = false;
	document.getElementById('displayCelda_'+dia+mes+ano).style.background='#00DD37';	
	
	var values = document.forms['filtroBuscadorUsuarios'].buscaDiasDisponibles.value;
	
	var val=values.split("#");
	
	if(val.length>1)
		{
		for (i=1; i<val.length; i++)
			{
			if(val[i] == dia+'|'+mes+'|'+ano) 
				{
				document.getElementById('displayCelda_'+dia+mes+ano).style.background=backcolor;
				existe = true;
				}
			else
				{
				newvalues += '#'+val[i];
				}
			}
			
		if(existe)
			document.forms['filtroBuscadorUsuarios'].buscaDiasDisponibles.value = newvalues;
		else
			document.forms['filtroBuscadorUsuarios'].buscaDiasDisponibles.value = newvalues.concat('#'+dia+'|'+mes+'|'+ano);
			
		}
	else
		{
		document.forms['filtroBuscadorUsuarios'].buscaDiasDisponibles.value = '#'+dia+'|'+mes+'|'+ano;	
		}
	}	
	
/***** OLD JS *****/
var currentsecond = 5; //Tiempo que tardan en cerrarse los divs de respuesta a alg�n evento

//Usada en configuracion de cuenta
function verify_email()
	{
	var clave = document.sendmail.clave.value;
	
	if(clave == "" || clave == null)
		{
		alert('Introduce la clave de acceso a tu cuenta.');
		document.sendmail.clave.focus();
		return;
		}
		
	var email = document.sendmail.email.value;
	var id_usuario = document.sendmail.id_usuario.value;
	DoCallback("verify_email=true&email="+email+"&id_usuario="+id_usuario);
	}	

function inicio(obj) {
    if (navigator.appName.indexOf('Explorer')>0) {
        obj.style.behavior='url(#default#homepage)';
        obj.setHomePage('http://www.parejas.com');
    } else {
        alert('Seleccione en las preferencias de su navegador, en opciones de pagina de inicio, "Utilizar pagina actual" o similar');
    }
} 

function favoritos(){
    if (navigator.appName.indexOf('Explorer')>0) {
        window.external.AddFavorite('http://www.parejas.com','http://www.parejas.com');
    } else {
        alert('Presiona las teclas Ctrl+D para agregar la pagina a tus favoritos');
    }
} 

function position(e,name)
	{
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
	var leftPos = e.clientX + -50 + 'px';
	var topPos = e.clientY + st + 'px';
	
	document.getElementById('ayuda'+name).style.left =  leftPos;
	document.getElementById('ayuda'+name).style.top =  topPos;
	document.getElementById('ayuda'+name).style.visibility =  'visible';
	}

function cerrarAyuda(name)
	{
	document.getElementById('ayuda'+name).style.visibility =  'hidden';
	}

function ocultaDiv(name)
	{
	document.getElementById(name).style.visibility =  'hidden';
	}

function muestraDiv(name,top)
	{
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
	document.getElementById(name).style.top =  st + top +'px';
	document.getElementById(name).style.visibility =  'visible';
	}

function displayBlockDiv(name)
	{
	document.getElementById(name).style.display =  'block';
	}	
	
function muestraDivUpdFoto(titulo,descripcion,idfoto,top)
	{
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
	document.getElementById('editafoto').style.top =  st + top +'px';
	document.getElementById('editafoto').style.visibility =  'visible';
	document.form_editafoto.titulo.value=titulo;
	document.form_editafoto.descripcion.value=descripcion;
	document.form_editafoto.idfoto.value=idfoto;
	}

function muestraDivUpdFoto2(titulo,descripcion,idfoto,name)
	{
	var nombreform = 'form_editafoto'+idfoto;
	document.getElementById(name+idfoto).style.display =  'block';
	document.forms[nombreform].titulo.value=titulo;
	document.forms[nombreform].descripcion.value=descripcion;
	document.forms[nombreform].idfoto.value=idfoto;
	}	

function envio_Foto()
	{
	if (document.form_nuevafoto.foto.value == "" || document.form_nuevafoto.foto.value == null)
		{
		alert('Introduce una foto!');
		document.form_nuevafoto.foto.focus();
		return false;
		}
	
	document.form_nuevafoto.submit();
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
	document.getElementById('nuevafoto2').style.top =  st + 'px';
	document.getElementById('nuevafoto2').style.visibility = 'visible';
	document.getElementById('nuevafoto1').style.visibility = 'hidden';
	}

function envio_Foto2()
	{
	if (document.form_nuevafoto.foto.value == "" || document.form_nuevafoto.foto.value == null)
		{
		alert('Introduce una foto!');
		document.form_nuevafoto.foto.focus();
		return false;
		}
		
	document.getElementById('loading').style.display='block';
	document.getElementById('status').style.display='none';
	document.form_nuevafoto.submit();
	}
	
	
function update_Foto()
	{
	document.form_editafoto.submit();
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); 
	document.getElementById('editafoto2').style.top =  st + 'px';
	document.getElementById('editafoto2').style.visibility = 'visible';
	document.getElementById('editafoto').style.visibility = 'hidden';
	}
	
function update_Foto2(idfoto)
	{
	var nombreform = 'form_editafoto'+idfoto;
	document.getElementById('loading'+idfoto).style.display='block';
	document.getElementById('status'+idfoto).style.display='none';
	document.forms[nombreform].submit();
	}	

function eliminaAnuncioPre(id,estado)
	{
	var agree=confirm("Quieres eliminar el anuncio?\n Puedes recuperarlo antes de que sea eliminado por administracion.");
	if (agree)
	    {
		DoCallback_anuncios("id_anuncio="+id+"&estado="+estado+"&eliminaPre=true");
		document.getElementById('anuncioEliminado'+id).style.display='block'; 
		document.getElementById('anuncioEliminado2'+id).style.display='none'; 		
		return;   
	    }
	else
	return;	
	}
	
function cambiaEstadoAnuncio(id,estado)
	{
	if (estado==3 || estado==5)
		{
		var agree=confirm("Quieres eliminar el anuncio?\n Puedes recuperarlo antes de que sea eliminado definitivamente por administracion.");
		if(agree)
			{
			DoCallback_anuncios("id_anuncio="+id+"&estado="+estado+"&cambiaestado=true");
			document.getElementById('recupera_'+id).style.display='block'; 
			document.getElementById("elimina_"+id).style.display='none'; 
			}
		}	
	else
		{
		DoCallback_anuncios("id_anuncio="+id+"&estado="+estado+"&cambiaestado=true");
		document.getElementById('recupera_'+id).style.display='none'; 
		document.getElementById("elimina_"+id).style.display='block'; 
		}			  
	}
		
function recuperarAnuncio(id,estado)
	{
	DoCallback_anuncios("id_anuncio="+id+"&estado="+estado+"&recupera=true");
	document.getElementById('anuncioEliminado'+id).style.display='none'; 
	document.getElementById("anuncioEliminado2"+id).style.display='block'; 
	return;   
	}

function convierteAnuncioPre(ref)
	{
	var agree=confirm("Vas a convertir el anuncio en express, el coste es de 10 creditos \n Quieres continuar?\n");
	if (agree)
	    {
		document.forms['convertirExpress_'+ref].submit();
		return;   
	    }
	else
	return;	
	}		
	
function eliminaFoto(id_foto,id)
	{
	var agree=confirm("Quieres eliminar la imagen definitivamente?\n");
	if (agree)
	    {
		DoCallback_album("id_foto="+id_foto+"&elimina=true");
		document.getElementById('tapa_eliminada.'+id).style.visibility='visible'; 
		//document.getElementById('tapa_favorita.'+id).style.visibility='hidden'; 
		//document.getElementById('tapa_botones.'+id).style.visibility='visible'; 
		return;   
	    }
	else
	return;	
	}

function favoritaFoto(id_foto,id,status)
	{
	if(status=='on')
		{
		document.getElementById('tapa_favorita.'+id).style.visibility='visible'; 
		document.getElementById('fav_on.'+id).style.visibility='hidden'; 
		document.getElementById('fav_off.'+id).style.visibility='visible'; 
		DoCallback_album("id_foto="+id_foto+"&favorita=true&status=on");
		}
	
	if(status=='off')
		{
		document.getElementById('tapa_favorita.'+id).style.visibility='hidden'; 
		document.getElementById('fav_on.'+id).style.visibility='visible';
		document.getElementById('fav_off.'+id).style.visibility='hidden'; 
		DoCallback_album("id_foto="+id_foto+"&favorita=true&status=off");
		}
	}

function eliminaAlbum(id_album)
	{
	var agree=confirm("Quieres eliminar el album definitivamente?\n");
	if (agree)
	    {
	    document.eliminaalbum.idalbum.value = id_album;
	    document.eliminaalbum.submit();
	    }
	else
		return;	
	}

function getObject(obj) 
	{
	var theObj;
	
	if(document.all) 
		{
		if(typeof obj=="string") 
			{
			return document.all(obj);
			}
		else
			{
			return obj.style;
			}
		}
	
	if(document.getElementById) 
		{
		if(typeof obj=="string") 
			{
			return document.getElementById(obj);
			}
		else
			{
			return obj.style;
			}
		}
	
	return null;
	}

//Contador de caracteres.
function Contar(entrada,salida,texto,caracteres) 
	{
	var entradaObj=getObject(entrada);
	var salidaObj=getObject(salida);
	var longitud=caracteres - entradaObj.value.length;
	if(longitud <= 0) 
		{
		longitud=0;
		texto='<span class="disable"> '+texto+' </span>';
		entradaObj.value=entradaObj.value.substr(0,caracteres);
		}
	salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
	}
	
//Contador de caracteres del perfil copmplemnetario
function ContarPerfil(entrada,salida,texto,caracteres) 
	{
	var entradaObj=getObject(entrada);
	var salidaObj=getObject(salida);
	var longitud=caracteres - entradaObj.value.length;
	if(longitud <= 0) 
		{
		longitud=0;
		texto="<span style='background:green;color:#FFF;'> &nbsp;Perfecto! Puedes seguir completando tu introducci&oacute;n&nbsp;</span>";
		}
	salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
	}	

function marcar(type) 
	{
	if(type=='select')
		{
		for (i=0; i<document.mailbox.mail.length; i++)document.mailbox.mail[i].checked=true;
		document.getElementById('marcar').style.visibility='hidden'; 
		document.getElementById('desmarcar').style.visibility='visible'; 
		}
	if(type=='unselect')
		{
		for (i=0; i<document.mailbox.mail.length; i++) document.mailbox.mail[i].checked=false;
		document.getElementById('marcar').style.visibility='visible'; 
		document.getElementById('desmarcar').style.visibility='hidden'; 
		}
	}

function marcarRed(type,name) 
	{
	if(type=='select')
		{
		for (i=0; i<document.forms[name].mail.length; i++)document.forms[name].mail[i].checked=true;
		document.getElementById('marcar_'+name).style.visibility='hidden'; 
		document.getElementById('desmarcar_'+name).style.visibility='visible'; 
		}
	if(type=='unselect')
		{
		for (i=0; i<document.forms[name].mail.length; i++) document.forms[name].mail[i].checked=false;
		document.getElementById('marcar_'+name).style.visibility='visible'; 
		document.getElementById('desmarcar_'+name).style.visibility='hidden'; 
		}
	}

function momaRed(name) 
	{
	for (i=1; i<document.forms[name].mail.length; i++)
		{
		var div = document.forms[name].mail[i].value+'.trans';
		var marcar = document.forms[name].marcar.value;
		var id_solicitud = document.forms[name].mail[i].value;
		
		if(marcar>0 && document.forms[name].mail[i].checked && document.getElementById(div).style.visibility=='hidden')
			{
			document.getElementById(div).style.visibility='visible'; 
			
			if (name=='red1')
				{
				if(marcar==2)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:#00D900;'>Solicitud Aceptada</div>";
				if(marcar==3)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:red;'>Solicitud Rechazada</div>";	
				DoCallback_perfil("id_solicitud="+id_solicitud+"&tipo="+marcar+"&red1=true");
				}
			else if (name=='red2')
				{
				if(marcar==5)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:#00D900;'>Usuario excluido</div>";
				DoCallback_perfil("id_solicitud="+id_solicitud+"&tipo="+marcar+"&red2=true");
				}
			else if (name=='red3')
				{
				if(marcar==4)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:#00D900;'>Solicitud anulada</div>";
				DoCallback_perfil("id_solicitud="+id_solicitud+"&tipo="+marcar+"&red3=true");
				}		
			else if (name=='menPerfil')
				{
				if(marcar==1)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:red;'>Mensaje eliminado</div>";
				DoCallback_perfil("id_mensaje="+id_solicitud+"&estado=0&menPerfil=true");
				}
			else if (name=='emoticones')
				{
				if(marcar==1)document.getElementById(div).innerHTML = "<div class='txtredact' style='color:red;'>Icono gestual eliminado</div>";
				DoCallback_perfil("id_emoticon="+id_solicitud+"&estado=0&emoticones=true");
				}	
									
			var nule = true;						
			}	
		}
		if (!nule) alert('Debes seleccionar al menos una opcion');
	}

function isValidEmail(strEmail) 
	{
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	if (strEmail.search(validRegExp) == -1) 
		{
		return false;
		} 
	return true; 
	}

function valida_formlocal() 
	{
	if(document.nuevolocal.nombre.value == "" || document.nuevolocal.nombre.value == null) 
		{
		alert('No puedes dejar el NOMBRE DEL LOCAL vacio!');
		document.nuevolocal.nombre.focus();
		return;
		}
	
	if(document.nuevolocal.direccion.value == "" || document.nuevolocal.direccion.value == null) 
		{
		alert('No puedes dejar la DIRECCION en blanco!');
		document.nuevolocal.direccion.focus();
		return;
		}	
		
	if(!isValidEmail(document.nuevolocal.emailadmin.value) || document.nuevolocal.emailadmin.value=="") 
		{
		alert('La direccion de correo de administracion no parece correcta');
		document.nuevolocal.email.focus();
		return;
		}	
		
	if(document.nuevolocal.claveadmin.value == "" || document.nuevolocal.claveadmin.value == null) 
		{
		alert('No puedes dejar la CLAVE DE ADMINISTRACION en blanco!');
		document.nuevolocal.claveadmin.focus();
		return;
		}	
		
	if(document.nuevolocal.claveadmin.value != document.nuevolocal.claveadmin2.value) 
		{
		alert('La clave no coincide!');
		document.nuevolocal.claveadmin2.focus();
		return;
		}				
		
	// returns true if the string only contains characters A-Z, a-z or 0-9
	var re = /[^a-zA-Z0-9_-]/g
	if (re.test(document.nuevolocal.claveadmin.value))
		{
		alert('La clave de administracion no puede contener caracteres extra&ntilde;os ni espacios');
		document.nuevolocal.claveadmin.focus();
		return;
		}	
		
	document.nuevolocal.submit();
	}

function valida_formevento() 
	{
	if(document.nuevoevento.nombre.value == "" || document.nuevoevento.nombre.value == null) 
		{
		alert('No puedes dejar el NOMBRE del evento vacio!');
		document.nuevoevento.nombre.focus();
		return;
		}
	
	if(document.nuevoevento.datos.value == "" || document.nuevoevento.datos.value == null) 
		{
		alert('No puedes dejar el campo de DATOS en blanco!');
		document.nuevoevento.datos.focus();
		return;
		}	
		
	document.nuevoevento.submit();
	}		
	
function valida_formlocalupdate() 
	{
	if(!isValidEmail(document.actualizarlocal.emaillocal.value) || document.actualizarlocal.emaillocal.value=="") 
		{
		alert('La direccion de correo de administracion no parece correcta');
		document.actualizarlocal.emaillocal.focus();
		return;
		}	
		
	if(document.actualizarlocal.clavelocal.value == "" || document.actualizarlocal.clavelocal.value == null) 
		{
		alert('No puedes dejar la CLAVE DE ADMINISTRACION en blanco!');
		document.actualizarlocal.clavelocal.focus();
		return;
		}			
		
	// returns true if the string only contains characters A-Z, a-z or 0-9
	var re = /[^a-zA-Z0-9_-]/g
	if (re.test(document.actualizarlocal.clavelocal.value))
		{
		alert('La clave de administracion no puede contener caracteres extranos ni espacios');
		document.actualizarlocal.clavelocal.focus();
		return;
		}	
		
	document.actualizarlocal.submit();
	}	

function actualizarDatosUsuario()
	{
	var email = document.sendmail.email.value;
	var clave = document.sendmail.clave.value; //clave principal
	var clave2 = document.sendmail.clave2.value;
	var id_usuario = document.sendmail.id_usuario.value;
			
	if(clave == "" || clave == null) 
		{
		alert('Debes escribir la clave de acceso a la cuenta.');
		document.sendmail.clave.focus();
		return;
		}	
		
	function isValidEmail(strEmail) 
		{
		validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		if (strEmail.search(validRegExp) == -1) 
			{
			return false;
			} 
		return true; 
		}
	
	if(email == "" || email == null) 
		{
		alert('Debes escribir una direccion de correo o dejar el actual');
		document.sendmail.email.focus();
		return;
		}
	
	if(email) 
		{
		if(!isValidEmail(email)) 
			{
			alert('La direccion de correo no parece correcta');
			document.sendmail.email.focus();
			return;
			}
		}	
		
	if(clave2 == "" || clave2 == null) 
		DoCallback("actualizaDatosUsuario=true&email="+email+"&clave="+clave+"&id_usuario="+id_usuario);	
	else
		DoCallback("actualizaDatosUsuario=true&email="+email+"&clave="+clave+"&clave2="+clave2+"&id_usuario="+id_usuario);	
		
	}
	



function countredirect()
	{
	if (currentsecond!=1)
		{
		currentsecond-=1
		if(document.getElementById('sendmail_div_time'))document.getElementById('sendmail_div_time').innerHTML = "<span style='font-size:8px;font-weight:normal;'>Esta ventana se cerrara en "+currentsecond+" segundos</span>";
		if(document.getElementById('sendmail_div_time2'))document.getElementById('sendmail_div_time2').innerHTML = "<span style='font-size:8px;font-weight:normal;'>Esta ventana se cerrara en "+currentsecond+" segundos</span>";
		}
	else
		{
		if(document.getElementById('sendmail_div'))document.getElementById('sendmail_div').style.visibility = 'hidden';
		if(document.getElementById('sendmail_div2'))document.getElementById('sendmail_div2').style.visibility = 'hidden';
		currentsecond = 6;
		return
		}
	setTimeout("countredirect()",1000)
	}
	
	
function crearAlbum()
	{
	var descripcion = document.nuevoalbum.descripcion.value;
	var titulo = document.nuevoalbum.titulo.value;
	
	if(titulo == "" || titulo == null) 
		{
		alert('Debes escribir el titulo del album');
		document.nuevoalbum.titulo.focus();
		return;
		}		
	
	if(descripcion == "" || descripcion == null) 
		{
		alert('Debes escribir una pequena descripcion del album');
		document.nuevoalbum.descripcion.focus();
		return;
		}

	document.nuevoalbum.submit();
	}

//Obsoleta parejas. v.3.5
function mensajePerfil()
	{
	for (i=0; i<document.form_mensajes_predefinidos.mensaje_id_mensaje.length; i++)
		{
		if(document.form_mensajes_predefinidos.mensaje_id_mensaje[i].checked)
		var id_mensaje = document.form_mensajes_predefinidos.mensaje_id_mensaje[i].value;
		}

	var id_usuario = document.getElementById('mensaje_id_usuario').value;
	var id_destinatario = document.getElementById('mensaje_id_destinatario').value;
	
	DoCallback_perfil("id_destinatario="+id_destinatario+"&id_usuario="+id_usuario+"&id_mensaje="+id_mensaje+"&mensajePerfil=true");
	}



//funci�n que cambia las provincias del select de provincias en funci�n del pa�s que se haya escogido en el select de pa�s.

//Usada en usuarios.php formname (busca_usuarios2)
//Usada en home.php formname (busca_usuarios2) buscador de usuario

//USADA EN CREARANUNCIO y CREAR PERFIL!!!!!
function cambia_provincia(prov)
	{
	if(prov==100)
		{
		document.busca_usuarios2.provincia.options.length=1;
		document.busca_usuarios2.provincia.options[0].value=100;
		document.busca_usuarios2.provincia.options[0].text='Todas';
		return;
		}
	
	DoCallback_cargaprovincia("prov="+prov);
	} 

//Usada en anuncios.php formname (busca)
//Usada en home.php formname (busca) buscador de anuncios
function cambia_provincia2(prov)
	{
	if(prov==100)
		{
		document.busca.provincia.options.length=1;
		document.busca.provincia.options[0].value=100;
		document.busca.provincia.options[0].text='Todas';
		return;
		}
		
	DoCallback_cargaprovincia2("prov="+prov);
	} 	
	
 var fromBoxArray = new Array();
    var toBoxArray = new Array();
    var selectBoxIndex = 0;
    
    function moveSingleElement()
    {
        var selectBoxIndex = this.parentNode.parentNode.id.replace(/[^\d]/g,'');
        var tmpFromBox;
        var tmpToBox;
        if(this.tagName.toLowerCase()=='select'){            
            tmpFromBox = this;
            if(tmpFromBox==fromBoxArray[selectBoxIndex])tmpToBox = toBoxArray[selectBoxIndex]; else tmpToBox = fromBoxArray[selectBoxIndex];
        }else{
        
            if(this.value.indexOf('>')>=0){
                tmpFromBox = fromBoxArray[selectBoxIndex];
                tmpToBox = toBoxArray[selectBoxIndex];            
            }else{
                tmpFromBox = toBoxArray[selectBoxIndex];
                tmpToBox = fromBoxArray[selectBoxIndex];    
            }
        }
        
        for(var no=0;no<tmpFromBox.options.length;no++){
            if(tmpFromBox.options[no].selected){
                tmpFromBox.options[no].selected = false;
                tmpToBox.options[tmpToBox.options.length] = new Option(tmpFromBox.options[no].text,tmpFromBox.options[no].value);
                
                for(var no2=no;no2<(tmpFromBox.options.length-1);no2++){
                    tmpFromBox.options[no2].value = tmpFromBox.options[no2+1].value;
                    tmpFromBox.options[no2].text = tmpFromBox.options[no2+1].text;
                    tmpFromBox.options[no2].selected = tmpFromBox.options[no2+1].selected;
                }
                no = no -1;
                tmpFromBox.options.length = tmpFromBox.options.length-1;
                                            
            }            
        }
        
        
        var tmpTextArray = new Array();
        for(var no=0;no<tmpFromBox.options.length;no++){
            tmpTextArray.push(tmpFromBox.options[no].text + '___' + tmpFromBox.options[no].value);            
        }
        tmpTextArray.sort();
        var tmpTextArray2 = new Array();
        for(var no=0;no<tmpToBox.options.length;no++){
            tmpTextArray2.push(tmpToBox.options[no].text + '___' + tmpToBox.options[no].value);            
        }        
        tmpTextArray2.sort();
        
        for(var no=0;no<tmpTextArray.length;no++){
            var items = tmpTextArray[no].split('___');
            tmpFromBox.options[no] = new Option(items[0],items[1]);
            
        }        
        
        for(var no=0;no<tmpTextArray2.length;no++){
            var items = tmpTextArray2[no].split('___');
            tmpToBox.options[no] = new Option(items[0],items[1]);            
        }
    }
    
    function moveAllElements()
    {
        var selectBoxIndex = this.parentNode.parentNode.id.replace(/[^\d]/g,'');
        var tmpFromBox;
        var tmpToBox;        
        if(this.value.indexOf('>')>=0){
            tmpFromBox = fromBoxArray[selectBoxIndex];
            tmpToBox = toBoxArray[selectBoxIndex];            
        }else{
            tmpFromBox = toBoxArray[selectBoxIndex];
            tmpToBox = fromBoxArray[selectBoxIndex];    
        }
        
        for(var no=0;no<tmpFromBox.options.length;no++){
            tmpToBox.options[tmpToBox.options.length] = new Option(tmpFromBox.options[no].text,tmpFromBox.options[no].value);            
        }    
        
        tmpFromBox.options.length=0;
        
    }
    
    
    
    function createMovableOptions(fromBox,toBox,totalWidth,totalHeight,labelLeft,labelRight)
    {        
        fromObj = document.getElementById(fromBox);
        toObj = document.getElementById(toBox);

        fromObj.ondblclick = moveSingleElement;
        toObj.ondblclick = moveSingleElement;

        fromBoxArray.push(fromObj);
        toBoxArray.push(toObj);
        
        var parentEl = fromObj.parentNode;
        
        var parentDiv = document.createElement('DIV');
        parentDiv.className='multipleSelectBoxControl';
        parentDiv.id = 'selectBoxGroup' + selectBoxIndex;
        parentDiv.style.width = totalWidth + 'px';
        parentDiv.style.height = totalHeight + 'px';
        parentEl.insertBefore(parentDiv,fromObj);
        
        
        var subDiv = document.createElement('DIV');
        subDiv.style.width = (Math.floor(totalWidth/2) - 15) + 'px';
        fromObj.style.width = (Math.floor(totalWidth/2) - 15) + 'px';

        var label = document.createElement('SPAN');
        label.innerHTML = labelLeft;
        subDiv.appendChild(label);
        
        subDiv.appendChild(fromObj);
        subDiv.className = 'multipleSelectBoxDiv';
        parentDiv.appendChild(subDiv);
        
        
        var buttonDiv = document.createElement('DIV');
        buttonDiv.style.verticalAlign = 'middle';
        buttonDiv.style.paddingTop = (totalHeight/2) - 50 + 'px';
        buttonDiv.style.width = '30px';
        buttonDiv.style.textAlign = 'center';
        parentDiv.appendChild(buttonDiv);
        
        var buttonRight = document.createElement('INPUT'); 
        buttonRight.type='button';
        buttonRight.value = '>';
        buttonDiv.appendChild(buttonRight);    
        buttonRight.onclick = moveSingleElement;    
        
        var buttonAllRight = document.createElement('INPUT');
        buttonAllRight.style.marginTop='3px';
        buttonAllRight.type='button';
        buttonAllRight.value = '>>';
        buttonAllRight.onclick = moveAllElements;
        buttonDiv.appendChild(buttonAllRight);        
        
        var buttonLeft = document.createElement('INPUT');
        buttonLeft.style.marginTop='10px';
        buttonLeft.type='button';
        buttonLeft.value = '<';
        buttonLeft.onclick = moveSingleElement;
        buttonDiv.appendChild(buttonLeft);        
        
        var buttonAllLeft = document.createElement('INPUT');
        buttonAllLeft.style.marginTop='3px';
        buttonAllLeft.type='button';
        buttonAllLeft.value = '<<';
        buttonAllLeft.onclick = moveAllElements;
        buttonDiv.appendChild(buttonAllLeft);
        
        var subDiv = document.createElement('DIV');
        subDiv.style.width = (Math.floor(totalWidth/2) - 15) + 'px';
        toObj.style.width = (Math.floor(totalWidth/2) - 15) + 'px';

        var label = document.createElement('SPAN');
        label.innerHTML = labelRight;
        subDiv.appendChild(label);
                
        subDiv.appendChild(toObj);
        parentDiv.appendChild(subDiv);        
        
        toObj.style.height = (totalHeight - label.offsetHeight) + 'px';
        fromObj.style.height = (totalHeight - label.offsetHeight) + 'px';

            
        selectBoxIndex++;
        
    }	
    
function multipleSelectOnSubmit()
	{
	for(var no=0;no<document.crearanuncio.toBox.length;no++)
		{
		var obj = document.crearanuncio.toBox;
		for(var no2=0;no2<obj.options.length;no2++)
			{
			obj.options[no2].selected = true;
			}
		}
	}    
	
function vacia_provincias()
	{
    document.crearanuncio.toBox.options.length=0;
	}  	
	
function update_tarjetacredito()
	{
	var id_datosbancarios = document.formActualizaVisa.id_datosbancarios.value;
	var nombre = document.formActualizaVisa.nombre.value;
	var apellidos = document.formActualizaVisa.apellidos.value;
	var direccion = document.formActualizaVisa.direccion.value;
	var poblacion = document.formActualizaVisa.poblacion.value;
	var provincia = document.formActualizaVisa.provincia.value;
	var email = document.formActualizaVisa.email.value;
	var dni = document.formActualizaVisa.dni.value;
	var telefono = document.formActualizaVisa.telefono.value;	
	var cp = document.formActualizaVisa.cp.value;	
	var id_tarjeta = document.formActualizaVisa.id.value;
	var titular = document.formActualizaVisa.titular.value;
	var num_tarjeta = document.formActualizaVisa.pan.value;
	var entidad = document.formActualizaVisa.entidad.value;
	var tipo_tarjeta = document.formActualizaVisa.tipotarjeta.value;
	var mes_caducidad = document.formActualizaVisa.mes.value;
	var ano_caducidad = document.formActualizaVisa.ano.value;
	var id_usuario = document.formActualizaVisa.id_usuario.value;
	var tienedatos = document.formActualizaVisa.tienedatos.value;

	function isValidEmail(strEmail) 
	  {
	   validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	   if (strEmail.search(validRegExp) == -1) {
	    return false;
	   } 
	   return true; 
	  }
	  	
	function isNumeric(str){
	  var re = /[^0-9]/g
	  if (re.test(str)) return false;
	  return true;
	} 	
	
	if (document.formActualizaVisa.nombre.value=="")
	    {
	    alert('Debe introducir el nombre')
	    document.formActualizaVisa.nombre.focus()
	    document.formActualizaVisa.nombre.style.background = '#FFFFD3'
	    return;
	    }
	else if(document.formActualizaVisa.apellidos.value=="")
	    {
	    alert('Debe introducir los apellidos')
	   	document.formActualizaVisa.apellidos.focus()
	    document.formActualizaVisa.apellidos.style.background = '#FFFFD3'
	    return;
	    } 
	else if(document.formActualizaVisa.direccion.value=="")
	    {
	    alert('Debe introducir la direccion')
	    document.formActualizaVisa.direccion.focus()
	    document.formActualizaVisa.direccion.style.background = '#FFFFD3'
	    return;
	    }
	else if(document.formActualizaVisa.poblacion.value=="")
	    {
	    alert('Debe introducir la poblacion')
	    document.formActualizaVisa.poblacion.focus()
	    document.formActualizaVisa.poblacion.style.background = '#FFFFD3'
	    return;
	    }	
	else if(document.formActualizaVisa.provincia.value=="")
	    {
	    alert('Debe introducir la provincia')
	    document.formActualizaVisa.provincia.focus()
	    document.formActualizaVisa.provincia.style.background = '#FFFFD3'
	    return;
	    }	     	    
	else if(document.formActualizaVisa.email.value == "" || document.formActualizaVisa.email.value == null) 
		{
		alert('Debe escribir una direccion de correo');
		document.formActualizaVisa.email.focus();
	    document.formActualizaVisa.email.style.background = '#FFFFD3'			
		return;
		}
	else if(!isValidEmail(document.formActualizaVisa.email.value)) 
		{
		alert('La direccion de correo no parece correcta');
		document.formActualizaVisa.email.focus();
	    document.formActualizaVisa.email.style.background = '#FFFFD3'	
		return;
		}	    
	else if(document.formActualizaVisa.dni.value=="")
	    {
	    alert('Debe introducir su DNI')
	   	document.formActualizaVisa.dni.focus()
	    document.formActualizaVisa.dni.style.background = '#FFFFD3'	    
	    return;
	    }	  	
	else if(document.formActualizaVisa.telefono.value=="")
	    {
	    alert('Debe introducir el telefono')
	    document.formActualizaVisa.telefono.focus()
	    document.formActualizaVisa.telefono.style.background = '#FFFFD3'
	    return;
	    }	    
	else if(document.formActualizaVisa.cp.value=="")
	    {
	    alert('Debe introducir el codigo postal')
	    document.formActualizaVisa.cp.focus()
	    document.formActualizaVisa.cp.style.background = '#FFFFD3'
	    return;
	    }		
	else if(document.formActualizaVisa.titular.value=="")
	    {
	    alert('Debe introducir el titular de la tarjeta')
	   	document.formActualizaVisa.titular.focus()
	    document.formActualizaVisa.titular.style.background = '#FFFFD3'		    
	    return;
	    }		        	    	    	          	
	else if(document.formActualizaVisa.pan.value=="")
	    {
	    alert('Debe introducir el numero de tarjeta')
	   	document.formActualizaVisa.pan.focus()
	    document.formActualizaVisa.pan.style.background = '#FFFFD3'		    
	    return;
	    }	 
	else if(!isNumeric(document.formActualizaVisa.pan.value)) 
		{
			alert(document.formActualizaVisa.pan.value)
		alert('El numero de la tarjeta de credito solo puede contener numeros');
	   	document.formActualizaVisa.pan.focus()
	    document.formActualizaVisa.pan.style.background = '#FFFFD3'	
		return;
		}	
	else if (document.formActualizaVisa.pan.value.length < 16)   
		{
		alert('El numero de la tarjeta de credito debe contener 16 numeros');
	   	document.formActualizaVisa.pan.focus()
	    document.formActualizaVisa.pan.style.background = '#FFFFD3'	
		return;
		}    
	else if(document.formActualizaVisa.entidad.value=="")
	    {
	    alert('Debe introducir la entidad bancaria')
	   	document.formActualizaVisa.entidad.focus()
	    document.formActualizaVisa.entidad.style.background = '#FFFFD3'		    
	    return;
	    }
	else if(document.formActualizaVisa.ano.value==2005 && document.formActualizaVisa.mes.value==01)
	    {
	    alert('Introduzca la fecha de caducidad de la tarjeta')
	   	document.formActualizaVisa.mes.focus()
	    document.formActualizaVisa.mes.style.background = '#FFFFD3'    
	    document.formActualizaVisa.ano.style.background = '#FFFFD3'
	    return;
	    }
	else
		{
		if(tienedatos)
			DoCallback("actualizaTarjetaCredito=true&id_datosbancarios="+id_datosbancarios+"&nombre="+encodeURIComponent(nombre)+"&apellidos="+encodeURIComponent(apellidos)+"&direccion="+encodeURIComponent(direccion)+"&poblacion="+encodeURIComponent(poblacion)+"&provincia="+encodeURIComponent(provincia)+"&email="+encodeURIComponent(email)+"&dni="+dni+"&telefono="+telefono+"&cp="+cp+"&titular="+encodeURIComponent(titular)+"&num_tarjeta="+num_tarjeta+"&entidad="+entidad+"&tipo_tarjeta="+tipo_tarjeta+"&mes_caducidad="+mes_caducidad+"&ano_caducidad="+ano_caducidad+"&id_tarjeta="+id_tarjeta+"&id_usuario="+id_usuario);	
		else
			DoCallback("creaTarjetaCredito=true&id_datosbancarios="+id_datosbancarios+"&nombre="+encodeURIComponent(nombre)+"&apellidos="+encodeURIComponent(apellidos)+"&direccion="+encodeURIComponent(direccion)+"&poblacion="+encodeURIComponent(poblacion)+"&provincia="+encodeURIComponent(provincia)+"&email="+encodeURIComponent(email)+"&dni="+dni+"&telefono="+telefono+"&cp="+cp+"&titular="+encodeURIComponent(titular)+"&num_tarjeta="+num_tarjeta+"&entidad="+entidad+"&tipo_tarjeta="+tipo_tarjeta+"&mes_caducidad="+mes_caducidad+"&ano_caducidad="+ano_caducidad+"&id_tarjeta="+id_tarjeta+"&id_usuario="+id_usuario);	
		}	
	}	
/***** OLD JS *****/



$(document).ready(function(){
	
	$("DIV.calOn").click(
		function(){
			id_anuncio= $(this).attr('id_anuncio');
			id_destino= $(this).attr('id_destino');
			id_origen= $(this).attr('id_origen');
			celda= $(this).attr('celda');
			jQuery.facebox({ ajax: '/pops/add-proposicion.php?id_destino='+id_destino+'&id_origen='+id_origen+'&celda='+celda+'&id_anuncio='+id_anuncio })	
		}
	);			
	
});