function PhoneHelper()
{

}
/*----------------------------------------------------------------------------*/
/*拨打电话*/
/*num为需要拨打的电话号码或手机号码*/
PhoneHelper.Dial=function(Num)
{
	window.external.Telphone_Dial(Num);
};
/*----------------------------------------------------------------------------*/
/*提机拨号*/
/*num为需要拨打的电话号码或手机号码*/
PhoneHelper.UpDial=function(Num)
{
	window.external.Telephone_SingleDial(Num);
};
/*----------------------------------------------------------------------------*/
/*挂机*/
PhoneHelper.CutLine=function()
{
    PhoneHelper.IsDiallingNumber=0;
	window.external.Telphone_CutLine();
};
/*----------------------------------------------------------------------------*/
/*提机*/
PhoneHelper.HoldUp=function()
{
	window.external.Telephone_PressLedBtn(1);
};
/*----------------------------------------------------------------------------*/
/*注册话机状态函数*/
PhoneHelper.regGetPhoneState=function(methodName)
{
    window.external.RegCallBack('getPhoneState',methodName,'JavaScript');
    /* 回调函数返回参数
  //           Action     nParam1     nParam2        pDataBuf
  //话机启动    0         0             0              NULL
  //来去电      1         LineID        (0/2)来/1去    号码
  //进入线路    2         LineID
  //退出线路    3         LineID
  //启动录音    4         LineID
  //暂停录音    5         LineID
  //保留线路    6         LineID
  //取回线路    7         LineID
  //拨号        8         LineID        0--9 A C        '0'--'9' '*' '#'
  //停止响铃    9         LineID
  //话机状态    10     当前通话线路     当前保留线路    '00000000,0,*,'
  //三方通话    11          0           0               NULL
  //PC语音      12     0=挂断/1=接通
  */
};
/*----------------------------------------------------------------------------*/
/*话机状态：默认挂机状态*/
PhoneHelper.PhoneState=0;
/*是否准备录音标识*/
PhoneHelper.IsRecording=0;
/*录音文件名称*/
PhoneHelper.SpeechFileName="";
/*服务器录音文件路径*/
PhoneHelper.ServerSpeechFileName="";
/*录音本地路径*/
PhoneHelper.SpeechFilePath="";
/*是否拨号状态*/
PhoneHelper.IsDiallingNumber=0;
/*----------------------------------------------------------------------------*/
/*即时通发送语音消息录音*/
PhoneHelper.SpeechRecord=function()
{
    var isRecord=false;
	if(PhoneHelper.PhoneState==0)
	{
	    /*准备录音*/
		window.external.Telphone_ReadingRecord();
		/*更改标识*/
        PhoneHelper.IsRecording=1;
        /*提示提机录音*/
        if(confirm('发送语音消息请提机后点击“确定”开始录音\r\n取消发送请直接点击“取消”')==true)
        {
            isRecord=true;
		    /*alert('请提机后点击“确定”开始录音');*/
		    /*开始录音*/
		    PhoneHelper.SpeechFileName=window.external.Telphone_StartRecord('fiels\\');
	    }
	    else
	    {
            PhoneHelper.IsRecording=0;
            window.external.Telphone_EndRecord();
	    }
	}
	return isRecord;
};
/*----------------------------------------------------------------------------*/
/*通话录音*/
PhoneHelper.CallStartRecord=function(dirName)
{
    var isRecord=false;
    try
    {
        /*准备录音*/
	    window.external.Telphone_ReadingRecord();
	    /*更改标识*/
        PhoneHelper.IsRecording=1;
        /*提示提机录音*/
        isRecord=true;
        /*开始录音*/
        PhoneHelper.SpeechFileName=window.external.Telphone_StartRecord(unescape(dirName));
	}
	catch(e)
	{
        PhoneHelper.IsRecording=0;
        window.external.Telphone_EndRecord();
	}
	return isRecord;
};
/*----------------------------------------------------------------------------*/
/*结束录音*/
PhoneHelper.SpeechEndRecord=function(DirName)
{
    if(typeof(DirName)=="undefined")
    {
        DirName='files\\';
	}
	PhoneHelper.SpeechFilePath=window.external.ApplicationPath()+DirName+PhoneHelper.SpeechFileName;
    window.external.Telphone_EndRecord();
	
	PhoneHelper.IsRecording=0;
};
/*----------------------------------------------------------------------------*/
/*即时通发送录音文件*/
PhoneHelper.SendSpeechRecord=function(SpeechFileName,SpeechFilePath)
{
    var isSend=false;
	PhoneHelper.SpeechFileName=SpeechFileName;
	PhoneHelper.SpeechFilePath=SpeechFilePath;
	if(PhoneHelper.SpeechFileName!="" && confirm('确定发送语音消息吗？')==true)
	{
	    isSend=true;
	    PhoneHelper.ServerSpeechFileName=window.external.Telphone_UpSpeech(PhoneHelper.SpeechFileName,'files');
	}
	window.external.FilesDelete(PhoneHelper.SpeechFilePath);
	
	return isSend;
};
/*----------------------------------------------------------------------------*/
/*当前话机状态*/
PhoneHelper.CurrentPhoneState=function()
{
    var StateObj=new Object();

	StateObj.CurLine=0;/*当前通话线路*/
	StateObj.CompanyID=0;/*当前通话公司ID*/
	StateObj.EmployeeID=0;/*当前通话联系人ID*/
	StateObj.sTel='';/*当前通话号码*/
	StateObj.sRealNo='';/*当前通话号码*/
	StateObj.Province='';/*来电号码归属省份*/
	StateObj.City='';/*来电号码归属城市*/
	StateObj.CallType=-1;/*CallType:Integer;//通话类型：0=未接，1＝已接，2＝去电*/
	
	window.external.GetLineInfoObj(StateObj);
	
	return StateObj;
};
/*----------------------------------------------------------------------------*/
/*设置出局码 */
PhoneHelper.SetOutCode=function(Code1)
{
    try
    {
	    window.external.Phone_SetOutCode(Code1, 0);
    }
    catch(e)
    {
        alert("PhoneHelper.SetOutCode:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*设置区号*/
PhoneHelper.SetAreaCode=function(AreaCode)
{
    try
    {
	    window.external.Phone_SetAreaCode(AreaCode);
    }
    catch(e)
    {
        alert("PhoneHelper.SetAreaCode:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*设置待机文字*/
PhoneHelper.SetWaitTxt=function(Txt)
{
    try
    {
	    window.external.Phone_SetWaitTxt(Txt);
    }
    catch(e)
    {
        alert("PhoneHelper.SetWaitTxt:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*设置快速拨号键*/
/*参数说明：KeyID是指键盘对应的位置，一共是1——36；注意KeyID不能为0，否则会全部清空快速拨号键*/
PhoneHelper.SetStoreKey=function(KeyID,Number)
{
    try
    {
	    window.external.Phone_SetStoreKey(KeyID,Number);
    }
    catch(e)
    {
        alert("PhoneHelper.SetStoreKey:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*设置黑名单到话机*/
/*参数说明：Tel1 是号码，Remark 是备注*/
PhoneHelper.AddTelbookRec=function(Tel1,Remark)
{
    try
    {
	    window.external.Phone_AddTelbookRec(3,"",Remark,Tel1,"","");
    }
    catch(e)
    {
        alert("PhoneHelper.AddTelbookRec:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*清空话机电话簿*/
PhoneHelper.ClearTelBook=function()
{
    try
    {
	    window.external.Phone_ClearTelBook();
    }
    catch(e)
    {
        alert("PhoneHelper.ClearTelBook:"+e.message);
    }
    CollectGarbage();
};
/*----------------------------------------------------------------------------*/
/*获取话机类型名称*/
PhoneHelper.Telphone_PhoneTypeName=function()
{
    return 'E6'; /*window.external.Telphone_PhoneTypeName();*/
};
/*----------------------------------------------------------------------------*/
/*获取话机是否连接*/
PhoneHelper.Telphone_IsConnection=function()
{
    return window.external.Phone_IsConnect();
}
