function base64() {}; base64.chars = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'); base64.cadena = ""; base64.cuenta = 0; base64.setCadena = function (str){ base64.cadena = str; base64.cuenta = 0; }; base64.read = function (){ if (!base64.cadena) return "END_OF_INPUT"; if (base64.cuenta >= base64.cadena.length) return "END_OF_INPUT"; var c = base64.cadena.charCodeAt(base64.cuenta) & 0xff; base64.cuenta++; return c; }; base64.prototype.encode = function (str){ base64.setCadena(str); var result = ''; var inBuffer = new Array(3); var lineCount = 0; var done = false; while (!done && (inBuffer[0] = base64.read()) != "END_OF_INPUT"){ inBuffer[1] = base64.read(); inBuffer[2] = base64.read(); result += (base64.chars[ inBuffer[0] >> 2 ]); if (inBuffer[1] != "END_OF_INPUT"){ result += (base64.chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]); if (inBuffer[2] != "END_OF_INPUT"){ result += (base64.chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]); result += (base64.chars [inBuffer[2] & 0x3F]); } else { result += (base64.chars [((inBuffer[1] << 2) & 0x3c)]); result += ('='); done = true; } } else { result += (base64.chars [(( inBuffer[0] << 4 ) & 0x30)]); result += ('='); result += ('='); done = true; } lineCount += 4; if (lineCount >= 76){ result += ('\n'); lineCount = 0; } } return result; }; b64 = new base64;//Pone el foco en el elemento indicado de la forma function foco(elemento, seleccionar){ document.f1[elemento].focus(); if(seleccionar != "") document.f1[elemento].select(); } //Fin de la función foco() //Sólo acepta números enteros var nav4 = window.Event ? true : false; function acceptNum(evt){ var key = nav4 ? evt.which : evt.keyCode; return(key <= 13 || (key >= 48 && key <= 57)); } //Fin de la función acceptNum(evt) //Sólo acepta letras function aceptaLetras(evt){ var key = nav4 ? evt.which : evt.keyCode; return(key <= 13 || key == 32 || key == 46 || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || (key >= 48 && key <= 57)); } //Fin de la función acceptNum(evt) //Función que deshabilita el botón de Submit function deshabilitaSubmit(){ document.getElementById("btnAceptar").disabled = true; document.getElementById("btnAceptar").value = "Enviando..."; return false; } //Fin de la función deshabilitaSubmit() //Función que habilita el botón Submit function habilitaSubmit(){ document.getElementById("btnAceptar").disabled = false; document.getElementById("btnAceptar").value = "ACEPTAR"; return false; } //Fin de la función habilitaSubmit() /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Función que compara fechas function comparaFechas(fechaInicio, fechaFin){ //Recibe las fechas en formato DD/MM/AAAA //Las separa para ponerlas en formato MM/DD/AAAA var fechaInicio2 = fechaInicio.split("/"); var fechaInicio3 = fechaInicio2[1] + "/" + fechaInicio2[0] + "/" + fechaInicio2[2]; var fechaFin2 = fechaFin.split("/"); var fechaFin3 = fechaFin2[1] + "/" + fechaFin2[0] + "/" + fechaFin2[2]; //Creamos las fechas var fechaInicio4 = new Date(fechaInicio3); var fechaFin4 = new Date(fechaFin3); //Comparamos //Si regresa -1, la fechaInicio > fechaFin //Si regresa 0, la fechaInicio == fechaFin //Si regresa 1, la fechaFin > fechaInicio if(fechaInicio4 > fechaFin4) return -1; else if(fechaInicio4 == fechaFin4) return 0; else return 1; } //Fin de la función comparaFechas(fechaInicio, fechaFin) //Funciones que validan que una fecha sea correcta function esDigito(sChr){ var sCod = sChr.charCodeAt(0); return ((sCod > 47) && (sCod < 58)); } //Fin de la función function esDigito(sChr) function valSep(oTxt){ var bOk = false; bOk = bOk || ((oTxt.charAt(2) == "-") && (oTxt.charAt(5) == "-")); bOk = bOk || ((oTxt.charAt(2) == "/") && (oTxt.charAt(5) == "/")); return bOk; } //Fin de la función function valSep(oTxt) function finMes(oTxt){ var nMes = parseInt(oTxt.substr(3, 2), 10); var nRes = 0; switch (nMes){ case 1: nRes = 31; break; case 2: nRes = 29; break; case 3: nRes = 31; break; case 4: nRes = 30; break; case 5: nRes = 31; break; case 6: nRes = 30; break; case 7: nRes = 31; break; case 8: nRes = 31; break; case 9: nRes = 30; break; case 10: nRes = 31; break; case 11: nRes = 30; break; case 12: nRes = 31; break; } return nRes; } //Fin de la función function finMes(oTxt) function valDia(oTxt){ var bOk = false; var nDia = parseInt(oTxt.substr(0, 2), 10); bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt))); return bOk; } //Fin de la función function valDia(oTxt) function valMes(oTxt){ var bOk = false; var nMes = parseInt(oTxt.substr(3, 2), 10); bOk = bOk || ((nMes >= 1) && (nMes <= 12)); return bOk; } //Fin de la función function valMes(oTxt) function valAno(oTxt){ var bOk = true; var nAno = oTxt.substr(6); bOk = bOk && ((nAno.length == 2) || (nAno.length == 4)); if (bOk){ for (var i = 0; i < nAno.length; i++){ bOk = bOk && esDigito(nAno.charAt(i)); } } return bOk; } //Fin de la función function valAno(oTxt) function validaFecha(oTxt){ var bOk = true; if (oTxt != ""){ bOk = bOk && (valAno(oTxt)); bOk = bOk && (valMes(oTxt)); bOk = bOk && (valDia(oTxt)); bOk = bOk && (valSep(oTxt)); if (!bOk) return false; else return true; } } //Fin de la función function validaFecha(oTxt) //Función que da formato DD/MM/AAAA a una fecha function formatoFecha(dia, mes, anio){ var nDia = ""; var nMes = ""; if(parseInt(dia) < 10) nDia = "0" + dia; else nDia = dia; if(parseInt(mes) < 10) nMes = "0" + mes; else nMes = mes; var fecha = nDia + "/" + nMes + "/" + anio; return fecha; } //Fin de la función formatoFecha(dia, mes, anio) /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Función que abre un popup function MM_openBrWindow(theURL, winName, features){ window.open(theURL, winName, features); } //Fin de la función MM_openBrWindow(theURL, winName, features) //Función que cierra un popup function cerrar(){ window.close(); } //Fin de la función cerrar() /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Función que valida si el email es correcto function esMail(mail){ //Generamos la expresión regular con las condiciones que debe cumplir un mail var b = /^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/; //Devolvemos verdadero si es correcto, de lo contrario devolvemos falso return b.test(mail); } //Fin de la función esMail(mail) //Función que corta el texto a la longitud indicada function cortarTexto(obj){ var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""; if(obj.getAttribute && obj.value.length > mlength) obj.value = obj.value.substring(0, mlength); } //Fin de la función cortarTexto(obj) /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Función que valida que el archivo introducido sea del tipo correcto function compruebaExtension(archivo){ extensionesPermitidas = new Array(".gif", ".jpg", ".png", ".bmp"); mierror = ""; if(! archivo){ permitida = false; } else{ //Recuperamos la extensión de este nombre de archivo extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); //Comprobamos si la extensión está entre las permitidas permitida = false; for(var i = 0; i < extensionesPermitidas.length; i++){ if(extensionesPermitidas[i] == extension){ permitida = true; break; } //Fin de if(extensionesPermitidas[i] == extension) } //Fin de for(var i = 0; i < extensionesPermitidas.length; i++) } //Fin de else return permitida; } //Fin de la función compruebaExtension(archivo) /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Funcion que muestra el div en la posicion del mouse function showdiv(elemento){ if(elemento == "flotante"){ document.getElementById("myMenu1").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderLeft = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderRight = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderBottom = "1px solid #FFFFFF"; document.getElementById("myMenu2").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderBottom = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderRight = "1px solid #A9D54E"; document.getElementById("myMenu1").style.height = "16px"; document.getElementById("ligaMenu1").className = "ligaMenu2"; document.getElementById("ligaMenu2").className = "ligaMenu"; limpiaFormLogin(); } else{ document.getElementById("myMenu2").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderRight = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderBottom = "1px solid #FFFFFF"; document.getElementById("myMenu1").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderBottom = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderLeft = "1px solid #A9D54E"; document.getElementById("myMenu2").style.height = "16px"; document.getElementById("myMenu1").style.height = "15px"; document.getElementById("ligaMenu2").className = "ligaMenu2"; document.getElementById("ligaMenu1").className = "ligaMenu"; limpiaFormRegistro(); } document.getElementById(elemento).style.display = "block"; document.getElementById("blanket").style.display = "block"; return; } //Fin de la función showdiv() function ID(id){ return document.getElementById(id);} //Función que oculta el div function hidediv(elemento){ document.getElementById(elemento).style.display = "none"; document.getElementById("myMenu1").style.borderLeft = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderRight = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu1").style.borderBottom = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderLeft = "0px"; document.getElementById("myMenu2").style.borderRight = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderTop = "1px solid #A9D54E"; document.getElementById("myMenu2").style.borderBottom = "1px solid #A9D54E"; document.getElementById("myMenu1").style.height = "18px"; document.getElementById("myMenu2").style.height = "18px"; document.getElementById("ligaMenu1").className = "ligaMenu"; document.getElementById("ligaMenu2").className = "ligaMenu"; cambiaEstilosMyMenu10(); cambiaEstilosMyMenu20(); var resetPass = ID("resetPaswd"); resetPass.style.display = "none"; ID("overlay").style.display = "block" ; } //Fin de la función hidediv() //Función que cierra los divs de Ingreso y de registro function cierraDivsIngreso(){ document.getElementById("blanket").style.display = "none"; hidediv("flotante"); hidediv("flotante2"); ID("overlay").style.display = "none" ; } //Fin de la función cierraDivsIngreso() //Función que limpia el formulario de Login function limpiaFormLogin(){ try{ document.f2.email.value = ""; document.f2.contr.value = ""; document.f2.recordarme.checked = false; } catch(e){} } //Fin de la función limpiaFormLogin() //Función que limpia el formulario de registro de usuarios function limpiaFormRegistro(){ try{ document.f1.nombre.value = ""; document.f1.apellidos.value = ""; document.f1.email.value = ""; document.f1.genero[0].checked = false; document.f1.genero[1].checked = false; document.f1.diaNacimiento.value = ""; document.f1.mesNacimiento.value = ""; document.f1.anioNacimiento.value = ""; document.f1.cont1.value = ""; document.f1.cont2.value = ""; document.f1.cars.value = ""; document.f1.genero1.value = ""; document.f1.ct.value = ""; } catch(e){} } //Fin de la función limpiaFormRegistro() /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ /***********************************************************************************************************************************/ //Función que genera un MD5 de una cadena var MD5 = function(string){ function RotateLeft(lValue, iShiftBits){ return(lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); } //Fin de la función RotateLeft(lValue, iShiftBits) function AddUnsigned(lX, lY){ var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); if(lX4 & lY4){ return(lResult ^ 0x80000000 ^ lX8 ^ lY8); } if(lX4 | lY4){ if(lResult & 0x40000000){ return(lResult ^ 0xC0000000 ^ lX8 ^ lY8); }else{ return(lResult ^ 0x40000000 ^ lX8 ^ lY8); } }else{ return(lResult ^ lX8 ^ lY8); } } //Fin de la función AddUnsigned(lX, lY)¿ function F(x, y, z){ return(x & y) | ((~x) & z); } function G(x, y, z){ return(x & z) | (y & (~z)); } function H(x, y, z){ return(x ^ y ^ z); } function I(x, y, z){ return(y ^ (x | (~z))); } function FF(a, b, c, d, x, s, ac){ a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function GG(a, b, c, d, x, s, ac){ a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function HH(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function II(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function ConvertToWordArray(string) { var lWordCount; var lMessageLength = string.length; var lNumberOfWords_temp1=lMessageLength + 8; var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; var lNumberOfWords = (lNumberOfWords_temp2+1)*16; var lWordArray=Array(lNumberOfWords-1); var lBytePosition = 0; var lByteCount = 0; while ( lByteCount < lMessageLength ) { lWordCount = (lByteCount-(lByteCount % 4))/4; lBytePosition = (lByteCount % 4)*8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<>>29; return lWordArray; }; function WordToHex(lValue) { var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; for (lCount = 0;lCount<=3;lCount++) { lByte = (lValue>>>(lCount*8)) & 255; WordToHexValue_temp = "0" + lByte.toString(16); WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); } return WordToHexValue; }; function Utf8Encode(string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }; var x=Array(); var k,AA,BB,CC,DD,a,b,c,d; var S11=7, S12=12, S13=17, S14=22; var S21=5, S22=9 , S23=14, S24=20; var S31=4, S32=11, S33=16, S34=23; var S41=6, S42=10, S43=15, S44=21; string = Utf8Encode(string); x = ConvertToWordArray(string); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; for (k=0;kEl E-mail no es correcto."; }else{ id("f1").email.style.borderColor = "#2EB5E5"; id("vus").innerHTML = "
E-mail correcto, nadie lo ha registrado.
"; // ok } }else{ id("f1").email.style.borderColor = "#f00"; id("vus").innerHTML = "
El E-mail ya está registrado.
"; //ocupado } /*if(http.responseText == 0){ document.getElementById("vus").style.display = "block"; if(esMail(document.getElementById("f1").email.value) == false) document.getElementById("vus").innerHTML = "El E-mail no es correcto."; else document.getElementById("vus").innerHTML = "¡Bien! Este E-mail nadie lo ha registrado."; } else{ document.getElementById("vus").style.display = "block"; document.getElementById("vus").innerHTML = "El E-mail ya está registrado."; } */ } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("email="+document.getElementById("f1").email.value); } catch(e){} finally{} } } //Fin de la función sndReq() //Función que consulta los datos del usuario para acceder al sistema function sndReq2(email, contrasena, url){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/validaAcceso/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ info = http.responseText; if(info.substr(0, 3) == "<->") document.getElementById("mensajeError").innerHTML = info.substr(3, (info.length - 4)); else location.href = "http://www.doctorweb.org/" + info; } else location.href = "http://www.doctorweb.org"; } } var recordarme = "n"; try{ if(document.f2.recordarme.checked) recordarme = "s"; } catch(e){} http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("email="+email+"&contrasena="+contrasena+"&recordarme="+recordarme+"&url="+url); } catch(e){} finally{} } //Fin de la función sndReq2(email, contrasena) //Función que solicita una nueva cadena aleatoria function sndReqRU3(){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/nuevaAleatoria/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ //Obtenemos el MD5 de la nueva cadena var cadena = MD5(http.responseText); //Definimos la nueva imagen document.getElementById("imgCap").src = "http://www.doctorweb.org/de2/popups/captcha.php?c="+http.responseText; //Cambiamos el valor a la variable document.getElementById("ctv1").value = cadena; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send(); } catch(e){} finally{} } //Fin de la función sndReqRU3() function sndReqRU4(){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/nuevaAleatoria/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ //Obtenemos el MD5 de la nueva cadena var cadena = MD5(http.responseText); //Definimos la nueva imagen document.getElementById("imgCaptcha").src = "http://www.doctorweb.org/de2/popups/captcha.php?c="+http.responseText; //Cambiamos el valor a la variable document.getElementById("ctv2").value = cadena; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send(); } catch(e){} finally{} } //Fin de la función sndReqRU3() //Función que inserta los datos de un usuario function sndReq4(){ /********************************* innerHTML of response to design CerrarNombreJavierApellido(s)Lopez LopezE-mailjavier@pce.com.mxGéneroMasculinoFecha de nacimiento11/5/1984Javier, sus datos se han guardado en nuestra base de datos. Para completar el registro cheque su E-mail y haga clic en la liga que le enviamos.

Atentamente,
Doctor Web
************************/ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/agregaUsuario/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ //document.getElementById("datosRegistro").innerHTML = http.responseText; //document.getElementById("flotante2").style.height = "300px"; document.getElementById('flotante2').innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("nombre="+document.getElementById("f1").nombre.value+"&apellidos="+document.getElementById("f1").apellidos.value+"&genero="+document.getElementById("f1").genero1.value+"&diaNacimiento="+document.getElementById("f1").diaNacimiento.value+"&mesNacimiento="+document.getElementById("f1").mesNacimiento.value+"&anioNacimiento="+document.getElementById("f1").anioNacimiento.value+"&email="+document.getElementById("f1").email.value+"&cont1="+document.getElementById("f1").cont1.value); } catch(e){} finally{} } //Fin de la función sndReq4() //Función que elimina la cookie del usuario function sndReq5(){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/eliminaCookie/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText == "") location.href = "http://www.doctorweb.org"; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send(); } catch(e){} finally{} } //Fin de la función sndReq5() //Función que envía contraseña al correo indicado function forgotPass(){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/sendForgotPass/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("mensajeError").innerHTML = http.responseText; return false; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("email="+document.f2FP.email.value); return false; } catch(e){return false;} finally{return false;} return false; } //Fin de la función forgotPass() //Función que devuelve ordena las calificaciones function sndReqMisCalif(valor, orden){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/misCalificaciones/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("datos").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("ordenarPor="+valor+"&orden="+orden+"&us="+document.getElementById("us").value); } catch(e){} finally{} } //Fin de sndReqMisCalif(valor, orden) //Función que recibe los datos del usuario para acceder al sistema function handleResponse2(){ try{ if((http.readyState == 4) && (http.status == 200)){ var response = http.responseText; var update = new Array(); if(response != ""){alert(response); document.getElementById("mensajeError").style.display = "block"; document.getElementById("mensajeError").innerHTML = response; } else window.location.href = "http://www.doctorweb.org/panel-de-usuario/"; } } catch(e){} finally{} } //Fin de la función handleResponse2() //Función necesaria para ejecutar el AJAX correctamente function createRequestObject(){ var xmlhttp; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(f){ xmlhttp = null; } } if(! xmlhttp && typeof XMLHttpRequest != "undefined") xmlhttp = new XMLHttpRequest(); return xmlhttp; } //Fin de la función createRequestObject()//Funciones de Administrador de Usuarios //Función que valida los datos de la sección function adusf1(seccion){ switch(seccion){ case 0: if(document.getElementById("nombreAU").value == ""){ alert("Campo requerido: Nombre"); return; } if(document.getElementById("apellidosAU").value == ""){ alert("Campo requerido: Apellidos"); return; } sndReqAU(seccion, document.getElementById("nombreAU").value, document.getElementById("apellidosAU").value, "", "", "", "", "", "", document.getElementById("eaAU").value); return; break; case 1: if((document.getElementsByName("generoAU")[0].checked == false) && (document.getElementsByName("generoAU")[1].checked == false)){ alert("Campo requerido: Género"); return; } if(document.getElementsByName("generoAU")[0].checked) document.getElementById("genero1AU").value = document.getElementsByName("generoAU")[0].value; else document.getElementById("genero1AU").value = document.getElementsByName("generoAU")[1].value; sndReqAU(seccion, "", "", document.getElementById("genero1AU").value, "", "", "", "", "", document.getElementById("eaAU").value); return; break; case 2: if((document.getElementById("diaNacimientoAU").value != "") || (document.getElementById("mesNacimientoAU").value != "") || (document.getElementById("anioNacimientoAU").value != "")){ if(document.getElementById("diaNacimientoAU").value == ""){ alert("Campo requerido: Día"); return; } if(document.getElementById("mesNacimientoAU").value == ""){ alert("Campo requerido: Mes"); return; } if(document.getElementById("anioNacimientoAU").value == ""){ alert("Campo requerido: Año"); return; } var fecha = formatoFecha(document.getElementById("diaNacimientoAU").value, document.getElementById("mesNacimientoAU").value, document.getElementById("anioNacimientoAU").value); if(validaFecha(fecha) == false){ alert("La fecha de nacimiento no es válida"); return; } } sndReqAU(seccion, "", "", "", document.getElementById("diaNacimientoAU").value, document.getElementById("mesNacimientoAU").value, document.getElementById("anioNacimientoAU").value, "", "", document.getElementById("eaAU").value); return; break; case 3: if(document.getElementById("emailAU").value == ""){ alert("Campo requerido: Nuevo E-mail"); return; } if(esMail(document.getElementById("emailAU").value) == false){ alert("El E-mail no es correcto"); return; } if(document.getElementById("vusAU").innerHTML == "El E-mail ya está registrado."){ alert("El E-mail ya está registrado"); return; } sndReqAU(seccion, "", "", "", "", "", "", document.getElementById("emailAU").value, "", document.getElementById("eaAU").value); return; break; case 4: if(document.getElementById("contAntAU").value == ""){ alert("Campo requerido: Contraseña anterior"); return; } if(document.getElementById("caAU").value != MD5(document.getElementById("contAntAU").value)){ alert("La contraseña anterior no es correcta"); return; } if(document.getElementById("cont1AU").value == ""){ alert("Campo requerido: Nueva contraseña"); return; } if(document.getElementById("cont2AU").value == ""){ alert("Campo requerido: Confirmar nueva contraseña"); return; } if(document.getElementById("cont1AU").value != document.getElementById("cont2AU").value){ alert("Las contraseñas no coinciden"); document.getElementById("cont1AU").value = ""; document.getElementById("cont2AU").value = ""; return; } if(document.getElementById("contAntAU").value == document.getElementById("cont1AU").value){ alert("La contraseña anterior es igual a la contraseña nueva"); return; } sndReqAU(seccion, "", "", "", "", "", "", "", document.getElementById("cont1AU").value, document.getElementById("eaAU").value); return; break; } //Fin de switch(seccion) } //Fin de la función valSubmit(seccion) //Función que pide validar las contraseñas function valContAU(){ if((document.getElementById("cont1AU").value != "") && (document.getElementById("cont2AU").value != "")){ if(document.getElementById("cont1AU").value == document.getElementById("cont2AU").value){ document.getElementById("contValAU").style.display = "block"; document.getElementById("contValAU").innerHTML = "Coinciden"; } else{ document.getElementById("contValAU").style.display = "block"; document.getElementById("contValAU").innerHTML = "No coinciden"; } } //Fin de if((document.getElementById("cont1AU").value != "") && (document.getElementById("cont2AU").value != "")) } //Fin de la función valContAU() //Función que muestra los datos de la sección function adusf2(seccion){ switch(seccion){ case 0: adusf3(1); adusf3(2); adusf3(3); adusf3(4); document.getElementById("sec0").style.display = "block"; document.getElementById("msec0").style.display = "none"; break; case 1: adusf3(0); adusf3(2); adusf3(3); adusf3(4); document.getElementById("sec1").style.display = "block"; document.getElementById("msec1").style.display = "none"; break; case 2: adusf3(0); adusf3(1); adusf3(3); adusf3(4); document.getElementById("sec2").style.display = "block"; document.getElementById("msec2").style.display = "none"; break; case 3: adusf3(0); adusf3(1); adusf3(2); adusf3(4); document.getElementById("sec3").style.display = "block"; document.getElementById("msec3").style.display = "none"; break; case 4: adusf3(0); adusf3(1); adusf3(2); adusf3(3); document.getElementById("sec4").style.display = "block"; document.getElementById("msec4").style.display = "none"; break; } //Fin de switch(seccion) } //Fin de la función adus2(seccion) //Función que oculta los datos de la sección function adusf3(seccion){ switch(seccion){ case 0: document.getElementById("sec0").style.display = "none"; document.getElementById("msec0").style.display = "block"; break; case 1: document.getElementById("sec1").style.display = "none"; document.getElementById("msec1").style.display = "block"; break; case 2: document.getElementById("sec2").style.display = "none"; document.getElementById("msec2").style.display = "block"; break; case 3: document.getElementById("sec3").style.display = "none"; document.getElementById("msec3").style.display = "block"; break; case 4: document.getElementById("sec4").style.display = "none"; document.getElementById("msec4").style.display = "block"; break; } //Fin de switch(seccion) } //Fin de la función adus3(seccion) //Función que cambia los estilos de las pestañas function cambiaEstiloPestana(pestana, ligaPestana){ document.getElementById(pestana).style.cursor = "pointer"; document.getElementById(pestana).style.background = "#A9D54E"; document.getElementById(ligaPestana).style.color = "#FFFFFF"; } //Fin de la función cambiaEstiloPestana(pestana, ligaPestana) //Función que regresa los estilos de las pestañas function regresaEstiloPestana(pestana, ligaPestana){ document.getElementById(pestana).style.background = "#FFFFFF"; document.getElementById(ligaPestana).style.color = "#A9D54E"; } //Fin de la función regresaEstiloPestana(pestana, ligaPestana) //Función que cambia el contenido del perfil de usuario function cambiaDatosPerfil(modulo){ if(modulo == "historial"){ document.getElementById("datosPerfil").style.display = "none"; document.getElementById("datosHistorial").style.display = "block"; document.getElementById("datosArticulosEnviados").style.display = "none"; document.getElementById("datosArticulosRecibidos").style.display = "none"; document.getElementById("pestana1").className = "ligaNoActual"; document.getElementById("pestana2").className = "ligaActual"; document.getElementById("pestana3").className = "ligaNoActual"; document.getElementById("pestana4").className = "ligaNoActual"; document.getElementById("ligaPestana1").className = "ligaPestana2"; document.getElementById("ligaPestana2").className = "ligaPestana"; document.getElementById("ligaPestana3").className = "ligaPestana2"; document.getElementById("ligaPestana4").className = "ligaPestana2"; } else if(modulo == "enviados"){ document.getElementById("datosPerfil").style.display = "none"; document.getElementById("datosHistorial").style.display = "none"; document.getElementById("datosArticulosEnviados").style.display = "block"; document.getElementById("datosArticulosRecibidos").style.display = "none"; document.getElementById("pestana1").className = "ligaNoActual"; document.getElementById("pestana2").className = "ligaNoActual"; document.getElementById("pestana3").className = "ligaActual"; document.getElementById("pestana4").className = "ligaNoActual"; document.getElementById("ligaPestana1").className = "ligaPestana2"; document.getElementById("ligaPestana2").className = "ligaPestana2"; document.getElementById("ligaPestana3").className = "ligaPestana"; document.getElementById("ligaPestana4").className = "ligaPestana2"; } else if(modulo == "recibidos"){ document.getElementById("datosPerfil").style.display = "none"; document.getElementById("datosHistorial").style.display = "none"; document.getElementById("datosArticulosEnviados").style.display = "none"; document.getElementById("datosArticulosRecibidos").style.display = "block"; document.getElementById("pestana1").className = "ligaNoActual"; document.getElementById("pestana2").className = "ligaNoActual"; document.getElementById("pestana3").className = "ligaNoActual"; document.getElementById("pestana4").className = "ligaActual"; document.getElementById("ligaPestana1").className = "ligaPestana2"; document.getElementById("ligaPestana2").className = "ligaPestana2"; document.getElementById("ligaPestana3").className = "ligaPestana2"; document.getElementById("ligaPestana4").className = "ligaPestana"; } else{ document.getElementById("datosPerfil").style.display = "block"; document.getElementById("datosHistorial").style.display = "none"; document.getElementById("datosArticulosEnviados").style.display = "none"; document.getElementById("datosArticulosRecibidos").style.display = "none"; document.getElementById("pestana1").className = "ligaActual"; document.getElementById("pestana2").className = "ligaNoActual"; document.getElementById("pestana3").className = "ligaNoActual"; document.getElementById("pestana4").className = "ligaNoActual"; document.getElementById("ligaPestana1").className = "ligaPestana"; document.getElementById("ligaPestana2").className = "ligaPestana2"; document.getElementById("ligaPestana3").className = "ligaPestana2"; document.getElementById("ligaPestana4").className = "ligaPestana2"; } } //Fin de la función cambiaDatosPerfil(modulo) /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ //Variables globales var http = createRequestObject(); var timeoutholder = null; //Función que ejecuta la activación/desactivación de una pregunta function sndReqAU(seccion, nombre, apellidos, genero, diaNac, mesNac, anioNac, email, nuevaContrasena, emailAnterior){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/actualizaPerfil/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText == ""){ switch(seccion){ case 0: document.getElementById("nombreInfo").innerHTML = nombre + " " + apellidos; adusf3(0); break; case 1: if(genero == "M") document.getElementById("generoInfo").innerHTML = "Masculino"; else document.getElementById("generoInfo").innerHTML = "Femenino"; adusf3(1); break; case 2: if((document.getElementById("diaNacimientoAU").value != "") && (document.getElementById("mesNacimientoAU").value != "") && (document.getElementById("anioNacimientoAU").value != "")){ var arreglo = new Array("", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); document.getElementById("fechaNacInfo").innerHTML = document.getElementById("diaNacimientoAU").value + " / " + arreglo[document.getElementById("mesNacimientoAU").value] + " / " + document.getElementById("anioNacimientoAU").value; } else document.getElementById("fechaNacInfo").innerHTML = "No indicada"; adusf3(2); break; case 3: location.href = "http://www.doctorweb.org"; break; case 4: document.getElementById("caAU").value = MD5(document.getElementById("cont1AU").value); document.getElementById("contAntAU").value = ""; document.getElementById("cont1AU").value = ""; document.getElementById("cont2AU").value = ""; document.getElementById("contValAU").style.display = "none"; document.getElementById("contValAU").innerHTML = ""; adusf3(4); break; } } else alert(http.responseText); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("seccion="+seccion+"&nombre="+nombre+"&apellidos="+apellidos+"&genero="+genero+"&diaNac="+diaNac+"&mesNac="+mesNac+"&anioNac="+anioNac+"&email="+email+"&nuevaContrasena="+nuevaContrasena+"&emailAnterior="+emailAnterior); } catch(e){} finally{} } //Fin de la función sndReqAU(idEncuesta, movimiento) //Función que ejecuta la búsqueda de los datos del usuario function sndReq2AU(){ if(document.getElementById("emailAU").value == ""){ document.getElementById("vusAU").innerHTML = ""; document.getElementById("vusAU").style.display = "none"; } else{ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/buscaUsuario/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText == 0){ document.getElementById("vusAU").style.display = "block"; if(esMail(document.getElementById("emailAU").value) == false) document.getElementById("vusAU").innerHTML = "El E-mail no es correcto."; else document.getElementById("vusAU").innerHTML = "¡Bien! Este E-mail nadie lo ha registrado."; } else{ document.getElementById("vusAU").style.display = "block"; document.getElementById("vusAU").innerHTML = "El E-mail ya está registrado."; } } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("email="+document.getElementById("emailAU").value); } catch(e){} finally{} } } //Fin de la función sndReq2AU() //Función necesaria para ejecutar el AJAX correctamente function createRequestObject(){ var xmlhttp; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(f){ xmlhttp = null; } } if(! xmlhttp && typeof XMLHttpRequest != "undefined") xmlhttp = new XMLHttpRequest(); return xmlhttp; } //Fin de la función createRequestObject()//Funciones del administrador de empresa //Función que muestra las empresas pendientes de autorizar function admEmpf1autoriza(){ document.getElementById("verEmpresas").style.display = "none"; document.getElementById("empresasPendientes").style.display = "block"; } //Fin de la función ademf1() //Función que oculta las empresas pendientes de autorizar function admEmpf2autoriza(){ document.getElementById("verEmpresas").style.display = "block"; document.getElementById("empresasPendientes").style.display = "none"; } //Fin de la función ademf2() //Función que cierra la ventana y recarga la principal function admEmpf1autoriza2(){ opener.location.reload(); window.close(); } //Fin de la función adem2f2() //Función que recarga la página con el Id. del tipo de empresa function adminEmpf1encuestas(){ if(document.getElementById("tipoPACC").value != "") sndReqPACC6(document.getElementById("tipoPACC").value); } //Fin de la función adminEmpf1encuestas() //Función que manda activar/desactivar una pregunta function adminEmpf2encuestas(idEncuesta, movimiento){ sndReqPACC(idEncuesta, movimiento); } //Fin de la función adminEmpf2encuestas(idEncuesta, movimiento) //Función que manda insertar una pregunta en la base de datos function adminEmpf3encuestas(){ if(document.getElementById("tipoPACC").value == ""){ alert("Campo requerido: Tipo"); return false; } if(document.f1PACC.preguntaPACC.value == ""){ alert("Campo requerido: Pregunta"); return false; } var resp = confirm("¿Están correctos los datos?"); if(resp){ sndReqPACC2(document.getElementById("tipoPACC").value, document.f1PACC.preguntaPACC.value); document.f1PACC.preguntaPACC.value = ""; return false; } else return false; } //Fin de la función adminEmpf3encuestas() //Función que valida los datos para agregar un tipo de empresa function adminEmpf1tiposEmpresa(){ if(document.f1AE02.tipo.value == ""){ habilitaSubmit(); alert("Campo requerido: Tipo de empresa"); return false; } var resp = confirm("¿Están correctos los datos?"); if(resp){ sndReq3(document.f1AE02.tipo.value); document.f1AE02.tipo.value = ""; return false; } else{ habilitaSubmit(); return false; } } //Fin de la función adminEmpf1tiposEmpresa() //Función que muestra las categorías por tipo de empresa function adminEmpf2tiposEmpresa(tipoEmpresa){ location.href = "http://www.doctorweb.org/panel-administrador/categorias/" + tipoEmpresa; } //Fin de la función adminEmpf2tiposEmpresa() //Función que valida los datos para una categoría function adminEmpf3tiposEmpresa(){ deshabilitaSubmit(); if(document.f1PAC.categoriaPAC.value == ""){ alert("Campo requerido: Categoría"); return false; } sndReqPAC10(document.f1PAC.iPAC.value, document.f1PAC.categoriaPAC.value); return false; } //Fin de la función adminEmpf3tiposEmpresa() //Función que ejecuta una acción sobre el usuario seleccionado function adminEmpf1usuarios(emailMD5, email, accion, mostrar, pagina){ if(accion == "e"){ var resp = confirm("¿Desea eliminar al usuario con E-mail " + email + "?"); if(resp) sndReqPAAU5(emailMD5, accion, mostrar, pagina); } else sndReqPAAU5(emailMD5, accion, mostrar, pagina); } //Fin de la función adminEmpf1usuarios(...) //Función que solicita la búsqueda de las empresas dependiendo el tipo de empresa function adminEmpf1empresas(){ if(document.getElementById("tipoPAAE").value != "") sndReqPAAE7(document.getElementById("tipoPAAE").value); } //Fin de la función adminEmpf1empresas() //Función que ejecuta una acción sobre un país function admEmpf1Paises(idPais, nombre, accion){ if(accion == "e"){ var resp = confirm("¿Desea eliminar el país " + nombre + "?"); if(resp) sndReqPAAP8(idPais, accion); return; } sndReqPAAP8(idPais, accion); } //Fin de la función admEmpf1Paises(idPais, nombre, accion) //Función que ejecuta una acción sobre una ciudad function admEmpf1Ciudades(idCiudad, nombre, accion){ if(accion == "e"){ var resp = confirm("¿Desea eliminar la ciudad " + nombre + "?"); if(resp) sndReq9(idCiudad, accion); return; } sndReq9(idCiudad, accion); } //Fin de la función admEmpf1Ciudades(idCiudad, nombre, accion) /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ //Variables globales var http = createRequestObject(); var timeoutholder = null; //Función que ejecuta la activación/desactivación de una pregunta function sndReqPACC(idEncuesta, movimiento){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/activaEncuesta.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ sndReqPACC6(document.getElementById("tipoPACC").value); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idEncuesta="+idEncuesta+"&movimiento="+movimiento); } catch(e){} finally{} } //Fin de la función sndReqPACC(idEncuesta, movimiento) //Function que ejecuta la inserción de una pregunta function sndReqPACC2(idTipoEmpresa, pregunta){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/generaEncuesta.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ sndReqPACC6(idTipoEmpresa); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idTipoEmpresa="+idTipoEmpresa+"&pregunta="+pregunta); } catch(e){} finally{} } //Fin de la función sndReqPACC2(idTipoEmpresa, pregunta) //Función que ejectura la inserción de un tipo de empresa function sndReq3(tipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/insertaTipoEmpresa.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("tiposEmpresas").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("tipoEmpresa="+tipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReq3(tipoEmpresa) //Función que elimina una empresa function sndReqPAAU4(idEmpresaMD5, razonSocial, accion){ if(accion == "e"){ var resp = confirm("¿Desea eliminar la empresa" + razonSocial + "?"); if(! resp) return; } var tipoEmpresa = ""; try{ tipoEmpresa = document.getElementById("tipo").value; } catch(e){} try{ http.open("post", "http://www.doctorweb.org/de2/ajax/autorizaEmpresa.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("muestraEmpresasPAAU").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idEmpresaMD5="+idEmpresaMD5+"&accion="+accion+"&tipoEmpresa="+tipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReqPAAU4(idEmpresaMD5, razonSocial) //Función que ejecuta las acciones sobre los usuarios desde el administrador de la empresa function sndReqPAAU5(emailMD5, accion, mostrar, pagina){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/autorizaUsuario.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("usuarios").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("emailMD5="+emailMD5+"&accion="+accion+"&mostrar="+mostrar+"&pagina="+pagina); } catch(e){} finally{} } //Fin de la función sndReqPAAU5(...) //Función que busca todas las encuestas de un tipo de empresa function sndReqPACC6(idTipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/muestraEncuestasTipoEmpresa.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("muestraEncuestasPACC").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("i="+idTipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReqPACC6(idTipoEmpresa) //Función que ejecuta la búsqueda de empresas function sndReqPAAE7(idTipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/muestraEmpresas/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("muestraEmpresasPAAE").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("i="+idTipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReqPAAE7(idTipoEmpresa) //Función que ejecuta una acción sobre un país function sndReqPAAP8(idPais, accion){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/actualizaPaises/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("muestraPaisesPAAP").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idPais="+idPais+"&accion="+accion); } catch(e){} finally{} } //Fin de la función sndReqPAAP8(idPais, accion) //Función que ejecuta una acción sobre una ciudad function sndReq9(idCiudad, accion){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/actualizaCiudades/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("muestraCiudades").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idCiudad="+idCiudad+"&accion="+accion); } catch(e){} finally{} } //Fin de la función sndReq9(idCiudad, accion) //Función que inserta los datos de una categoría function sndReqPAC10(tipoEmpresa, categoria){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/insertaCategoria/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("categoriasPAC").innerHTML = http.responseText; document.f1PAC.categoriaPAC.value = ""; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("tipoEmpresa="+tipoEmpresa+"&categoria="+categoria); } catch(e){} finally{} } //Fin de la función sndReqPAC10(idTipoEmpresa, categoria) //Función que muestra los usuarios desde el administrador de la empresa paginación function sndReqPAAU11(mostrar, pagina){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/muestraUsuariosPaginacion.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("usuarios").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("mostrar="+mostrar+"&pagina="+pagina); } catch(e){} finally{} } //Fin de la función sndReqPAAU5(emailMD5, accion) //Función necesaria para ejecutar el AJAX correctamente function createRequestObject(){ var xmlhttp; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(f){ xmlhttp = null; } } if(! xmlhttp && typeof XMLHttpRequest != "undefined") xmlhttp = new XMLHttpRequest(); return xmlhttp; } //Fin de la función createRequestObject()//Funciones de Empresas //Función que valida que los datos de la empresa estén llenos correctamente function aef1(){ if(document.f1RE.tipo.value == ""){ alert("Campo requerido: Tipo"); return false; } if(document.f1RE.categoria.value == ""){ alert("Campo requerido: Categoría"); return false; } if(document.f1RE.razonSocial.value == ""){ alert("Campo requerido: Nombre"); return false; } if(document.getElementById("vem02RE").innerHTML != ""){ alert("La empresa " + document.f1RE.razonSocial.value + " ya fue registrada."); return false; } if(document.f1RE.descripcion.value == ""){ alert("Campo requerido: Descripción"); return false; } if(document.f1RE.pais.value == ""){ alert("Campo requerido: País"); return false; } if(document.f1RE.pais.value == "otroPais"){ if(document.f1RE.nuevoPais.value == ""){ alert("Campo requerido: Nuevo país"); return false; } } else{ if(document.f1RE.estado.value == ""){ alert("Campo requerido: Estado"); return false; } if(document.f1RE.ciudad.value == ""){ alert("Campo requerido: Ciudad / Delegación"); return false; } if(document.f1RE.ciudad.value == "otraCiudad"){ if(document.f1RE.nuevaCiudad.value == ""){ alert("Campo requerido: Nueva ciudad / delegación"); return false; } } else{ if(document.f1RE.colonia.value == ""){ alert("Campo requerido: Colonia"); return false; } } } if(document.f1RE.calleYNo.value == ""){ alert("Campo requerido: Calle y No."); return false; } if(document.f1RE.cp.value == ""){ alert("Campo requerido: C.P."); return false; } if(document.f1RE.telefono1.value == ""){ alert("Campo requerido: Teléfono 1"); return false; } var resp = confirm("¿Están correctos los datos?"); if(! resp){ return false; } } //Fin de la función aef1() //Función que muestra las categorías del tipo de empresa function aef2(){ if(document.f1RE.tipo.value != ""){ document.getElementById("cuerpoDRW").style.cursor="wait"; sndReqRE2(document.f1RE.tipo.value); } else{ document.getElementById("tituloCategoria").style.display = "none"; document.getElementById("campoCategoria").style.display = "none"; document.getElementById("campoCategoria").innerHTML = ""; } } //Fin de la función aef2() //Función que muestra los estados function aef3(){ if((document.f1RE.pais.value != "") && (document.f1RE.pais.value != "otroPais")){ document.getElementById("cuerpoDRW").style.cursor="wait"; sndReqRE3(document.f1RE.pais.value); } else if((document.f1RE.pais.value != "") && (document.f1RE.pais.value == "otroPais")){ document.getElementById("tituloNuevoPais").style.display = "block"; document.getElementById("campoNuevoPais").style.display = "block"; } else{ document.getElementById("tituloNuevoPais").style.display = "none"; document.getElementById("campoNuevoPais").style.display = "none"; } document.getElementById("tituloEstado").style.display = "none"; document.getElementById("campoEstado").style.display = "none"; document.getElementById("campoEstado").innerHTML = ""; document.getElementById("tituloCiudad").style.display = "none"; document.getElementById("campoCiudad").style.display = "none"; document.getElementById("campoCiudad").innerHTML = ""; document.getElementById("tituloColonia").style.display = "none"; document.getElementById("campoColonia").style.display = "none"; document.getElementById("campoColonia").innerHTML = ""; } //Fin de la función aef3() //Función que muestra las ciudades / delegaciones function aef4(){ if(document.f1RE.estado.value != ""){ document.getElementById("cuerpoDRW").style.cursor="wait"; sndReqRE4(document.f1RE.estado.value); } else{ document.getElementById("tituloCiudad").style.display = "none"; document.getElementById("campoCiudad").style.display = "none"; document.getElementById("campoCiudad").innerHTML = ""; } document.getElementById("tituloColonia").style.display = "none"; document.getElementById("campoColonia").style.display = "none"; document.getElementById("campoColonia").innerHTML = ""; } //Fin de la función aef4() //Función que muestra las colonias function aef5(){ if((document.f1RE.ciudad.value != "") && (document.f1RE.ciudad.value != "otraCiudad")){ document.getElementById("cuerpoDRW").style.cursor="wait"; sndReqRE5(document.f1RE.ciudad.value); } else if((document.f1RE.ciudad.value != "") && (document.f1RE.ciudad.value == "otraCiudad")){ document.getElementById("tituloNuevaCiudad").style.display = "block"; document.getElementById("campoNuevaCiudad").style.display = "block"; document.getElementById("tituloColonia").style.display = "none"; document.getElementById("campoColonia").style.display = "none"; document.getElementById("campoColonia").innerHTML = ""; } else{ document.getElementById("tituloNuevaCiudad").style.display = "none"; document.getElementById("campoNuevaCiudad").style.display = "none"; document.getElementById("tituloColonia").style.display = "none"; document.getElementById("campoColonia").style.display = "none"; document.getElementById("campoColonia").innerHTML = ""; } } //Fin de la función aef5() /***************************************************************************************************************/ /***************************************************************************************************************/ /***************************************************************************************************************/ /***************************************************************************************************************/ /***************************************************************************************************************/ //Variables globales var http = createRequestObject(); var http2 = createRequestObject(); var timeoutholder = null; //Función que consulta la razón social de la empresa function sndReqRE(valor){ if(valor != ""){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/validaRazonSocial/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ document.getElementById("vem01RE").style.display = "block"; document.getElementById("vem02RE").style.display = "block"; document.getElementById("vem02RE").innerHTML = http.responseText; } else{ document.getElementById("vem01RE").style.display = "none"; document.getElementById("vem02RE").style.display = "none"; document.getElementById("vem02RE").innerHTML = ""; } } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("r="+valor); } catch(e){} finally{} } //Fin de if(valor != "") else{ document.getElementById("vem01RE").style.display = "none"; document.getElementById("vem02RE").style.display = "none"; document.getElementById("vem02RE").innerHTML = ""; } } //Fin de la función sndReqRE() //Función que muestra las categorías del tipo de empresa function sndReqRE2(idTipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/categoriasTipoEmpresa/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("campoCategoria").innerHTML = http.responseText; document.getElementById("tituloCategoria").style.display = "block"; document.getElementById("campoCategoria").style.display = "block"; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idTipoEmpresa="+idTipoEmpresa); } catch(e){} finally{} document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqRE2(idTipoEmpresa) //Función que ejecuta la búsqueda de estados de un país function sndReqRE3(idPais){ try{ http2.open("post", "http://www.doctorweb.org/ajaxDesarrollo/estadosPais/", true); http2.onreadystatechange = function(){ if(http2.readyState == 4){ document.getElementById("tituloEstado").style.display = "block"; document.getElementById("campoEstado").style.display = "block"; document.getElementById("campoEstado").innerHTML = http2.responseText; document.getElementById("tituloNuevoPais").style.display = "none"; document.getElementById("campoNuevoPais").style.display = "none"; } } http2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http2.send("idPais="+idPais); } catch(e){} finally{} document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqRE3(idPais) //Función que ejecuta la búsqueda de las ciudades / delegaciones de un estado function sndReqRE4(idEstado){ try{ http2.open("post", "http://www.doctorweb.org/ajaxDesarrollo/ciuadadesEstados/", true); http2.onreadystatechange = function(){ if(http2.readyState == 4){ document.getElementById("tituloCiudad").style.display = "block"; document.getElementById("campoCiudad").style.display = "block"; document.getElementById("campoCiudad").innerHTML = http2.responseText; } } http2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http2.send("idEstado="+idEstado); } catch(e){} finally{} document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqRE4(idEstado) //Función que ejecuta la búsqueda de las colonias de una ciudad / delegación function sndReqRE5(idCiudad){ try{ http2.open("post", "http://www.doctorweb.org/ajaxDesarrollo/coloniasCiudad/", true); http2.onreadystatechange = function(){ if(http2.readyState == 4){ document.getElementById("tituloNuevaCiudad").style.display = "none"; document.getElementById("campoNuevaCiudad").style.display = "none"; document.getElementById("tituloColonia").style.display = "block"; document.getElementById("campoColonia").style.display = "block"; document.getElementById("campoColonia").innerHTML = http2.responseText; } } http2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http2.send("idCiudad="+idCiudad); } catch(e){} finally{} document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqRE5(idCiudad) //Función necesaria para ejecutar el AJAX correctamente function createRequestObject(){ var xmlhttp; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(f){ xmlhttp = null; } } if(! xmlhttp && typeof XMLHttpRequest != "undefined") xmlhttp = new XMLHttpRequest(); return xmlhttp; } //Fin de la función createRequestObject()//Funciones del foro var http = createRequestObject(); var http2 = createRequestObject(); var timeoutholder = null; //Función que muestra los estados de un país function f1foro01(){ if(document.getElementById("paisZS").value != "") sndReqZS11(document.getElementById("paisZS").value); } //Fin de la función f1foro01() //Función que valida los datos de un comentario function forof2principal(){ if(document.f1ZS.anonimoZS[0].checked) document.f1ZS.a1ZS.value = "N"; else if(document.f1ZS.anonimoZS[1].checked) document.f1ZS.a1ZS.value = "NC"; else document.f1ZS.a1ZS.value = "A"; arreglo = document.f1ZS.ecZS.value.split("(**)"); contador = 0; for(var x = 0; x < arreglo.length; x++) if(arreglo[x] != "") contador++; if(contador != 3){ alert("Califique los 3 criterios"); return false; } var comentario = document.f1ZS.comentarioZS.value; var anonimo = document.f1ZS.a1ZS.value; var idEmpresa = document.f1ZS.iZS.value; var email = document.f1ZS.urZS.value; var tipoEmpresa = document.getElementById("teZS").value; var encuesta = document.getElementById("ecZS").value; document.f1ZS.comentarioZS.value = ""; document.f1ZS.anonimoZS[0].checked; sndReqZS4(comentario, anonimo, idEmpresa, email, tipoEmpresa, encuesta); return false; } //Fin de la función forof2principal() //Función que muestra los datos para modificar un comentario function forof3principal(idComentario){ var nombre = "tabla_" + idComentario; var nombre2 = "muestraLigas_" + idComentario; document.getElementById(nombre).style.display = "block"; document.getElementById(nombre2).style.display = "none"; } //Fin de la función forof3principal(idComentario) //Función que valida los datos de un comentario modificado function forof4principal(idComentario){ var comentario = document.getElementById("comentarioZS_" + idComentario).value; var anonimo = document.getElementById("anonimoZS_" + idComentario).value; var idEmpresa = document.getElementById("eZS").value; var email = document.getElementById("urZS").value; var tipoEmpresa = document.getElementById("teZS").value; sndReqZS3(idComentario, comentario, anonimo, idEmpresa, email, tipoEmpresa); return false; } //Fin de la función forof4principal() //Función que oculta los datos de un comentario function forof5principal(idComentario){ var nombre = "tabla_" + idComentario; var nombre2 = "muestraLigas_" + idComentario; document.getElementById(nombre).style.display = "none"; document.getElementById(nombre2).style.display = "block"; } //Fin de la función forof5principal(idComentario) //Función que valida los radios seleccionados function forof6principal(idComentario, elemento){ nombre1 = "anonimo_" + idComentario + "_1"; nombre2 = "anonimo_" + idComentario + "_2"; nombre3 = "anonimo_" + idComentario + "_3"; if(elemento == "1"){ document.getElementById(nombre1).checked = true; document.getElementById(nombre2).checked = false; document.getElementById(nombre3).checked = false; } else if(elemento == "2"){ document.getElementById(nombre1).checked = false; document.getElementById(nombre2).checked = true; document.getElementById(nombre3).checked = false; } else{ document.getElementById(nombre1).checked = false; document.getElementById(nombre2).checked = false; document.getElementById(nombre3).checked = true; } } //Fin de la función forof6principal(idComentario, elemento) //Función que elimina un comentario function forof7principal(idComentario){ var comentario = document.getElementById("comentarioZS_" + idComentario).value; var idEmpresa = document.getElementById("eZS").value; var email = document.getElementById("urZS").value; var tipoEmpresa = document.getElementById("teZS").value; var resp = confirm("¿Desar eliminar el comentario?\n" + comentario); if(resp) sndReqZS5(idComentario, idEmpresa, email, tipoEmpresa); } //Fin de la función forof7principal(idComentario) //Función que coloca el valor de la encuesta en el formulario function forof8principal(valor){ document.getElementById("vv").value = valor; } //Fin de la función forof8principal() //Función que define el valor de una calificación function defineCalificacion(valor){ if(document.f1ZS.ecZS.value == "") document.f1ZS.ecZS.value = valor; else{ arreglo = document.f1ZS.ecZS.value.split("(**)"); var stat = false; for(var x = 0; x < arreglo.length; x++){ arreglo2 = arreglo[x].split("(!!)"); arreglo3 = valor.split("(!!)"); if(arreglo2[1] == arreglo3[1]){ stat = true; arreglo[x] = valor; } } if(stat == false) document.f1ZS.ecZS.value = document.f1ZS.ecZS.value + "(**)" + valor; else{ var cadena = ""; for(var x = 0; x < arreglo.length; x++) if(arreglo[x] != "") cadena = cadena + arreglo[x] + "(**)"; document.f1ZS.ecZS.value = cadena; } } calificacionComentario(); } //Fin de la función defineCalificacion(valor) //Función que define el promedio de cada calificación por comentario function calificacionComentario(){ var calificacion = parseFloat(0); //Recorremos todas las calificaciones seleccionadas para definir el promedio arreglo = document.f1ZS.ecZS.value.split("(**)"); var contador = 0; for(var x = 0; x < arreglo.length; x++){ if(arreglo[x] != ""){ arreglo2 = arreglo[x].split("(!!)"); calificacion += parseFloat(arreglo2[2]); contador++; } } //Fin de for(var x = 0; x < arreglo.length; x++) //Definimos la calificación global del usuario calificacion = (calificacion / contador); calificacion = Math.round(calificacion * 10) / 10; calificacion2 = calificacion + ""; //Verificamos si tiene decimales calif = calificacion2.split("."); tamanoCalif = calif.length; var images = ""; for(var x = 1; x <= 5; x++){ if(x <= calificacion) images = images + ""; else{ if(tamanoCalif == 2){ if((x - 1) > calificacion) images = images + ""; else images = images + ""; } else images = images + ""; } } //Fin de for(var x = 1; x <= 5; x++) document.getElementById("imagenGlobalUsuario").innerHTML = images; document.getElementById("mensajeCalificacionGlobalUsuario").innerHTML = "(" + calificacion + " de 5)"; } //Fin de la función calificacionComentario() //Función que deja las calificaciones del usuario en blanco function calificacionesEnBlanco(){ //Dejamos las calificaciones del usuario en blanco nuevoArreglo = document.f1ZS.ecZS.value.split("(**)"); for(var x = 0; x < arreglo.length; x++){ if(nuevoArreglo[x] != undefined){ nuevoArreglo2 = nuevoArreglo[x].split("(!!)"); elemento = "enc_" + nuevoArreglo2[0] + "_" + nuevoArreglo2[1]; condicion = "onMouseOver='colorea(this.id);' onClick='defineCalificacion(this.id);' onMouseOut='borra(this.id);'"; images = ""; for(var y = 1; y <= 5; y++){ images = images + ""; } //Fin de for(var y = 1; y <= 5; y++) document.getElementById(elemento).innerHTML = images; } //Fin de if(nuevoArreglo[x] != undefined) } //Fin de for(var x = 0; x < arreglo.length; x++) //Borramos la imagen global del usuario images = ""; for(var x = 1; x <= 5; x++){ images = images + ""; } //Fin de for(var x = 1; x <= 5; x++) document.getElementById("imagenGlobalUsuario").innerHTML = images; document.f1ZS.ecZS.value = ""; } //Fin de la función calificacionesEnBlanco() //Función que colorea el starRating function colorea(valor){ //Descomponemos el valor valor2 = valor.split("(!!)"); var variable = ""; for(var x = 1; x <= 5; x++){ variable = valor2[0] + "(!!)" + valor2[1] + "(!!)" + x + "(!!)" + valor2[3]; if(x <= valor2[2]) document.getElementById(variable).src = "http://www.doctorweb.org/de2/images/star1_yellow.gif"; else document.getElementById(variable).src = "http://www.doctorweb.org/de2/images/star0_yellow.gif"; } //Fin de for(var x = 1; x <= 5; x++) if(valor2[2] == 1) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = "Malo"; else if(valor2[2] == 2) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = "Regular"; else if(valor2[2] == 3) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = "Bueno"; else if(valor2[2] == 4) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = "Muy bueno"; else if(valor2[2] == 5) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = "Excelente"; else document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = ""; } //Fin de la función colorea(valor) //Función que borra el starRating function borra(valor){ //Descomponemos el valor valor2 = valor.split("(!!)"); var variable = ""; var idEncuesta = valor2[1]; var encontrada = false; if(document.f1ZS.ecZS.value != ""){ arreglo = document.f1ZS.ecZS.value.split("(**)"); for(var x = 0; x < arreglo.length; x++){ arreglo2 = arreglo[x].split("(!!)"); //Verificamos si ya se seleccionó una calificación sobre la encuesta, si ya se seleccionó onmouseout regresa a la calificación seleccionada if(idEncuesta == arreglo2[1]){ encontrada = true; for(var y = 1; y <= 5; y++){ variable = valor2[0] + "(!!)" + valor2[1] + "(!!)" + y + "(!!)" + valor2[3]; if(y <= arreglo2[2]) document.getElementById(variable).src = "http://www.doctorweb.org/de2/images/star1_yellow.gif"; else document.getElementById(variable).src = "http://www.doctorweb.org/de2/images/star0_yellow.gif"; } //Fin de for(var y = 1; y < 5; y++) } //Fin de if(idEncuesta == arreglo2[1]) } //Fin de for(var x = 0; x < arreglo.length; x++) } //Fin de if(document.f1ZS.ecZS.value != "") //Si no se ha calificado, pone en blanco las estrellas if(encontrada == false){ for(var x = 1; x <= 5; x++){ variable = valor2[0] + "(!!)" + valor2[1] + "(!!)" + x + "(!!)" + valor2[3]; document.getElementById(variable).src = "http://www.doctorweb.org/de2/images/star0_yellow.gif"; } //Fin de for(var x = 1; x <= 5; x++) } //Fin de if(encontrada == true) document.getElementById("valor_enc_" + valor2[0] + "_" + valor2[1]).innerHTML = ""; } //Fin de la función borra(valor) //Función que cambia una pestaña para ver comentarios o calificar a una empresa function cambiaPestana(pestana){ if(pestana == 1){ document.getElementById("pestanaForumTopLeft").className = "pestanaForumTopLeft"; document.getElementById("contenedorPestana1").style.background = ""; document.getElementById("contenedorPestana1").style.borderBottom = "0px"; document.getElementById("contenedorPestana1").style.marginLeft = "-6px"; document.getElementById("contenedorPestana1").style.paddingBottom = "4px"; document.getElementById("contenedorPestana1").style.paddingTop = "0px"; document.getElementById("contenedorPestana1").style.width = "305px"; document.getElementById("pestanaForumTopRight").className = ""; document.getElementById("contenedorPestana2").style.background = "#FFFFFF"; document.getElementById("contenedorPestana2").style.borderBottom = "1px solid #6B8232"; document.getElementById("contenedorPestana2").style.borderLeft = "1px solid #6B8232"; document.getElementById("contenedorPestana2").style.marginLeft = "-2px"; document.getElementById("contenedorPestana2").style.paddingBottom = "4px"; document.getElementById("contenedorPestana2").style.width = "315px"; document.getElementById("contenidoPestanaZS1").style.display = "block"; document.getElementById("contenidoPestanaZS2").style.display = "none"; } else{ document.getElementById("pestanaForumTopLeft").className = ""; document.getElementById("contenedorPestana1").style.background = "#FFFFFF"; document.getElementById("contenedorPestana1").style.borderBottom = "1px solid #6B8232"; document.getElementById("contenedorPestana1").style.marginRight = "-9px"; document.getElementById("contenedorPestana1").style.paddingTop = "7px"; document.getElementById("contenedorPestana1").style.width = "304px"; document.getElementById("pestanaForumTopRight").className = "pestanaForumTopRight"; document.getElementById("contenedorPestana2").style.borderBottom = "0px"; document.getElementById("contenedorPestana2").style.marginLeft = "8px"; document.getElementById("contenedorPestana2").style.paddingLeft = "0px"; document.getElementById("contenedorPestana2").style.width = "305px"; document.getElementById("contenidoPestanaZS1").style.display = "none"; document.getElementById("contenidoPestanaZS2").style.display = "block"; /* document.getElementById("pestanaForoZS1").className = "pestanaForo2"; document.getElementById("pestanaForoZS2").className = "pestanaForo1"; document.getElementById("ligaPestanaForoZS1").className = "ligaPestanaForo2"; document.getElementById("ligaPestanaForoZS2").className = "ligaPestanaForo1"; document.getElementById("contenidoPestanaZS1").style.display = "none"; document.getElementById("contenidoPestanaZS2").style.display = "block";*/ } } //Fin de la función cambiaPestana(pestana) /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ /*******************************************************************************************************************/ //Función que ejecuta la inserción/actualización de la calificación por empresa function sndReqZS(valor){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/actualizaResultadoEncuesta/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.f1ZS.ecZS.value = ""; resp = http.responseText.split("(!!)"); idEmpresa = resp[0]; idEncuesta = resp[1]; calificacion = resp[2]; eventos = resp[3]; calificacionEmpresa = resp[4]; mensajeCalificacionEmpresa = resp[5]; calificacionGlobalUsuario = resp[6]; calificacionCriterio = resp[7]; cuantosCalifico = resp[8]; cambiarImagenEmpresa(calificacionEmpresa, mensajeCalificacionEmpresa); cambiarImagenCriterio(idEncuesta, calificacionCriterio, eventos); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("encuesta="+valor); } catch(e){} finally{} } //Fin de la función sndReqZS(search, startpoint) //Función que manda actualizar un comentario function sndReqZS2(idComentario, comentario, anonimo, accion){ try{ http.open("get", "http://www.doctorweb.org/de2/popups/actualizaComentario.php?i="+idComentario+"&c="+comentario+"&a="+anonimo+"&cc="+accion); http.onreadystatechange = handleResponse2; http.send(null); } catch(e){} finally{} } //Fin de la función sndReqZS2(...) //Función que actualiza los datos de un comentario function sndReqZS3(idComentario, comentario, anonimo, idEmpresa, email, tipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/actualizaComentario/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("datosComentariosZS").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idComentario="+idComentario+"&comentario="+comentario+"&anonimo="+anonimo+"&idEmpresa="+idEmpresa+"&email="+email+"&tipoEmpresa="+tipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReqZS3(...) //Función que inserta los datos de un comentario hacia una empresa function sndReqZS4(comentario, anonimo, idEmpresa, email, tipoEmpresa, encuesta){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/insertaComentario/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ info = http.responseText; arreglo = info.split("(*-*-*!)"); //Colocamos los comentarios document.getElementById("datosComentariosZS").innerHTML = arreglo[0]; //Obtenemos las calificaciones por encuesta arreglo2 = arreglo[1].split("(**)"); for(var x = 0; x < arreglo.length; x++){ //Descomponemos el arreglo2 arreglo3 = arreglo2[x].split("(!!)"); //Definimos el objeto y la calificación objetoEncuesta = "calZS_" + arreglo3[0]; calificacion = "(" + arreglo3[1] + " de 5) " + arreglo3[2] + " calificaciones"; document.getElementById(objetoEncuesta).innerHTML = calificacion; //Definimos la imagen de la calificación objetoImagen = "usrZS_" + arreglo3[0]; //Verificamos si tiene decimales calif = arreglo3[1].split("."); tamanoCalif = calif.length; var images = ""; for(var y = 1; y <= 5; y++){ if(y <= arreglo3[1]) images = images + ""; else{ if(tamanoCalif == 2){ if((y - 1) > arreglo3[1]) images = images + ""; else images = images + ""; } else images = images + ""; } } //Fin de for(var y = 1; y <= 5; y++) document.getElementById(objetoImagen).innerHTML = images; } //Fin de for(var x = 0; x < arreglo.lengt; x++) //Colocamos las calificaciones de la empresa arreglo4 = arreglo[2].split("(!!)"); calificacionGlobal = arreglo4[0]; mensajeGlobal = arreglo4[1]; document.getElementById("calificacionEmpresaMensajeZS").innerHTML = mensajeGlobal; //Verificamos si tiene decimales calif = calificacionGlobal.split("."); tamanoCalif = calif.length; //Definimos la imagen de la calificación global de la empresa var images = ""; for(var x = 1; x <= 5; x++){ if(x <= calificacionGlobal) images = images + ""; else{ if(tamanoCalif == 2){ if((x - 1) > calificacionGlobal) images = images + ""; else images = images + ""; } else images = images + ""; } } //Fin de for(var x = 1; x <= 5; y++) document.getElementById("calificacionEmpresaEstrellaZS").innerHTML = images; document.getElementById("calificacionGlobalMedalla").innerHTML = calificacionGlobal; //Dejamos las calificaciones del usuario en blanco calificacionesEnBlanco(); //Mostramos los comentarios cambiaPestana(2); } //Fin de if(http.readyState == 4) } //Fin de http.onreadystatechange = function() http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("comentario="+comentario+"&anonimo="+anonimo+"&idEmpresa="+idEmpresa+"&email="+email+"&tipoEmpresa="+tipoEmpresa+"&encuesta="+encuesta); } catch(e){} finally{} } //Fin de la función sndReqZS4(...) //Función que elimina los datos de un comentario hacia una empresa function sndReqZS5(idComentario, idEmpresa, email, tipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/eliminaComentario/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ info = http.responseText; arreglo = info.split("(*-*-*!)"); document.getElementById("datosComentariosZS").innerHTML = arreglo[0]; //Obtenemos las calificaciones por encuesta arreglo2 = arreglo[1].split("(**)"); for(var x = 0; x < arreglo.length; x++){ //Descomponemos el arreglo2 arreglo3 = arreglo2[x].split("(!!)"); //Definimos el objeto y la calificación objetoEncuesta = "calZS_" + arreglo3[0]; calificacion = "(" + arreglo3[1] + " de 5) " + arreglo3[2] + " calificaciones"; document.getElementById(objetoEncuesta).innerHTML = calificacion; //Definimos la imagen de la calificación objetoImagen = "usrZS_" + arreglo3[0]; //Verificamos si tiene decimales calif = arreglo3[1].split("."); tamanoCalif = calif.length; var images = ""; for(var y = 1; y <= 5; y++){ if(y <= arreglo3[1]) images = images + ""; else{ if(tamanoCalif == 2){ if((y - 1) > arreglo3[1]) images = images + ""; else images = images + ""; } else images = images + ""; } } //Fin de for(var y = 1; y <= 5; y++) document.getElementById(objetoImagen).innerHTML = images; } //Fin de for(var x = 0; x < arreglo.lengt; x++) //Colocamos las calificaciones de la empresa arreglo4 = arreglo[2].split("(!!)"); calificacionGlobal = arreglo4[0]; mensajeGlobal = arreglo4[1]; document.getElementById("calificacionEmpresaMensajeZS").innerHTML = mensajeGlobal; //Verificamos si tiene decimales calif = calificacionGlobal.split("."); tamanoCalif = calif.length; var images = ""; for(var x = 1; x <= 5; x++){ if(x <= calificacionGlobal) images = images + ""; else{ if(tamanoCalif == 2){ if((x - 1) > calificacionGlobal) images = images + ""; else images = images + ""; } else images = images + ""; } } //Fin de for(var x = 1; x <= 5; x++) document.getElementById("calificacionGlobalMedalla").innerHTML = calificacionGlobal; document.getElementById("calificacionEmpresaEstrellaZS").innerHTML = images; } //Fin de if(http.readyState == 4) } //Fin de http.onreadystatechange = function() http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idComentario="+idComentario+"&idEmpresa="+idEmpresa+"&email="+email+"&tipoEmpresa="+tipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReqZS5(idComentario, idEmpresa, email) //Función que muesta los estados del país seleccionado function sndReqZS6(pais){ try{ http.open("post", "http://www.doctorweb.org/de2/ajax/estadosPais.php", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ document.getElementById("tablaEstadosZS").style.display = "block"; document.getElementById("tablaEstadosZS").innerHTML = http.responseText; } else document.getElementById("tablaEstadosZS").style.display = "none"; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais); } catch(e){} finally{} } //Fin de la función sndReqZS6(pais) //Función que busca los municipios de un estado function sndReq7(idEstado){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/municipiosEstado/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ document.getElementById("tablaMunicipios").style.display = "block"; document.getElementById("tablaMunicipios").innerHTML = http.responseText; } else document.getElementById("tablaMunicipios").style.display = "none"; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idEstado="+idEstado); } catch(e){} finally{} } //Fin de la función sndReq7(idEstado) //Función que consulta las empresas de un tipo de empresa function sndReq8(idTipoEmpresa){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/empresaTipoEmpresa/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ document.getElementById("muestraEmpresas").innerHTML = http.responseText; } } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idTipoEmpresa="+idTipoEmpresa); } catch(e){} finally{} } //Fin de la función sndReq8(idTipoEmpresa) //Función que solicita la tabla de empresas ordenadas por cierto criterio function sndReqFP9(pais, estado, ciudad, tipoEmpresa, categoria, criterio, pagina){ document.getElementById("cuerpoDRW").style.cursor="wait"; try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/tablaEmpresasCalificacion/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.responseText != ""){ info = http.responseText; arreglo = info.split("(-_-_)"); document.getElementById("muestraEmpresasZS").innerHTML = arreglo[0]; document.getElementById("paginaZS").value = arreglo[1]; } } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais+"&estado="+estado+"&ciudad="+ciudad+"&tipoEmpresa="+tipoEmpresa+"&categoria="+categoria+"&criterio="+criterio+"&pagina="+pagina); } catch(e){} finally{} document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqFP9(...) //Función que consulta los comentarios hacia la empresa function sndReq10(){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/consultaComentarios/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("datosComentarios").innerHTML = http.responseText; } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("idEmpresa="+document.f1ZS.i.value+"&email="+document.f1ZS.ur.value+"&tipoEmpresa="+document.getElementById("te").value) } catch(e){} finally{} } //Fin de la función sndReq10() //Función que consulta los estados de un páis function sndReqZS11(pais){ document.getElementById("cuerpoDRW").style.cursor="wait"; var pais = document.getElementById("paisZS").value; if(pais != ""){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/estadosPais2/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("estadosZS").innerHTML = http.responseText; sndReqZS15(0, "", "", "", "", ""); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais); } catch(e){} finally{} } else cambiaFormulario("estado"); } //Fin de la función sndReqZS11(pais) //Función que consulta las ciudades de un estado function sndReqZS12(valor){ document.getElementById("cuerpoDRW").style.cursor="wait"; var pais = document.getElementById("paisZS").value; var estado = document.getElementById("estadoZS").value; if(estado != ""){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/ciuadadesEstados2/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("ciudadesZS").innerHTML = http.responseText; sndReqZS15(0, "", "", "", "", ""); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais+"&estado="+estado); } catch(e){} finally{} } else cambiaFormulario("ciudad"); } //Fin de la función sndReqZS12(valor) //Función que consulta los tipos de empresa function sndReqZS13(valor){ var pais = document.getElementById("paisZS").value; var estado = document.getElementById("estadoZS").value; var ciudad = document.getElementById("ciudadZS").value; if(ciudad != ""){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/tiposEmpresa/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("tiposEmpresasZS").innerHTML = http.responseText; sndReqZS15(0, "", "", "", "", ""); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais+"&estado="+estado+"&ciudad="+ciudad); } catch(e){} finally{} } else cambiaFormulario("tipoEmpresa"); } //Fin de la función sndReq13(valor) //Función que consulta las categorías de un tipo de empresa function sndReqZS14(valor){ document.getElementById("cuerpoDRW").style.cursor="wait"; var pais = document.getElementById("paisZS").value; var estado = document.getElementById("estadoZS").value; var ciudad = document.getElementById("ciudadZS").value; var tipoEmpresa = document.getElementById("tiposZS").value; var categoria = document.getElementById("categoriaZS").value; if(tipoEmpresa != ""){ try{ http.open("post", "http://www.doctorweb.org/ajaxDesarrollo/categoriasTipoEmpresa2/", true); http.onreadystatechange = function(){ if(http.readyState == 4){ document.getElementById("categoriasZS").innerHTML = http.responseText; sndReqZS15(0, "", "", "", "", ""); } } http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("pais="+pais+"&estado="+estado+"&ciudad="+ciudad+"&tipoEmpresa="+tipoEmpresa+"&categoria="+categoria); } catch(e){} finally{} } else cambiaFormulario("categoria"); } //Fin de la función sndReqZS14(valor) //Función que consulta las empresas de la categoría function sndReqZS15(pagina, pais, estado, ciudad, tipoEmpresa, categoria){ document.getElementById("cuerpoDRW").style.cursor="wait"; pais = document.getElementById("paisZS").value; estado = document.getElementById("estadoZS").value; ciudad = document.getElementById("ciudadZS").value; tipoEmpresa = document.getElementById("tiposZS").value; categoria = document.getElementById("categoriaZS").value; if(tipoEmpresa != "") document.getElementById("myForumTitle").innerHTML = tipoEmpresa; else document.getElementById("myForumTitle").innerHTML = "Establecimiento"; if((pais == "") && (estado == "") && (ciudad == "") && (tipoEmpresa == "") && (categoria == "")){ document.getElementById("muestraEmpresasZS").innerHTML = ""; document.getElementById("paginaZS").value = ""; } else{ try{ http2.open("post", "http://www.doctorweb.org/ajaxDesarrollo/empresasCategorias/", true); http2.onreadystatechange = function(){ if(http2.readyState == 4){ info = http2.responseText; arreglo = info.split("(-_-_)"); document.getElementById("muestraEmpresasZS").innerHTML = arreglo[0]; document.getElementById("paginaZS").value = arreglo[1]; } } http2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http2.send("pais="+pais+"&estado="+estado+"&ciudad="+ciudad+"&tipoEmpresa="+tipoEmpresa+"&categoria="+categoria+"&pagina="+pagina); } catch(e){} finally{} } document.getElementById("cuerpoDRW").style.cursor="default"; } //Fin de la función sndReqZS15(...) //Función que cambia el formulario dependiendo de la opción seleccionada function cambiaFormulario(elemento){ var estado = ""; var ciudad = ""; var tipoEmpresa = ""; var categoria = ""; if(elemento == "estado"){ document.getElementById("estadosZS").innerHTML = estado; document.getElementById("ciudadesZS").innerHTML = ciudad; // document.getElementById("categoriasZS").innerHTML = categoria; sndReqZS15(0); } else if(elemento == "ciudad"){ document.getElementById("ciudadesZS").innerHTML = ciudad; // document.getElementById("categoriasZS").innerHTML = categoria; sndReqZS15(0); } else if(elemento == "tipoEmpresa"){ document.getElementById("categoriasZS").innerHTML = categoria; sndReqZS15(0); } else if(elemento == "categoria"){ document.getElementById("categoriasZS").innerHTML = categoria; sndReqZS15(0); } } //Fin de la función cambiaFormulario() //Función que recibe el status de la actualización del comentario function handleResponse2(){ try{ if((http.readyState == 4) && (http.status == 200)){ var response = http.responseText; var update = new Array(); window.location.reload(); } } catch(e){} finally{} } //Fin de la función handleResponse2() //Función que cambia los datos de la calificación de la empresa function cambiarImagenEmpresa(calificacionEmpresa, mensajeCalificacionEmpresa){ var images = ""; for(var x = 0; x < 5; x++){ if(x < Math.floor(calificacionEmpresa)) images = images + ""; else images = images + ""; } document.getElementById("calificacionEmpresaEstrellaZS").innerHTML = images; document.getElementById("calificacionEmpresaMensajeZS").innerHTML = mensajeCalificacionEmpresa; } //Fin de la función cambiarImagenEmpresa(calificacionEmpresa, mensajeCalificacionEmpresa) //Función que cambia la imagen de la calificación de un criterio de calificación function cambiarImagenCriterio(idEncuesta, calificacionCriterio, eventos){ var images = ""; for(var x = 0; x < 5; x++){ if(x < Math.floor(calificacionCriterio)) images = images + ""; else images = images + ""; } document.getElementById("usrZS_"+idEncuesta).innerHTML = images; document.getElementById("calZS_"+idEncuesta).innerHTML = "(" + calificacionCriterio + " de 5) " + eventos + " calificaciones"; } //Fin de la función cambiarImagenCriterio(idEncuesta, calificacionCriterio, eventos) //Función necesaria para ejecutar el AJAX correctamente function createRequestObject(){ var xmlhttp; try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(f){ xmlhttp = null; } } if(! xmlhttp && typeof XMLHttpRequest != "undefined") xmlhttp = new XMLHttpRequest(); return xmlhttp; } //Fin de la función createRequestObject() function _(_id){ return document.getElementById(_id); } function confirm_send(){ _nombre=_('nombre').value; _email=_('email').value; _telefono=_('telefono').value; _apellido=_('apellido').value; _mensajes=_('mensajes').value; var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); if(_nombre==""){ alert("Para poder suscribirte necesitas escribir tu nombre"); _('nombre').focus(); return false; }else if(_apellido==""){ alert("falta introducir tu apellido"); _('apellido').focus(); return false; }else if (pattern.test(_email)==false){ alert("Tu email proporcionado es incorrecto"); _('email').focus(); return false; }else if(_telefono==""){ alert("Para poder suscribirte necesitas escribir tu telefono"); _('telefono').focus(); return false; }else if(_mensajes==""){ alert("falta introducir tu mensaje"); _('mensajes').focus(); return false; }else{ alert("Sus datos se han enviado con �xito, gracias."); return true; } } function sendFriend(){ __url=location.href.toString(); var docTitle = document.title.toString(); window.open('http://www.doctorweb.org/enviar/'+b64.encode(__url)+":"+b64.encode(docTitle),'win2','width=410,height=380,menubar=no,resizable=no,scrollbars=no,titlebar=no,directories=no,location=no'); } function _(_e){ return document.getElementById(_e); } function changeTabsEnf(e){ var _divs=_('contentEnf'); var nodes=_divs.childNodes.length; for(each=0;each