function alertaError(tmpTipoError)
	{
	var tmpMsg = '';

	switch(tmpTipoError)
		{
		// Errores CATEGORÍA
		case 1:
			tmpMsg = 'La categoria indicada ya existe.';	
			break;
		// Errores DOCUMENTOS
		case 4:
			tmpMsg = 'No se ha podido insertar el fichero';
			break;
		case 5:
			tmpMsg = 'No existe el documento';
			break;
			
		// Errores ENLACES
		case 8: tmpMsg = 'La Url es incorrecta. Ejemplo:\n  Nombre: Terra\n  Url: http://www.terra.es';
			break;
			
		// Errores PRODUCTOS
		case 11: tmpMsg = 'No existe el producto';
			break;
			
		// Errores COMMON	
		case 10: tmpMsg = 'No se ha podido insertar la imagen.';
			break;
		
		// Errores VIVIENDAS
		case 20: tmpMsg = 'No se puede insertar mas viviendas.\nSe ha superado el numero maximo permitido';
			break;
		}

	if (tmpMsg != '')
		alert(tmpMsg);
	}

var tmpFormLinkName = "formGen";

// -------------------------------------------------------------------
// ---- FUNCIONES GENERICAS
	function validaPasswords(tmpPass1, tmpPass2)
	{
		var retorno = true
		
		if (tmpPass1 != tmpPass2 || tmpPass1 == '' || tmpPass1.length >= 50)
			retorno = false;
			
		return retorno
	}
	
	// Función que engloba la validacion de un fichero
	function validaFichero_vacio(tmpFile, tmpExtensiones, tmpFlagValidaFicheroVacio)
	{
		var retorno = '';
		
		if ((tmpFlagValidaFicheroVacio) || (!tmpFlagValidaFicheroVacio && tmpFile != ''))
		{
			retorno = validaFichero(tmpFile, tmpExtensiones)
		}
		return retorno;
	}
	
	// Función que valida un fichero que se requiera que este.
	function validaFichero(tmpFile, tmpExtensiones)
	{
		var retorno = ''
		var tmpTipoMsg = 0;
		
		tmpTipoMsg = isValidFile_Name(tmpFile);				
		switch (tmpTipoMsg)
		{
			//Valores devueltos por isValidFile_Name
			case 1: retorno = 'Debe seleccionar un fichero'; break;
			case 2: retorno = 'El fichero no tiene extension'; break;
			case 3: retorno = 'El nombre del fichero tiene una longitud excesiva'; break;			
		}				
		if (retorno == '')
		{
			tmpTipoMsg = isValidFile_Extension(tmpFile, tmpExtensiones);
			switch (tmpTipoMsg)
			{
				//Valores devueltos por isValidFile_Extension
				case 1: retorno = 'Tipo de fichero no adminitido'; break;			
			}
		}
		return retorno;
	}
	
	//Esta función valida que la extension del fichero sea correcta. Devolverá
	//los siguiente codigos de error:
	//		- 0: ningun error
	//		- 1: extension no admitida
	function isValidFile_Extension(tmpFile, tmpExtensiones)
	{
		var retorno = 1;	//ERROR
		var i;
		var tmpExtensionesArray = tmpExtensiones.split(',');
		var tmpExtensionesArray_size = tmpExtensionesArray.length;
		var tmpFile_array = tmpFile.split('.');
		var tmpFile_arraySize = tmpFile_array.length;
		var tmpFile_extension = tmpFile_array[tmpFile_arraySize-1];
		tmpFile_extension = '.'.concat(tmpFile_extension);
		tmpFile_extension = tmpFile_extension.toUpperCase();
		for (i=0; i<tmpExtensionesArray_size; i++)
		{
			if (tmpFile_extension == tmpExtensionesArray[i].toUpperCase())		
				retorno = 0;	// OK
		}		
		return retorno;
	}
	
	//Esta función valida que el nombre del fichero sea correcto. Devolverá
	//los siguiente codigos de error:
	//		- 0: ningun error
	//		- 1: cadena vacia
	//		- 2: no tiene extension
	//		- 3: excede en longitud
	function isValidFile_Name(tmpFile)
	{			
		var tmpLongMax = 250;
		var retorno = 0;
		var tmpFileArray = tmpFile.split('.')
	
		if (tmpFile == '')
			retorno = 1
		if (retorno == 0 && tmpFileArray.length <= 1) // no hay extension
			retorno = 2
		if (retorno == 0 && tmpFile.length >= tmpLongMax) 
			retorno = 3	
		return retorno
	}
	

// -------------------------------------------------------------------
// ---- SECCION VIVIENDAS

	function doViviendas_nuevo(tmpNombreCampo_ref, tmpNombreCampo_nombre, tmpNombreCampo_desc,
								tmpNombreCampo_descEng, tmpNombreCampo_descIta,
								tmpNombreCampo_descGer, tmpNombreCampo_descFra,
								tmpNombreCampo_supCons, tmpNombreCampo_supSalon,
								tmpNombreCampo_supParcela, tmpNombreCampo_numHab,
								tmpNombreCampo_numBan, tmpNombreCampo_numAseos,
								tmpNombreCampo_trastero, tmpNombreCampo_parking,
								tmpNombreCampo_piscina, tmpNombreCampo_terraza,
								tmpNombreCampo_jardin, tmpNombreCampo_idTipoViv,
								tmpNombreCampo_idZona, tmpNombreCampo_idTipoOper,
								tmpNombreCampo_idPoblacion, tmpNombreCampo_precio, 
								tmpNombreCampo_file, tmpExtensiones)
	{
		// No se validan los campos parking, piscina, terraza, jardin, itTipoViv
		// idTipoOper, idZona porque los valores los da un radio button o un combo
		// Notas sobre las SUPERFICIES:
		//		- Construida: Se comprueba si existe y es obligatoria
		//		- Salon: Se comprueba si existe y NO es obligatoria
		//		- Parcela: Se comprueba si existe y NO es obligatoria
		
		var tmpForm = document.getElementById(tmpFormLinkName);
		var seguir = true;
		var tmpMsgError = '';
		var tmpCampoAux_name = '';
		var tmpCampoAux_value = '';
		//Valido tNombreCampo_ref
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_ref;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value.length == 0 || tmpCampoAux_value.length > 50)
				{
					seguir = false;
					tmpMsgError = 'La referencia no es valida';
				}
			}
		}
		//Valido tmpNombreCampo_nombre
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_nombre;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value.length == 0 || tmpCampoAux_value.length > 50)
				{
					seguir = false;
					tmpMsgError = 'El nombre no es valido';
				}
			}
		}
		
		//Valido tmpNombreCampo_supCons
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_supCons;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value == '' || isNaN(tmpCampoAux_value))
				{
					seguir = false;
					tmpMsgError = 'La sup cons no es un numero';
				}
			}
		}
		//Valido tmpNombreCampo_supSalon
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_supSalon;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value != '')
					if (isNaN(tmpCampoAux_value))
					{
						seguir = false;
						tmpMsgError = 'La sup salon no es un numero';
					}
			}
		}
		//Valido tmpNombreCampo_supParcela
		if (seguir)
			{
			tmpCampoAux_name = tmpNombreCampo_supParcela;
			if (tmpCampoAux_name != '')
				{
				// Validamos el tamaño de parcela sólo si se indica un valor.
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value != '')
					if (isNaN(tmpCampoAux_value))
					{
							seguir = false;
							tmpMsgError = 'La sup parcela no es un numero';
					}
				}
			}
			
		/*
		//Valido tmpNombreCampo_numHab
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_numHab;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value == '' || isNaN(tmpCampoAux_value))
				{
					seguir = false;
					tmpMsgError = 'El num de hab no es un numero';
				}
			}
		}

		//Valido tmpNombreCampo_numBan
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_numBan;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value == '' || isNaN(tmpCampoAux_value))
				{
					seguir = false;
					tmpMsgError = 'El num de banos no es un numero';
				}
			}
		}

		//Valido tmpNombreCampo_numAseos
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_numAseos;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value == '' || isNaN(tmpCampoAux_value))
				{
					seguir = false;
					tmpMsgError = 'El num de aseos no es un numero';
				}
			}
		}
		*/

		//Valido tmpNombreCampo_precio
		if (seguir)
		{
			tmpCampoAux_name = tmpNombreCampo_precio;
			if (tmpCampoAux_name != '')
			{
				tmpCampoAux_value = document.getElementById(tmpCampoAux_name).value;
				if (tmpCampoAux_value == '' || isNaN(tmpCampoAux_value))
				{
					seguir = false;
					tmpMsgError = 'El precio no es un numero';
				}
			}
		}

		// Valido que el fichero sea correcto y que tenga las extensiones permitidas
		if (seguir)
		{
			try
			{
				tmpFile = document.getElementById(tmpNombreCampo_file).value;
			}
			catch (errorinfo)
			{
				tmpFile = ''
			}
			tmpMsgError = validaFichero_vacio(tmpFile, tmpExtensiones, false)
			if (tmpMsgError != '')
				seguir = false;					
		}
		

		if (!seguir)
		{
			alert(tmpMsgError);
		}
		else
		{
			tmpForm.submit();
		}
	}

	function doViviendas_del(tmpUrlBorrado, tmpNombreForm, tmpNombreCampo_idVivienda, tmpValor_idVivienda)
	{
		var tmpCampo_idVivienda;
		var tmpForm;
		if (confirm('Esta seguro de que desea borrar la vivienda?'))
		{
			tmpForm = document.getElementById(tmpNombreForm);
			tmpCampo_idVivienda = document.getElementById(tmpNombreCampo_idVivienda);	
			tmpCampo_idVivienda.value = tmpValor_idVivienda;
			
			tmpForm.action = tmpUrlBorrado;
			tmpForm.submit();
		}
	}
	
	function doViviendas_PutPaginacion_OutOfFrame(tmpNomCampo_Parent_PagAnterior, tmpNomCampo_Parent_PagSiguiente, tmpNomCampo_Parent_PagNums, tmpCadPag_Anterior, tmpCadPag_Siguiente, tmpCadPag_Nums)
		{
		// Llamado desde un iframe, me coloca en determinados <span> del padre, señalados por 'tmpNomCampo_Parent_...'
		// el texto indicado por 'tmpCadPag_...' (supuestamente, elementos de paginación)
		var tmpPaginacionAnterior = parent.document.getElementById(tmpNomCampo_Parent_PagAnterior);
		var tmpPaginacionNumPags = parent.document.getElementById(tmpNomCampo_Parent_PagNums);
		var tmpPaginacionSiguiente = parent.document.getElementById(tmpNomCampo_Parent_PagSiguiente);

		if (parent)
			{
			tmpPaginacionAnterior = parent.document.getElementById(tmpNomCampo_Parent_PagAnterior);
			tmpPaginacionSiguiente= parent.document.getElementById(tmpNomCampo_Parent_PagSiguiente);
			tmpPaginacionNumPags  = parent.document.getElementById(tmpNomCampo_Parent_PagNums);

			if (tmpPaginacionAnterior)
				tmpPaginacionAnterior.innerHTML = tmpCadPag_Anterior;

			if (tmpPaginacionNumPags)
				tmpPaginacionNumPags.innerHTML  = tmpCadPag_Nums;
				
			if (tmpPaginacionSiguiente)
				tmpPaginacionSiguiente.innerHTML  = tmpCadPag_Siguiente;	
				
			}
		}
	
	
	function doViviendas_Promociones_Del(tmpUrlBorrado, tmpNomForm ,tmpNomCampo_idVivienda, tmpNomCampo_idDestinosPortales, tmpValor_idVivienda, tmpValor_idDestinosPortales)
		{
		var tmpCampo_idVivienda, tmpCampo_idDestinosPortales
		var tmpForm;
		
		if (confirm('Esta seguro de que desea desvincular la vivienda?'))
			{
			tmpForm = document.getElementById(tmpNomForm)
			tmpCampo_idVivienda = document.getElementById(tmpNomCampo_idVivienda);	
			tmpCampo_idDestinosPortales = document.getElementById(tmpNomCampo_idDestinosPortales);			
	
			tmpCampo_idVivienda.value = tmpValor_idVivienda;
			tmpCampo_idDestinosPortales.value = tmpValor_idDestinosPortales;
	
			tmpForm.action = tmpUrlBorrado
			tmpForm.submit()
			}
		}

	function doViviendas_Promociones_Nuevo(tmpUrlNuevo, tmpNomForm ,tmpNomCampoDestino_idVivienda, tmpNomCampoDestino_idDestinosPortales, tmpNomCampoOrigen_Combo_idVivienda, tmpNomCampoOrigen_Combo_idDestinosPortales)		
		{
		// Da valor a los campos hidden indicados por sus nombres 'destino' a partir del valor seleccionado
		// desde dos combos de origen, indicados por sus nombres 'origen'
		var tmpCampo_idVivienda, tmpCampo_idDestinosPortales;
		var tmpCampoOrigen_Combo_idVivienda, tmpCampoOrigen_Combo_idDestinosPortales;
		var tmpForm;

		tmpForm = document.getElementById(tmpNomForm)
		tmpCampo_idVivienda = document.getElementById(tmpNomCampoDestino_idVivienda);	
		tmpCampo_idDestinosPortales = document.getElementById(tmpNomCampoDestino_idDestinosPortales);			

		tmpCampoOrigen_Combo_idVivienda = document.getElementById(tmpNomCampoOrigen_Combo_idVivienda)
		tmpCampoOrigen_Combo_idDestinosPortales = document.getElementById(tmpNomCampoOrigen_Combo_idDestinosPortales)
		
		tmpCampo_idVivienda.value = tmpCampoOrigen_Combo_idVivienda.options[tmpCampoOrigen_Combo_idVivienda.selectedIndex].value;
		tmpCampo_idDestinosPortales.value = tmpCampoOrigen_Combo_idDestinosPortales.options[tmpCampoOrigen_Combo_idDestinosPortales.selectedIndex].value;
		
		tmpForm.method = "POST"
		tmpForm.action = tmpUrlNuevo
		tmpForm.submit()
		}

	function doViviendas_Situaciones_del(tmpUrlBorrado, tmpNombreForm, tmpNombreCampo_idSituacionVivienda, tmpValor_idSituacionVivienda, tmpValor_NumViviendasAsociadas)
	{
		var tmpCampo_idSituacionVivienda;
		var tmpForm;
		if (tmpValor_NumViviendasAsociadas > 0)
		{
			alert ('La zona de viviendas no se puede eliminar porque tiene viviendas asociadas');
		}
		else
		{			
			if (confirm('Esta seguro de que desea borrar la zona?'))
			{
				tmpForm = document.getElementById(tmpNombreForm);
				tmpCampo_idSituacionVivienda = document.getElementById(tmpNombreCampo_idSituacionVivienda);	
				tmpCampo_idSituacionVivienda.value = tmpValor_idSituacionVivienda;
				
				tmpForm.action = tmpUrlBorrado;
				tmpForm.submit();
			}
		}
	}
	
	function doViviendas_Situaciones_nuevo(tmpNombreForm, tmpNombreCampo_SituacionEsp, 
											tmpNombreCampo_SituacionIng, 
											tmpNombreCampo_SituacionFra, 
											tmpNombreCampo_SituacionGer, 
											tmpNombreCampo_SituacionIta)
	{
	
		var tmpForm = document.getElementById(tmpNombreForm);		
		var tmpMsgError = '';
		var tmpCampoErroneo = null;
		var tmpSituacionEsp = document.getElementById(tmpNombreCampo_SituacionEsp);
		var tmpSituacionIng;
		var tmpSituacionFra;
		var tmpSituacionGer;
		var tmpSituacionIta;
		
		if (tmpSituacionEsp && tmpMsgError == '')
		{
			if (tmpSituacionEsp.value == '' || tmpSituacionEsp.value.length > 30)
			{
				tmpMsgError = 'Debe de introducir un nombre en castellano';
				tmpCampoErroneo = tmpSituacionEsp;
			}
		}		
		if (tmpNombreCampo_SituacionIng && tmpMsgError == '')
		{
			tmpSituacionIng = document.getElementById(tmpNombreCampo_SituacionIng);
			if (tmpSituacionIng.value == '' || tmpSituacionIng.value.length > 30)
			{
				tmpMsgError = 'Debe de introducir un nombre en ingles';
				tmpCampoErroneo = tmpSituacionIng;
			}
		}
		if (tmpNombreCampo_SituacionFra && tmpMsgError == '')
		{
			tmpSituacionFra = document.getElementById(tmpNombreCampo_SituacionFra);
			if (tmpSituacionFra.value == '' || tmpSituacionFra.value.length > 30)
			{
				tmpMsgError = 'Debe de introducir un nombre en frances';
				tmpCampoErroneo = tmpSituacionFra;
			}
		}
		if (tmpNombreCampo_SituacionGer && tmpMsgError == '')
		{
			tmpSituacionGer = document.getElementById(tmpNombreCampo_SituacionGer);
			if (tmpSituacionGer.value == '' || tmpSituacionGer.value.length > 30)
			{
				tmpMsgError = 'Debe de introducir un nombre en aleman';
				tmpCampoErroneo = tmpSituacionGer;
			}
		}
		if (tmpNombreCampo_SituacionIta && tmpMsgError == '')
		{
			tmpSituacionIta = document.getElementById(tmpNombreCampo_SituacionIta);
			if (tmpSituacionIta.value == '' || tmpSituacionIta.value.length > 30)
			{
				tmpMsgError = 'Debe de introducir un nombre en italiano';
				tmpCampoErroneo = tmpSituacionIta;
			}
		}
		
		if (tmpMsgError != '')
		{
			alert(tmpMsgError);
			tmpCampoErroneo.focus();
		}
		else
			tmpForm.submit();		
	}
	

// -------------------------------------------------------------------
// ---- SECCION CONTACTOS PUBLICA

function doContacto_enviar(tmpNombreCampo_mail, tmpNombreCampo_texto, tmpNombreCampo_titulo, tmpNombreCampo_descripcion)
{
	var tmpForm = document.getElementById(tmpFormLinkName)
	var tmpMsgError = '';
	var tmpCampoErroneo = null;
	var tmpMail = document.getElementById(tmpNombreCampo_mail);
	var tmpTexto = document.getElementById(tmpNombreCampo_texto);
	var tmpTitulo;
	var tmpDescripcion;
	
	//Valido el mail
	if (tmpMail && tmpMsgError == '')
		{
		if (!val_isCorrect_EmailAddress(tmpMail.value,true))
			{
			tmpMsgError = 'Debe especificar su E-mail de contacto\n';
			tmpCampoErroneo = tmpMail;
			}
		}
		
	//Valido el texto
	if (tmpTexto && tmpMsgError == '')
		{
		if (tmpTexto.value == '')
			{
			tmpMsgError = 'Es obligatorio especificar la consulta\n'
			tmpCampoErroneo = tmpTexto;
			}
		}
	
	//Valido el titulo si es necesario
	if (tmpNombreCampo_titulo != '' && tmpMsgError == '')
	{
		tmpTitulo = document.getElementById(tmpNombreCampo_titulo);
		if (tmpTitulo)
			{
			if (tmpTitulo.value == '')
				tmpMsgError = 'Debe especificar un asunto\n';
				tmpCampoErroneo = tmpTitulo;
			}
	}		
	
	//Valido la descripcion si es necesario
	if (tmpNombreCampo_descripcion != '' && tmpMsgError == '')
	{
		tmpDescripcion = document.getElementById(tmpNombreCampo_descripcion);
		if (tmpDescripcion)
			{
			if (tmpDescripcion.value == '')
				tmpMsgError = 'Debe especificar una descripcion\n';
				tmpCampoErroneo = tmpDescripcion;
			}
	}

	if (tmpMsgError == '')
		tmpForm.submit();
	else
		{
		tmpCampoErroneo.focus()
		alert (tmpMsgError);
		}
}

// -------------------------------------------------------------------
// ---- SECCION CAMBIO PASSWORD ADMINISTRACION

	function doCambioPassAdmin_Gen_Cambiar(tmpForm, tmpNomCampo_Pass1, tmpNomCampo_Pass2)
		{
		// Función General de Validación del cambio de password en una administración
		var tmpCampoPass_1, tmpCampoPass_2
		var tmpForm
		var tmpMsgError = 'El password es incorrecto';	

		tmpCampoPass_1 = document.getElementById(tmpNomCampo_Pass1);		
		tmpCampoPass_2 = document.getElementById(tmpNomCampo_Pass2);

		if ( (tmpCampoPass_1) && (tmpCampoPass_2) && (tmpForm))
			{

			if (validaPasswords(tmpCampoPass_1.value, tmpCampoPass_2.value))
				{
				tmpForm.submit();		
				}
			else
				alert(tmpMsgError);
			}
		else
			alert('Los campos que deben contener los valores de password o el formulario no existen.');
		}


	function doCambioPassAdmin_cambiar(tmpPassword1, tmpPassword2)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)			
		var tmpMsgError = ''
		var seguir;
	
		seguir = validaPasswords(tmpPassword1, tmpPassword2)
		if (seguir == false)
		{
			tmpMsgError = 'El password es incorrecto';
		}
		
		if (tmpMsgError == '')
			tmpForm.submit();		
		else
			alert(tmpMsgError);
	}
// -------------------------------------------------------------------
// ---- SECCION LOGIN ADMINISTRACION

	function doAdmin_Gen_login(tmpForm, tmpNombreCampo_user, tmpNombreCampo_pass)
	{
		// Función General de Validación del Login
		var tmpMsgError = ''
		var tmpCampoUser = document.getElementById(tmpNombreCampo_user)
		var tmpCampoPass = document.getElementById(tmpNombreCampo_pass)		
		
		var tmpUser;
		var tmpPassword;
		var tmpLongMax = 50
	
		if (tmpForm && tmpCampoUser && tmpCampoPass)
			{
			tmpUser = tmpCampoUser.value;	
			tmpPassword = tmpCampoPass.value;
				
			//Valido el usuario
			if 	(tmpUser == '' || tmpUser.length>= tmpLongMax)
			{
				tmpMsgError = 'Usuario incorrecto';
			}
			//Valido el password
			if (tmpMsgError == '')
				if (tmpPassword == '' || tmpPassword.length >= tmpLongMax)		
					tmpMsgError = 'Password incorrecto';		
			
			if (tmpMsgError == '')
				tmpForm.submit();		
			else
				alert(tmpMsgError);
			}
		else
			alert('El Campo Usuario, el Campo Password o El Formulario no estan instanciados.')
	}


	function doAdmin_login(tmpNombreCampo_user, tmpNombreCampo_pass)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)			
		var tmpMsgError = ''
		var tmpUser = document.getElementById(tmpNombreCampo_user).value;
		var tmpPassword = document.getElementById(tmpNombreCampo_pass).value;
		var tmpLongMax = 50
	
		//Valido el usuario
		if 	(tmpUser == '' || tmpUser.length>= tmpLongMax)
		{
			tmpMsgError = 'Usuario incorrecto';
		}
		//Valido el password
		if (tmpMsgError == '')
			if (tmpPassword == '' || tmpPassword.length >= tmpLongMax)		
				tmpMsgError = 'Password incorrecto';		
		
		if (tmpMsgError == '')
			tmpForm.submit();		
		else
			alert(tmpMsgError);
	}

	
// -------------------------------------------------------------------
// ---- SECCION PRODUCTOS ADMINISTRACION

	function doProducto_modificar(tmpCampoNombre_nombre, tmpCampoNombre_ref, tmpCampoNombre_desc, tmpCampoNombre_file, tmpExtensiones)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)			
		var tmpMsgError = ''
		var tmpNombre = document.getElementById(tmpCampoNombre_nombre).value;
		var tmpRef = document.getElementById(tmpCampoNombre_ref).value;
		var tmpDesc = document.getElementById(tmpCampoNombre_desc).value;
		var tmpFile;
		var tmpLongCampos = 50;
		var procesar_file = true;
		
		if (tmpNombre == '' || tmpNombre.length>=tmpLongCampos)
			tmpMsgError = 'Debe introducir un nombre'
		
		if (tmpMsgError == '')	//Valido la referencia
		{
			if (tmpRef == '' || tmpRef.length>=tmpLongCampos)
				tmpMsgError = 'Debe introducir una referencia'
		}
		
		if (tmpMsgError == '')	//Valido la descripcion
		{
			if (tmpDesc == '')
				tmpMsgError = 'Debe introducir una descripcion'
		}
		
		try
		{
			tmpFile = document.getElementById(tmpCampoNombre_file).value;
			if (tmpFile == '')
				procesar_file = false
		}
		catch (errorinfo)
		{
			procesar_file = false
		}
		// Se procesa el fichero si es necesario
		if (tmpMsgError == '' && procesar_file)
		{
			tmpMsgError = validaFichero(tmpFile, tmpExtensiones);
		}
		
		if (tmpMsgError == '')
		{
			//tmpForm.action = './modificar.aspx'
			tmpForm.submit();		
		}
		else
			alert(tmpMsgError);
	}
	

	function doProducto_nuevo(tmpCampoNombre_nombre, tmpCampoNombre_ref, tmpCampoNombre_desc, tmpCampoNombre_file, tmpExtensiones)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)			
		var tmpMsgError = ''
		var tmpNombre = document.getElementById(tmpCampoNombre_nombre).value;
		var tmpRef = document.getElementById(tmpCampoNombre_ref).value;
		var tmpDesc = document.getElementById(tmpCampoNombre_desc).value;
		var tmpFile = document.getElementById(tmpCampoNombre_file).value;
		var tmpLongCampos = 50;
		
		if (tmpNombre == '' || tmpNombre.length>=tmpLongCampos)
			tmpMsgError = 'Debe introducir un nombre'
		
		if (tmpMsgError == '')	//Valido la referencia
		{
			if (tmpRef == '' || tmpRef.length>=tmpLongCampos)
				tmpMsgError = 'Debe introducir una referencia'
		}
		
		if (tmpMsgError == '')	//Valido la descripcion
		{
			if (tmpDesc == '')
				tmpMsgError = 'Debe introducir una descripcion'
		}
		
		if (tmpMsgError == '' && tmpFile != '')	//Valido el tipo de fichero introducido
		{	
			tmpMsgError = validaFichero(tmpFile, tmpExtensiones);
		}
				
		if (tmpMsgError == '')
		{
			tmpForm.action = './nuevo.aspx'
			tmpForm.submit();		
		}
		else
			alert(tmpMsgError);
	}
	
	function doProducto_del(tmpIdProducto, tmpNombreCampo_idProducto)
	{
		// Realiza el borrado, previa confirmación, del link indicado.
		var tmpForm = document.getElementById(tmpFormLinkName)			
		if (tmpForm)
		{
			if (confirm('Realmente desea eliminar el elemento?'))
			{
				document.getElementById(tmpNombreCampo_idProducto).value = tmpIdProducto;
				tmpForm.action = './borrar.aspx'
				tmpForm.submit();
			}
		}
	}	
	
	function doProducto_delGaleria (tmpIdGaleria, tmpIdTipoGal, tmpNombreCampo_idGal, tmpNombreCampo_idTipoGal)
	{
		// Realiza el borrado, previa confirmación, de la galería indicada.
		var tmpForm = document.getElementById(tmpFormLinkName)			
		if (confirm('Realmente desea eliminar el elemento?'))
		{
			tmpForm.action = '../categorias/borrar.aspx'
			document.getElementById(tmpNombreCampo_idGal).value = tmpIdGaleria;
			document.getElementById(tmpNombreCampo_idTipoGal).value = tmpIdTipoGal;
			tmpForm.submit();								
		}					
	}
		
	function doProducto_createGal(tmpNombreGal, tmpIdTipoGal, tmpNombreCampo_nombreGal, tmpNombreCampo_idTipoGal)
	{
		// Realiza la llamada a crear galería.
		var tmpForm = document.getElementById(tmpFormLinkName)
		if (tmpNombreGal != '' && tmpNombreGal.length <= 50)
		{
			tmpForm.action = '../categorias/nuevo_do.aspx'
			document.getElementById(tmpNombreCampo_nombreGal).value = tmpNombreGal;
			document.getElementById(tmpNombreCampo_idTipoGal).value = tmpIdTipoGal;
			tmpForm.submit();
		}
		else
		{
			alert ('El nombre de la galeria no es correcto');
		}
	}	
	
// -------------------------------------------------------------------
// ---- SECCION DOCS ADMINISTRACION

	function doDocs_modificar(tmpUser, tmpPassword1, tmpPassword2)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)
		var tmpMsgError = ''
		
		if (tmpUser != '' && tmpUser.length <= 50)
			if (!validaPasswords(tmpPassword1, tmpPassword2))
				tmpMsgError = 'El usuario o passwords introducidos son incorrectos';
				
		if (tmpMsgError == '')
			tmpForm.submit();
		else
			alert(tmpMsgError);
	}
	
	function doDocs_nuevo(tmpNombreCampo_user, tmpNombreCampo_password1, tmpNombreCampo_password2, tmpFile, tmpExtensiones)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)
		var tmpMsgError = ''
		var tmpUser = document.getElementById(tmpNombreCampo_user).value;				
		var tmpPassword1 = document.getElementById(tmpNombreCampo_password1).value;				
		var tmpPassword2 = document.getElementById(tmpNombreCampo_password2).value;				
		var introducidoUsuario = false
		
		tmpMsgError = validaFichero(tmpFile, tmpExtensiones);
		
		if (tmpMsgError == '')
		{
			if (tmpUser.length >= 1 && tmpUser.length <= 50)
			{
				introducidoUsuario = true;
			}
			else
			{
				if (tmpUser == '')
				{
					introducidoUsuario = false;
				}
				else
				{
					tmpMsgError = 'El usuario es incorrecto';
				}				
			}
		}
		if (tmpMsgError == '')
		{
			if (introducidoUsuario == true)
			{
				if (!validaPasswords(tmpPassword1, tmpPassword2))
					tmpMsgError = 'Debe de introducir los passwords iguales asociados al usuario';
			}
			else
			{
				if (tmpPassword1 != '' || tmpPassword2 != '')
					tmpMsgError = 'Debe de introducir un usuario con los passwords'
			}
		}
		
		if (tmpMsgError == '')
			tmpForm.submit();
		else
			alert(tmpMsgError);

	}
	
	function doDocs_delDoc(tmpIdDoc, tmpNombreCampo)
	{
		var tmpForm = document.getElementById(tmpFormLinkName)
		var tmpUrl = 'borrar.aspx';
	
		if (confirm('Estas seguro de que desea borrar el documento?'))
		{	
			document.getElementById(tmpNombreCampo).value = tmpIdDoc;
			tmpForm.action = tmpUrl
			tmpForm.submit();
		}
	}

// -------------------------------------------------------------------
// ---- SECCION LINKS ADMINISTRACION


	function doLink_ValidaLink(tmpNombreCampoNombreLink, tmpNombreCampoUrl)
	{
		var tmpForm = document.getElementById(tmpFormLinkName);
		var tmpUrl = document.getElementById(tmpNombreCampoUrl).value;
		var tmpNombreLink = document.getElementById(tmpNombreCampoNombreLink).value;
		var tmpMsgError = '';
		var tmpIndice = 0;

		//Valido el nombre del link
		if (tmpNombreLink == '')
		{
			tmpMsgError = 'Debe de introducir un nombre para el enlace';
		}
	
		//Valido la url
		if (tmpMsgError == '')
		{
			tmpIndice = tmpUrl.toLowerCase().lastIndexOf('http://');

			if (tmpIndice<0)
			{
				tmpUrl = 'http://' + tmpUrl;
			}			
			if (!val_isCorrect_Url(tmpUrl,true))
			{
				tmpMsgError = 'La Url es incorrecta';
			}
		}
		
		if (tmpMsgError != '')
		{		
			alert(tmpMsgError);
		}
		else
		{
			document.getElementById(tmpNombreCampoUrl).value = tmpUrl;
			document.getElementById(tmpNombreCampoNombreLink).value = tmpNombreLink;
			tmpForm.submit();
		}
	}
		
		function doLink_del(tmpIdLink, tmpNombreCampo_IdLink)
			{
			// Realiza el borrado, previa confirmación, del link indicado.
			var tmpForm = document.getElementById(tmpFormLinkName)			
			if (confirm('Realmente desea eliminar el elemento?'))
				{
				document.getElementById(tmpNombreCampo_IdLink).value = tmpIdLink;
				tmpForm.action = 'borrar.aspx'
				tmpForm.submit();
				}
			}	
		
		function doLink_delGaleria (tmpIdGaleria, tmpNombreCampo_IdLink, tmpNombreCampo_TipoGal, tmp_idTipoGal)
		{
			// Realiza el borrado, previa confirmación, de la galería indicada.
			var tmpForm = document.getElementById(tmpFormLinkName)			
			if (confirm('Realmente desea eliminar el elemento?'))
				{
				document.getElementById(tmpNombreCampo_IdLink).value = tmpIdGaleria;
				document.getElementById(tmpNombreCampo_TipoGal).value = tmp_idTipoGal;
				tmpForm.action = '../categorias/borrar.aspx';
				tmpForm.submit();
				}
				
		}
			
		function doLink_createGal(tmpNombreGal, tmpIdTipoGal, tmpNombreCampo_Galeria, tmpNombreCampo_IdTipoGal)
		{
			// Realiza la llamada a crear galería.
			var tmpForm = document.getElementById(tmpFormLinkName)
			var tmpMsgError = '';
			
			if (tmpNombreGal == '')
			{
				tmpMsgError = 'Debe introducir un nombre para la galeria';
			}
			
			if (tmpMsgError == '')
			{
				if (tmpNombreGal.length >= 50)
					tmpMsgError = 'El nombre de la galeria no debe exceder los 50 caracteres';
			}
			
			if (tmpMsgError == '')
			{
				tmpForm.action = '../categorias/nuevo_do.aspx'
				document.getElementById(tmpNombreCampo_Galeria).value = tmpNombreGal;
				document.getElementById(tmpNombreCampo_IdTipoGal).value = tmpIdTipoGal;
				
				tmpForm.submit();
			}
			else
				alert(tmpMsgError);
		}
			
// -------------------------------------------------------------------
// ---- FIN SECCION LINKS
