//fired when quantity changed
function dosubmit2(x){
	var stk = (document.forms[x].instock.value * 1);
	
        t = eval("document." + x + ".quantity")
        failed = false
        if (isNaN(t.value))
        {
           alert("Please enter a valid number in quantity ");
           t.value = 1;
           t.focus();
           failed = true
		   
        }
        else 
        {
          if (t.value <= 0 )
          {
                        alert("Quantity cannot be zero or less");
                        t.value = 1;
                        t.focus();
						
                        failed = true
          }
        }
        
        document.forms[x].classid.value = document.forms['navigation'].classid.options[document.forms['navigation'].classid.selectedIndex].value;
        document.forms[x].email.value = document.forms['navigation'].email.value;
        
        if(t.value <= stk){
        	eval("document." +x+ ".submit()")
        } else {
        	if(stk > 1){
        	  alert('We only have ' + stk + ' items left in stock.')
        	} else {
        	  alert('We only have ' + stk + ' item left in stock.')
        	}
        	t.value = stk;
        	eval("document." +x+ ".submit()")
        }
        if (failed)
           document ['navigation'].quanttest.value = 'nogo'
        
        
}

<!---------------------FUNCTION WHICH IS FIRED WHEN SHIPPING ZONES ARE CHANGED------------------>
   //fired when shopping zones are changed

   var allowordernow = true

   function change_zone()
   {   allowordernow = false          
       var zone=document ['navigation'].zoneid.options[document ['navigation'].zoneid.selectedIndex].value;
       if (document ['navigation'].email)
          var zcemail = document ['navigation'].email.value
       else
          var zcemail = ""
       window.location.href="viewcart.asp?zoneid="+zone+"&email=" + zcemail
   }


   function change_cll()
   {
       var zone=17;
       var cll=document ['navigation'].classid.options[document ['navigation'].classid.selectedIndex].value;
       if (document ['navigation'].email)
          var zcemail = document ['navigation'].email.value
       else
          var zcemail = ""
       //window.location.href="viewcart.asp?zoneid=" + zone + "&classid=" + cll+"&email=" + zcemail

       var doc = document.forms['navigation'];
       if(document['navigation'].classid.selectedIndex == 1){
         document.getElementById('updatedelivery').innerHTML = "£3.95<br><font size='1'>(FREE for orders over £25)</font>";
       } else if(document['navigation'].classid.selectedIndex == 2){
         document.getElementById('updatedelivery').innerHTML = "£8.95<br><font size='1'>(FREE for orders over £40)</font>";
       } else if(document['navigation'].classid.selectedIndex == 3){
          document.getElementById('updatedelivery').innerHTML = "FREE<br><font size='1'>(Valid offer code required)</font>";
       } else if(document['navigation'].classid.selectedIndex == 4){
          document.getElementById('updatedelivery').innerHTML = "£7.50<br><font size='1'>(Approximately $10)</font>";
       } else if(document['navigation'].classid.selectedIndex == 5){
          document.getElementById('updatedelivery').innerHTML = "£5.00<br><font size='1'>(Approximately &euro;6)</font>";
       } else if(document['navigation'].classid.selectedIndex == 6){
          document.getElementById('updatedelivery').innerHTML = "tbc";
       } else {
         document.getElementById('updatedelivery').innerHTML = "&nbsp;";
       }
   }


   //fired when order now is clicked

   function gocart()
   {

   if (document ['navigation'])
   {
      if (document ['navigation'].zoneid)
      {
         xzval = document ['navigation'].zoneid.value
         if (xzval == -1)
         { 
            alert("Please select a shipping zone first")
            return
         }
      }  

      if (document ['navigation'].classid)
      {
         xzval = document ['navigation'].classid.value
         if (xzval == -1)
         { 
            alert("Please select a shipping class first")
            return
         }
      }

      if (allowordernow){  
         if (document ['navigation'].quanttest.value == 'go')
            document ['navigation'].submit();
         else
            document ['navigation'].quanttest.value = 'go'
         }
   }
   }              
   