'common.vbs
'去除字符串两端空格

function JTrim(strInput)
	JTrim=trim(strInput)
end function
'date.vbs
   
    '===========================================
    '计算两日期相差的日期年月日等
    '===========================================
    
    function vbDateDiff(interval,date1,date2,firstdayofweek,firstdayofyear)
	    vbDateDiff = DateDiff(interval,date1,date2,firstdayofweek,firstdayofyear)
    end function

   
	'	返回表达式，此表达式已被格式化为日期或时间。 
	'
	'	    vbFormatDateTime(Date[, NamedFormat])
	'
	'	    参数
	'	    Date
	'
	'	    必选项。要被格式化的日期表达式。
	'
	'	    NamedFormat
	'
	'	    可选项。指示所使用的日期/时间格式的数值，如果省略，则使用 vbGeneralDate。
    function vbFormatDateTime(expression,namedFormat)
	    vbFormatDateTime = FormatDateTime(expression,namedFormat)
    end function
	
	' 是否为日期 
    function vbIsDate(expression)
	    vbIsDate = IsDate(expression)
    end function
    
	function vbCBool(expression)
		vbCBool = CBool(expression)
	end function

	function vbNow()
		vbNow = Now()
	end function    
	'检查客户端组件否则已经安装
    function CheckIsObjectInstalled(strClassString)
	    on error Resume Next
	    dim bIsObjectInstalled 
	    bIsObjectInstalled=false
	    
	    dim xTestObj
	    err.Clear 
	    set xTestObj=CreateObject(strClassString)
	    if (err.number=0) and (xTestObj="[object]") then 
	        bIsObjectInstalled=true
	    end if 
	    set xTestObj=nothing
	    err.Clear 
	    CheckIsObjectInstalled=bIsObjectInstalled
	end function
	'设置IE的安全
	function SetRegisterSecurity()
	    on error resume next
	    dim WshShell
	    set WshShell =CreateObject("WScript.Shell")
	    '设置控件的安全模式
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1001", "0", "REG_DWORD"
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1004", "0", "REG_DWORD"
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1200", "0", "REG_DWORD"
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1201", "0", "REG_DWORD"
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1405", "0", "REG_DWORD"
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\2201", "0", "REG_DWORD"
        '禁用xinxp弹出窗口阻止程序
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\PopupMgr", "no"
        '设置IE检查所有页面的较新版本 为每次访问此页面时检查 
        WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\SyncMode5", "3", "REG_DWORD"
	end function
	'检查并运行
    function CheckAndUpdateClientCAB()
        SetRegisterSecurity
        if (CheckIsObjectInstalled("LeadingMISHtmlToOffice.ExcelExport")=false) then
            window.open("/Utility/CAB/理正客户端安装包.rar")
        end if
    end function	
  