<html>
<body>
<h2>This is unit test page of SAF Channel object</h2>
<div>
<table>
<tr>
<td>Vendor Name:</td>
<td><Input id="VendorName" Value="Microsoft" size=30></input></td>
<tr>
<td>VendorID:</td>
<td><Input id="VendorID" Value="CN=Microsoft Corporation,L=Redmond,S=Washington,C=US" size=50></Input></td>
<tr>
<td>Config file location:</td>
<td><Input id="ConfigFile" value="d:\mpc\helpctr\saf\test\config.xml" size=80 type=file></input><input type=button value="view xml" Onclick=ViewXML()></td>
<tr>
<td align=right><Input type=button value="Register Support Channel" OnClick=Register()></Input></td>
<td align=right><Input type=button value="Remove Support Channel" OnClick=RemoveChannel()></Input></td>
</table>
</div>
<br>
<hr>
<div>
<table>
<tr>
<td>ProductID:</td>
<td><Input id="ProductID" Value="Microsoft Millennium Beta" size=50></Input></td>
<tr>
<td>Display String:</td>
<td><Input id="Display" Value="This is the Microsoft Word bug #1" size=50></Input></td>
<tr>
<td>URL:</td>
<td><Input id="URL" Value="http://support.microsoft.com/word?ASP=1" size=50></Input></td>
<tr>
<td>Progress:</td>
<td><Input id="Progress" Value="Building..." size=50></Input></td>
<tr>
<td>XML Data File:</td>
<td><Input id="XMLDataFile" value="d:\mpc\helpctr\saf\test\config.xml" size=80 type=file></td>
<tr>
<td align=right><Input type=button value="Add Incident" OnClick=AddIncident()></Input></td>
<td align=right><input type=button value="Close Incident" OnClick=CloseIncident()></td>
<td align=right><Input type=button value="Remove Incident" OnClick=RemoveIncident()></td>
</table>
</div>
<br>
<hr>
<div>
<table>
<tr>
<td>Use above VendorID and ProductID as the channel ID.
<tr>
<td><input type=button value="Show Channel Open-incidents" OnClick=ShowOpenedInc()></td>
<td><input type=button value="Show Channel Closed-incidents" OnClick=ShowClosedInc()></td>
</table>
</div>
<br>
<hr>
<table>
<tr>
<td><input type=button value="Show All Channels" OnClick=ShowAllChannel()></td>
<tr>
<td><hr></td>
<tr>
<td><input type=button value="Show me vendor directory" OnClick=ShowVendorDirectory()></td>
</table>

</body>
<Script Language=VBScript>
Sub ViewXML()
    if Len(ConfigFile.Value) = 0 Then
        MsgBox "Please select file first"
    else
        Dim x
        set x = Window.open(ConfigFile.Value)
        x.focus
    end if
End Sub

Sub ShowOpenedInc()
    Dim x
    set x = Window.open("status_test.htm")
    x.focus
End Sub

Sub ShowClosedInc()
    Dim x
    set x = Window.Open("status_h_test.htm")
    x.focus
End Sub

Sub ShowAllChannel()
    Dim x
    set x = Window.Open("Vendor_test.htm")
    x.focus
End Sub

Sub RemoveChannel()
    Dim x
    Set x = CreateObject("SAF.SAFAPI")
    call x.RemoveSupportChannel(VendorID.Value, VendorName.Value, ConfigFile.Value)
    Set x = Nothing
End Sub

Sub Register()
    Dim x
    Set x = CreateObject("SAF.SAFAPI")
    call x.RegisterSupportChannel(VendorID.Value, VendorName.Value, ConfigFile.Value)
    Set x = Nothing
End Sub

Sub AddIncident()
'MsgBox VendorID.value
    Dim x, y
    set x = CreateObject("SAF.SAFAPI")
    set y = x.GetChannel(VendorID.Value, ProductID.Value)
    y.RecordIncident Display.Value, URL.Value, Progress.Value, XMLDataFile.Value
    set y = Nothing
    set x = Nothing
End Sub

Sub ShowVendorDirectory()
    Dim x, y
    set x = CreateObject("SAF.SAFAPI")
    set y = x.GetChannel(VendorID.Value, ProductID.Value)
    MsgBox "Path: " & y.VendorDirectory
    set y = Nothing
    set x = Nothing
End Sub

Sub CloseIncident()
    Dim x
	Dim y
	Dim z
    Set x = CreateObject("SAF.SAFAPI")
    Set y = x.GetChannel(VendorID.Value, ProductID.Value)
    Set z = y.Incidents(2)
    For Each oItem In z
        If oItem.URL = URL.Value Then
		    oItem.CloseIncidentItem
            Exit For
        End if
    next
End Sub

Sub RemoveIncident()
    Dim x
	Dim y
	Dim z
    Set x = CreateObject("SAF.SAFAPI")
    Set y = x.GetChannel(VendorID.Value, ProductID.Value)
    Set z = y.Incidents(1)
    For Each oItem In z
        If oItem.URL = URL.Value Then
		    oItem.DeleteIncidentItem
            Exit For
        End if
    next
End Sub
</Script>
</html>