/* $Id : index.js 2008-12-10 14:04:10Z nkballs $ */

/* *
 * 根据分类调用对应品牌列表
 */
function change_recommend_goods_by_type(type, channel_id)
{
  Ajax.call('channel_a_do.php?step=change_recommend_goods_by_type&channel_id=' + channel_id, 'type=' + type, changeRecommendGoodsByTypeResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应品牌列表 反馈信息
 */
function changeRecommendGoodsByTypeResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
    var recommend_goods = document.getElementById('recommend_goods');

    if (recommend_goods)
    {
      recommend_goods.innerHTML = result.content;
    }
	
	var menuInfo = document.getElementById('recommend_menu');

    if (menuInfo)
    {
      menuInfo.innerHTML = result.menu;
    }
  }
}

/* *
 * 根据分类调用对应商品列表
 */
function change_goods_by_category(category_id, channel_id)
{
  Ajax.call('channel_a_do.php?step=change_goods_by_category&channel_id='+channel_id, 'category_id=' + category_id, changeGoodsByCategoryChannelResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应商品列表 反馈信息
 */
function changeGoodsByCategoryChannelResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
	
	var child = document.getElementById('category_child');

    if (child)
    {
      child.innerHTML = result.children_list;
    }
	
	var goodsInfo = document.getElementById('goods_list');

    if (goodsInfo)
    {
      goodsInfo.innerHTML = result.goods_list;
    }
  }
}

/* *
 * 根据分类调用对应商品列表
 */
function change_sex(sex, channel_id)
{
  Ajax.call('channel_a_do.php?step=change_sex&channel_id='+channel_id, 'sex=' + sex, changeSexResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应商品列表 反馈信息
 */
function changeSexResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
    var sexx = document.getElementById('sex');

    if (sexx)
    {
      sexx.innerHTML = result.sex_info;
    }
	
	var child = document.getElementById('category_child');

    if (child)
    {
      child.innerHTML = result.children_list;
    }
	
	var goodsInfo = document.getElementById('goods_list');

    if (goodsInfo)
    {
      goodsInfo.innerHTML = result.goods_list;
    }
  }
}

