
 
 /*应用层*/
function App(){}
App.Virsion={
ee:"ee",
schedule:"schedule",
main:"mian"
}
/*版本主窗体编号：*/
App.eeVirsion=-1;/*即时通版本主窗体编号*/
App.scheduleVirsion=-2;/*日程版本主窗体编号*/
App.mainVirsion=-1;/*主窗体编号*/

App.LoginUser =null;
 
/*获取当前登陆用户信息*/
App.CurrentUser=function(virsionType) {
    if(App.LoginUser==null)
    {
        var stringUrl="";
        var formIndex=-999;
        if(typeof(virsionType)=="undefined")
        {
            formIndex=window.external.GetFormIdx();
        }
        else if(virsionType==App.Virsion.ee)
        {
            formIndex=App.eeVirsion;
        }
        else if(virsionType==App.Virsion.schedule)
        {
            formIndex=App.scheduleVirsion;
        }
        else if(virsionType==App.Virsion.main)
        {
            formIndex=App.mainVirsion;
        }
        stringUrl =window.external.GetDocumentObject(formIndex).location.href;

        App.LoginUser = {};
        App.LoginUser.UserID =App.query("uid",stringUrl) == null ? 1 : App.query("uid",stringUrl);
        App.LoginUser.UserName = App.query("uname",stringUrl) == null ? "IKE" : App.query("uname",stringUrl);
        App.LoginUser.DepartmentID = 1;
        App.LoginUser.DepartmentName = "IKE";
        stringUrl=null;
        formIndex=null;
    }
    CollectGarbage();
    return App.LoginUser;
};

App.arr={
    sysc:"251%257%251%203%247%246%238%241%239",
    sysDC:"204%202%203%247%246%246%237%235%252",
    sysDH:"204%202%208%237%244%248%237%250",
    sysType:"182%236%244%244",
    sysConfigType:"182%235%238%239",
    sysPath:"220%247%247%244%211%241%252%183",
    sysbinPath:"234%241%246%183",
    firLable:"251%235%250%241%248%252%168%251%250%235%197%175",
    scLable:"175%168%244%233%246%239%253%233%239%237%197%175",
    tLable:"242%233%254%233%251%235%250%241%248%252%175",
    fLable:"252%257%248%237",
    ffLable:"197%175%252%237%256%252%183%242%233%254%233%251%235%250%241%248%252%175",
    sLable:"198%196%183",
    svLable:"251%235%250%241%248%252%198",
    scriLable:"251%235%250%241%248%252%183%198",
    scrpLable:"251%235%250%241%248%252",
    fcom:"236%247%235%253%245%237%246%252%182%255%250%241%252%237%176",
    scom:"177%195"
};
/*设置应用程序标题*/
App.SetTitle=function(_title){
   window.external.SetApplication(_title,1,0,0);
};
/*排序顺序*/
App.Sort={
    ASC:"ASC",
    DESC:"DESC"
};
/*数据库操作类型*/
App.SqlAction={
    Insert:"insert",
    Update:"update",
    Delete:"delete"
};
/*数据类型_Delphi*/
App.DataType={
        ftUnknown:'ftUnknown',
        ftString:'ftString',
        ftSmallint:'ftSmallint',
        ftInteger:'ftInteger',
        ftWord:'ftWord',
        ftBoolean:'ftBoolean',
        ftFloat:'ftFloat',
        ftCurrency:'ftCurrency',
        ftBCD:'ftBCD',
        ftDate:'ftDate',
        ftTime:'ftTime',
        ftDateTime:'ftDateTime',
        ftBytes:'ftBytes',
        ftVarBytes:'ftVarBytes',
        ftAutoInc:'ftAutoInc',
        ftBlob:'ftBlob',
        ftMemo:'ftMemo',
        ftGraphic:'ftGraphic',
        ftFmtMemo:'ftFmtMemo',
        ftParadoxOle:'ftParadoxOle',
        ftDBaseOle:'ftDBaseOle',
        ftTypedBinary:'ftTypedBinary',
        ftCursor:'ftCursor',
        ftFixedChar:'ftFixedChar',
        ftWideString:'ftWideString',
        ftLargeint:'ftLargeint',
        ftADT:'ftADT',
        ftArray:'ftArray',
        ftReference:'ftReference',
        ftDataSet:'ftDataSet',
        ftOraBlob:'ftOraBlob',
        ftOraClob:'ftOraClob',
        ftVariant:'ftVariant',
        ftInterface:'ftInterface',
        ftIDispatch:'ftIDispatch',
        ftGuid:'ftGuid',
        ftTimeStamp:'ftTimeStamp',
        ftFMTBcd:'ftFMTBcd'
}
/*应用配置*/
App.Config={
    /*分隔符*/
    split:"|"
}
/*框架路径*/
App.ApplicationPath=function()
{
    var strpath=window.external.ApplicationPath();
    return strpath;
};
/*应用程序登陆模式*/
App.GetLoginMode=function()
{
    try
    {
        return window.external.GetLoginMode();
    }
    catch(e)
    {
        return 0;
    }
};
/*消息按钮*/
App.MsgButton={
    OK:0,                           /*OK*/
    OK_Cancel:1,                    /*OK   取消*/
    Abort_Retry_Ignore:2,           /*终止   重试   忽略*/
    Yes_NO_Cancel:3,                /*是   否  取消*/
    Yes_NO:4,                       /*是 否*/
    Retrying_Cancel:5               /*重试 取消*/
};
/*消息返回值*/
App.MsgButtonValue={
    OK:1,
    Cancel:2,
    Abort:3,
    Retry:4,
    Ignore:5,
    Yes:6,
    No:7
};
/*提示框*/
App.ShowMessageBox=function(_text,_caption,_msgButton){
    if(_caption=="" || _caption==null || _caption==undefined)
    {
        _caption="提示";
    }
    var ret=window.external.ShowMessageBox(_text,_caption,_msgButton,2,1);
    return ret;
};
/*获取客户端屏幕分辨率大小*/
App.clientScreenSize=function()
{
    var sizeObj=new Object();
    sizeObj.Width=0;
    sizeObj.Height=0;
    window.external.GetScreenSize(sizeObj);
    return sizeObj;
};
/*显示泡泡提示*/
App.popShow=function(Text1,Text2,Text3,_timeout){
    window.external.ShowBalloonHint(Text1,Text2,Text3,_timeout,0,0);
};
/*获取菜单回调函数传回的值*/
App._menuX=0;
App._menuY=0;
App._menuCurrentObj=null;
App._menuAction=null;

App._getCallBack=function(_x,_y,_currentObj){
    App._menuX=_x;
    App._menuY=_y;
    App._menuCurrentObj=_currentObj;
    if(App._menuAction!=null && App._menuAction!=undefined && App._menuAction!='')
    {
        eval(App._menuAction+"()");
    }
};
/*注册菜单函数方法*/
App.regMenuMethod=function(methodName){
    App._menuAction=methodName;
    window.external.RegCallBack('OnRightButton','App._getCallBack','JavaScript');
};
/*注册托盘点击事件*/
App.regOnTrayIconClick=function(methodName)
{
    window.external.RegCallBack('OnTrayIconClick',methodName,'JavaScript');
};
/*注册鼠标拖放文件事件*/
App.regOnDropFiles=function(methodName)
{
    window.external.RegCallBack('OnDropFiles',methodName,'JavaScript');
};
/*注册关闭页面执行的动作*/
App.regFormClose=function(methodName)
{
    window.external.RegCallBack('OnFormClose',methodName,'JavaScript');
};
/*设置是否允许链接 是：1，否：0*/
App.SetNullHref=function(IsDrag)
{
    window.external.SetDragFile(IsDrag);
};
/*清除当前窗体注册动作函数*/
App.FormClearRegEvent=function(eventName)
{
    if(typeof(eventName)=='undefined')
    {
        eventName='';
    }
    window.external.FormClearRegEvent(eventName);
};
/*生成菜单对象*/
App.MenuObj=function(){
    var MenuObj=new Object();
	MenuObj.Caption=new Array();
	MenuObj.OnClick=new Array();
	MenuObj.Enabled=new Array();
	MenuObj.Visible=new Array();
	MenuObj.ParentIdx=new Array();
	MenuObj.Checked=new Array();
	MenuObj.RadioItem=new Array();
	MenuObj.ScriptType='JavaScript';
	
	return MenuObj;
};
/*调用方式
		
	MenuObj.Caption[0]='新建文档';		
	MenuObj.OnClick[0]='PopupItemClick(0,1,2,"abcd")';
	MenuObj.Enabled[0]=1;
	MenuObj.Visible[0]=1;	
	MenuObj.ParentIdx[0]=-1;
	
	MenuObj.Caption[1]='打开文档';	
	MenuObj.OnClick[1]='';
	MenuObj.Enabled[1]=1;
	MenuObj.Visible[1]=1;
	MenuObj.ParentIdx[1]=-1;
	
	MenuObj.Caption[2]='保存文档';	
	MenuObj.OnClick[2]='PopupItemClick(2,3,4,"efgh")';
	MenuObj.Enabled[2]=0;
	MenuObj.Visible[2]=1;
	MenuObj.ParentIdx[2]=-1;	

	
	MenuObj.Caption[3]='打开文档 1';	
	MenuObj.OnClick[3]='PopupItemClick(3,4,5,"ijkl")';
	MenuObj.Enabled[3]=1;
	MenuObj.Visible[3]=1;
	MenuObj.ParentIdx[3]=1;	

	
	MenuObj.Caption[4]='打开文档 2';	
	MenuObj.OnClick[4]='PopupItemClick(4,5,6,"mnop")';
	MenuObj.Enabled[4]=1;
	MenuObj.Visible[4]=1;
	MenuObj.ParentIdx[4]=1;	

  App.menuShow(MenuObj);
*/

/*菜单显示方法*/
App.menuShow=function(MenuObj){
    for(i=0;i<MenuObj.Caption.length;i++)
    {
        if(MenuObj.Enabled[i]==undefined)
        {
            MenuObj.Enabled[i]=1;
        }
        if(MenuObj.Visible[i]==undefined)
        {
            MenuObj.Visible[i]=1;
        }
        if(MenuObj.Checked[i]==undefined)
        {
            MenuObj.Checked[i]=0;
        }
        if(MenuObj.RadioItem[i]==undefined)
        {
            MenuObj.RadioItem[i]=0;
        }
        if(MenuObj.OnClick[i]==undefined)
        {
            MenuObj.OnClick[i]="";
        }
        if(MenuObj.ParentIdx[i]==undefined)
        {
            MenuObj.ParentIdx[i]=-1;
        }
    }
	MenuObj.Count=MenuObj.Caption.length;
    window.external.ShowPopupMenu(App._menuX,App._menuY,MenuObj);
    
    MenuObj=null;
};
/*文件处理*/
/*上传文件*/
App.UpFile=function(FilePath,FileName,ShowProgress)
{
    return window.external.UpFile(unescape(FilePath),unescape(FileName),ShowProgress);
};
/*下载文件*/
App.DownLoadFile=function(FileName,SaveFileName,ShowProgress,ftpPath)
{
    if(typeof(ftpPath)=="undefined" || ftpPath=="undefined")
    {
        ftpPath="";
    }
    return window.external.DownFile(unescape(ftpPath),unescape(FileName),unescape(SaveFileName),ShowProgress);
};
/*下载文件*/
App.DownFile_NotSelect=function(SeverFileName,SaveFilePath,SaveFileName,ShowProgress,ftpPath)
{
    if(typeof(ftpPath)=="undefined" || ftpPath=="undefined")
    {
        ftpPath="";
    }
    return window.external.DownFile_NotSelect(unescape(ftpPath),unescape(SeverFileName),unescape(SaveFilePath),unescape(SaveFileName),ShowProgress);
};
/*打开文件*/
App.OpenFile=function(FileName)
{
    window.external.OpenFile(FileName);
};
/*
获取文件大小：
单位为：字节
*/
App.FileSize=function(FilePath)
{
    return  window.external.FileSize(FilePath);
}
/*读取本地文件*/
App.ReadFile=function(Path,FileName)
{
   return window.external.FilesRead(Path,FileName);
};
/*创建本地文件*/
App.CreateFile=function(Path,FileName,Content)
{
   return window.external.FilesCreate(Path,FileName,Content);
};
/*加载文件*/
App.LoadFile=function(){
    return window.external.LoadFile();
};
/*删除服务器文件*/
App.DeleteFile=function(FileName,ftpPath){
    if(typeof(ftpPath)=="undefined" || ftpPath=="undefined")
    {
        ftpPath="";
    }
    return window.external.DeleteServerFile(unescape(ftpPath),unescape(FileName));
};
/*复制文件*/
App.FileCopy=function(FilePath,FileName){
    window.external.FilesCopy(FilePath,FileName);
}
/*剪切文件*/
App.FileMove=function(FilePath,FileName){
    window.external.FilesMove(unescape(FilePath),FileName);
}
/*复制文件无路径选择*/
App.FileCopy_Nodialog=function(FilePath,FileName){
    window.external.FileCopy_Nodialog(FilePath,FileName);
}
/*剪切文件无路径选择*/
App.FileMove_Nodialog=function(FilePath,FileName){
    window.external.FileMove_Nodialog(unescape(FilePath),FileName);
}
/*删除本地文件*/
App.FileDelete=function(FilePath){
    window.external.FilesDelete(unescape(FilePath));
}
/*检验文件是否存在*/
App.FileIsExist=function(FileFullName)
{
    return window.external.FileIsExist(unescape(FileFullName));
};
/*判断指定文件夹是否存在*/
App.DirectIsExist=function(Path)
{
    return window.external.Direct_Exist(unescape(Path));
};
/*创建本地文件夹*/
App.Direct_Create=function(Path)
{
    return window.external.Direct_Create(unescape(Path));
};
/*删除本地文件夹*/
App.Direct_Delete=function(Path)
{
    return window.external.Direct_Delete(unescape(Path));
};
/*选择本地文件夹*/
App.Direct_Load=function(DefultFileName)
{
    return window.external.Direct_Load(unescape(DefultFileName));
};
/*定时处理回调函数*/
App._CallBackFrameMethod=function(ifrmIndex,iThreadNum,iSTime,MethodName)
{
    window.external.RegCBTimer(ifrmIndex,iThreadNum,iSTime,MethodName);
};
/*闪烁托盘头像*/
App.FlashIcon=function(FormIndex,OnOff,nType,nId,nParam1,nParam2,nParam3,sParam4,sParam5,sParam6)
{
    window.external.FlashTrayIcon(FormIndex,OnOff,nType,nId,nParam1,nParam2,nParam3,sParam4,sParam5,sParam6);
};
/*停止托盘头像闪烁*/
App.StopFlashIcon=function(FormIndex)
{
    window.external.FlashTrayIcon(FormIndex,0,0,0,0,0,0,"","","");
};
/*创建短信对象*/
App.NewSmsObj=function()
{
    var _NewSmsObj=new Object();
    
    /*号码个数*/
    _NewSmsObj.MobileCount=0;
    /*号码组*/
    _NewSmsObj.MobileAry=new Array();;
    /*短信内容*/
    _NewSmsObj.SmsContent="";
    /*是否显示发送短信窗体：0是不显示，1是显示*/
    _NewSmsObj.nShowForm=1;
    
    return _NewSmsObj;
    
/*  MobileCount:Integer;*/
/*  MobileAry:Array of String;*/
/*  SmsContent:String;*/
/*  nShowForm:Integer*/

};
/*发送短信*/
App.SendInformation=function(SmsObj)
{
    return window.external.Information_Send(SmsObj);
};
/*创建邮件对象*/
App.NewEmailObj=function()
{
    var _NewEmailObj=new Object();
    
    /*接收邮件地址个数*/
    _NewEmailObj.AddressCount=0;
    /*接收邮件地址组合*/
    _NewEmailObj.AddressAry=new Array();
    /*附件个数*/
    _NewEmailObj.AttachCount=0;
    /*附件地址组合*/
    _NewEmailObj.AttachFile=new Array();
    /*邮件标题*/
    _NewEmailObj.Title="";
    /*邮件内容*/
    _NewEmailObj.Content="";
    /*是否显示编写邮件窗体：0是不显示，1是显示*/
    _NewEmailObj.nShowForm=1;
    
    return _NewEmailObj;
    
/*  AddressCount:Integer;*/
/*  AddressAry:Array of String;*/
/*  AttachCount:Integer;*/
/*  AttachFile:Array of String;*/
/*  Title:String;*/
/*  Content:String;*/
/*  nShowForm:Integer*/


};
/*发送邮件*/
App.SendEmail=function(EmailObj)
{
    return window.external.Email_Send(EmailObj);
};
/*发送传真*/
App.SendTax=function(GetTaxNumGroup,TaxContent,TaxType)
{
    return window.external.Tax_Send(GetTaxNumGroup,TaxContent,TaxType);
};
/*截屏*/
App.CutScreen=function(SaveFolder)
{
    return window.external.InterceptScreenToJpg(SaveFolder);
};
/*导出到excel*/
/*参数说明：*/
/*1、FieldOb  */
/* 
		var FieldObj=new object();
		FieldObj.Count=5;
		FieldObj.Caption=new Array();
		FieldObj.FieldName=new Array();

		FieldObj.Caption[0]='简称';
		FieldObj.FieldName[0]='SIMPLE_NAME';
*/
/*2、DataObject：为导出数据的集合
3、showDialog：是否显示存放地址选择对话框
4、saveFileFullName：保存完整路径包括文件名*/
App.ExportExcel=function(FieldOb,DataObject,saveFileFullName)
{
    var fileFullName="";
    if(typeof(saveFileFullName)=="undefined" || saveFileFullName==null ||saveFileFullName=="")
    {
        fileFullName="";
    }
    else
    {
        fileFullName=saveFileFullName;
    }
    window.external.ExportExcelFile(FieldOb,DataObject,fileFullName);
    fileFullName=null;
};
/*禁用回退和刷新功能 */
App.forbidBackSpace=function() 
{ /*BackSpace CtrlN,CtrlR F5 */
    if (((event.keyCode == 8) &&                                                    
         ((event.srcElement.type != "text" && 
         event.srcElement.type != "textarea" && 
         event.srcElement.type != "password") || 
         event.srcElement.readOnly == true)) || 
        ((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82)) ) ||(event.keyCode == 116) 
        ) {                                                   
        event.keyCode = 0; 
        event.returnValue = false; 
    } 
};
/*获取路径参数指*/
App.query=function(item,urlValue) {
    var url=null;
    if(typeof(urlValue)=="undefined")
    {
        url=location.search;
    }
    else
    {
        url=urlValue;
    }
	var svalue = url.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
	url=null;
	urlValue=null;
    return svalue ? svalue[1] : svalue;

};
/*根据IE版本得到边界变化值*/
App.ieMargin=function()
{
    var marginValue=0;
    if (window.XMLHttpRequest) 
    {
        if (!window.ActiveXObject) 
        {
            marginValue = 11; /*Mozilla, Safari,...*/
        } 
        else 
        {
            marginValue = 5; /*IE7*/
        }
    } 
    else 
    {
        marginValue =5; /*IE6*/
    }
    return marginValue;
};
/*根据IE版本得到水平边界变化值*/
App.ieHorMargin=function()
{
    var marginValue=0;
    if (window.XMLHttpRequest) 
    {
        if (!window.ActiveXObject) 
        {
            marginValue = 21; /*Mozilla, Safari,...*/
        } 
        else 
        {
            marginValue = 10; /*IE7*/
        }
    } 
    else 
    {
        marginValue =0; /*IE6*/
    }
    return marginValue;
};
/*打开IE浏览器*/
App.OpenIE=function(UrlValue)
{
    window.external.OpenIE(UrlValue);
};
/*-------------------------------------------------------------*/
/*字符集合*/
 function StringBuffer()
 {
     this._strings_=new Array();
 }
 StringBuffer.prototype.appendLine=function (str)
 {
    this._strings_.push(str);
 }
 StringBuffer.prototype.toString=function ()
 {
     return this._strings_.join("");
 }
 StringBuffer.prototype.clear=function ()
 {
    this._strings_=null;
    this._strings_=new Array();
 }
/*-------------------------------------------------------------*/