function validateCookieEnabled(){ // remember, these are the possible parameters for Set_Cookie: // name, value, expires, path, domain, secure Set_Cookie( 'test', 'none', '', '/', '', '' ); // if Get_Cookie succeeds, cookies are enabled, since //the cookie was successfully created. if ( Get_Cookie( 'test' ) ) { /* this is an example of a set cookie variable, if you want to use this on the page or on another script instead of writing to the page you would just check that value for true or false and then do what you need to do. */ cookie_set = true; // and these are the parameters for Delete_Cookie: // name, path, domain // make sure you use the same parameters in Set and Delete Cookie. Delete_Cookie('test', '/', ''); return true; } // if the Get_Cookie test fails, cookies //are not enabled for this session. else { cookie_set = false; return false; } } function getOrderCode(){ var code = "W"; var now = new Date(); var year = now.getFullYear(); var monthnumber = now.getMonth(); var monthday = now.getDate(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); if(monthnumber.toString().length==1){ // incrementamos el numero del mes monthnumber = monthnumber + 1 ; // agregamos cero al principio del numero de mes monthnumber = '0'+monthnumber; } if(monthday.toString().length==1){ // agregamos cero al principio del numero de mes monthday = '0'+monthday; } code = code + year + monthnumber + monthday + hour + second + '-'; return code; } function setUrlPedido() { var cookieValue = Get_Cookie('V_Cookie'); if (cookieValue) { var idUser_cookie = Get_Cookie_Value("sso_idUser",cookieValue); if(idUser_cookie){ // Esta Autenticado javascript:window.location.replace("pedido"); return true; } return false; } else { alert("Para realizar un pedido debe estar Autenticado"); return false; } } function existUser(message){ var cookieValue = Get_Cookie('V_Cookie'); if (cookieValue) { var idUser_cookie = Get_Cookie_Value("sso_idUser",cookieValue); if(idUser_cookie){ // Esta Autenticado return true; }else{ // No esta Autenticado alert(message); return false; } }else{ alert(message); return false; } } function checkPasswdFields(field1,field2,message,numchars){ if(field1 != field2){ alert(message); return false; }else{ if(field1.length < numchars){ alert("Debe proporcionar un password de al menos "+numchars+" caracteres"); return false; } } return true; } function checkEmailFields(field1,field2,message){ if(field1 != field2){ alert(message); return false; } return true; } function checkFilled(field,message) { if (message==null) message='Por favor, rellene el campo'; if (field.type=='select-one') { if (field.selectedIndex==-1 || field.options[field.selectedIndex].value=='NULL' ) { alert(message); field.focus(); return false; } } else { if (field.value==null || field.value=='NULL' || field.value=='null' || field.value.length==0) { alert(message); field.focus(); return false; } } return true; } function checkEmail(field,message) { var result = true; var atposition = field.value.indexOf("@"); if ( atposition <= 0 ) { alert(message); field.focus(); result = false; } var str = field.value.substring(atposition+1, field.value.length - 1); if (result && str.indexOf(".") <= 0 ) { alert(message); field.focus(); result = false; } return result; } // function for COMENTARIO field in espec_hospital, it replace the special character "\/" with a new line character in order to show COMENTARIO field properly function replaceCarryReturn(comentario){ if(comentario != ""){ resultado = comentario.replace (/\r\n/g, "#%%#"); resultado = resultado.replace (/\n/g, "#%%#"); return resultado; }else return ""; } //FUNCION QUE REEMPLAZA EN UN TEXTO EL SALTO DE LINEA POR UNA MARCA, ESTA FUNCION ES PARA AJAX function replaceCarryReturnAjax(comentario){ if(comentario != ""){ resultado = comentario.replace (/\r\n/g, "[@@]"); resultado = resultado.replace (/\n/g, "[@@]"); return resultado; }else return ""; } function noaccent(chaine) { temp = chaine.replace(/[âäàáÂÄÁÀ]/gi,"a"); temp = temp.replace(/[éèëêÉÈËÊ]/gi,"e"); temp = temp.replace(/[îïíìÎÏÍÌ]/gi,"i"); temp = temp.replace(/[ôöóòÔÖÒÓ]/gi,"o"); temp = temp.replace(/[ûüùúÛÜÙÚ]/gi,"u"); temp = temp.replace(/[ñÑ]/gi,"n"); //temp = temp.replace(/[-]/gi,""); //temp = temp.replace(/(^\s*)|(\s*$)/g,''); return temp; } function checkText(form) { //controle si le champs est bien rempli var maReg = new RegExp( "[a-zA-Z0-9\\s]{3,}", "gi" ) ; var resultat = noaccent(form.name.value).search( maReg ) ; if (resultat<0){ alert("Es oblitaria una palabra de al menos 3 letras "); form.value.focus(); return false; } form.name.value=noaccent(form.name.value); return true; } function Set_Cookie( name, value, expires, path, domain, secure ) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ){ expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function Get_Cookie( name ) { var start = document.cookie.indexOf( name + "=" ); //alert("cookieValue es: "+document.cookie); //alert("name es: "+name+" ,start es: "+start); var len = start + name.length + 1; if ( ( !start ) &&( name != document.cookie.substring( 0, name.length ) ) ){ return null; } if ( start == -1 ) return null; var end = document.cookie.indexOf( ";", len ); if ( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); } //Esta funcion permite obtener valores concretos dentro del campo value de la cookie //Se emplea el caracter & como separador function Get_Cookie_Value(valueField, valueCookie){ //verifico el caracter separador a usar: & o %26 var separador = "&"; if(valueCookie.indexOf("%26") != -1) separador = "%26"; var ind = valueCookie.indexOf(valueField+"="); if(ind != -1){ ind = ind + valueField.length + 1; var end = valueCookie.indexOf(separador, ind); if(end==-1) end = valueCookie.length; return unescape(valueCookie.substring(ind,end)); }else return null; } function Delete_Cookie( name, path, domain ) { if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1170 00:00:01 GMT"; } // show and hide div function divControl(divName) { var divObject = eval("document.getElementById('" + divName + "')"); if(divObject!=null){ if(divObject.style.display=='none'){ divObject.style.display=''; }else{ divObject.style.display='none'; } } } //Décode une chaîne function html_entity_decode(texte) { texte = texte.replace(/"/g,'"'); // 34 22 texte = texte.replace(/&/g,'&'); // 38 26 texte = texte.replace(/'/g,"'"); // 39 27 texte = texte.replace(/</g,'<'); // 60 3C texte = texte.replace(/>/g,'>'); // 62 3E texte = texte.replace(/ˆ/g,'^'); // 94 5E texte = texte.replace(/‘/g,'‘'); // 145 91 texte = texte.replace(/’/g,'’'); // 146 92 texte = texte.replace(/“/g,'“'); // 147 93 texte = texte.replace(/”/g,'”'); // 148 94 texte = texte.replace(/•/g,'•'); // 149 95 texte = texte.replace(/–/g,'–'); // 150 96 texte = texte.replace(/—/g,'—'); // 151 97 texte = texte.replace(/˜/g,'˜'); // 152 98 texte = texte.replace(/™/g,'™'); // 153 99 texte = texte.replace(/š/g,'š'); // 154 9A texte = texte.replace(/›/g,'›'); // 155 9B texte = texte.replace(/œ/g,'œ'); // 156 9C texte = texte.replace(/ť/g,''); // 157 9D texte = texte.replace(/ž/g,'ž'); // 158 9E texte = texte.replace(/Ÿ/g,'Ÿ'); // 159 9F texte = texte.replace(/ /g,' '); // 160 A0 texte = texte.replace(/¡/g,'¡'); // 161 A1 texte = texte.replace(/¢/g,'¢'); // 162 A2 texte = texte.replace(/£/g,'£'); // 163 A3 texte = texte.replace(/¤/g,' '); // 164 A4 texte = texte.replace(/¥/g,'¥'); // 165 A5 texte = texte.replace(/¦/g,'¦'); // 166 A6 texte = texte.replace(/§/g,'§'); // 167 A7 texte = texte.replace(/¨/g,'¨'); // 168 A8 texte = texte.replace(/©/g,'©'); // 169 A9 texte = texte.replace(/ª/g,'ª'); // 170 AA texte = texte.replace(/«/g,'«'); // 171 AB texte = texte.replace(/¬/g,'¬'); // 172 AC texte = texte.replace(/­/g,'­'); // 173 AD texte = texte.replace(/®/g,'®'); // 174 AE texte = texte.replace(/¯/g,'¯'); // 175 AF texte = texte.replace(/°/g,'°'); // 176 B0 texte = texte.replace(/±/g,'±'); // 177 B1 texte = texte.replace(/²/g,'²'); // 178 B2 texte = texte.replace(/³/g,'³'); // 179 B3 texte = texte.replace(/´/g,'´'); // 180 B4 texte = texte.replace(/µ/g,'µ'); // 181 B5 texte = texte.replace(/¶/g,'¶'); // 182 B6 texte = texte.replace(/·/g,'·'); // 183 B7 texte = texte.replace(/¸/g,'¸'); // 184 B8 texte = texte.replace(/¹/g,'¹'); // 185 B9 texte = texte.replace(/º/g,'º'); // 186 BA texte = texte.replace(/»/g,'»'); // 187 BB texte = texte.replace(/¼/g,'¼'); // 188 BC texte = texte.replace(/½/g,'½'); // 189 BD texte = texte.replace(/¾/g,'¾'); // 190 BE texte = texte.replace(/¿/g,'¿'); // 191 BF texte = texte.replace(/À/g,'À'); // 192 C0 texte = texte.replace(/Á/g,'Á'); // 193 C1 texte = texte.replace(/Â/g,'Â'); // 194 C2 texte = texte.replace(/Ã/g,'Ã'); // 195 C3 texte = texte.replace(/Ä/g,'Ä'); // 196 C4 texte = texte.replace(/Å/g,'Å'); // 197 C5 texte = texte.replace(/Æ/g,'Æ'); // 198 C6 texte = texte.replace(/Ç/g,'Ç'); // 199 C7 texte = texte.replace(/È/g,'È'); // 200 C8 texte = texte.replace(/É/g,'É'); // 201 C9 texte = texte.replace(/Ê/g,'Ê'); // 202 CA texte = texte.replace(/Ë/g,'Ë'); // 203 CB texte = texte.replace(/Ì/g,'Ì'); // 204 CC texte = texte.replace(/Í/g,'Í'); // 205 CD texte = texte.replace(/Î/g,'Î'); // 206 CE texte = texte.replace(/Ï/g,'Ï'); // 207 CF texte = texte.replace(/Ð/g,'Ð'); // 208 D0 texte = texte.replace(/Ñ/g,'Ñ'); // 209 D1 texte = texte.replace(/Ò/g,'Ò'); // 210 D2 texte = texte.replace(/Ó/g,'Ó'); // 211 D3 texte = texte.replace(/Ô/g,'Ô'); // 212 D4 texte = texte.replace(/Õ/g,'Õ'); // 213 D5 texte = texte.replace(/Ö/g,'Ö'); // 214 D6 texte = texte.replace(/×/g,'×'); // 215 D7 texte = texte.replace(/Ø/g,'Ø'); // 216 D8 texte = texte.replace(/Ù/g,'Ù'); // 217 D9 texte = texte.replace(/Ú/g,'Ú'); // 218 DA texte = texte.replace(/Û/g,'Û'); // 219 DB texte = texte.replace(/Ü/g,'Ü'); // 220 DC texte = texte.replace(/Ý/g,'Ý'); // 221 DD texte = texte.replace(/Þ/g,'Þ'); // 222 DE texte = texte.replace(/ß/g,'ß'); // 223 DF texte = texte.replace(/à/g,'à'); // 224 E0 texte = texte.replace(/á/g,'á'); // 225 E1 texte = texte.replace(/â/g,'â'); // 226 E2 texte = texte.replace(/ã/g,'ã'); // 227 E3 texte = texte.replace(/ä/g,'ä'); // 228 E4 texte = texte.replace(/å/g,'å'); // 229 E5 texte = texte.replace(/æ/g,'æ'); // 230 E6 texte = texte.replace(/ç/g,'ç'); // 231 E7 texte = texte.replace(/è/g,'è'); // 232 E8 texte = texte.replace(/é/g,'é'); // 233 E9 texte = texte.replace(/ê/g,'ê'); // 234 EA texte = texte.replace(/ë/g,'ë'); // 235 EB texte = texte.replace(/ì/g,'ì'); // 236 EC texte = texte.replace(/í/g,'í'); // 237 ED texte = texte.replace(/î/g,'î'); // 238 EE texte = texte.replace(/ï/g,'ï'); // 239 EF texte = texte.replace(/ð/g,'ð'); // 240 F0 texte = texte.replace(/ñ/g,'ñ'); // 241 F1 texte = texte.replace(/ò/g,'ò'); // 242 F2 texte = texte.replace(/ó/g,'ó'); // 243 F3 texte = texte.replace(/ô/g,'ô'); // 244 F4 texte = texte.replace(/õ/g,'õ'); // 245 F5 texte = texte.replace(/ö/g,'ö'); // 246 F6 texte = texte.replace(/÷/g,'÷'); // 247 F7 texte = texte.replace(/ø/g,'ø'); // 248 F8 texte = texte.replace(/ù/g,'ù'); // 249 F9 texte = texte.replace(/ú/g,'ú'); // 250 FA texte = texte.replace(/û/g,'û'); // 251 FB texte = texte.replace(/ü/g,'ü'); // 252 FC texte = texte.replace(/ý/g,'ý'); // 253 FD texte = texte.replace(/þ/g,'þ'); // 254 FE texte = texte.replace(/ÿ/g,'ÿ'); // 255 FF return texte; } function html_entity_decode(str) { var ta=document.createElement("textarea"); ta.innerHTML=str.replace(//g,"&gt;"); return ta.value; } function msg(tipo) { var cookieValue = LireCookie('V_Cookie'); if(!cookieValue || cookieValue=='deleted=true') { desplegarCapaRegistro(tipo); return false; } else { if (tipo!=3) { var name_cookie = Get_Cookie_Value("sso_profession",cookieValue); name_cookie = decodeHex(name_cookie); var pais_cookie = Get_Cookie_Value("sso_country",cookieValue); pais_cookie = decodeHex(pais_cookie); if ((name_cookie=='Farmacia' || name_cookie=='Industria Farmacéutica' || name_cookie=='Medicina' || name_cookie=='Odontología') || pais_cookie!='España') {} else { desplegarCapaRegistro(tipo); return false; } } return true; } }