
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function esconde_todas()
{
	jQuery('.cabecera_filtro_negra').slideUp(200);
	jQuery('.filtro_gris').slideUp(200);
	
	jQuery('#cierre_1').slideUp(0);
	jQuery('#cierre_2').slideUp(0);
	jQuery('#cierre_3').slideUp(0);	
}

function muestra_menu(id)
{
	jQuery('#cabecera_filtro_negra_'+id).slideDown(400);
	jQuery('#filtro_gris_'+id).slideDown(400);
	
	if (id==1)
	{
		jQuery('#cierre_1').slideDown(0);	
		//document.getElementById('cabecera_1').onclick = esconde_todas();
		//document.getElementById('link_1').onclick = "esconde_todas();";
	}
	if (id==10)
	{
		jQuery('#cierre_2').slideDown(0);	
	}
	if (id==4)
	{
		jQuery('#cierre_3').slideDown(0);	
	}
}



function imagen_home()
{
	if (document.datos.foto.value=="")
	{
		alert ("Debe seleccionar la nueva Imagen");
	}
	else
	{
		document.datos.submit();
	}
}



function envia_form()
{
	if (document.datos.empresa.value=="")
	{
		alert ("Debe cumplimentar el Nombre de su Empresa.");
	}
	else if (document.datos.nombre.value=="")
	{
		alert ("Debe cumplimentar su Nombre.");
	}
	else if (document.datos.apellidos.value=="")
	{
		alert ("Debe cumplimentar sus Apellidos.");
	}
	else if (document.datos.telefono.value=="")
	{
		alert ("Debe cumplimentar su Telefono de Contacto.");
	}
//	else if (document.datos.email.value=="")
//	{
//		alert ("Debe cumplimentar su Direccion de Email.");
//	}
	else if (document.datos.consulta.value=="")
	{
		alert ("Debe introducir su Consulta.");
	}
	else
	{
		document.datos.action="contacto_confirm.php";
		document.datos.submit();
	}
}


function envia_catalogo()
{
	if (document.form.empresa.value=="")
	{
		alert ("Debe cumplimentar el Nombre de su Empresa.");
	}
	else if (document.form.nombre.value=="")
	{
		alert ("Debe cumplimentar su Nombre.");
	}
	else if (document.form.apellidos.value=="")
	{
		alert ("Debe cumplimentar sus Apellidos.");
	}
	else if (document.form.telefono.value=="")
	{
		alert ("Debe cumplimentar su Telefono de Contacto.");
	}
	else if (document.form.email.value=="")
	{
		alert ("Debe cumplimentar su Direccion de Email.");
	}
	
	else
	{
		document.form.action="productos_catalogo_confirm.php";
		document.form.submit();
	}
}

function popUpLoc()
{
	var winattributes="width=700px,height=300px,resizable=no,top=200px,left=150px";
	window.open("localizacion.php","", winattributes)	
}

function popUpFiltro()
{
	var winattributes="width=640px,height=200px,resizable=no,top=200px,left=150px";
	window.open("clientes_filtro.php","", winattributes)	
}

function cerrarsesion ()
{
	if (confirm("¿Desea cerrar la sesión actual del Administrador?"))
	{
		location.href="cerrarsesion.php";
	}
}


function clientes_filtrar()
{
	
	nombre=document.datos.nombre.value;
	activo=document.datos.activo.value;
	tipo=document.datos.tipo.value;
	if (tipo==0)
	{
		tipo="";	
	}
	opener.location='clientes_listado.php?tipo='+tipo+'&nombre='+nombre+'&activo='+activo;
	window.close();	
}


function nueva_imagen()
{
	contador=parseInt(document.datos.contador_imagenes.value);
	contador_new=contador+1;
	var capa=document.getElementById("div_imagenes_"+contador);
	capa.innerHTML="Descripcion Imagen&nbsp;&nbsp;<input type='text' name='descripcion_"+contador+"' size='50'><br>Nueva Imagen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='file' name='imagen_"+contador+"' size='40'  onChange='javascript:nueva_imagen();'><br><br><div id='div_imagenes_"+contador_new+"'></div>";
	document.datos.contador_imagenes.value=contador_new;
}

function clientes_alta()
{
	
	cliente_valida=0;
	if ((document.datos.tipo.value==2) || (document.datos.tipo.value==3) || (document.datos.tipo.value==4))
	{
		cliente_valida=1;
	}
	
	cliente_pecho=0;
	if ((document.datos.tipo.value==3) || (document.datos.tipo.value==4))
	{
		cliente_pecho=1;
	}
	
	cliente_pene=0;
	if ((document.datos.tipo.value==2) || (document.datos.tipo.value==4))
	{
		cliente_pene=1;
	}
	
	cliente_error=0;
	
	
	if (document.datos.activo.value=="9999")
	{
		//alert ("Debe seleccionar si el Cliente esta Activo");
		cliente_error=1;
	}
	else if (document.datos.tipo.value=="0")
	{
		//alert ("Debe seleccionar el Tipo de Cliente");
		cliente_error=1;
	}
	else if (document.datos.nombre.value=="")
	{
		//alert ("Debe introducir el Nombre");
		cliente_error=1;
	}
	else if (document.datos.error_usuario.value==1)
	{
		//alert ("Debe introducir el Nombre");
		document.datos.nombre_unico.value="";
		cliente_error=1;
	}
	else if ((cliente_valida==0) && (document.datos.logo.value==""))
	{
		//alert ("Debe seleccionar el Logo");
		cliente_error=1;
	}
	else if (document.datos.movil.value=="")
	{
		//alert ("Debe introducir el Telefono 1");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.nacionalidad.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, la NACIONALIDAD es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.idiomas.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un IDIOMA");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.pelo.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, el COLOR DE PELO es obligatorio");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.ojos.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, el COLOR DE OJOS es obligatorio");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.edad.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, la EDAD es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.altura.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, la ALTURA es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.altura.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, la ALTURA es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_pecho==1) && (document.datos.medidas_1.value=="0"))
	{
		//alert ("Para el Tipo de cliente, debe seleccionar el TAMAÑO DEL PECHO");
		cliente_error=1;
	}
	else if ((cliente_pene==1) && (document.datos.medidas_2.value=="0"))
	{
		//alert ("Para el Tipo de cliente, debe seleccionar el TAMAÑO DEL PENE");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.orientacion.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un TIPO DE ORIENTACION SEXUAL");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.servicios.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un TIPO DE SERVICIO");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.tarifa_hora.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe introducir la TARIFA UNA HORA");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.forma_pago_1.checked==false) && (document.datos.forma_pago_2.checked==false) && (document.datos.forma_pago_3.checked==false))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos una FORMA DE PAGO");
		cliente_error=1;
	}
	
	if (cliente_error==1)
	{
		if (confirm("Se han encontrado datos obligatorios sin cumplimentar. ¿Desea grabar el cliente actual con estado 'FALTAN DATOS'?"))
		{
			document.datos.activo.value="2";
			cliente_error=0;
		}
	}
	
	
	if (cliente_error==0)
	{
		document.datos.method="post";
		document.datos.action="clientes_alta2.php";
		document.datos.submit();
	}
}


function clientes_modificacion(id_usuario)
{
	
	cliente_valida=0;
	if ((document.datos.tipo.value==2) || (document.datos.tipo.value==3) || (document.datos.tipo.value==4))
	{
		cliente_valida=1;
	}
	
	cliente_pecho=0;
	if ((document.datos.tipo.value==3) || (document.datos.tipo.value==4))
	{
		cliente_pecho=1;
	}
	
	cliente_pene=0;
	if ((document.datos.tipo.value==2) || (document.datos.tipo.value==4))
	{
		cliente_pene=1;
	}
	
	cliente_error=0;
	
	
	if (document.datos.activo.value=="9999")
	{
		//alert ("Debe seleccionar si el Cliente esta Activo");
		cliente_error=1;
	}
	else if (document.datos.tipo.value=="0")
	{
		//alert ("Debe seleccionar el Tipo de Cliente");
		cliente_error=1;
	}
	else if (document.datos.nombre.value=="")
	{
		//alert ("Debe introducir el Nombre");
		cliente_error=1;
	}
	
	else if (document.datos.movil.value=="")
	{
		//alert ("Debe introducir el Telefono 1");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.nacionalidad.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, la NACIONALIDAD es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.idiomas.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un IDIOMA");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.pelo.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, el COLOR DE PELO es obligatorio");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.ojos.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, el COLOR DE OJOS es obligatorio");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.edad.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, la EDAD es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.altura.value=="0"))
	{
		//alert ("Para el Tipo de cliente seleccionado, la ALTURA es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.altura.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, la ALTURA es obligatoria");
		cliente_error=1;
	}
	else if ((cliente_pecho==1) && (document.datos.medidas_1.value=="0"))
	{
		//alert ("Para el Tipo de cliente, debe seleccionar el TAMAÑO DEL PECHO");
		cliente_error=1;
	}
	else if ((cliente_pene==1) && (document.datos.medidas_2.value=="0"))
	{
		//alert ("Para el Tipo de cliente, debe seleccionar el TAMAÑO DEL PENE");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.orientacion.value==""))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un TIPO DE ORIENTACION SEXUAL");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.servicios.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos un TIPO DE SERVICIO");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.tarifa_hora.value==0))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe introducir la TARIFA UNA HORA");
		cliente_error=1;
	}
	else if ((cliente_valida==1) && (document.datos.forma_pago_1.checked==false) && (document.datos.forma_pago_2.checked==false) && (document.datos.forma_pago_3.checked==false))
	{
		//alert ("Para el Tipo de cliente seleccionado, debe seleccionar al menos una FORMA DE PAGO");
		cliente_error=1;
	}
	
	if (cliente_error==1)
	{
		if (confirm("Se han encontrado datos obligatorios sin cumplimentar. ¿Desea grabar el cliente actual con estado 'FALTAN DATOS'?"))
		{
			document.datos.activo.value="2";
			cliente_error=0;
		}
	}
	
	
	if (cliente_error==0)
	{
		document.datos.method="post";
		document.datos.action="clientes_detalle2.php?id="+id_usuario
		document.datos.submit();
		
	}
}


function clientes_borrar(nombre, codigo)
{
	if (confirm("¿Desea borrar el Cliente '"+nombre+"'?"))
	{
	location.href="clientes_baja.php?id="+codigo;
	}
}


function clientes_borrar_foto(codigo, cliente)
{
	if (confirm("¿Desea borrar la Foto seleccionada?"))
	{
	location.href="clientes_fotos_baja.php?id="+codigo+"&cliente="+cliente;
	}
}



/*FUNCIONES PARA CARGAR LOS COMBOS DE MUNICIPIO Y DISTRITO*/
function ajaxobj() {
	try {
		_ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			_ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			_ajaxobj = false;
		}
	}
   
	if (!_ajaxobj && typeof XMLHttpRequest!='undefined') {
		_ajaxobj = new XMLHttpRequest();
	}
	
	return _ajaxobj;
}

function carga(val, fichero, combo) {
	var ajax = ajaxobj();
	
	//alert (combo2.value);
	
	var combo2 = document.getElementById(combo);	
	
	var longitud=combo2.options.length;
	for (var i=0; i<longitud;i++)
	{
		combo2.options[0] = null;
	}
	//alert (1);
	//combo2.options[0]= new Option ("--Seleccione--","0",false,true)
	ajax.open("POST", fichero, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			var datos = (ajax.responseXML).firstChild;
			var obj = document.getElementById(combo);
			for (var i=0; i<obj.options.length; i++) {
        obj.removeChild(obj.firstChild);
      }
	 // alert (2);
	  //alert (datos.childNodes.length); 
	  obj.options[0]= new Option ("--Seleccione--","0",false,true);
	 // alert (4);
      for (var i=1; i<(datos.childNodes.length+1); i++) {
        var elem = datos.childNodes[i-1].firstChild.data;
        
		var array_aux=elem.split("----");
		obj.options[i] = new Option (array_aux[1],array_aux[0],false,false);
		//new Option (valormodelo[1],valormodelo[0],false,false);
      }
		}
	}
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send("&val="+val);
	//alert (3);
}


function carga_anuncio(val, fichero, combo) {
	var ajax = ajaxobj();
	//alert (combo);
	
	//alert (combo2.value);
	
	var combo2 = document.getElementById(combo);	
	
	var longitud=combo2.options.length;
	for (var i=0; i<longitud;i++)
	{
		combo2.options[0] = null;
	}
	//combo2.options[0]= new Option ("--Seleccione--","0",false,true)
	ajax.open("POST", fichero, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			var datos = (ajax.responseXML).firstChild;
			var obj = document.getElementById(combo);
			for (var i=0; i<obj.options.length; i++) {
        obj.removeChild(obj.firstChild);
      }
	  //alert (datos.childNodes.length); 
	  obj.options[0]= new Option ("SELECCIONE","000",false,true)
      for (var i=1; i<(datos.childNodes.length+1); i++) {
        var elem = datos.childNodes[i-1].firstChild.data;
        
		var array_aux=elem.split("----");
		obj.options[i] = new Option (array_aux[1],array_aux[0],false,false);
		//new Option (valormodelo[1],valormodelo[0],false,false);
      }
		}
	}
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send("&val="+val);
}

/**/



function carga_municipios()
{

	var combo2 = document.datos.distrito;
	var longitud=combo2.options.length;
	for (var i=0; i<longitud;i++)
	{
		combo2.options[0] = null;
	}

	combo2.options[0]= new Option ("--Seleccione--","0",false,true)
	
	var combo1 = document.datos.municipio;
	var longitud=combo1.options.length;
	for (var i=0; i<longitud;i++)
	{
		combo1.options[0] = null;
	}
	
	combo1.options[0]= new Option ("--Seleccione--","0",false,true)
	var array_aux=document.datos.ciudad.value.split("----");
	if (document.datos.ciudad.value!="0")
	{
			
		var arrayvalores=array_aux[1].split("@@@@");
		var valormodelo;
		i=0;

		for (var prop in arrayvalores) 
		{
			valormodelo=arrayvalores[prop].split(";;;;");
			
			i=i+1;
			if (valormodelo[1]>"0")
			{
				combo1.options[i]= new Option (valormodelo[1],valormodelo[0],false,false);
			}
		}
		
	}
}

function nueva_imagen()
{
	contador=parseInt(document.datos.contador_imagenes.value);
	contador_new=contador+1;
	var capa=document.getElementById("div_imagenes_"+contador);
	capa.innerHTML="Imagen:&nbsp;&nbsp;&nbsp;<input type='file' name='imagen_"+contador+"' size='40'  onChange='javascript:nueva_imagen();'><br><br><div id='div_imagenes_"+contador_new+"'></div>";
	document.datos.contador_imagenes.value=contador_new;
}

function anuncios_alta()
{
	/*if (document.datos.cod_concepto_facturacion.value=="0")
	{
		alert ("Debes seleccionar el Tipo de Anuncio");
	}
	else */
	if (document.datos.fecha_ini.value=="")
	{
		alert ("Debes seleccionar la Fecha de Inicio");
	}
	else if (document.datos.tarifa_base.value=="")
	{
		alert ("Debes introducir la Tarifa Base");
	}
	/*else if ((document.datos.cod_concepto_facturacion.value!="1") && (document.datos.imagen.value==""))
	{
		alert ("Debes seleccionar la Imagen para el Anuncio");
	}*/
	else
	{
		if (document.datos.tarifa.value=="")
		{
			document.datos.tarifa.value=0;
		}
		document.datos.submit();	
	}
}


function banners_alta()
{
	
	if ((document.datos.tipo.value!=5) && (document.datos.cliente.value=="000"))
	{
		alert ("Debes seleccionar el Cliente");
	}
	else if ((document.datos.tipo.value==5) && (document.datos.cliente.value=="000") && (document.datos.nombre.value=="") && (document.datos.web.value==""))
	{
		alert ("Debe seleccionar el Cliente");
	}
	else if (document.datos.foto.value=="")
	{
		alert ("Debes seleccionar la Imagen");
	}
	else if (document.datos.fecha_ini.value=="")
	{
		alert ("Debes seleccionar la Fecha de Inicio");
	}
	else if (document.datos.tarifa_base.value=="")
	{
		alert ("Debes introducir la Tarifa Base");
	}
	else
	{
		document.datos.submit();	
	}
}


function banners_detalle()
{
	if ((document.datos.tipo.value!=5) && (document.datos.cliente.value=="000"))
	{
		alert ("Debes seleccionar el Cliente");
	}
	else if ((document.datos.tipo.value==5) && (document.datos.cliente.value=="000") && (document.datos.nombre.value=="") && (document.datos.web.value==""))
	{
		alert ("Debe seleccionar el Cliente");
	}
	else if (document.datos.fecha_ini.value=="")
	{
		alert ("Debes seleccionar la Fecha de Inicio");
	}
	else if (document.datos.tarifa_base.value=="")
	{
		alert ("Debes introducir la Tarifa Base");
	}
	else
	{
		document.datos.submit();	
	}
}


function anuncios_detalle()
{
	/*if (document.datos.cod_concepto_facturacion.value=="0")
	{
		alert ("Debes seleccionar el Tipo de Anuncio");
	}
	else */
	if (document.datos.tarifa_base.value=="")
	{
		alert ("Debes introducir la Tarifa Base");
	}
	else
	{
		if (document.datos.tarifa.value=="")
		{
			document.datos.tarifa.value=0;
		}
		document.datos.submit();	
	}
}



function anuncios_borrar(codigo, cliente)
{
	if (confirm("¿Desea borrar el Anuncio Seleccionado?"))
	{
	location.href="anuncios_baja.php?id="+codigo+"&cliente="+cliente;
	}
}




function objetoAjax()
{
	var xmlhttp=false;
	try 
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function MostrarConsulta(datos)
{ 
	divResultado = document.getElementById('derecha'); 
	ajax=objetoAjax();
	
	datos=datos+document.consulta.consulta_txt.value;
	//	alert(datos); consulta_tipo.php
	datos = datos.replace("á","a");
	datos = datos.replace("é","e");
	datos = datos.replace("í","i");
	datos = datos.replace("ó","o");
	datos = datos.replace("ú","u");
	//  alert(datos);
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			divResultado.innerHTML = ajax.responseText;
		}
	} 
	ajax.send(null);
}

function actualizaConsulta()
{
	texto_final="?tipo="+document.consulta.tipo.value;
	texto_final=texto_final+"&ciudad="+document.consulta.ciudad.value;
	texto_final=texto_final+"&txt_buscar="+document.consulta.txt_buscar.value;
	

	texto_final=texto_final+"&edad_min="+document.consulta.edad_min.value;
	texto_final=texto_final+"&edad_max="+document.consulta.edad_max.value;
	
	total_idiomas=document.consulta.total_idiomas.value;
	//alert (total_idiomas);
	for (i=1;i<=total_idiomas;i++)
	{
		//alert ('idioma_'+i);
		chk = document.getElementById('idioma_'+i); 
		
		if (chk.checked==true)
		{
			
			texto_final=texto_final+"&idioma_"+i+"=1";
		}
		else
		{
			//texto_final=texto_final+"&idioma_"+i+"=0";
		}
		
	}
	
	
	if (document.consulta.orientacion.value!="000")
	{
		texto_final=texto_final+"&orientacion="+document.consulta.orientacion.value;
	}
	
	if (document.consulta.nacionalidad.value!="000")
	{
		texto_final=texto_final+"&nacionalidad="+document.consulta.nacionalidad.value;
	}
	
	texto_final=texto_final+"&tarifa_min="+document.consulta.tarifa_min.value;
	texto_final=texto_final+"&tarifa_max="+document.consulta.tarifa_max.value;
	
	total_pelos=document.consulta.total_pelos.value;
	for (i=1;i<=total_pelos;i++)
	{
		//alert ('idioma_'+i);
		chk = document.getElementById('pelo_'+i); 
		
		if (chk.checked==true)
		{
			texto_final=texto_final+"&pelo_"+i+"=1";
		}
		else
		{
			//texto_final=texto_final+"&pelo_"+i+"=0";
		}
		
	}
	
	
	total_ojos=document.consulta.total_ojos.value;
	for (i=1;i<=total_ojos;i++)
	{
		//alert ('idioma_'+i);
		chk = document.getElementById('ojo_'+i); 
		
		if (chk.checked==true)
		{
			texto_final=texto_final+"&ojo_"+i+"=1";
		}
		else
		{
			//texto_final=texto_final+"&ojo_"+i+"=0";
		}
		
	}
	
	texto_final=texto_final+"&estatura_min="+document.consulta.estatura_min.value;
	texto_final=texto_final+"&estatura_max="+document.consulta.estatura_max.value;
	
	texto_final=texto_final+"&peso_min="+document.consulta.peso_min.value;
	texto_final=texto_final+"&peso_max="+document.consulta.peso_max.value;
	
	if (document.consulta.pecho_1.checked==true)
	{
			texto_final=texto_final+"&pecho_1=1";
	}
	if (document.consulta.pecho_2.checked==true)
	{
			texto_final=texto_final+"&pecho_2=1";
	}
	if (document.consulta.pecho_3.checked==true)
	{
			texto_final=texto_final+"&pecho_3=1";
	}
	if (document.consulta.pecho_4.checked==true)
	{
			texto_final=texto_final+"&pecho_4=1";
	}
	
	
	if (document.consulta.pene_1.checked==true)
	{
			texto_final=texto_final+"&pene_1=1";
	}
	if (document.consulta.pene_2.checked==true)
	{
			texto_final=texto_final+"&pene_2=1";
	}
	if (document.consulta.pene_3.checked==true)
	{
			texto_final=texto_final+"&pene_3=1";
	}
	if (document.consulta.pene_4.checked==true)
	{
			texto_final=texto_final+"&pene_4=1";
	}
	
	total_servicios=document.consulta.total_servicios.value;
	for (i=1;i<=total_servicios;i++)
	{
		//alert ('idioma_'+i);
		chk = document.getElementById('servicio_'+i); 
		
		if (chk.checked==true)
		{
			texto_final=texto_final+"&servicio_"+i+"=1";
		}
		else
		{
			//texto_final=texto_final+"&servicio_"+i+"=0";
		}
		
	}
	
	if (document.consulta.viajes.checked==true)
	{
		texto_final=texto_final+"&viajes=1";
	}
	else
	{
		//texto_final=texto_final+"&viajes=0";
	}

	if (document.consulta.salidas.checked==true)
	{
		texto_final=texto_final+"&salidas=1";
	}
	else
	{
		//texto_final=texto_final+"&salidas=0";
	}
	
	if (document.consulta.chk_agencia.checked==true)
	{
		texto_final=texto_final+"&chk_agencia=1";
	}
	
	if (document.consulta.chk_independiente.checked==true)
	{
		texto_final=texto_final+"&chk_independiente=1";
	}
	
	
	if (document.consulta.chk_forma_pago_1.checked==true)
	{
		texto_final=texto_final+"&chk_forma_pago_1=1";
	}
	if (document.consulta.chk_forma_pago_2.checked==true)
	{
		texto_final=texto_final+"&chk_forma_pago_2=1";
	}
	if (document.consulta.chk_forma_pago_3.checked==true)
	{
		texto_final=texto_final+"&chk_forma_pago_3=1";
	}
	
	
	document.consulta.consulta_txt.value=texto_final;
	
	if (document.consulta.tipo.value=="")
	{
		MostrarConsulta("consulta_ciudad.php");	
	}
	else
	{
		MostrarConsulta("consulta_tipo.php");	
	}
	
	
	
	
}

function insertarVisitaTfno(id)
{ 
	divResultado = document.getElementById("visitaTfno"); 
	ajax=objetoAjax();
	
	datos="visita_tfno.php?id="+id;
	
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			divResultado.innerHTML = ajax.responseText;
		}
	} 
	ajax.send(null);
}


function mostrar_movil(num, id)
{
	var capa=document.getElementById("mostrar_movil");
	capa.innerHTML=	num;
	insertarVisitaTfno(id);
	//alert (id);
}

function mostrar_movil_1(num, id)
{
	var capa=document.getElementById("mostrar_movil_1");
	capa.innerHTML=	num;
	insertarVisitaTfno(id);
	//alert (id);
}




function calcula_posicionAJAX(tipo, puja, ciudad, nombreCiudad)
{ 
	
	divResultado = document.getElementById("cantidad_puja"); 
	divResultado.innerHTML =puja + "&euro;";
	divResultado = document.getElementById("resultado_posicion"); 
	
	ajax=objetoAjax();
	
	cadena="calcula_posicion_puja.php?tipo="+tipo+"&puja="+puja+"&ciudad="+ciudad+"&nombreCiudad="+nombreCiudad;
	//alert(cadena);
	ajax.open("GET", cadena);
	
	ajax.onreadystatechange=function(){
		if (ajax.readyState==4) {
			
			divResultado.innerHTML = (ajax.responseText).split("|")[0];
			document.getElementById("cantidad_puja_max").innerHTML = (ajax.responseText).split("|")[1];
			document.getElementById("resultado_posicion_p").innerHTML = (ajax.responseText).split("|")[2]; 
			if ((ajax.responseText).split("|")[3]!="") {
				document.getElementById("cantidad_puja_p_max").innerHTML = (ajax.responseText).split("|")[3];
			}
			else {
				document.getElementById("cantidad_puja_p_max").innerHTML = (parseInt(puja)+1)+"&euro;";
			}
		}
	} 
	ajax.send(null);
}


function calcula_posicion()
{
	var tipo=document.datos.tipo.value;
	var puja=document.datos.puja.value;
	var ciudad=document.datos.ciudad_puja.value;
    var x=document.datos.ciudad_puja;
    var nombreCiudad = x.options[x.selectedIndex].text;
    	
	if (puja=="")
	{
		puja=0;	
	}
	//alert (nombreCiudad);
	calcula_posicionAJAX(tipo, puja, ciudad, nombreCiudad);
	//alert (id);
}



function admin_tipo_cliente()
{	
	tipo=document.datos.tipo.value;
	//alert (tipo);
	if ((tipo==1) || (tipo==5))
	{
		jQuery('.personas').slideUp(0);	
		jQuery('.agencias').slideDown(0);	
	}
	else
	 {
		jQuery('.agencias').slideUp(0);	
		jQuery('.personas').slideDown(0);	
	 }
	
}


/*function calcula_edad(fecha)
{
	array_fecha=fecha.split("/");
	if (array_fecha.length!=3)
	{
		alert ("La fecha introducida es incorrecta");	
	}
	else
	{
		array_hoy=fecha.split("/");
		alert (array_fecha.length);	
	}
}*/

function calcula_edad(fecha){ 

    //calculo la fecha de hoy 
    hoy=new Date() 
    //alert(hoy) 

    //calculo la fecha que recibo 
    //La descompongo en un array 
    var array_fecha = fecha.split("/") 
    //si el array no tiene tres partes, la fecha es incorrecta 
    if (array_fecha.length!=3) 
		alert ("La fecha introducida es incorrecta");
       //return false 

    //compruebo que los ano, mes, dia son correctos 
    var ano 
    ano = parseInt(array_fecha[2]); 
    if (isNaN(ano))
		alert ("La fecha introducida es incorrecta");
       //return false 

    var mes 
    mes = parseInt(array_fecha[1]); 
    if (isNaN(mes)) 
		alert ("La fecha introducida es incorrecta");
       //return false 

    var dia 
    dia = parseInt(array_fecha[0]); 
    if (isNaN(dia)) 
		alert ("La fecha introducida es incorrecta");
       //return false 


    //si el año de la fecha que recibo solo tiene 2 cifras hay que cambiarlo a 4 
    if (ano<=99) 
       ano +=1900 

    //resto los años de las dos fechas 
    edad=hoy.getYear()- ano - 1; //-1 porque no se si ha cumplido años ya este año 

    //si resto los meses y me da menor que 0 entonces no ha cumplido años. Si da mayor si ha cumplido 
    if (hoy.getMonth() + 1 - mes < 0) //+ 1 porque los meses empiezan en 0 
	{

       document.datos.edad.value=edad;
	}
    else if (hoy.getMonth() + 1 - mes > 0) 
	{

       document.datos.edad.value=edad+1;
	}

    //entonces es que eran iguales. miro los dias 
    //si resto los dias y me da menor que 0 entonces no ha cumplido años. Si da mayor o igual si ha cumplido 
    else if (hoy.getUTCDate() - dia >= 0) 
	{
		
       document.datos.edad.value=edad + 1 ;
	}
	else
	{

   	 document.datos.edad.value= edad ;
	}
} 


function valida_anunciate()
{
	
	if (document.datos.nombre.value=="")
	{
		alert ("Debes cumplimentar tu NOMBRE");	
	}
	else if (document.datos.movil.value=="")
	{
		alert ("Debes cumplimentar el TELEFONO 1");	
	}
	else if (document.datos.email.value=="")
	{
		alert ("Debes cumplimentar el EMAIL");	
	}
	else if ((document.datos.agencia.checked==false) && (document.datos.independiente.checked==false))
	{
		alert ("Debes cumplimentar si perteneces a una AGENCIA o eres INDEPENDIENTE");	
	}
	else if (document.datos.orientacion.value=="000")
	{
		alert ("Debes seleccionar tu ORIENTACION");	
	}
	else if (document.datos.nacionalidad.value=="000")
	{
		alert ("Debes seleccionar tu NACIONALIDAD");	
	}
	else if (document.datos.total_idiomas.value==0)
	{
		alert ("Debes seleccionar los IDIOMAS");	
	}
	else if (document.datos.ciudad.value=="000")
	{
		alert ("Debes seleccionar la PROVINCIA DONDE RESIDES ACTUALMENTE");	
	}
	else if ((document.datos.municipio.value=="000") && (document.datos.municipio.options.length>1)) 
	{
		alert ("Debes cumplimentar el MUNICIPIO DONDE RESIDES ACTUALMENTE");	
	}
	else if ((document.datos.distrito.value=="000") && (document.datos.distrito.options.length>1))
	{
		alert ("Debes cumplimentar el DISTRITO DONDE RESIDES ACTUALMENTE");		
	}
	else if (document.datos.direccion.value=="")
	{
		alert ("Debes cumplimentar tu DIRECCION");	
	}
	else if (document.datos.dia.value=="000")
	{
		alert ("Debes seleccionar el DIA de NACIMIENTO");	
	}
	else if (document.datos.mes.value=="000")
	{
		alert ("Debes seleccionar el MES de NACIMIENTO");	
	}
	else if (document.datos.ano.value=="")
	{
		alert ("Debes seleccionar el AÑO de NACIMIENTO");	
	}
	else if (document.datos.estatura.value=="")
	{
		alert ("Debes cumplimentar tu ESTATURA");	
	}
	else if (isNaN(document.datos.estatura.value))
	{
		alert ("Debes introducir una ESTATURA correcta. Por ejemplo: 160");	
	}
	else if (document.datos.peso.value=="")
	{
		alert ("Debes cumplimentar tu PESO");	
	}
	else if (isNaN(document.datos.peso.value))
	{
		alert ("Debes introducir un PESO correcto. Por ejemplo: 54");	
	}
	else if (document.datos.ojos.value=="000")
	{
		alert ("Debes seleccionar el COLOR DE OJOS");	
	}
	else if (document.datos.pelo.value=="000")
	{
		alert ("Debes seleccionar el COLOR DE PELO");	
	}
	else if ((document.datos.tipo.value!="chicos") && (document.datos.pecho.value=="000"))
	{
		alert ("Debes seleccionar el TAMAÑO DE PECHO");	
	}
	else if ((document.datos.tipo.value!="chicas") && (document.datos.pene.value=="000"))
	{
		alert ("Debes seleccionar el TAMAÑO DE PENE");	
	}
	else if ((document.datos.horario_1.value=="000") && (document.datos.horario_2.value=="000") && (document.datos.horario_3.value=="000") && (document.datos.horario_4.value=="000") && (document.datos.horario_5.value=="000") && (document.datos.horario_6.value=="000") )
	{
		alert ("Debes seleccionar el HORARIO");	
	}
	else if ((document.datos.horario_1.value=="000") && (document.datos.horario_2.value!="000")) 
	{
		alert ("Debes seleccionar el HORARIO de LUNES A VIERNES");	
	}
	else if ((document.datos.horario_1.value!="000") && (document.datos.horario_2.value=="000")) 
	{
		alert ("Debes seleccionar el HORARIO de LUNES A VIERNES");	
	}
	else if ((document.datos.horario_3.value=="000") && (document.datos.horario_4.value!="000")) 
	{
		alert ("Debes seleccionar el HORARIO de SABADOS");	
	}
	else if ((document.datos.horario_3.value!="000") && (document.datos.horario_4.value=="000")) 
	{
		alert ("Debes seleccionar el HORARIO de SABADOS");	
	}
	else if ((document.datos.horario_5.value=="000") && (document.datos.horario_6.value!="000")) 
	{
		alert ("Debes seleccionar el HORARIO de DOMINGOS");	
	}
	else if ((document.datos.horario_5.value!="000") && (document.datos.horario_6.value=="000")) 
	{
		alert ("Debes seleccionar el HORARIO de DOMINGOS");	
	}
	else if (document.datos.total_servicios.value==0)
	{
		alert ("Debes seleccionar los SERVICIOS");	
	}
	else if (isNaN(document.datos.tarifa_media_hora.value))
	{
		alert ("Debes introducir una TARIFA 30 MINUTOS correcta. Por ejemplo: 70");	
	}
	else if (document.datos.tarifa_hora.value=="")
	{
		alert ("Debes cumplimentar la TARIFA 1 HORA");	
	}
	else if (isNaN(document.datos.tarifa_hora.value))
	{
		alert ("Debes introducir una TARIFA 1 HORA correcta. Por ejemplo: 120");	
	}
	else if (isNaN(document.datos.tarifa_dos_horas.value))
	{
		alert ("Debes introducir una TARIFA 2 HORAS correcta. Por ejemplo: 150");	
	}
	else if (isNaN(document.datos.tarifa_tres_horas.value))
	{
		alert ("Debes introducir una TARIFA 3 HORAS correcta. Por ejemplo: 190");	
	}
	else if (isNaN(document.datos.tarifa_desplazamiento.value))
	{
		alert ("Debes introducir una TARIFA DESPLAZAMIENTO correcta. Por ejemplo: 300");	
	}
	else if (isNaN(document.datos.tarifa_noche.value))
	{
		alert ("Debes introducir una TARIFA NOCHE correcta. Por ejemplo: 500");	
	}
	else if (isNaN(document.datos.tarifa_finde.value))
	{
		alert ("Debes introducir una TARIFA FIN DE SEMANA correcta. Por ejemplo: 800");	
	}
	else if ((document.datos.forma_pago_1.checked==false) && (document.datos.forma_pago_2.checked==false) && (document.datos.forma_pago_3.checked==false))
	{
		alert ("Debes seleccionar una FORMA DE PAGO");	
	}
	else
	{
		//alert ("va todo bien");
		document.datos.method="post";
		document.datos.action="anunciate-envio";
		document.datos.submit();
	}
}

function valida_usuario_AJAX (usuario)
{ 
	
	divResultado = document.getElementById("validacion_usuario"); 
	
	ajax=objetoAjax();
	
	cadena="clientes_validacion.php?usuario="+usuario;
	
	ajax.open("GET", cadena);
	
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			divResultado.innerHTML = ajax.responseText;
			if (divResultado.innerHTML.indexOf("delete.gif")!=-1)
			{
				document.datos.error_usuario.value=1;
			}
			else
			{
				document.datos.error_usuario.value=0;
			}
		}
	} 
	ajax.send(null);
	
}


function valida_usuario(usuario)
{
	
	valida_usuario_AJAX(usuario);

}

function valida_usuario_det(usuario)
{
	
	if (usuario!=document.datos.nombre_unico_ant.value)
	{
		valida_usuario_AJAX(usuario);
	}
	else
	{
		divResultado = document.getElementById("validacion_usuario"); 
		divResultado.innerHTML="<img src='../img/ok.png' />";
		document.datos.error_usuario.value=0;		
	}

}






