function cartHider() {

    changebutton=function(n){

        t=n.split("cart_update_");

        document.getElementById("update_button_"+t[1]).setAttribute("class", "showthis");

    }

    // turn off all the update buttons

    var myA = document.getElementsByTagName('input');

    // loop through them all

    for (var i=0;i<myA.length;i++) {

        var theid=myA[i].getAttribute("id");

        if(theid){

            var thenumber=theid.split("cart_update_");

            if(thenumber[1]!=undefined){

                targetthis=thenumber[1];

                document.getElementById("update_button_"+targetthis).setAttribute("class", "hidethis");

                document.getElementById("cart_update_"+targetthis).onchange=function(){

                    changebutton(this.id);

                }

            }

        }

    }

}



function cartChecker() {

    $("form#CartIndexForm").submit(function() {

        var error = 0;



        if($("select#ShippingRegion").val() == "") {

            error = 1;

            alert('Please select a Shipping Region');

        }



        if($("select#ShippingRegion").val() == "USA" && $("input#ShippingZipcode").val() == "") {

            error = 1;

            alert('Please enter a valid Zip Code');

        }



        if(error == 0) {

            //document.shipForm.action ="cart.php?calcShip=true";

            //document.shipForm.target = "_self";

            return true;

        } else{

            return false;

        }



    });

}



window.onload = function() {

    cartHider();

    cartChecker();

}
