window.onload = function () { //var check = initXMLHTTP(); //if (!check) return; //isBusy=true; } var check = initXMLHTTP(); //if (!check) return; isBusy=true; var xmlhttp; function initXMLHTTP () { try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { xmlhttp=false } } if (!xmlhttp) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } return xmlhttp; } var oldQueryString,isBusy,zending, cooing=1; function getXmlHttpRequest(){ var request; try { request = new ActiveXObject("Msxml2.XMLHTTP"); Msxml2.XMLHTTP return request; } catch (e) {} try { request = new ActiveXObject("Microsoft.XmlHttp"); return request; } catch (e) {} try { request = new ActiveXObject("MSXML.XmlHttp"); return request; } catch (e) {} try { request = new ActiveXObject("MSXML3.XmlHttp"); return request; } catch (e) {} if (window.XMLHttpRequest && window.DOMParser && document.implementation && document.implementation.createDocument) { request = new XMLHttpRequest(); return request; } } var qq=""; function doajax(uuid) { var curHref = new String(location.href); if(cooing==1){ qq=uuid; var s="?"; s+="SelectedObjectUUID="+uuid+"&shadow=1"; if (isBusy) { xmlhttp.onreadystatechange = function () {}; xmlhttp.abort(); isBusy = false; } var td=document.getElementById('td_'+uuid); td.innerHTML=''; if (curHref.toLowerCase().indexOf("https") != -1) { xmlhttp.open("GET","https://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ShadowAddToMYC-AddSrch"+s,true); } else { xmlhttp.open("GET","http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ShadowAddToMYC-AddSrch"+s,true); } cooing=0; isBusy = true; xmlhttp.onreadystatechange = processResponse; xmlhttp.send(null); if (typeof analytics !== "undefined" && typeof sioProducts !== "undefined" && sioProducts[uuid] != null) { delete sioProducts[uuid]['quantity']; analytics.track('Wishlisted Product', sioProducts[uuid]); } }else{ alert("Please wait, the previous product hasn't been added yet.") } } function processResponse() { if ( xmlhttp.readyState == 4 ) { if ( xmlhttp.responseText.indexOf('invalid') == -1 ) { cooing=1; if(xmlhttp.responseText.indexOf('login') == -1){ var td=document.getElementById('td_'+xmlhttp.responseText); td.innerHTML=''; } else{ s="?SelectedObjectUUID="+qq; window.location.href="http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ViewB2BWishlist-AddItem"+s; } } } } function updateAddToCart(prodUUID, mixIn){ var inp = mixIn != null ? 'addto_' + prodUUID + '_' + mixIn : 'addto_' + prodUUID; inp = inp.replace(/\./g,"\\."); var url = "http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ViewExplodedDiagram-InBasketProductStatus" + "?ProductUUID=" + prodUUID; if (mixIn != null) { url += "&MixIn=" + mixIn; } jQuery.ajax({ url: url, success: function (response) { jQuery("#"+inp).html(response); jQuery("body").trigger("updateBalloon"); }, error: function (response) {} }); } var input=null; var parentProductPopupVisible = false; var canAddToCart = true; function addtocart(prodRef, prodUUID, mixIn, isLP) { if (!canAddToCart) { return false; } canAddToCart = false; var adding; var inCart; var addingElt = document.getElementById('adding'); if(typeof(addingElt.innerText)!='undefined') { adding = addingElt.innerText; } else { adding = addingElt.textContent; } var incartElt = document.getElementById('inCart'); if(typeof(incartElt.innerText)!='undefined') { inCart = incartElt.innerText; } else { inCart = incartElt.textContent; } input = mixIn != null ? 'addto_'+prodRef + '_' + mixIn : 'addto_'+prodRef; if(document.getElementById(input).value === 'IN CART' || document.getElementById(input).value === 'In Cart'){ location.href="http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ViewCurrentReq-Update"; return; } var td=document.getElementById(input); td.value = adding; var quantityId = mixIn != null ? 'Quantity_' + prodRef + '_' + mixIn : 'Quantity_' + prodRef; var quantity=document.getElementById(quantityId); var q = quantity.value; var curHref = new String(location.href); var url ; var lpid = (isLP) ? '&LandingPageID=PT_CAT0000' : ""; if (curHref.toLowerCase().indexOf("https") != -1) { url = "https://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ShadowAddToCart-Add" +"?ProductRefIDs="+prodRef +"&SelectedObjectUUID="+prodUUID +"&ProductRefID="+prodRef +"&ProductRef="+prodRef +"&BuyingMode=Default" +"&Quantity_"+prodRef+"="+q +lpid; } else { url = "http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ShadowAddToCart-Add" +"?ProductRefIDs="+prodRef +"&SelectedObjectUUID="+prodUUID +"&ProductRefID="+prodRef +"&ProductRef="+prodRef +"&BuyingMode=Default" +"&Quantity_"+prodRef+"="+q +lpid; } jQuery("input.submitt_add_to_cart").attr("disabled","disabled"); parentProductPopupVisible = true; jQuery.ajax({ url: url, success: function (responce) { canAddToCart = true; if (document.getElementById(input) != null) { jQuery("input.submitt_add_to_cart").removeAttr("disabled"); document.getElementById(input).value=inCart; loadCartPopup(responce); }; parentProductPopupVisible = false; }, error: function (responce) { canAddToCart = true; parentProductPopupVisible = false; jQuery("body").css("overflow","auto"); var td=document.getElementById(input).value="ADD TO CART"; } }); if (typeof analytics !== "undefined" && typeof sioProducts !== "undefined" && sioProducts[prodUUID] != null) { sioProducts[prodUUID].quantity = q != '' ? parseInt(q) : 1; analytics.track('Added Product', sioProducts[prodUUID]); } }