/* $Id: listtable.js 8049 2007-04-10 02:54:11Z scottye $ */
var listTable = new Object;

var st=(location.href.lastIndexOf("/")) + 1;
var ed=location.href.lastIndexOf("?");
if(ed<=0)ed=location.href.length;
listTable.url=location.href.substring(st,ed) + "?is_ajax=0";
/**
 * 翻页
 */
listTable.gotoPage = function(page,args)
{
    window.location.href=listTable.url+"&page="+page+"&search=1"+args;
}
/**
 * 分类跳转
 */
listTable.cat= function(obj,opt,cfm)
{
  var  id= obj.options[obj.selectedIndex].value; 
  args = "&act=" + opt + "&id=" + id;
  window.location.href=listTable.url+args;
}
/**
 * 表操作处理
 */
listTable.control = function(id,opt,cfm)
{
   if(opt=='view')
  {
	  window.open(cfm+'?id='+id);
  }
  else
  {
    var args ="&act=" + opt + "&id=" + id;
    if(cfm!='')
    {
	  if(confirm(cfm))window.location.href=listTable.url+args;
    }
	else
	{
	  window.location.href=listTable.url+args;	
	}
  }
}
/* *
 * 处理下拉列表改变的函数
 *
 * @obj     object  下拉列表
 * @type    integer 类型
 * @selName string  目标列表框的名称
 */
listTable.slt = function(obj)
{
  var cat_id= obj.options[obj.selectedIndex].value;
  var args="&cat_id="+cat_id;
  window.location.href=listTable.url+args;
}
/**
 * 全选
 */
listTable.selectAll = function(obj, chk)
{
  if (chk == null)
  {
    chk = 'checkboxes';
  }

  var elems = obj.form.getElementsByTagName("INPUT");

  for (var i=0; i < elems.length; i++)
  {
    if (elems[i].name == chk || elems[i].name == chk + "[]")
    {
      elems[i].checked = obj.checked;
    }
  }
}