/*是否为电话号码*/
function isTel(tel)
{
  strTemp="0123456789-()#+";
  for (i=0;i<tel.length;i++)
  {
    j=strTemp.indexOf(tel.charAt(i));
    if (j==-1){return false;}
  }
  return true;
}

/*反选所有复选框(目标复选框，本身)*/
function selectAll(ctl,obj)
{
  if(!ctl)return;
  if(!ctl.length)ctl.checked=obj.checked;
  for(var i=0;i<ctl.length;i++)ctl[i].checked=obj.checked;
}

/*返回checkbox组被选中的个数*/
function cbxSel(obj)
{
  if(!obj.length)return obj.checked?1:0;
  var iSel=0;
  for(var i=0;i<obj.length;i++)
  {
    if(obj[i].checked)iSel++;
  }
  return iSel;
}

/*返回checkbox组值 a,b,c,d,e,f,g */
function cbxValue(obj)
{
  if(!obj.length)return obj.checked?obj.value:"";
  var sValue="";
  for(var i=0;i<obj.length;i++)
  {
    if(obj[i].checked)sValue+=obj[i].value+",";
  }
  return sValue.length==0?"":sValue.substring(0,sValue.length-1);
}

/*删除一条或多条记录,默认(frm.id,'index.asp') **只转到页面，不实现功能 */
function _del(obj,page)
{
  if(obj==null||obj=='')obj=frm.id;
  if(page==null||page=='')page="index.asp";
  if(cbxSel(obj)==0)return alert('请选择记录。');
  if(!confirm('Are You Sure?'))return;
  window.location=page+'?del='+cbxValue(obj);
}

/*修改记录 只能是一条,默认(frm.id,'edit.asp') **只转到页面，不实现功能 */
function _edit(obj,page)
{
  if(obj==null||obj=='')obj=frm.id;
  if(page==null||page=='')page="edit.asp";
  if(cbxSel(obj)!=1)return alert('请选择[一条]记录。');
  window.location=page+'?id='+cbxValue(obj);
}

/*是否是数字*/
function isNum(tel)
{
  strTemp="0123456789.";
  for (i=0;i<tel.length;i++)
  {
    j=strTemp.indexOf(tel.charAt(i));
    if (j==-1) return false;
  }
  return true;
}
/*是否为邮件*/
function isMail(v)
{
  if(!v.indexOf("@")>1){return false}
  if(!v.indexOf(".")>2){return false}
  return true;
}

function FrmNotSpace(obj,msg)
{
  if (obj.value=='')
  {
    alert(msg);
    obj.select();
    return false
  }
  else
  {
    return true;
  }
}


