﻿var root="http://www.toepferei-langerwehe.de/";var colorwarning="#FFCCCC";var statusrequest=null;function doload(){var search=window.location.search;var param;var element=document.getElementById("findbar");var expires=new Date();if(search>""){param=getparam(search,"adword");if(param>""){expires.setTime(expires.getTime()+(1000*60*60*24*30));document.cookie="adword="+decodeURIComponent(param)+"; path=/; expires="+expires.toUTCString();}param=getparam(search,"customer");if(param>"")savecookie("CustomerNumber",param,true);param=getparam(search,"email");if(param>"")savecookie("CustomerEMail",param,true);}if(element!=undefined){document.getElementById("findstring").value="Finden im Töpferei-Webshop";element.style.display="block";}showaccount();showcard();}function dobuy(){var rows=document.getElementById("variants").rows;var row;var index;var key;var caption;var specs;var quantity;var price;var count=0;var item;var items="";var soldout=true;if(window.navigator.cookieEnabled){items=getitems();for(var i=1;i<rows.length;i++){row=rows[i];key=row.cells.item(0).getElementsByTagName("a");if(key.length==0)key=row.cells.item(0).getElementsByTagName("p");key=key.item(0).innerHTML;caption=row.cells.item(1).getElementsByTagName("a");if(caption.length==0)caption=row.cells.item(1).getElementsByTagName("p");caption=uncode(caption.item(0).innerHTML);index=caption.toLowerCase().indexOf("<br>");if(index>0)caption=caption.substring(0,index);index=caption.toLowerCase().indexOf("</em> ");if(index>0)caption=caption.substring(index+6);specs=row.cells.item(1).getElementsByTagName("input").item(0);with(row.cells.item(2).getElementsByTagName("input").item(0)){if(disabled==false){soldout=false;quantity=value;}else{quantity="";}}price=row.cells.item(3).getElementsByTagName("p").item(0).innerHTML;if(quantity.length>0){quantity=val(quantity);quantity=(isNaN(quantity))?0:quantity;quantity=(quantity>=1)?quantity.toString():"";}if(price.length>0){price=val(price);price=(isNaN(price))?"":format(price);}if(quantity.length>0){if(specs!=undefined){if(specs.value.substring(0,1)=="<"){specs.style.backgroundColor=colorwarning;alert("Bitte geben Sie die fehlenden Daten bei "+specs.value+" ein.");return;}specs.style.backgroundColor="";}count=count+parseFloat(quantity);items=(items.length==0)?"":(items+"$");items=items+caption+"$"+key+"$"+price+"$"+quantity;item=key+" ("+caption+")";if(specs!=undefined){items=items+"$"+specs.value+"$$$";}}}if(count==0){if(soldout==true){alert("Alle Artikel dieser Seite sind bereits ausverkauft.");}else{alert("Bitte geben Sie eine Menge ein.");rows[1].cells.item(2).getElementsByTagName("input").item(0).focus();}}else{for(var i=1;i<rows.length;i++){rows[i].cells.item(2).getElementsByTagName("input").item(0).value="";}alert((count==1)?"Sie haben den Artikel "+item+" in den Warenkorb gelegt.":"Sie haben "+count.toString()+" Artikel in den Warenkorb gelegt.");document.cookie="Items="+escape(items)+"; path=/;";showcard();}}}function dobuynow(key,caption,price,specs,quantity){var items="";if(window.navigator.cookieEnabled){items=getitems();items=(items.length==0)?"":(items+"$");items=escape(items+caption+"$"+key+"$"+price+"$"+((quantity==undefined)?"1":quantity)+((specs>"")?"$"+specs+"$$$":""));if(quantity==undefined){if(specs.substring(0,1)=="<"){alert("Sie haben den Artikel "+key+" ("+caption+") in den Warenkorb gelegt. Für den Artikel benötigen wir zusätzliche Angaben. Bitte ergänzen Sie diese später auf der Bestellkarte.");}else{alert("Sie haben den Artikel "+key+" ("+caption+") in den Warenkorb gelegt.");}}document.cookie="Items="+items+"; path=/;";showcard();}}function dobuyproductselection(){var element=document.getElementById("productselection");var specs="";with(document.getElementById("productspecsinput")){if(style.display=="block"){specs=value;if(specs==""){style.backgroundColor=colorwarning;alert("Bitte geben Sie die fehlenden Daten ein.");focus();return;}value="";}}with(element.options.item(element.selectedIndex)){if(disabled==true){alert("Der Artikel ist bereits ausverkauft.");return;}dobuynow(element.value,unescape(getAttribute("data-caption")),getAttribute("data-price"),specs);}}function dochangeproductselection(){var element=document.getElementById("productselection");var price;var specs;var floor;if(element!=undefined){if(element.options.length>1)element.style.display="block";with(element.options.item(element.selectedIndex)){price=getAttribute("data-price");specs=getAttribute("data-specs");}element=document.getElementById("productprice");if(element!=undefined){price=val(price).toFixed(2);if(right(price,3)==".00"){price=price.substr(0,price.length-3)+",-";}else{price=price.substr(0,price.length-3)+",<span>"+right(price,2)+"</span>";}element.innerHTML="€ "+price;}with(document.getElementById("productspecslabel")){innerHTML=specs.replace(/>/,"").replace(/</,"");style.display=(specs=="")?"none":"block";}with(document.getElementById("productspecsinput")){value="";style.display=(specs=="")?"none":"block";}}}function docheckout(){window.location=(islocal()?"":root)+"warenkorb.html";}function doclear(){if(window.navigator.cookieEnabled){document.cookie="Items=; path=/";}}function doClickLabel(element){}function dofindfocus(element){element.style.color="black";element.value="";}function dofindblur(element){element.style.color="silver";element.value=(element.value=="")?"Finden im Töpferei-Webshop":element.value;}function dogetstatus(){statusrequest=createrequest();if(statusrequest){statusrequest.open("GET",root+"php/getstatus.php?products="+document.getElementById("variants").getAttribute("data-products"));statusrequest.onreadystatechange=getstatus;statusrequest.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");statusrequest.send(null);}}function getstatus(){var rows;var cells;var element;var key;var pos;var statuslines;var statuscodes=new Array();var statustexts=new Array();if(statusrequest.readyState==4){statuslines=unescape(statusrequest.responseText).split("<br>");for(var i=0;i<statuslines.length;i++){pos=statuslines[i].indexOf("=");if(pos!=-1){key=statuslines[i].substr(0,pos);statuscodes[key]=parseInt(statuslines[i].substr(pos+1,1));statustexts[key]=statuslines[i].substr(pos+3);}}element=document.getElementById("productselection");if(element!=undefined){for(var i=0;i<element.options.length;i++){with(element.options.item(i)){if(statuscodes[value]==2){disabled=true;innerHTML="AUSVERKAUFT "+innerHTML;}}}}rows=document.getElementById("variants").rows;for(var row=1;row<rows.length;row++){cells=rows[row].cells;element=cells.item(0).children.item(0);if(element.children.length>0){element=element.children.item(0);};key=element.innerHTML;if(statustexts[key]>""){element=cells.item(1).children.item(0);element.innerHTML=element.innerHTML+"<br>"+statustexts[key];}if(statuscodes[key]==2){with(cells.item(2).children.item(0)){style.display="none";getElementsByTagName("input").item(0).disabled=true;}}}}dochangeproductselection();}function dogohome(){window.location=(islocal()?tolocal():root)+"index.html";}function dologin(redirect){if(redirect!=undefined){if(getvalue("Customer")>""){window.location=redirect;return;}}window.location=(islocal()?"":root)+"login.html?referrer="+window.location+((redirect==undefined)?"":"&redirect="+redirect);}function dologout(){document.cookie="Customer=; path=/";dogohome();}function donote(product,caption,description){var key="$"+product+"$";var notes=getvalue("Notes");if(notes.indexOf(key)==-1){if(notes.split("_").length>=10){alert("Die Anzahl der Artikel auf dem Merkzettel ist auf 10 Stück begrenzt. Entfernen Sie Artikel um weitere hinzufügen.");}else{notes=notes+((notes=="")?"":"_")+key+caption+"$"+description+"$"+window.location;savecookie("Notes",escape(notes),true);}}window.location=(islocal()?"../":root)+"merkzettel.html?referrer="+window.location;}function doShowOrderHistory(){dologin((islocal()?"":root)+"bestellhistorie.html");}function dospecsblur(element,specs){if(element.value==""){element.value=specs;element.style.color="";}}function dospecsfocus(element){element.style.color="black";element.value=(element.value.substring(0,1)=="<")?"":element.value;}function dovalidatenumber(e){var key=(e.which==undefined)?e.keyCode:e.which;if(((key>=48)&&(key<=57))||(key==8)||(key==0))return true;if(e.preventDefault){e.preventDefault();return false;};e.returnValue=false;return false;}function createrequest(){var xmlhttp;if(window.XMLHttpRequest){try{xmlhttp=new XMLHttpRequest();}catch(e){xmlhttp=false;}}else{try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){xmlhttp=false;}}}return xmlhttp;}function format(number){var s=Math.floor(Math.round(number*100)).toString();while(s.length<3){s="0"+s;}return s.substring(0,s.length-2)+","+s.substring(s.length-2,s.length);}function getdefaultcountry(){return "Deutschland";}function getitems(){return getvalue("Items");}function getparam(search,param){var index=search.indexOf(param+"=");var value="";if(index>0){value=search.substring(index+param.length+1);index=value.indexOf("&");if(index>0)value=value.substring(0,index);}return value;}function getvalue(cookie){var value=document.cookie;var i;i=value.indexOf(cookie+"=");if(i>=0){value=value.substring(i+cookie.length+1);i=value.indexOf(";");if(i>=0){value=value.substr(0,i);}return unescape(value);}else{return "";}}function islocal(){return(window.location.protocol=="file:");}function tolocal(){var s1=window.location.pathname;var s2=s1.replace(/\//g,"");return((s1.length-7)==s2.length)?"../":"";}function isvalidmail(email){return email.match(/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i);}function right(text,length){return text.substring(text.length-length);}function savecookie(name,value,neverexpires){document.cookie=name+"="+value+"; path=/;"+((neverexpires==true)?" expires=Thu, 31-Dec-2099 23:59:59 GMT;":"");}function showaccount(){var element=document.getElementById("opening");var customer=getvalue("Customer");if(element!=undefined){element.innerHTML="Willkommen "+(customer==""?"Gast":customer)+"!";document.getElementById("login").style.display=((customer>"")||((window.location.pathname.indexOf("login.html")!=-1)))?"none":"block";document.getElementById("logout").style.display=(customer>"")?"block":"none";}}function showcard(){var items;var i;var price;var quantity;var count=0;var total=0;if(window.navigator.cookieEnabled){items=getitems();if(items.length>0){items=items.split("$");for(i=1;i<=items.length;i++){items[i-1]=unescape(items[i-1]);}for(i=0;i<items.length;i=i+4){if(items[i+3].length>0){price=parseFloat(items[i+2].replace(",","."));quantity=parseFloat(items[i+3].replace(",","."));if(isNaN(quantity)==false){count=count+quantity;if(isNaN(price)==false){total=total+Math.round(price*quantity*100)/100;}}}}}}with(document.getElementById("basketcount")){style.display="block";innerHTML=count.toString()+"&nbsp;Position"+((count==1)?"":"en")};with(document.getElementById("basketvalue")){style.display="block";innerHTML=format(total)+" EUR *"};}function showmore(element){document.getElementById("more").style.display="none";$("#moretext").slideDown("fast");}function trim(text){return text.replace(/^\s+/,"").replace(/\s+$/,"");}function uncode(text){return unescape(text.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">"));}function val(text){var ch;var value="";for(var i=1;i<=text.length;i++){ch=text.substr(i-1,1);if((ch==",")||(ch==".")){ch=".";}else{ch=((ch>="0")&&(ch<="9"))?ch:"";}value=value+ch;}return parseFloat(value);}function initFactFinder(){setFactFinderSearchButtonId("findbutton");setFactFinderTextfieldId("findstring");setFactFinderChannel("www-toepferei-langerwehe-de_de");}function trackFactFinder(search){_gaq.push(['_trackEvent','FactFinder','Search',search]);}var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-3992974-2']);_gaq.push(['_gat._anonymizeIp']);_gaq.push(['_trackPageview']);(function(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
