$(document).ready(function(){
  $("#tradestats").load("/s/tradehandler.cgi?model_id=" + page_model_id + "&a=gs");
});

function actiontrade(action,model_id) {
  var isok = 1;
  if (action == 's') {
    alert("Sorry this action is not allowed here. Please go to your portfolio to make a sale.");
    isok = 0;
  }

  if (isok == 1) {
    $.ajax({
      url: "/s/tradehandler.cgi?i=m&a=" + action + "&model_id=" + model_id,
      cache: false,
      success: function(html){
        // do something here
        if (html == 'xb') {
          alert("Sorry you can only buy or sell once per minute per model.");
        } else {
          $("#tradestats").load("/s/tradehandler.cgi?model_id=" + model_id + "&a=gs");
          $("#buycell").html("Model has been added to your portfolio.");
        }
      }
    });
  }
}
