document.write("<script type='text/javascript' src='js/imagePreview.js'></script>");
function calculate(id, price, stock, value)
{
	if(isNumeric(value))
	{
		stock = parseInt(stock);
		if(value > stock)
		{
			value = stock;
			$("#txtcount_" + id).val(stock);
			alert("Er zijn nog " + stock + " producten in voorraad");
		}
		var subtotal = price * value;
		var total = 0;
		
		$("#subtotal_" + id).html("&euro; " + subtotal);
		$("#txtsubtotal_" + id).val(subtotal);		

		for ( var i=0; i<products.length; i++ ){
		  total += parseInt($("#txtsubtotal_" + products[i]).val());
		}		
		
		$("#total").html("Totaal : &euro; " + total);
		
	}
	else
	{
		alert("gelieve een numerieke waarde in te geven");
	}
}

function isNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


  function removeOrder(id)
 {
	
  	if(id != "")
	{
		 $.post("remove_order.php",{
			   id: id
			 }, function(output) {
				$("#orders_container").html(output);		
		 }); 
	}

 }