function addToList (entry, field) { if((field.value.length - 1) > 0) { if(field.value.charAt(field.value.length-1) == ',') { field.value = field.value + entry; } else { field.value = field.value + ',' + entry; } } else { field.value = field.value + entry; } } var startX = 195; //Horizontal position var startY = 275; //Vertical position function FloatTopDiv() { ftlObj = ml("MyCart"); setInterval("stayTopLeft(ftlObj)", 50); function ml(id) { var el = document.getElementById(id); el.sP = function(y) { this.style.top=y; } el.x = startX; el.y = startY; return el; } } function stayTopLeft(ftlObj) { var pY = navigator.appName.indexOf("Netscape")!= -1 ? pageYOffset : document.documentElement.scrollTop; if(pY >= startY) { ftlObj.y += (pY - ftlObj.y)/4; ftlObj.y += 10; } else { ftlObj.y += (startY - ftlObj.y)/4; } stringToSend = ftlObj.y + "px"; ftlObj.sP(stringToSend); } function RemoveCartItem(strDescription, strBrand) { var strRowID = strDescription + strBrand; //alert(strRowID); var pCell = document.getElementById(strRowID).childNodes.item(0); //alert("Cart Item Removed!"); var pCell2 = document.getElementById(strRowID).childNodes.item(1); var pRow = document.getElementById(strRowID); var strPrevColor= pRow.className; pNextRow = pRow.nextSibling; pCell.parentNode.removeChild(pCell); pCell2.parentNode.removeChild(pCell2); pRow.parentNode.removeChild(pRow); // Set Sibling to the color of the deleted item. pNextRow.setAttribute("className",strPrevColor); strPrevColor= pNextRow.className; // Move to next item pNextRow = pNextRow.nextSibling; while (pNextRow != null) { if (strPrevColor == "groceryListWht") { pNextRow.setAttribute("className","groceryListOrg"); strPrevColor = "groceryListOrg"; } else if (strPrevColor == "groceryListOrg") { pNextRow.setAttribute("className","groceryListWht"); strPrevColor = "groceryListWht"; } pNextRow = pNextRow.nextSibling; } } function UpdateCartItem(strDescription, strBrand, strQnty) { //alert("UpdateCartItem Called"); var strRowID = strDescription + strBrand; var tRow = document.getElementById(strRowID); var pCell = document.getElementById(strRowID).childNodes.item(1); var newTextQnty = document.createTextNode(strQnty); var NewCellQnty = document.createElement("td"); NewCellQnty.setAttribute("align","center"); NewCellQnty.setAttribute("width","10"); NewCellQnty.appendChild(newTextQnty); tRow.replaceChild(NewCellQnty, pCell); } function AddCartItem(strQnty, strItem, strBrand,bFlash) { // Get the first tbody node in the 'GroceryCartTable' table. var tbody = document.getElementById("GroceryCartTable").getElementsByTagName ("tbody")[0]; var LastRowAdded = tbody.getElementsByTagName ("tr")[0]; // Create New Row and Cell with text, to be inserted into the table var NewRow = document.createElement("TR"); NewRow.id = strItem + strBrand; NewRow.setAttribute("valign","top"); NewRow.setAttribute("className","groceryListOrg"); // Alternate row colors. if (LastRowAdded) { if ( LastRowAdded.className=="groceryListWht") { NewRow.setAttribute("className","groceryListOrg"); } else { NewRow.setAttribute("className","groceryListWht"); } } else { // No items yet NewRow.setAttribute("className","groceryListWht"); } var NewCell = document.createElement("TD"); var NewCellQnty = document.createElement("TD"); NewCellQnty.setAttribute("align","center"); NewCellQnty.setAttribute("width","10"); NewCell.setAttribute("width","115"); NewCell.setAttribute("align","left"); //text-align: center; // Always add a space between item and brand strItem = strItem + " "; var strItemAndBrand = strItem + " " + strBrand; var newText = document.createTextNode(strItemAndBrand); var newTextQnty = document.createTextNode(strQnty); NewCell.appendChild(newText); NewCellQnty.appendChild(newTextQnty); NewRow.appendChild(NewCell); NewRow.appendChild(NewCellQnty); // Get the first row after the body tag and insert new row before it. if (LastRowAdded) { tbody.insertBefore(NewRow,LastRowAdded); } else { // No itmes yet tbody.appendChild(NewRow); } // Flash new item added LastRowAdded = tbody.getElementsByTagName ("tr")[0]; if(bFlash == 1) { //StartBlink(LastRowAdded.id, 'PaleTurquoise'); //StartBlink(LastRowAdded.id, 'LightSalmon'); StartBlink(LastRowAdded.id, 'LightSkyBlue'); } //alert("AddCartItem Called"); }