IE4 = (document.all); NS4 = (document.layers); if (!IE4) { if (!NS4) NS4 = (document.getElementById); } var form1=false; var form2=false; if (NS4) document.captureEvents(Event.KEYPRESS); document.onkeypress = doKey; function processClicks() { return false; } function processKeys() { return false; } function validateAll(form) { // &&(!(isNotEmpty(form.tFP))) if (!(isNotEmpty(form.tISBN)) &&(!(isNotEmpty(form.tTi))) &&(!(isNotEmpty(form.tAu))) &&(!(isNotEmpty(form.tEd))) &&((form.sL1[form.sL1.selectedIndex].value==-1)&&(form.sL2[form.sL2.selectedIndex].value==-1)&&(form.sL3[form.sL3.selectedIndex].value==-1))) { if (!(isNotEmpty(form.tPmin)) || !(isNotEmpty(form.tPmax))) { open_error_window('','Por favor, especifica un criterio de búsqueda además del precio.'); return false; } else { open_error_window('','Por favor, especifica un criterio de búsqueda.'); return false; } } else { if (validate(form)){ form.tISBN.value=ReplaceChar(form.tISBN.value,'%','*'); form.tTi.value=Trim(form.tTi.value); form.tTi.value=ReplaceChar(form.tTi.value,'%','*'); form.tAu.value=Trim(form.tAu.value); form.tAu.value=ReplaceChar(form.tAu.value,'%','*'); form.tEd.value=Trim(form.tEd.value); form.tEd.value=ReplaceChar(form.tEd.value,'%','*'); return true; } } } function replaceChars(entry, replace_this, with_this) { temp = "" + entry; // temporary holder while (temp.indexOf(replace_this)>-1) { pos= temp.indexOf(replace_this); temp = "" + (temp.substring(0, pos) + with_this + temp.substring((pos + replace_this.length), temp.length)); } return temp; } function doKey(e) { whichASC = (NS4) ? e.which : event.keyCode; whichKey = String.fromCharCode(whichASC).toLowerCase(); oid= getMeaningWords(document.fSearchAll.tValueForSearch.value); oid= Trim(oid); oid=escape(oid); if (whichASC == 13) { if (form1||(!form1 && !form2)) { if (document.fSearchAll.tValueForSearch.value != '') { var tBusq = ''; if (document.fSearchAll.tBusq) { if (document.fSearchAll.tBusq[0].checked) { tBusq = document.fSearchAll.tBusq[0].value; } if (document.fSearchAll.tBusq[1].checked) { tBusq = document.fSearchAll.tBusq[1].value; } if (document.fSearchAll.tBusq[2].checked) { tBusq = document.fSearchAll.tBusq[2].value; } if (document.fSearchAll.tBusq[3].checked) { tBusq = document.fSearchAll.tBusq[3].value; } //tBusq = document.fSearchAll.tBusq.options[document.fSearchAll.tBusq.selectedIndex].value; //if (tBusq == '') tBusq = document.fSearchAll.tBusq.options[0].value; } else { tBusq = 't'; } document.onkeypress=processKeys; document.fSearchAll.tValueForSearch.value=ReplaceChar(document.fSearchAll.tValueForSearch.value,'%','*'); document.fSearchAll.NotQueryAgain.value='false'; document.fSearchAll.action='http://www.casadellibro.com/busquedas/quickResults/0,,1-'+tBusq+"-"+oid+',00.html'; document.fSearchAll.submit() } else { if ((typeof document.fBusquedaAvanzada != 'undefined')&&(typeof document.fBusquedaAvanzada != null)) { if(validateAll(document.fBusquedaAvanzada)) redirectSearch(document.fBusquedaAvanzada) } } } if (form2) { if ((typeof document.fBusquedaAvanzada != 'undefined')&&(typeof document.fBusquedaAvanzada != null)) { if(validateAll(document.fBusquedaAvanzada)) redirectSearch(document.fBusquedaAvanzada); } } } } function setFormModified(formName) { var testTxt='*'+document.fSearchAll.tValueForSearch.value+'*'; if (formName=='quick') { if(testTxt != '**') { form1=true; form2=false; }; } if (formName=='advanced') { form1=false; form2=true; }; } function busca() { if (document.fSearchAll.tValueForSearch.value != '') { var tBusq = "t"; if (document.fSearchAll.tBusq[0].checked) { tBusq = document.fSearchAll.tBusq[0].value; } if (document.fSearchAll.tBusq[1].checked) { tBusq = document.fSearchAll.tBusq[1].value; } if (document.fSearchAll.tBusq[2].checked) { tBusq = document.fSearchAll.tBusq[2].value; } if (document.fSearchAll.tBusq[3].checked) { tBusq = document.fSearchAll.tBusq[3].value; } oid= getMeaningWords(document.fSearchAll.tValueForSearch.value); oid= Trim(oid); oid=escape(oid); document.onclick = processClicks; document.fSearchAll.tValueForSearch.value=ReplaceChar(document.fSearchAll.tValueForSearch.value,'%','*'); document.fSearchAll.NotQueryAgain.value='false'; document.fSearchAll.action='http://www.casadellibro.com/busquedas/quickResults/0,,1-'+tBusq+'-'+oid+',00.html'; document.fSearchAll.submit(); } else { open_error_window('','No se han especificado criterios de búsqueda'); } } function isEmptyWord(str) { str= Trim(str).toLowerCase(); //Preposicion: a, de, con, en, del, al, por, para, segun esPreposicion= (str=="a") || (str=="de") || (str=="con") || (str=="en") || (str=="del") || (str=="al") || (str=="por") || (str=="para") || (str=="segun"); //Articulo determinado: el, la , lo, los, las esDeterminado= (str=="el") || (str=="la") || (str=="lo") || (str=="los") || (str=="las"); //Articulo Indeterminado: un, una, uno, unos, unas esIndeterminado= (str=="un") || (str=="una") || (str=="uno") || (str=="unos") || (str=="unas"); //Conjunciones: y, o, e, que esConjuncion= (str=="y") || (str=="o") || (str=="e") || (str=="que"); //Catalan: i, unes, les, els esCatalan= (str=="i") || (str=="unes") || (str=="les") || (str=="els"); //Ingles: of, in, on, the, this, that, those, these, a esIngles= (str=="of") || (str=="in") || (str=="on") || (str=="the") || (str=="this") || (str=="that") || (str=="those") || (str=="these") || (str=="a"); //Pronombre personales: yo, tu , ella, nosotros, vosotros, nosotras, vosotras, ellos, ellas esPronombre= (str=="yo") || (str=="tu") || (str=="ella") || (str=="nosotros") || (str=="vosotros") || (str=="nosotras") || (str=="vosotras") || (str=="ellos") || (str=="ellas"); //Demostrativos: esto, esta, eso, esa, ese esDemostrativo= (str=="esto") || (str=="esta") || (str=="eso") || (str=="esa") || (str=="ese"); //Posesivos: mio, mia, tuyo, tuya, suyo, suya, mi esPosesivo= (str=="mio") || (str=="mia") || (str=="tuyo") || (str=="tuya") || (str=="suyo") || (str=="suya") || (str=="mi"); isEmpty= esPreposicion || esDeterminado || esIndeterminado || esConjuncion || esCatalan || esIngles || esPronombre || esDemostrativo | esPosesivo; return isEmpty; } function getMeaningWords(s) { var token=""; var cadenaFinal= ""; var cadena= new String(s); for (var i=0; i< cadena.length; i++) { if (cadena.charAt(i)!=' ') token=token+cadena.charAt(i); else { if (isEmptyWord(Trim(token))) token=""; else { cadenaFinal=cadenaFinal+" "+Trim(token); token=""; } } } if (isEmptyWord(Trim(token))) token=""; else cadenaFinal=cadenaFinal+" "+Trim(token); cadenaFinal= replaceChars(cadenaFinal, ".", " "); return cadenaFinal.toLowerCase(); } function Querystring() { // get the query string, ignore the ? at the front. var querystring=location.search.substring(1,location.search.length); // parse out name/value pairs separated via & var args = querystring.split('&'); // split out each name = value pair for (var i=0;i < args.length;i++) { var pair = args[i].split('='); // Fix broken unescaping temp = unescape(pair[0]).split('+'); temp0 = temp.join(' '); temp = unescape(pair[1]).split('+'); temp1 = temp.join(' '); this[temp0]=temp1; } this.get=Querystring_get; } function Querystring_get(strKey,strDefault) { var value=this[strKey]; if (value==null){value=strDefault;} return value; } var qs = new Querystring(); var carritoLibros=qs.get("bl",""); var ChildListArray; ChildListArray=carritoLibros.split("-"); function findInBolsa(codigoLibro) { for (var i=1; i < ChildListArray.length; i++) { if (ChildListArray[i]==codigoLibro) { return true; } }; return false; } function displayBolsa(codigoLibro,htmltodisplay) { if (findInBolsa(codigoLibro)) { document.write(htmltodisplay); return true; } else { return false; } } var qsF = new Querystring(); var favoritoLibros='0-'+qsF.get("blf",""); var ChildListArrayF; ChildListArrayF=favoritoLibros.split("-"); function findInFavoritos(codigoLibro) { for (var i=1; i < ChildListArrayF.length; i++) { if (ChildListArrayF[i]==codigoLibro) { return true; } }; return false; } function displayFavoritos(codigoLibro,htmltodisplay) { if (findInFavoritos(codigoLibro)) { document.write(htmltodisplay); return true; } else { return false; } } function irFavoritos (url) { document.onclick = processClicks; window.location=url; } function envio48h(url) { var hWnd = window.open("/otros/envio48hmensaje","","width=475,height=345,resizable=yes,status=yes,scrollbars=yes"); if ((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window; } function getImage(codSeccion, oidSeccion) { var image=""; if (codSeccion==1) image="cl1on.gif"; if (codSeccion==2) image="cl2on.gif"; if (codSeccion==3) image="cl3on.gif"; if (codSeccion==4) image="cl4on.gif"; if (codSeccion==5) image="cl5on.gif"; //if (codSeccion==6) image="cl6on.gif"; if (codSeccion==6) image="cl21on.gif"; if (codSeccion==7) image="cl7on.gif"; if (codSeccion==8) image="cl8on.gif"; if (codSeccion==9) image="cl9on.gif"; if (codSeccion==10) image="cl10on.gif"; if (codSeccion!=oidSeccion) { //image="off-"+image; var re = /on/; var newstr = image.replace(re, ""); image = newstr; } return image; } function writeDebajoMenu(oidSeccion) { var linea = "
"; if (oidSeccion==1) { linea="
"; } if (oidSeccion==2) { linea="
"; } if (oidSeccion==3) { linea="
"; } if (oidSeccion==4) { linea="
"; } if (oidSeccion==5) { linea="
"; } if (oidSeccion==6) { linea="
"; } if (oidSeccion==7) { linea="
"; } if (oidSeccion==8) { linea="
"; } if (oidSeccion==9) { linea="
"; } if (oidSeccion==10) { linea="
"; } document.write(linea); } function writeMenu(oidSeccion) { var novedades = getCookie("categorias"); var enlaceNovedades = "4"; if (novedades!=null) { var posicion1 = novedades.indexOf("-"); var primeraCategoria = novedades.substring(0, posicion1); if (posicion1==-1) { primeraCategoria = novedades; } if (primeraCategoria != "") { enlaceNovedades = "4-" + primeraCategoria + "-P-1"; } } document.write(''); } function isFloat (s) { var i; var seenDecimalPoint = false; if (isEmpty(s)) if (isFloat.arguments.length == 1) return defaultEmptyOK; else return (isFloat.arguments[1] == true); if (s == decimalPointDelimiter) return false; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true; else if (!isDigit(c)) return false; } // All characters are numbers. return true; } function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isWhitespace (s) { var i; if (isEmpty(s)) return true; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } // All characters are whitespace. return true; } function validaTextArea(field,maxlimit) { if(field.value.length > maxlimit) { field.blur(); open_error_window('El área de texto no puede contener más de '+maxlimit+' caracteres.'); field.value=field.value.substring(0,maxlimit-1); } } function LTrim(str) { for (var i=0; str.charAt(i)==" "; i++); return str.substring(i,str.length); } function RTrim(str) { for (var i=str.length-1; str.charAt(i)==" "; i--); return str.substring(0,i+1); } function Trim(str) { return LTrim(RTrim(str)); } var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); function LZ(x) {return(x<0||x>9?"":"0")+x} function isDate(val,format) { var date=getDateFromFormat(val,format); if (date==0) { return false; } return true; } function compareDates(date1,dateformat1,date2,dateformat2) { var d1=getDateFromFormat(date1,dateformat1); var d2=getDateFromFormat(date2,dateformat2); if (d1==0 || d2==0) { return -1; } else if (d1 > d2) { return 1; } return 0; } function _isInteger(val) { var digits="1234567890"; for (var i=0; i < val.length; i++) { if (digits.indexOf(val.charAt(i))==-1) { return false; } } return true; } function _getInt(str,i,minlength,maxlength) { for (var x=maxlength; x>=minlength; x--) { var token=str.substring(i,i+x); if (token.length < minlength) { return null; } if (_isInteger(token)) { return token; } } return null; } function isNotEmptyAlert(field) { var inputStr = field.value if (inputStr == "" || inputStr == null) { alert("This field requires an entry.") field.focus() field.select() return false } return true } function isNotEmpty(field) { var inputStr = Trim(field.value) if (inputStr == "" || inputStr == null) { return false } return true } function isNumberAlert(field) { if (isNotEmpty(field)) { var inputStr = Trim(field.value) for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.substring(i, i + 1) if (oneChar < "0" || oneChar > "9") { alert("Please make sure entries are numbers only.") field.focus() field.select() return false } } return true } return false } function isNumber(field) { if (isNotEmpty(field)) { var inputStr = Trim(field.value) for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.substring(i, i + 1) if (oneChar < "0" || oneChar > "9") { return false } } return true } return false } function isFloat(field) { if (isNotEmpty(field)) { var inputStr = Trim(field.value) for (var i = 0; i < inputStr.length; i++) { var oneChar = inputStr.substring(i, i + 1) if ((oneChar < "0" || oneChar > "9") && (oneChar != '.')) { return false } } return true } return false } function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } var pathSeccion="/secciones/seccion"; var pathBiblio="/fichas/fichabiblio"; var ca= qs.get("ca","null"); if (ca!='null') { setCookie("codigoAfiliado",ca,"","/","",""); } function showURL(path,oid) { var caSession= getCookie('codigoAfiliado'); if ((ca=="74") || (caSession=="74")){ var url= 'http://www.casadellibro.com'+path+"in/0,,"+oid+",00.html?ca=74"; } else if ((ca=="110") || (caSession=="110")){ var url= 'http://www.casadellibro.com'+path+"in/0,,"+oid+",00.html?ca=110"; } else if ((ca=="112") || (caSession=="112")){ var url= 'http://www.casadellibro.com'+path+"in/0,,"+oid+",00.html?ca=112"; } else if ((ca=="100") || (caSession=="100")){ var url= 'http://www.casadellibro.com'+path+"in/0,,"+oid+",00.html?ca=100"; } else { var url= 'http://www.casadellibro.com'+path+"/0,,"+oid+",00.html"; } window.location=url; } function openDefaultNewWindow( url, windowName, width, height ) { options = "menubar=no,toolbar=no,height=" + height + ",width=" + width; return window.open( url, windowName, options ); } function imprimir() { window.print(); } function volver() { window.history.back(); } function changeAction(form, newUrl) { form.action=newUrl; } function submitToUrl(form, newUrl) { changeAction(form, newUrl); form.submit(); } function checkWindowOpen( windowHandle, url, windowName, width, height ) { if( windowHandle == null || windowHandle.closed ) { windowHandle = openDefaultNewWindow( url, windowName, width , height ); } else { windowHandle.location = url; windowHandle.focus(); } return windowHandle; } function ReplaceChar(String, OldChar, NewChar){ for(var n=0; n"); } else { document.write(""); } } function dFav(codigoLibro,enlaceFavoritos) { if (!(displayFavoritos('codigoLibro',''))) { funcHref("43",enlaceFavoritos); } } function aFav(codigoLibro,enlaceBolsa,enlaceFavoritos) { if (findInBolsa(codigoLibro)) { funcHref("46",enlaceBolsa); } else { if (!(findInFavoritos(codigoLibro))) { funcHref("43",enlaceFavoritos); } else { funcHref("44",""); } } } function aCar(codigoLibro,enlaceCarrito) { if (!(findInBolsa(codigoLibro))) { funcHref("41",enlaceCarrito); } else { funcHref("38",""); } } function processClicks() { return false; } function LTrim(str) { for (var i=0; str.charAt(i)==" "; i++); return str.substring(i,str.length); } function RTrim(str) { for (var i=str.length-1; str.charAt(i)==" "; i--); return str.substring(0,i+1); } function Trim(str) { return LTrim(RTrim(str)); } function isEmail(StrObj) { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(StrObj)) { return true; } else { return false; } } function validaBoletin() { var tipo = ""; if ((!document.myFormBoletin.tipogeneral.checked) && (!document.myFormBoletin.tiponoticia.checked)) { open_error_window('Tipo de boletín.'); } else { if (document.myFormBoletin.tipogeneral.checked) { tipo = document.myFormBoletin.tipogeneral.value + "|"; } if (document.myFormBoletin.tiponoticia.checked) { tipo = tipo + document.myFormBoletin.tiponoticia.value; } document.myFormBoletin.tipoboletin.value = tipo; if (!isEmail(document.myFormBoletin.email.value)) { open_error_window('Email incorrecto.'); } else { document.onclick = processClicks; document.myFormBoletin.submit(); } } } (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(StrObj)) { return true; } else { return false; } } function validaBoletin() { var tipo = ""; if ((!document.myFormBoletin.tipogeneral.checked) && (!document.myFormBoletin.tiponoticia.checked)) { open_error_window('Tipo de boletín.'); } else { if (document.myFormBoletin.tipogeneral.checked) { tipo = document.myFormBoletin.tipogeneral.value + "|"; } if (document.myFormBoletin.tiponoticia.checked) { tipo = tipo + document.myFormBoletin.tiponoticia.value; } document.myFormBoletin.tipoboletin.value = tipo; if (!isEmail(document.myFormBoletin.email.value)) { open_error_window('Email incorrecto.'); } else { document.onclick = processClicks; document.myFormBoletin.submit(); } } }