
/* GESTIÓN DE FORMULARIO ******************************************************************************/

	// Validamos que ha introducido todos los datos
	function formCorrecto() {
		// Explorer y Mozilla presentan valores 0 y -1 si no selecciona opción
		if ((document.Formulario.lstProvincia.selectedIndex > 0) &&
		    (document.Formulario.lstMotivo.selectedIndex > 0)) {
		    	return true;
		}
		else {
			return false;
		}
	}

/* Fin de GESTIÓN DE FORMULARIO ***********************************************************************/

/* GESTIÓN DE COOKIE ******************************************************************************/

	//Crea una cookie con los parámetros dados.
	function setCookie(nombre, valor, caducidad) {
		var fecha_caducidad = new Date();
		fecha_caducidad.setDate(fecha_caducidad.getDate() + caducidad);
		document.cookie = nombre + '=' + escape(valor) + ';expires=' + fecha_caducidad.toGMTString();
	}
	
	//Recoge el valor de una cookie. NULL si no existe.
	function getCookie(nombre) {
		var nombreCookie = nombre + "=";
		var dc = document.cookie;
		if (dc.length>0) {
			begin = dc.indexOf(nombreCookie);
			if (begin!=-1) {
				begin += nombreCookie.length;
				end = dc.indexOf(";", begin);
				if (end==-1) end = dc.length;
				return (dc.substring(begin, end));
			}
		}
	}
	
	//Comprueba que la COOKIE exista. Si no, la crea.
	//Ahora con la cookie, envía el formulario y luego lo esconde.
	function enviarFormulario() {
		var miCookie = "trabajoCRM";
		if (formCorrecto() == true) {
			if (getCookie(miCookie)==null) setCookie(miCookie, "true", 5);
			document.getElementById("tablaFormulario").style.visibility = "hidden";
			//document.Formulario.submit();
			return true;
		}
		else {
			alert("Debes completar ambos campos correctamente.");
			return false;
		}
	}
	
	//Comprueba si la cookie existe. Si no existe, muestra el formulario.
	function checkCookie() {
		var miCookie = "trabajoCRM";
		if (getCookie(miCookie)==null) document.getElementById("tablaFormulario").style.visibility = "visible";
		return true;
	}

/* Fin de GESTIÓN DE COOKIE ***********************************************************************/



/* ESTILO DEL MENÚ LATERAL :: HOVER ***************************************************************/
	
	function marca(objeto) {
		objeto.style.background = "#ffedce";
		return 0;
	}
	
	function desmarca(objeto) {
		objeto.style.background = "#ffffff";
		return 0;
	}
	
/* Fin de ESTILO DEL MENÚ LATERAL :: HOVER ********************************************************/