



	function enviarAnuncio(vu_form)
	{
		var lu_titulo = vu_form.elements['tx_titulo'];
		var lu_categoria = vu_form.elements['sl_categoria'];
		var lu_poblacion = vu_form.elements['sl_poblacion'];
		var lu_nombre = vu_form.elements['tx_nombre'];
		var lu_telefono = vu_form.elements['tx_telefono'];
		var lu_email = vu_form.elements['tx_email'];
		var lu_anuncio = vu_form.elements['tx_anuncio'];
		
		Form.trimField(lu_titulo);
		Form.trimField(lu_nombre);
		Form.trimField(lu_telefono);
		Form.trimField(lu_email);
		
		Form.trimField(lu_anuncio);
		var ls_anuncio = lu_anuncio.value;
		ls_anuncio = ls_anuncio.replace('\r', '');
		ls_anuncio = ls_anuncio.replace('\t', '');
		ls_anuncio = ls_anuncio.replace('\n', '');
		
		if (lu_titulo.value == '')
		{
			return(Form.msgError(lu_titulo, 'Introduzca el título del anuncio'));
		}
		else if(!lu_categoria.options.selectedIndex > 0)
		{
			return(Form.msgError(lu_categoria, 'Seleccione una categoría para el anuncio'));
		}
		else if(!lu_poblacion.options.selectedIndex > 0)
		{
			return(Form.msgError(lu_poblacion, 'Seleccione una población para el anuncio'));
		}
		else if(lu_email.value != '' && !Form.isMail(lu_email.value))
		{
			return(Form.msgError(lu_email, 'La dirección de e-mail tiene un formato incorrecto'));
		}
		else if (ls_anuncio == '')
		{
			return(Form.msgError(lu_anuncio, 'Introduzca el texto del anuncio'));
		}
		else
		{
			if (vu_form.elements['MAX_FILE_SIZE'])
			{
				var re = /\.jpg$/i;
				var lb_files = false;
				for (var i = 0; i <= 3; i++)
				{
					var lu_file = vu_form.elements['tx_file_' + i];
					var ls_file = ('' + lu_file.value).trim();
					if (ls_file !== '')
					{
						lb_files = true;
						if (!re.test(ls_file)) { alert('Sólo se permiten imágenes del tipo JPG'); return(false); }
					}
				}

				if (lb_files)
				{
					vu_form.enctype = 'multipart/form-data';
					if (vu_form.encoding) vu_form.encoding = 'multipart/form-data';
				}
			}
			return(true);
		}
	}



	function addInputFiles(vs_text)
	{
		var lu_div = document.getElementById('imagenes');
		if (!lu_div) return;
		
		var ls_div = vs_text;
		for (var i = 0; i < 4; i++) ls_div += '<div class="imagenes-item"><input type="file" size="100" name="tx_file_' + i + '" /></div>' + "\n";
		
		lu_div.innerHTML = ls_div;
		lu_div.style.display = 'block';
	}



	function eliminarAnuncio()
	{
		if (confirm('¿Borrar el anuncio?' + "\n\n" + 'La eliminación del anuncio será definitiva.'))
		{
			var lu_form = document.forms['fm_anuncio'];
			lu_form.elements['hd_delete'].value = '1';
			lu_form.submit();
		}
	}
