function btnAddCart_onclick(rowCount, id)  {

    selected = true;

    if (document.getElementById("hidAttributeItems" + id).value > 0)  {
       for (i = 1; i <= document.getElementById("hidAttributeItems" + id).value; i++)  {
           attributeId = document.getElementById("hidAttributeId" + id + ":" + i).value;
           if (document.getElementById(attributeId).value == "")  {
              selected = false;
           }
       }
    }


    if (selected)  {
       if (document.getElementById("qty" + rowCount).value > 0)  {
          document.getElementById("button").value = "AddCart";
          document.getElementById("itemId").value = id;
          document.getElementById("itemQty").value = document.getElementById("qty" + rowCount).value;
       
          document.forms['OrderForm'].submit(); 
        } else  {
          window.alert("Please enter in a quantity greater than zero.");
        }
    } else  {
       window.alert("Please select all the product attributes.");
    }
} 

function category_onclick(categoryId)  {
    document.getElementById("button").value = "ClickCategory";
    document.getElementById("hidCategoryId").value = categoryId;

    if (categoryId != 0)  {
       categoryNav = new String(document.getElementById("hidCategoryNav").value);    
       categorySearch = new String("," + categoryId);

       found = false;

       if (categoryNav.indexOf("," + categoryId) >= 0)  {
          categoryNavStart = categoryNav.substring(0, categoryNav.indexOf(categorySearch) + categorySearch.length);
          categoryNavEnd = categoryNav.substring(categoryNav.indexOf(categorySearch) + categorySearch.length, categoryNav.length);
          document.getElementById("hidCategoryNav").value = categoryNavStart;

          found = true;
       }

       if (!found)  {
          if (document.getElementById("hidCategoryNav").value == "")  {
             document.getElementById("hidCategoryNav").value = "," + categoryId;
          } else  {
             document.getElementById("hidCategoryNav").value = document.getElementById("hidCategoryNav").value + "," + categoryId;
          }
       }
    } else  {
       document.getElementById("hidCategoryNav").value = "";
    }

    document.forms['IndexForm'].submit(); 
}

function attributes_onchange(attributeId, productRow)  {
    attributesTotal = 0;

    attributeIds = new String(document.getElementById("hidAttributeItemIds" + productRow).value);
    attributeIds = attributeIds.split(";;");

    for (j=0; j < attributeIds.length; j++)  {
        attributeId = attributeIds[j];
        if (attributeId != "")  {



    attributeValue = document.getElementById(attributeId)[document.getElementById(attributeId).selectedIndex].value;
    if (attributeValue != "" )  {
       attributePrices = new String (document.getElementById("hidAttributePrices" + attributeId).value);   

       arrAttributePrices = attributePrices.split("::");

       for (i=0; i < arrAttributePrices.length; i++)  {
           currentPrice = new String(arrAttributePrices[i]);
           attributeSearch = attributeValue + ";;";

           if (currentPrice.indexOf(attributeSearch) >= 0)  { 
              attributePrice = currentPrice.substring(currentPrice.indexOf(";;") + 2, currentPrice.length);

              tdNetPrice = new String(document.getElementById("tdNetPrice" + productRow).innerHTML);
              tdNetPrice = tdNetPrice.substring(1, tdNetPrice.length);            
              
              itemPrice = parseFloat(attributePrice);
              attributesTotal = parseFloat(attributesTotal) + parseFloat(itemPrice);
           }
       }
   } else  {
       attributesTotal += 0;
   }

}
}

itemTotal = parseFloat(document.getElementById("purchNetAmt" + productRow).value) + parseFloat(attributesTotal);
document.getElementById("tdNetPrice" + productRow).innerHTML = "$ " + itemTotal.toFixed(2);
}
