	var so = new SWFObject("images/flash4.swf", "flash", "599", "251", "7", "#666666");
    so.addParam("wmode","transparent");
    so.addParam("flash");so.write("flash");

    function add_shoppingcart(pid)
    {
      var qty=jQuery('#txt_quantity').val();      
      var size=jQuery('#sel_size').val();
      var width=jQuery('#sel_width').val();
      var url="ajax.clophill.php";
      var params={"case":"add_cart","productid":pid,"quantity":qty,"sizeid":size,"widthid":width};
      jQuery.getJSON(url,params,add_shoppingcart_result);  
       
      jQuery('#addtocart_'+pid).hide();
			jQuery('#process_'+pid).show();	  
    }
    
    function add_shoppingcart_result(arr)
    {
      var sum=0;	
      var width=Number(arr['product_width']);
      var sizename=arr['size_name'];
      jQuery('#addtocart_'+arr['id']).show();
			jQuery('#process_'+arr['id']).hide();
			jQuery('#subtotal').html(Number(arr["totalamount"]).toFixed(2));
			var sum=Number(jQuery('#subtotal').text());
      
      //alert(Number(arr["totalamount"]).toFixed(2))
      if(arr["status"]==1)      
      {
        jQuery('#pname_'+arr['shoppingid']).html(arr["name"]);      
        jQuery('#pqty_'+arr['shoppingid']).html(arr["qty"]);      
        jQuery('#price_'+arr['shoppingid']).html(arr["price"].toFixed(2));
        jQuery('#subtotal').html(Number(arr["totalamount"]).toFixed(2));
      }
      else if(arr["status"]==0)
      { 
        jQuery('#shoppingcart').append('<tr><td id="pname_'+arr['shoppingid']+'" width="35%" align="left">'+arr['pname']+'<\/td><td id="pqty_'+arr['shoppingid']+'" width="40%" align="right">'+arr['qty']+'<\/td><td id="price_'+arr['shoppingid']+'" align="right" width="25%">'+arr['price'].toFixed(2)+'<\/td><\/tr>');
      } 
      if(sizename!="")
        {
          //alert(width);
          jQuery('#pname_'+arr['shoppingid']).html(arr["pname"]+"("+sizename+")"); 
        }
        if(width>0)
        {
          //alert(width);
          jQuery('#pqty_'+arr['shoppingid']).html("("+arr["qty"]+"*"+width+")"); 
        }
      
      //jQuery('#subtotal').html(Number(arr["totalamount"]).toFixed(2)); 

      //jQuery('#frm_final_total').val(jQuery("#total_amount").html());
      var delivery=Number(arr["delivery_amount"]);
      jQuery('#delivery').text(delivery.toFixed(2));            
			var vat=(sum+delivery) * (vat_rate/100);			
			jQuery('#vat').text(vat.toFixed(2));      
			var grand_total=sum+vat+delivery;
			jQuery('#gtotal').text(grand_total.toFixed(2));
    }

