/*是否为电话号码*/
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="";
  if(cbxSel(obj)==0)return alert('select item(s) please');
  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('select one item please');
  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;
  }
}

function reStatus(){}

function doZoom(size){
  document.getElementById('infoBody').style.fontSize=size+'px';
}

function chCatelog(obj)
{
  try
  {
    var swapObj=document.getElementById("swapObj");
    var targetObj =document.getElementById(obj.next);
    swapObj.src="/include/jsCatelog.asp?_tObj="+obj.next+"&_parentId="+obj.value;
    targetObj.length=0;
    targetObj.options[0]=new Option('请稍候','');
  }
  catch(e){}
}

function buy(id)
{
  url='/shop/shopCar.asp?id='+id;
  var windowReturnValue=window.showModalDialog(url,'','dialogWidth:650px;dialogHeight:400px;status:0;scroll:1;help:0');
  if(windowReturnValue=='checkout')window.location='/shop/checkOut.asp';
}

function initJsEditBox(obj)
{
  obj.document.designMode="on";
  obj.document.open();
  obj.document.write("<body style='font-size:12px;border:0px #000000 solid' leftmargin=0 topmargin=0 ></body>");
  obj.document.close();
}

function formatText(_action,_value)
{
  frmEdit.document.selection.createRange().execCommand(_action,false,_value);
}

function sendLocalSMS(id)
{
  url='/sms/sendLocalSMS.asp?id='+id;
  window.open(url,'_blank','width:200px;heiht:150px;top:10px;left:10px');
}

function commonSearch()
{
  window.open('/search/search.asp?Keyword='+commonKeyword.value,'_blank');
}


function quickSubmit(obj)
{
  if((event.ctrlKey && window.event.keyCode == 13) || (event.altKey && window.event.keyCode == 83)) 
  {
    obj.click();
  }
}