// remote scripting library // (c) copyright 2005 modernmethod, inc var sajax_debug_mode = false; var sajax_request_type = "GET"; function sajax_debug(text) { if (sajax_debug_mode) alert("RSD: " + text) } function sajax_init_object() { sajax_debug("sajax_init_object() called..") var A; try { A=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { A=new ActiveXObject("Microsoft.XMLHTTP"); } catch (oc) { A=null; } } if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); if (!A) sajax_debug("Could not create connection object."); return A; } function sajax_do_call(func_name, args) { var i, x, n; var uri; var post_data; uri = "/javascript/ajax.js.php"; if (sajax_request_type == "GET") { if (uri.indexOf("?") == -1) uri = uri + "?rs=" + escape(func_name); else uri = uri + "&rs=" + escape(func_name); for (i = 0; i < args.length-1; i++) uri = uri + "&rsargs[]=" + escape(args[i]); uri = uri + "&rsrnd=" + new Date().getTime(); post_data = null; } else { post_data = "rs=" + escape(func_name); for (i = 0; i < args.length-1; i++) post_data = post_data + "&rsargs[]=" + escape(args[i]); } x = sajax_init_object(); x.open(sajax_request_type, uri, true); if (sajax_request_type == "POST") { x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } x.onreadystatechange = function() { if (x.readyState != 4) return; sajax_debug("received " + x.responseText); var status; var data; status = x.responseText.substring(0,7); //data = x.responseText.substring(2); data = x.responseText; if (status == "foo") alert("Error: " + data); else //args[args.length-1](data); args[args.length-1](data,x); } x.send(post_data); sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); sajax_debug(func_name + " waiting.."); delete x; } // wrapper for addToCart function x_addToCart() { sajax_do_call("addToCart", x_addToCart.arguments); } // wrapper for loadNewItems function x_loadNewItems() { sajax_do_call("loadNewItems", x_loadNewItems.arguments); } // wrapper for loadSaleItems function x_loadSaleItems() { sajax_do_call("loadSaleItems", x_loadSaleItems.arguments); } function do_addToCart_cb(new_data,requestDom) { xmldom = requestDom.responseXML; cartAddNodes = xmldom.getElementsByTagName("cart_add"); for (var i = 0; i < cartAddNodes.length; i++) { var id = cartAddNodes[i].getAttribute('id'); var parent_id = cartAddNodes[i].getAttribute('parent_id'); var status = cartAddNodes[i].getAttribute('status'); var sub_total = cartAddNodes[i].getAttribute('sub_total'); var item_count = cartAddNodes[i].getAttribute('item_count'); var addedContentNode = document.getElementById('product_details_' + parent_id); var addedActionsNode = document.getElementById('list_actions_table_' + parent_id); var miniCartNode = document.getElementById('mini_cart'); var emptyCartNode = document.getElementById('empty_cart'); var itemCountNode = document.getElementById('cart_item_count'); var subTotalNode = document.getElementById('cart_sub_total'); if (!addedContentNode || !addedActionsNode || status != 'success') { var failedFields = cartAddNodes[i].getElementsByTagName('failed_field'); for (var j = 0; j < failedFields.length; j++) { var fieldName = failedFields[j].getAttribute('name'); switch (fieldName) { case 'product': alert('You have chosen an invalid product!'); break; case 'quantity': alert('You have chosen an invalid quantity!'); break; default: alert(addedContentNode + '\n' + addedActionsNode + '\n' + parent_id); break; } } } else if (status == 'success') { setupCartAddedMessage(addedContentNode, addedActionsNode); restoreActionsTable(parent_id); if (currentDetailsTable && currentActionsTable) { if (self.Effect) { Effect.SlideUp(currentDetailsNode, {duration:0.5,queue:'end',afterUpdate:updateActionHeights,afterFinish:resetActionsUpdateCounter}); } else { currentDetailsTable.style.display = 'none'; } } if (emptyCartNode) { emptyCartNode.style.display = 'none'; } if (miniCartNode && itemCountNode && subTotalNode) { miniCartNode.style.display = 'block'; itemCountNode.innerHTML = item_count > 1 ? item_count + ' Items' : item_count + ' Item'; subTotalNode.innerHTML = sub_total; } var quantityNode = document.getElementById('quantity_for_' + parent_id); if (quantityNode) { quantityNode.value = ''; } } } } function do_addToCart(id, qty) { x_addToCart(id, qty, do_addToCart_cb); return false; } // ***********************************// // NEW ITEMS // // ***********************************// var new_items = new Array(); function do_loadNewItems_cb(new_data,requestDom) { xmldom = requestDom.responseXML; new_items = new Array(); var newItemNodes = xmldom.getElementsByTagName("new_item"); for (var i = 0; i < newItemNodes.length; i++) { var new_item = {id:0, parent_id:0, kind:'', title:'', description:'', image:''}; new_item.id = parseInt(unescape(newItemNodes[i].getAttribute('id')), 10); new_item.parent_id = unescape(newItemNodes[i].getAttribute('parent_id')); new_item.kind = unescape(newItemNodes[i].getAttribute('kind')); new_item.title = unescape(newItemNodes[i].getAttribute('title')); new_item.description = unescape(newItemNodes[i].getAttribute('description')); new_item.image = unescape(newItemNodes[i].getAttribute('image')); new_item.crumbs = unescape(newItemNodes[i].getAttribute('crumbs')); new_items[i] = new_item; } initNewItems(); } function do_loadNewItems(qty) { x_loadNewItems(1, do_loadNewItems_cb); return false; } // ************************************// // SALE ITEMS // // ************************************// var sale_items = new Array(); function do_loadSaleItems_cb(new_data,requestDom) { xmldom = requestDom.responseXML; sale_items = new Array(); var saleItemNodes = xmldom.getElementsByTagName("sale_item"); for (var i = 0; i < saleItemNodes.length; i++) { var sale_item = {id:0, parent_id:0, kind:'', title:'', description:'', image:''}; sale_item.id = parseInt(unescape(saleItemNodes[i].getAttribute('id')), 10); sale_item.parent_id = unescape(saleItemNodes[i].getAttribute('parent_id')); sale_item.kind = unescape(saleItemNodes[i].getAttribute('kind')); sale_item.title = unescape(saleItemNodes[i].getAttribute('title')); sale_item.description = unescape(saleItemNodes[i].getAttribute('description')); sale_item.crumbs = unescape(saleItemNodes[i].getAttribute('crumbs')); sale_items[i] = sale_item; } initSaleItems(); } function do_loadSaleItems() { x_loadSaleItems(do_loadSaleItems_cb); return false; } // ************************************// // PROPERTIES // // ************************************// var colors = new Array(); var adhesives = new Array(); var parts = new Array(); var units = new Array(); colors[9] = 'WHITE'; colors[5] = 'BLACK'; colors[25] = 'CLEAR'; colors[1] = 'YELLOW'; colors[2] = 'RED'; colors[3] = 'BLUE'; colors[4] = 'GREEN'; colors[6] = 'GREY'; colors[7] = 'ORANGE'; colors[8] = 'ROYAL'; colors[10] = 'BEIGE'; colors[11] = 'BROWN'; colors[12] = 'VIOLET'; colors[13] = 'PURPLE'; colors[14] = 'CHARCOAL'; colors[15] = 'ANTIQUE GREY'; colors[16] = 'EGG SHELL'; colors[17] = 'ROYAL BLUE'; colors[18] = 'WINE(BURGUNDY)'; colors[19] = 'A) WHITE'; colors[20] = 'B) BLACK'; colors[21] = 'GRAY'; colors[26] = 'SPANISH RED'; adhesives[1] = '0115 RUBBER ADHESIVE'; adhesives[8] = '0112 RUBBER ADHESIVE'; adhesives[2] = '0172 ACRYLIC ADHESIVE'; adhesives[3] = 'HIGH'; adhesives[4] = 'LOW'; adhesives[6] = 'SUPER'; adhesives[5] = 'MEDIUM'; adhesives[7] = 'SUPER HIGH'; adhesives[9] = '0119 RUBBER ADHESIVE'; adhesives[10] = 'VHB™ ACRYLIC ADHESIVE'; adhesives[11] = 'GPA RUBBER ADHESIVE'; parts[1] = 'HOOK'; parts[2] = 'LOOP'; units[1] = 'YD'; units[4] = 'RL'; units[5] = 'BX'; units[6] = 'EA'; units[22] = 'CN'; units[24] = ' PCS'; units[25] = 'BAG'; units[26] = 'PAD';