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="
");
} 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();
}
}
}
");
} else {
document.write("
");
}
}
function dFav(codigoLibro,enlaceFavoritos) {
if (!(displayFavoritos('codigoLibro','