/* $Id : index.js 2008-12-10 14:04:10Z nkballs $ */

/* *
 * 根据分类调用对应品牌列表
 */
function change_brand_by_channel(channel)
{
  Ajax.call('common.php?step=change_brand_by_channel', 'channel=' + channel, changeBrandByCategoryResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应品牌列表 反馈信息
 */
function changeBrandByCategoryResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
    var brandInfo = document.getElementById('brandListByCategory');

    if (brandInfo)
    {
      brandInfo.innerHTML = result.content;
    }
	
	var menuInfo = document.getElementById('category_in_menu_brand');

    if (menuInfo)
    {
      menuInfo.innerHTML = result.category_list;
    }
  }
}

/* *
 * 根据分类调用对应商品列表
 */
function change_goods_by_category(category_id)
{
  Ajax.call('common.php?step=change_goods_by_category', 'category_id=' + category_id, changeGoodsByCategoryResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应商品列表 反馈信息
 */
function changeGoodsByCategoryResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
	var categoryInfo = document.getElementById(result.category_guide_id);

    if (categoryInfo)
    {
      categoryInfo.innerHTML = result.category_guide;
    }
	
    var childrenInfo = document.getElementById(result.children_list_id);

    if (childrenInfo)
    {
      childrenInfo.innerHTML = result.children_list;
    }
	
	var goodsInfo = document.getElementById(result.goods_list_id);

    if (goodsInfo)
    {
      goodsInfo.innerHTML = result.goods_list;
    }
  }
}

/* *
 * 根据分类调用对应品牌列表
 */
function change_recommend_goods_by_type_index(type)
{
  Ajax.call('common.php?step=change_recommend_goods_by_type', 'type=' + type, changeRecommendGoodsByTypeIndexResponse, 'POST', 'JSON');
}

/* *
 * 处理 根据分类调用对应品牌列表 反馈信息
 */
function changeRecommendGoodsByTypeIndexResponse(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;
    }
  }
}

/* *
 * 首页主体部分ajax调用文章列表
 */
function change_article_list_index(type)
{
  Ajax.call('common.php?step=change_article_list_index', 'type=' + type, changeArticleListIndexResponse, 'POST', 'JSON');
}

/* *
 * 处理 首页主体部分ajax调用文章列表 反馈信息
 */
function changeArticleListIndexResponse(result)
{
  if (result.error > 0)
  {
        location.href = './';
  }
  else
  {
    var article_list = document.getElementById('article_list');

    if (article_list)
    {
      article_list.innerHTML = result.content;
    }
  }
}
