function renderProduct(product_id) {
  //alert(product_id);
  doAjaxRequest('CoMeT_function=run_module&module=AFS_Prod&function=afs_products&action=render_product&product_id=' + product_id, renderProductResponse);
}

function renderProductResponse(html) {
  $('#products').html(html);
}







function renderProductRecipes(product_id) {

  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=afs_recipe_links&action=update_recipe_links&product_id=' + product_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('product_recipes_list').innerHTML = resp.responseText;
        $("product_recipes_list").style.display = 'block';
      }
    }
  });
}

function doRenderProduct(product_id) {

  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=afs_products&action=render_product&product_id=' + product_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('products').innerHTML = resp.responseText;
      }
    }
  });
}


function listProductCatsUpdate(cat_id) {

  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=list_product_categories&action=list_product_categories_update&cat_id=' + cat_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('product_nav').innerHTML = resp.responseText;
        $("product_recipes_list").style.display = 'none'; //hide recipes box on click
      }
    }
  });
}

function listProductSubCategoriesUpdate(cat_id, parent_cat_id) {
  //alert('parent_cat_id: ' + parent_cat_id + ', cat_id: ' + cat_id);
  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=list_product_categories&action=list_product_sub_categories_update&parent_cat_id=' + parent_cat_id + '&cat_id=' + cat_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('subcats_' + parent_cat_id).innerHTML = resp.responseText;
        $("product_recipes_list").style.display = 'none'; //hide recipes box on click
      }
    }
  });
}

function listProductsUpdate(cat_id) {
  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=afs_products&action=list_products_update&cat_id=' + cat_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('products').innerHTML = resp.responseText;
      }
    }
  });
}

function listProductsCatUpdate(parent_cat_id) {

  var pars = 'CoMeT_function=run_module&module=AFS_Prod&function=afs_products&action=list_products_cat_update&parent_cat_id=' + parent_cat_id;

  new Ajax.Request('?',
  {
    method: 'post',
    postBody: pars,
    encoding: 'ISO-8859-1',
    onComplete: function(resp) {
      if (resp.status == 200) {
        $('products').innerHTML = resp.responseText;
      }
    }
  });
}
