// FUNCIONES 
	
	function gestionBoletin(){
		var Accion;
		var Email = document.getElementById("boletin-email").value;
		var objAlta = eval("document.getElementById('boletin-accion1')");
		var objBaja = eval("document.getElementById('boletin-accion0')");
		if(objAlta.checked){
			Accion = objAlta.value;
		}
		else if(objBaja.checked){
			Accion = objBaja.value;
		}
		xajax_gestionBoletin(Accion, Email);
	}
	
	
	
	function enviarBusqueda(){
		if(top.location.hostname == '192.168.10.126'){
			var PathUrl = 'http://192.168.10.126/promo-regalos';
		}
		else{
			var PathUrl = 'http://www.promo-regalos.com';
		}
		var busqueda = document.getElementById('txtbuscar').value;
		var busqueda_precio = document.getElementById('preciobuscar').value;
		var busqueda_precio_hasta = document.getElementById('preciobuscar_hasta').value;
		if(busqueda != "" || busqueda_precio != "" || busqueda_precio_hasta != ""){		
			if(busqueda == ""){
				busqueda = 'Todo';
			}
			if(busqueda_precio == ""){
				busqueda_precio = 0;
			}
			if(busqueda_precio == ""){
				busqueda_precio_hasta = 99999;
			}
			busqueda = replaceChars(trim(busqueda));
			busqueda = busqueda.replace('ñ', 'nnn');
			busqueda = busqueda.replace('Ñ', 'NNN');
			var url_pag = PathUrl + '/buscar/' + busqueda + '-' + busqueda_precio + '-' + busqueda_precio_hasta + '/es/1/';
			document.location.href= url_pag;
		}
		else{
			alert('Tienes que rellenar al menos un campo del formulario');
			return false;
		}
	}


	function ltrim(s) {
	   return s.replace(/^\s+/, "");
	}
	
	function rtrim(s) {
	   return s.replace(/\s+$/, "");
	}
	
	function trim(s) {
	   return rtrim(ltrim(s));
	}
	
	function replaceChars(entry) {
		var pos
		var out = " "; // reemplazar el espacio
		var add = "_"; // por la subguion _
		var temp = "" + entry;
		while (temp.indexOf(out)>-1) {
			pos = temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
		}
		return temp;
	}

	function validarAcceso(){
		var login = document.getElementById('usuario_acceso').value;
		var password = document.getElementById('password_acceso').value;
		if(login != '' && password != ''){
			xajax_validarDistribuidor(login, password);
		}
		else{
			return false;
		}
	}

	function verificarAlfaNumerico(obj, e){
		var opc = false;
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla > 47 && tecla < 58) { // numeros del 1 al 9
			opc = true;
		}
		if (tecla > 64 && tecla < 91) { // A-Z MAYUSCULA
			opc = true;
		}
		if (tecla > 96 && tecla < 123) { // a-z minusculas
			opc = true;
		}					
		if (tecla == 209 || tecla == 241) { // ñ y Ñ
			opc = true;
		}	
		if(tecla == 13){
			opc = true;
		}
 // de estos solo va el 8 que es delete los demas no van en firefox
 // 32 - SPACE
		if (tecla == 8 || tecla == 0 || tecla == 32) {
			opc = true;
		}
		return opc;
	} 
	
	
	