' 证书下载
Dim PDCSP
Dim FTCSP
Dim TDCSP
Dim TLCSP
Dim WLCSP

PDCSP="SafeSign CSP Version 1.0"
FTCSP="EnterSafe USBKey CSP for SPDB v1.0"
TDCSP="Tendyron OnKey CSP SPDB v1.0"
TLCSP="Tendyron OnKey DB CSP SPDB v1.0"
WLCSP="Watchdata SPDB CSP v3.3"

'是否是Vista系统
Function IsVista
	Dim info
	info = navigator.appVersion	'window.clientInformation.appVersion
	If InStr(Info,"NT 6")>0 Or InStr(Info,"NT 10")>0 Then
		IsVista = true
	Else
		IsVista = false
	End if
End Function

'显示CSP列表
Sub FindProviders
	If IsVista() Then
		EnumCspsVista
	Else
		EnumCspsOthers
	End if
End Sub

'非Vista CSP列表
Sub EnumCspsOthers
		Dim i, count
		i = 0
		count=0
		Dim el
		Dim temp
		Dim selectprov
		Dim Enroll
		selectprov = -1
		On Error Resume Next
		Set Enroll = EnrollNew
		if(0 = len(Enroll.enumProviders(0,0))) Then
			Set Enroll = EnrollOld
		end if

		Do While True
			temp = ""
			Enroll.providerType = 1
			temp = Enroll.enumProviders(i,0)
			If Len(temp) = 0 Then
				Exit Do
			Else
				If temp <> "Microsoft Enhanced Cryptographic Provider v1.0" Then
					set el = document.createElement("OPTION")
					el.text = temp
					el.value = 1
					document.all.cryptprov.add(el)
					count = count + 1
					If selectprov = -1 Then
							If el.text = "Microsoft Enhanced Cryptographic Provider v1.0" Then
								selectprov = count
							End If
					End If
				End If
				i = i + 1
			End If
		Loop
		If selectprov = -1 Then
			selectprov = 0
		End If
		document.all.cryptprov.selectedIndex = selectprov
End Sub

'Vista CSP列表
Sub EnumCspsVista
	Dim Csps
	Dim Csp
	Dim el
	Dim i
	Dim indexEnhanced
    Dim selectprov
	selectprov = -1
    
	On Error Resume Next

	i = 0
	indexEnhanced = 0

	Set Csps = CreateObject("X509Enrollment.CCspInformations")
	Csps.AddAvailableCsps

	For i=0 To Csps.Count - 1
		Set Csp = Csps.ItemByIndex(i)

		If Csp.Type = 1 Then
			If Csp.Name <> "Microsoft Base Cryptographic Provider v1.0" Then
				set el = document.createElement("OPTION")
				el.text = Csp.Name
				el.value = Csp.Name

				document.all.cryptprov.add(el)
				count = count + 1
				If selectprov = -1 Then
						If el.text = "Microsoft Enhanced Cryptographic Provider v1.0" Then
							selectprov = count
						End If
				End If
			End If
		End If
	Next
	If selectprov = -1 Then
			selectprov = 0
	End If

	document.all.cryptprov.selectedIndex = selectprov
End Sub

'
Sub Load_Patch()
	
		appVersion=window.clientInformation.appVersion
		userLanguage=window.clientInformation.userLanguage
		
		'patch url location
		'Windows 98
		Win98cn="/download/patchs/323172CHS8.EXE"
		Win98en="/download/patchs/323172USA8.EXE"
		
		'WinME
		WinMEcn="/download/patchs/323172CHSM.EXE"
		WinMEen="/download/patchs/323172USAM.EXE"
		
		'Windows NT 4.0
		WinNTcn="/download/patchs/CHSQ323172i.exe"
		WinNTen="/download/patchs/Q323172i.exe"
		
		'Windows 2000
		Win2000cn="/download/patchs/q323172_W2K_SP4_X86_CN.exe"
		Win2000en="/download/patchs/q323172_W2K_SP4_X86_EN.exe"
		
		'Windows XP
		WinXPcn="/download/patchs/Q323172_WXP_SP1_x86_CHS.exe"
		WinXPen="/download/patchs/Q323172_WXP_SP1_x86_ENU.exe"
		
		msurl="/per2008/netbankFAQ.html#q5"
		
		if (Instr(1,appVersion,"Windows 98",1) <> 0) Then
			if (Instr(1,appVersion,"Win 9x 4.90",1) <> 0) Then
				Select Case userLanguage
					Case "en-us" call WritePage(WinMEen)
					Case "zh-cn" call writePage(WinMEcn)
					Case Else call writePage(msurl)
				End Select
			Else
				Select Case userLanguage
					Case "en-us" call WritePage(Win98en)
					Case "zh-cn" call writePage(Win98cn)
					Case Else call writePage(msurl)
				End Select
			End If
		End If
		
		if (Instr(1,appVersion,"Windows NT 5.0",1) <> 0) Then
			Select Case userLanguage
				Case "en-us" call WritePage(Win2000en)
				Case "zh-cn" call writePage(Win2000cn)
				Case Else call writePage(msurl)
			End Select
		End If
		
		if (Instr(1,appVersion,"Windows NT 5.1",1) <> 0) Then
			Select Case userLanguage
				Case "en-us" call WritePage(WinXPen)
				Case "zh-cn" call writePage(WinXPcn)
				Case Else call writePage(msurl)
			End Select
		End If
		
		if (Instr(1,appVersion,"Windows NT 4.0",1) <> 0) Then
			Select Case userLanguage
				Case "en-us" call WritePage(Win2000en)
				Case "zh-cn" call writePage(Win2000cn)
				Case Else call writePage(msurl)
			End Select
		End If
End Sub

'显示信息
function writePage(url)
		content="<p><B>为了正确下载浦发的证书，请首先下载补丁程序：</B>"
		
		urllocation="<p><a href='https://ebank.spdb.com.cn" + url + "'>下载</a>"
		
		document.body.innerHTML=content+urllocation
End function