var client; var level = 0; createClient(); function createClient() { try { client = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Couldn't create the client... please contact info@europewebcompany.com"); } } function callback() { if (client.readyState == 4) { if (client.status == 200) { if (client.responseText != ""){ try{ getObject("loading").style.visibility = "hidden"; getObject("category"+level).disabled = false; if (client.responseText.length > 6){ setChild(level, client.responseText); decreaseMenu(); } else { window.location = "https://www.europewebcompany.com/search.php?cat=" + client.responseText + getCategorieIds(); } } catch(e){ } } createClient(); } else { alert("There was a problem retrieving the response:" + client.statusText); createClient(); } } } function decreaseMenu(){ var totalSize = getObject("category1").offsetWidth; for(i=2; i<= 4; i++){ try{ totalSize += getObject("category" + i).offsetWidth; }catch(e){} } if(totalSize > 600){ for(i=1; i< 4; i++){ if(getObject("category"+i).style.width == "") getObject("category"+i).style.width = (getObject("category"+i).offsetWidth)-30; } } } function setChild(theLevel, theText) { var parent = getObject("categories"); var newSpan = document.createElement('span'); var spanIdName = 'category'+theLevel+'Span'; newSpan.setAttribute('id',spanIdName); newSpan.innerHTML = theText; parent.appendChild(newSpan); } function getSubCategory(id){ var chosenCat = id.value; if(isNaN(chosenCat)) chosenCat=chosenCat.substring((chosenCat.indexOf("cat=")+4)); if(chosenCat > 0) id.disabled = true; var tmpLevel = id.name.substring(8); if (tmpLevel <= level){ cleanSubcategories(tmpLevel); } level = tmpLevel; if (chosenCat > 0){ getObject("loading").style.visibility = "visible"; client.onreadystatechange = callback; client.open("get","https://www.europewebcompany.com/getSubCategories.php?ID="+chosenCat+"&lvl="+level+"&date=" + new Date(),true); client.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); client.send(null); } else if(chosenCat < 0) window.location = "https://www.europewebcompany.com/search2.php?cat=" + (chosenCat*-1) + getCategorieIds(); } function cleanSubcategories(id){ var error = 0; while (error == 0){ try{ var childnode=getObject("category"+id+"Span"); getObject("categories").removeChild(childnode); } catch(es){ error = 1; } id++; } } function getCategorieIds(){ var error = 0; var id=1; var result = ""; while (error == 0){ try{ var childnode=getObject("category"+id); var theValue = childnode.value; if(isNaN(theValue)) theValue=theValue.substring(theValue.indexOf("cat=")+4); if(theValue < 0) theValue = 0; result += ("&lvl" + id + "=" + theValue) } catch(es){ error = 1; } id++; } return result; }