1) The clear cart code is set to trigger on post:
if ((Request.ServerVariables("Request_Method") = "POST")) then
you should set it to trigger an page load:
if (("" = "")) then
2) The code should not be before the doctype, it should be after the closing HTML.