        var shippingTotal = 0.00;
        var subtotal = 0.00;

        function carryOver(sel, price, sh)
        {
            document.getElementById(price).childNodes[0].nodeValue = parseFloat(sel.options[sel.selectedIndex].value).toFixed(2);
            getShipping();
        }

        function resetCarryOver()
        {
            document.forms[0].reset();
            var tds = document.getElementById('productTable').getElementsByTagName('td');
            for(var i = 0; i < tds.length; i++)
            {
            	if(tds[i].className == 'total')
            	{
            		tds[i].childNodes[0].nodeValue = '0.00';
            	}
            }
            document.getElementById('sping').childNodes[0].nodeValue = '$0.00';
            document.getElementById('stot').childNodes[0].nodeValue = '$0.00';
        }

        function getShipping()
        {
            shippingTotal = 0.00;
            var shlist = document.getElementsByTagName('select');
            for(var x=0; x < shlist.length; x++)
            {
                var _sh = shlist[x].getAttribute("sh");
                if(shlist[x].selectedIndex > 0)
                {
                  shippingTotal += parseFloat(shlist[x].selectedIndex) * parseFloat(_sh);
                }
            }

            document.getElementById('sping').childNodes[0].nodeValue = shippingTotal.toFixed(2);
            getTotal();
        }

        function getTotal()
        {
            subtotal = 0.00;
            var list = document.getElementById('productTable').getElementsByTagName('td');
            for(var i=0; i < list.length; i++)
            {
                if(list[i].className == 'total')
                {
                    subtotal += parseFloat(list[i].childNodes[0].nodeValue);
                }
            }
            subtotal += shippingTotal;
            document.getElementById('stot').childNodes[0].nodeValue = subtotal.toFixed(2);
        }

        function onSub()
        {
            var orderArray = new Array();
            var orderlist = document.getElementById('productTable').getElementsByTagName('select');
            for(var i=0; i < orderlist.length; i++)
            {
                var opts = orderlist[i].options;
                if(opts.selectedIndex > 0)
                {
                    orderArray.push(i + '/' + opts.selectedIndex);
                }
            }
            document.getElementById("orderlist").value = orderArray.toString();

            if(checkAddress())
            {
                document.aspnetForm.submit();
            }
            else
            {
                return false;
            }
        }

        function checkAddress()
        {
            var chkAddress = true;
            var _shipto = '';
            var _shipaddress = '';
            var _shipcity = '';
            var _shipzip = '';

            if (navigator.appName == 'Microsoft Internet Explorer')
            {
                _shipto = document.getElementById("ctl00_ContentPlaceHolder1_shipto").innerText;
                _shipaddress = document.getElementById("ctl00_ContentPlaceHolder1_shipaddress").innerText;
                _shipcity = document.getElementById("ctl00_ContentPlaceHolder1_shipcity").innerText;
                _shipzip = document.getElementById("ctl00_ContentPlaceHolder1_shipzip").innerText;
            }
            else
            {
                _shipto = document.getElementById("ctl00_ContentPlaceHolder1_shipto").textContent;
                _shipaddress = document.getElementById("ctl00_ContentPlaceHolder1_shipaddress").textContent;
                _shipcity = document.getElementById("ctl00_ContentPlaceHolder1_shipcity").textContent;
                _shipzip = document.getElementById("ctl00_ContentPlaceHolder1_shipzip").textContent;
            }

            if(_shipto.length < 1)
            {
                chkAddress = VaildationFailed('Shipping name');
            }

            if((_shipaddress.length < 1) && (chkAddress))
            {
                chkAddress = VaildationFailed('Shipping address');
            }

            if((_shipcity.length < 1) && (chkAddress))
            {
                chkAddress = VaildationFailed('Shipping city');
            }

            if(((_shipzip.length < 5) || (isNaN(_shipzip))) && (chkAddress))
            {
                chkAddress = VaildationFailed('A valid shipping zip');
            }

            return chkAddress;
        }

        function VaildationFailed(failpoint)
        {
            alert(failpoint + ' is required.');
            document.getElementById("validform").value = 'false';
            return false;
        }

        function printable()
        {
            window.open("products.xml","orderform","menubar=0,resizable=0,scrollbars=1,width=700,height=500,status=no,toolbars=no,menubars=no");
        }
