// Lee las etiquetas de un XML -> xmlhttp.responseXML.documentElement var xmlDoc; function showTags(theTag,thePlace,campoActualiza) { var xx; var x; x = xmlDoc.getElementsByTagName(theTag); /* for (i=0,j=0; i "; } // Crea el objecto xmlhttp function creaAjax() { var xmlhttp = false; try { // versión de JavaScript superior a la 5 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { // objecto tradicional ActiveX if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlhttp; } // Procesa un XMLHttpRequest // IdObj: debe ser o
// response: XML ó Texto (html) // method: GET ó POST // str: string de valores que se enviarán (var=valor&var2=valor2...) // funcion: al finalizar la respuesta se ejecuta la función js que se le pase function procesAjax(URL,IdObj,response,method,str,funcion) { xmlhttp = creaAjax(); xmlhttp.open(method, URL); if (method == "POST") { // Añadimos un par etiqueta/valor al encabezado en el momento de enviarlo xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); } xmlhttp.onreadystatechange = function() { // readyState = estado actual del objecto, status = respuesta del servidor if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (response == "XML") { document.getElementById(IdObj).innerHTML = xmlhttp.responseXML; xmlDoc=xmlhttp.responseXML.documentElement; } else { document.getElementById(IdObj).innerHTML = xmlhttp.responseText; } if (funcion) eval(funcion); } } if (method == "GET") { xmlhttp.send(null); } else { xmlhttp.send(str); } } function checkDomain(domain) { procesAjax('/sections/whois/whois_ajax.php?whois='+domain,'reg_domains','HTML','GET','') xmlhttp.onreadystatechange = function() { // Esperamos que responda o mejor dicho que termine el objecto de procesAjax() if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { //setTimeout(document.getElementById('reg_domains').innerHTML = xmlhttp.responseText, 5000); document.getElementById('reg_domains').innerHTML = xmlhttp.responseText; } } } function str_replace(search, replace, subject) { // * example 1: str_replace(' ', '.', 'Kevin van Zonneveld'); // * returns 1: 'Kevin.van.Zonneveld' // * example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars'); // * returns 2: 'hemmo, mars' var f = search, r = replace, s = subject; var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length; while (j = 0, i--) { if (s[i]) { while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){}; } }; return sa ? s : s[0]; } //Retorna: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF error, -2 = CIF error, -3 = NIE error, 0 = ??? error function valida_nif_cif_nie(a) { var temp=a.toUpperCase(); var cadenadni="TRWAGMYFPDXBNJZSQVHLCKE"; if (temp!==''){ //si no tiene un formato valido devuelve error if ((!/^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$/.test(temp) && !/^[T]{1}[A-Z0-9]{8}$/.test(temp)) && !/^[0-9]{8}[A-Z]{1}$/.test(temp)) { return 0; } //comprobacion de NIFs estandar if (/^[0-9]{8}[A-Z]{1}$/.test(temp)) { posicion = a.substring(8,0) % 23; letra = cadenadni.charAt(posicion); var letradni=temp.charAt(8); if (letra == letradni) { return 1; } else { return -1; } } //algoritmo para comprobacion de codigos tipo CIF suma = parseInt(a[2])+parseInt(a[4])+parseInt(a[6]); for (i = 1; i < 8; i += 2) { temp1 = 2 * parseInt(a[i]); temp1 += ''; temp1 = temp1.substring(0,1); temp2 = 2 * parseInt(a[i]); temp2 += ''; temp2 = temp2.substring(1,2); if (temp2 == '') { temp2 = '0'; } suma += (parseInt(temp1) + parseInt(temp2)); } suma += ''; n = 10 - parseInt(suma.substring(suma.length-1, suma.length)); //comprobacion de NIFs especiales (se calculan como CIFs) if (/^[KLM]{1}/.test(temp)) { if (a[8] == String.fromCharCode(64 + n)) { return 1; } else { return -1; } } //comprobacion de CIFs if (/^[ABCDEFGHJNPQRSUVW]{1}/.test(temp)) { temp = n + ''; if (a[8] == String.fromCharCode(64 + n) || a[8] == parseInt(temp.substring(temp.length-1, temp.length))) { return 2; } else { return -2; } } //comprobacion de NIEs //T if (/^[T]{1}/.test(temp)) { if (a[8] == /^[T]{1}[A-Z0-9]{8}$/.test(temp)) { return 3; } else { return -3; } } //XYZ if (/^[XYZ]{1}/.test(temp)) { pos = str_replace(['X', 'Y', 'Z'], ['0','1','2'], temp).substring(0, 8) % 23; if (a[8] == cadenadni.substring(pos, pos + 1)) { return 3; } else { return -3; } } } return 0; } function checkCCC(i_entidad,i_oficina,i_digito,i_cuenta) { // Funcion recibe como parámetro la entidad, la oficina, // el digito (concatenación del de control entidad-oficina y del de control entidad) // y la cuenta. Espera los valores con 0's a la izquierda. // Devuelve true o false. // NOTAS: // Formato deseado de los parámetros: // - i_entidad (4) // - i_oficina (4) // - i_digito (2) // - i_cuenta (10) var wtotal,wcociente, wresto; if (i_entidad.length != 4) { return false; } if (i_oficina.length != 4) { return false; } if (i_digito.length != 2) { return false; } if (i_cuenta.length != 10) { return false; } wtotal = i_entidad.charAt(0) * 4; wtotal += i_entidad.charAt(1) * 8; wtotal += i_entidad.charAt(2) * 5; wtotal += i_entidad.charAt(3) * 10; wtotal += i_oficina.charAt(0) * 9; wtotal += i_oficina.charAt(1) * 7; wtotal += i_oficina.charAt(2) * 3; wtotal += i_oficina.charAt(3) * 6; // busco el resto de dividir wtotal entre 11 wcociente = Math.floor(wtotal / 11); wresto = wtotal - (wcociente * 11); // wtotal = 11 - wresto; if (wtotal == 11) { wtotal=0; } if (wtotal == 10){ wtotal=1; } if (wtotal != i_digito.charAt(0)) { return false; } //hemos validado la entidad y oficina //----------------------------------- wtotal = i_cuenta.charAt(0) * 1; wtotal += i_cuenta.charAt(1) * 2; wtotal += i_cuenta.charAt(2) * 4; wtotal += i_cuenta.charAt(3) * 8; wtotal += i_cuenta.charAt(4) * 5; wtotal += i_cuenta.charAt(5) * 10; wtotal += i_cuenta.charAt(6) * 9; wtotal += i_cuenta.charAt(7) * 7; wtotal += i_cuenta.charAt(8) * 3; wtotal += i_cuenta.charAt(9) * 6; // busco el resto de dividir wtotal entre 11 wcociente = Math.floor(wtotal / 11); wresto = wtotal - (wcociente * 11); // wtotal = 11 - wresto; if (wtotal == 11){wtotal=0;} if (wtotal == 10){wtotal=1;} if (wtotal != i_digito.charAt(1)){ //alert(wtotal+' y no '+i_digito.charAt(1)); return false; } // hemos validado la cuenta corriente return true; } function checkAsociaCCC() { if (checkCCC(document.nuevoCliente.entidad.value,document.nuevoCliente.oficina.value,document.nuevoCliente.DC.value,document.nuevoCliente.cuenta.value) == false) { alert('Su número de cuenta es incorrecto'); document.nuevoCliente.entidad.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.oficina.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.DC.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.cuenta.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.entidad.focus(); return false; } return true; } function checkForm(paso) { if (paso == 0) { if (!document.contratacion.dominio.value) { alert('Debe introducir el dominio para asociar el hosting'); document.contratacion.dominio.focus(); return false; } } else if (paso == 1) { if (document.contratacion.acepto.checked == false) { alert('Debe aceptar las condiciones del contrato'); return false; } } else if (paso == 2) { // Login Cliente if (document.login.email.value) { var filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+$/; if (!filtro.test(document.login.email.value)) { alert('El formato de su E-Mail es incorrecto.'); document.login.email.style.backgroundColor = '#ffc4c4'; document.login.email.focus(); return false; } } if (document.login.passwd.value && !document.login.email.value) { alert('Introduzca su cuenta de acceso'); document.login.email.style.backgroundColor = '#ffc4c4'; document.login.email.focus(); return false; } if (document.login.email.value && !document.login.passwd.value) { alert('Introduzca su contraseña de acceso'); document.login.passwd.style.backgroundColor = '#ffc4c4'; document.login.passwd.focus(); return false; } if (!document.login.email.value) { // Nuevo Cliente if (document.nuevoCliente.tipoCliente[0].checked) { // Particular if (!document.nuevoCliente.nombreCompleto.value) { alert('Introduzca su nombre completo'); document.nuevoCliente.nombreCompleto.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.nombreCompleto.focus(); return false; } // 1 = NIF ok, 2 = CIF ok, 3 = NIE ok if (valida_nif_cif_nie(document.nuevoCliente.NIF.value) < 1 || valida_nif_cif_nie(document.nuevoCliente.NIF.value) > 3) { alert('DNI o NIE no válido, formato: 12345678A o X1234567A'); document.nuevoCliente.NIF.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.NIF.focus(); return false; } } else { // Empresa if (!document.nuevoCliente.empresa.value) { alert('Introduzca el nombre de su empresa'); document.nuevoCliente.empresa.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.empresa.focus(); return false; } if (!document.nuevoCliente.personaContacto.value) { alert('Introduzca el nombre de la persona de contacto'); document.nuevoCliente.personaContacto.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.personaContacto.focus(); return false; } // 1 = NIF ok, 2 = CIF ok, 3 = NIE ok if (valida_nif_cif_nie(document.nuevoCliente.NIF.value) < 1 || valida_nif_cif_nie(document.nuevoCliente.NIF.value) > 3) { alert('CIF no válido, formato: B12345678'); document.nuevoCliente.NIF.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.NIF.focus(); return false; } } // campos comunes if (!document.nuevoCliente.emailNuevo.value) { alert('Debe introducir su E-Mail.'); document.nuevoCliente.emailNuevo.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.emailNuevo.focus(); return false; } else { var filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})+$/; if (!filtro.test(document.nuevoCliente.emailNuevo.value)) { alert('El formato de su E-Mail es incorrecto.'); document.nuevoCliente.emailNuevo.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.emailNuevo.focus(); return false; } } if (!document.nuevoCliente.direccion.value) { alert('Introduzca su dirección'); document.nuevoCliente.direccion.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.direccion.focus(); return false; } if (!document.nuevoCliente.CP.value) { alert('Introduzca su código postal'); document.nuevoCliente.CP.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.CP.focus(); return false; } if (!document.nuevoCliente.passwdNuevo.value) { alert('Introduzca su contraseña de acceso'); document.nuevoCliente.passwdNuevo.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.passwdNuevo.focus(); return false; } else { if (document.nuevoCliente.passwdNuevo.value != document.nuevoCliente.repetirpasswdNuevo.value) { alert('Su contraseña no coincide en su repetición'); document.nuevoCliente.repetirpasswdNuevo.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.repetirpasswdNuevo.focus(); return false; } } if (document.nuevoCliente.entidad.value || document.nuevoCliente.oficina.value || document.nuevoCliente.DC.value || document.nuevoCliente.cuenta.value) { if (checkCCC(document.nuevoCliente.entidad.value,document.nuevoCliente.oficina.value,document.nuevoCliente.DC.value,document.nuevoCliente.cuenta.value) == false) { alert('Su número de cuenta es incorrecto'); document.nuevoCliente.entidad.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.oficina.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.DC.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.cuenta.style.backgroundColor = '#ffc4c4'; document.nuevoCliente.entidad.focus(); return false; } } } // Fin si no es login } return true; } function tipoCliente() { alert(document.nuevoCliente.tipoCliente.value); if (document.nuevoCliente.tipoCliente.value == "particular") { document.getElementById("trEmpresa").style.display = "none"; document.getElementById("trParticular").style.display = ""; } else { document.getElementById("trEmpresa").style.display = ""; document.getElementById("trParticular").style.display = "none"; } } var doAlerts=true; function changeSheets(whichSheet){ whichSheet=whichSheet-1; if(document.styleSheets){ var c = document.styleSheets.length; for(var i=0;i -1 ) { var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); var aQueryString = strQueryString.split("&"); for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) { if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ) { var aParam = aQueryString[iParam].split("="); strReturn = aParam[1]; break; } } } return unescape(strReturn); } // Planes - Cambio de estilos var whosOn = ''; function doClick(obj) { menu = new Array("planPersonal","planProfesional","planEmpresas","planCorporativo"); for (i=0;i