// JavaScript Document
function formulario_registro(formobj){
			var nombre 		= document.getElementById('nombre').value;
			var e_mail 		= document.getElementById('e_mail').value;
			var comentario	= document.getElementById('password').value;
			var seguridad	= document.getElementById('seguridad').value;			
			
			var valido		= document.getElementById('usuario_valido').value;
			
			if (valido != 0){
				alert("El E-mail ya esta utilizado, por favor, indique otro");
				return false;				
			}
			
			if(nombre == "" || nombre == null || 
			   e_mail == "" || e_mail == null || 
			   comentario == "" || comentario == null || 
			   seguridad == "" || seguridad == null){
				alert("Debe rellenar los campos: Nombre, E-mail, Password, Seguridad");
				return false;
			}else{
				return true;
			}
		}
		
		function formulario_datos(formobj){
			var nombre 		= document.getElementById('nombre').value;
			var e_mail 		= document.getElementById('e_mail').value;
			var comentario	= document.getElementById('password').value;
			
			if(nombre == "" || nombre == null || 
			   e_mail == "" || e_mail == null || 
			   comentario == "" || comentario == null ){
				alert("Debe rellenar los campos: Nombre, E-mail, Password");
				return false;
			}else{
				return true;
			}
		}		
		
		function formulario_logging(formobj){
			var e_mail 		= document.getElementById('e_mail').value;
			var password	= document.getElementById('password').value;
						
			if(e_mail == "" || e_mail == null || 
			   password == "" || password == null ){
				alert("Debe rellenar los campos: E-mail, Password");
				return false;
			}else{
				return true;
			}
		}

		function init(){
			Event.observe("combo_provincia", "change", comprobarProvincia);
		}
		function limpiar(){
		    document.getElementById("div_municipio").innerHTML = "";
		}
		function comprobarProvincia(){
			if(this.value != 0){
				new Ajax.Updater('div_municipio', url_global+'/admin/includes_generales/combo_municipio2.php?provincia='+this.value, {
		  			method: 'get',
					insertion: Insertion.Bottom,
					parameters: "provincia="+this.value,
					onSuccess: function(transport){				
						var response = transport.responseText || "no response text";
						limpiar();
					}
				});
			}else{
				document.getElementById("div_municipio").innerHTML = "&nbsp;&nbsp;Debe seleccionar primero una provincia";		
				alert("Debe seleccionar una provincia");
			}
		}
		function disponibilidad(campo){
				var registro = document.form1.e_mail.value;
				if(campo.value != "" && campo.value != null){
						new Ajax.Updater('div', url_global+'/includes/formularios/existe_usuario.php?nombre='+campo.value, {
							method: 'get',
							insertion: Insertion.Bottom,
							parameters: "provincia="+this.value,
							onSuccess: function(transport){	
							  	var response = transport.responseText || "no response text";
							  	document.form1.usuario_valido.value = parseInt(transport.responseText);
							  	if(parseInt(transport.responseText) == 1){
  							  		alert("El E-mail ya está utilizado, por favor, indique otro");					  
						  		}
							}
						});
				}
		}
		
		function valor_mas(){
			var nuevo_valor = document.getElementById('valor');
			var valores     = document.getElementById('valores_selector');
			
			if(nuevo_valor.value == ""){
				alert("Debe insertar un valor");
				return;
			}
			
			valores.value  += (nuevo_valor.value + ";") ;
			
			var valores_html= document.getElementById('valores_html');			
		
			var aux = "<div><p>"+nuevo_valor.value + "  <input type='button' value='Eliminar Valor' onclick='valor_menos(\""+nuevo_valor.value + "\")'/></p></div>";
			
			valores_html.innerHTML += aux;
			
			nuevo_valor.value="";
		}
		
		function valor_menos(cad){
			var valores     = document.getElementById('valores_selector');
			
			var cadenaTexto    = valores.value;
			var fragmentoTexto = new Array();

			fragmentoTexto = cadenaTexto.split(';');
			valores.value   = "";
			
			var i = 0;
			
			var valores_html= document.getElementById('valores_html');
			valores_html.innerHTML = "";

			for (i=0; i<fragmentoTexto.length; i++){
				if(fragmentoTexto[i] != cad){			
					if(fragmentoTexto[i] != ""){
					    valores.value += (""+fragmentoTexto[i]+";");
						var aux = "<div><p>"+fragmentoTexto[i]+ "  <input type='button' value='Eliminar Valor' onclick='valor_menos(\""+fragmentoTexto[i]+ "\")'/></p></div>";
						valores_html.innerHTML += aux;
					}
				}
			} 
		}		
		
		function formulario_encuesta1(formobj){
			var pregunta 		= document.getElementById('pregunta').value;
			var descripcion1 	= document.getElementById('descripcion1').value;
			var descripcion2	= document.getElementById('descripcion2').value;
			var etiqueta_selector	= document.getElementById('etiqueta_selector').value;			
			var valores_selector	= document.getElementById('valores_selector').value;			
			var etiqueta_cantidad	= document.getElementById('etiqueta_cantidad').value;			
			
			if(pregunta == "" || descripcion1 == null || 
			   descripcion2 == "" || etiqueta_selector == null || 
			   valores_selector == "" || etiqueta_cantidad == null ){
				alert("Debe rellenar los campos: Pregunta, Descripcion 1, Descripcion 2, Etiqueta Selector, Valores Selector, Etiqueta Cantidad");
				return false;
			}else{
				return true;
			}
		}
		
		function formulario_encuesta2(formobj){
			var pregunta 		= document.getElementById('pregunta').value;
			var descripcion1 	= document.getElementById('descripcion1').value;
			var descripcion2	= document.getElementById('descripcion2').value;
			//var etiqueta_selector	= document.getElementById('etiqueta_selector').value;			
			var valores_selector	= document.getElementById('valores_selector').value;			
			
			if(pregunta == "" || descripcion1 == null || 
			   descripcion2 == "" ||  valores_selector == "" ){
				alert("Debe rellenar los campos: Pregunta, Descripcion 1, Descripcion 2, Valores Selector");
				return false;
			}else{
				return true;
			}
		}		
