function SetQuantity(elm) { $('q'+elm.value).disabled = !elm.checked; if (elm.checked) { $('q'+elm.value).value = 1; $('q'+elm.value).focus(); } else { $('q'+elm.value).value = ''; } } //Plumar function AddToCart() { var exp = new RegExp("ItemSizeID"); var exp1 = new RegExp("ItemQuantity"); var IDs = new Array(); var data = new Object(); with (document.forms[0]) { for (var i = 0; i < elements.length; i++) { if (exp.test(elements[i].name)) { if (elements[i].checked) { IDs.push(elements[i].value); data[elements[i].value] = $('q'+elements[i].value).value; var catcher = elements[i].value; } } if (exp1.test(elements[i].name)) { if(elements[i].value!==''){ data[catcher] = elements[i].value; } } } } if (IDs.length == 0) { alert(GetTranslation('no-option-selected')); return; } $('add-to-cart-loading').show(); var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.responseJS) { if (req.responseJS && req.responseJS["Answer"] == "Done") { document.getElementById("BasketTotalSum").innerHTML = req.responseJS["Total"]; console.log('req response is ',req.responseJS["Total"]); document.getElementById("BasketTotalItems").innerHTML = req.responseJS["Qty"]; with (document.forms[1]) { for (var i = 0; i < elements.length; i++) { if (exp.test(elements[i].name)) { if (elements[i].checked) { elements[i].checked = false; $('q'+elements[i].value).value = ''; $('q'+elements[i].value).disabled = true; } } } } } else { alert("error"); } $('add-to-cart-loading').hide(); } } } req.caching = false; req.open("POST", "/ajax.php", true); req.send({ Action: 'AddToCart', ProductID: IDs, 'Data': data}); console.log('data is ',data); } function CorrectTblStyles(id) { document.observe("dom:loaded", function() { $(id).select('tr').each(function (elm, ind){ if (ind % 2 == 1) elm.addClassName('even'); else elm.addClassName('odd'); }); }); } function SetValue(elm) { if (!elm.defValue) elm.defValue = elm.value; if (elm.value == elm.defValue) elm.value = ''; } function OpenPrintPage() { var re = /\?/; var sym = '?'; if (re.test(window.location.href)) sym = '&'; LinkWindow(window.location.href + sym + 'print=1', {resizable : 1}); } function LinkWindow(linkURL, options) { if (window.event) { event.cancelBubble = true; event.returnValue = false; } if (!options) options = {}; var width = options.width || null; var height = options.height || null; if (!width) { width = Math.ceil(screen.width/2); if (width < 650) width = 650; } if (!height) { var height = Math.ceil(screen.height*0.6); if (height < 400) height = 400; } var toolbar = options.toolbar || 0; var location = options.location || 0; var directories = options.directories || 0; var menubar = options.menubar || 0; var scrollbars = options.scrollbars || 1; var resizable = options.resizable || 0; var status = options.status || 0; var fullscreen = options.fullscreen || 0; var name = options.name || "Additional"; var left = options.left || Math.ceil(screen.width/4); var top = options.top || Math.ceil(screen.height*0.1); var oTarget = window.open(linkURL, name, "height="+height+",width="+width+",scrollbars="+scrollbars+",left="+left+",top="+top+",toolbar="+toolbar+",location"+location+",directories"+directories+",menubar"+menubar+",resizable"+resizable+",status"+status+",fullscreen"+fullscreen); oTarget.focus(); return false; }