NM_E_NOT_ACTIVE = 0x81000203;

        
//Use NetMeeting API to launch NetMeeting and drive it into the conference
function Handle_NetMeeting_API(strProtocol, strMCUAddress, strMeetingID, strPassword, isPrivate)
{
    var ErrNo = 0;
            
    ErrNo = NetMeetingCAC.ClientJoinConference(strProtocol, strMCUAddress, strMeetingID, strPassword);

    //If NetMeeting was once open and has been closed; have user restart                
    while (NM_E_NOT_ACTIVE == ErrNo)
    {
        L_NetMeetingStopped_ErrorMessage = "Der Exchange-Konferenzdienst hat festgestellt, dass Sie NetMeeting beendet haben. Starten Sie NetMeeting neu, und klicken Sie dann auf 'OK'.";
                    
        //Allow the user to get out of the loop by clicking CANCEL
        if (!window.confirm(L_NetMeetingStopped_ErrorMessage))
        {
            //Clear the error so the user doesn't get a nasty dialog
            ErrNo = 0;
            break;
        }
        ErrNo = NetMeetingCAC.ClientJoinConference(strProtocol, strMCUAddress, strMeetingID, strPassword);
    }
                
    if (0 != ErrNo) //On any random kind of error resort to manual use                
        Handle_Manual_Launch(isPrivate)
    else
        Show_Info_Window();
}

// Displays the NetMeeting ActiveX control in the client frame
function Handle_NetMeeting_ActiveX(strProtocol, strMCUAddress, strMeetingID, strPassword, strIsPrivate, ErrNo)
{
    var bIssueCall;
    var strCallTo;
            
    L_NetMeetingID_Text = "NetMeeting";
    L_NetMeeting_Text   = "NetMeeting 3.0 inline aktiviert";
    L_NetMeetingTitle_HTMLText = "<FONT STYLE=font:verdana><U><B>Microsoft Exchange Data Conferencing Service</B></U></FONT>";
    L_NetMeetingShare_HTMLText = "<nobr><B>Share an application</B>. <wbr>First, start the application. <wbr>Then click this button and <wbr>select the application<wbr> from the dialog box. <wbr>To give another meeting participant <wbr>control of the application, <wbr>click <B>Allow control</B>.</nobr>";
    L_NetMeetingChat_HTMLText  = "<nobr><B>Chat</B>. <wbr>Click to chat with other participants.</nobr>";
    L_NetMeetingDraw_HTMLText  = "<nobr><B>Draw on a whiteboard</B>. <wbr>Click to open a whiteboard that <wbr>participants can use to make <wbr>sketches or share graphics.</nobr>";
    L_NetMeetingSend_HTMLText  = "<nobr><B>Send a file</B>. <wbr>Click to send a file to <wbr>one or more participants.</nobr>";
    L_NetMeetingSecure_HTMLText= "Sicherer Anruf";
            
    document.write('</HEAD>');
    document.write('<BODY BGCOLOR=#D4D0C8>');
    document.write('<table border="0" width="680" cellspacing="0" cellpadding="0" align="left" height="207">');
    document.write('<tr>');
    // Include the ActiveX control
    document.write('  <td width="302" rowspan="5" valign="top" height="207"><object ID=NetMeeting CLASSID="CLSID:3E9BAF2D-7A79-11d2-9334-0000F875AE17 alt="'+L_NetMeeting_Text+'"><PARAM NAME="MODE" VALUE="DataOnly"></object>');

    if ("1" == strIsPrivate)
    {
        document.write('<br>&nbsp&nbsp&nbsp&nbsp' + L_NetMeetingSecure_HTMLText);
    }

    document.write('</td>');
    document.write('</tr>');
    // Add in text descriptions for help
    document.write('<tr>');
    document.write('  <td width="31" valign="top" height="59"><img border="0" src="Share.gif" align="texttop" width="31" height="24"></td>');
    document.write('  <td>' + L_NetMeetingShare_HTMLText + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('  <td width="31" valign="top" height="26"><img border="0" src="chat.gif" align="texttop" width="31" height="24"></td>');
    document.write('  <td>' + L_NetMeetingChat_HTMLText + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('  <td width="31" valign="top" height="40"><img border="0" src="whiteboard.gif" align="texttop" width="31" height="24"></td>');
    document.write('  <td>' + L_NetMeetingDraw_HTMLText + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('  <td width="31" valign="top" height="26"><img border="0" src="send_file.gif" align="texttop" width="31" height="24"></td>');
    document.write('  <td>' + L_NetMeetingSend_HTMLText + '</td>');
    document.write('</tr>');
    document.write('</table>');

    bIssueCall = true;
            
    while (0 != NetMeeting.IsInConference())
    {
        L_NetMeetingInConference_ErrorMessage = "Der Exchange-Konferenzdienst hat festgestellt, dass Sie bereits über eine geöffnete NetMeeting-Verbindung verfügen. Bitte beenden Sie die aktuelle NetMeeting-Verbindung, und klicken Sie dann auf 'OK'.";
                    
        //Allow the user to get out of the loop by clicking CANCEL
        if (!window.confirm(L_NetMeetingInConference_ErrorMessage))
        {
            bIssueCall = false;
            break;
        }
    }

    // Make sure we should still issue the call and that the user
    // didn't have problems setting up the certificate to use
    if (true != bIssueCall)
        return;

    // Set the certificate to use only for secure conferences where
    // the user didn't have problems selecting a certificate
    if ("1" == strIsPrivate && 0 == ErrNo)
    {
        ErrNo = NetMeetingCAC.SetClientCertificate();
                
        //if (0 != ErrNo)
        //{
        //    L_ErrorSettingClientCertificate_ErrorMessage = "The Data Conferencing Service was unable to properly set the certificate that will be used for this secure conference.";
                        
        //    alert(L_ErrorSettingClientCertificate_ErrorMessage);
        //}
    }
    // Set up a basic T.120 call with no Audio/video and no H.323 preliminary negotiation
    strCallTo = strMCUAddress+"+type=host+";

    if ("H323.A" == strProtocol)
        strCallTo += "av=true+H323=true";
    else
        strCallTo += "av=false+H323=false";

    strCallTo += "+conference="+strMeetingID;
                
    if ("1" == strIsPrivate)
        strCallTo += "+secure=true";
    else
        strCallTo += "+secure=false";
                    
    if ("" != strPassword)
        strCallTo += "+password="+strPassword;
                    
    NetMeeting.CallTo(strCallTo);
}

function Notify_Private_Unsupported_Client()
{
    L_UnsupportedClient_ErrorMessage = "Um einer privaten Datenkonferenz beitreten zu können, benötigen Sie ein Konferenzclientprogramm, das private Konferenzen unterstützt, beispielsweise Microsoft(R) NetMeeting, Version 3.01 oder höher. Sie können die aktuelle Version von NetMeeting unter der Adresse http://www.microsoft.com/msdownload/iebuild/netmeet/DE/115080.htm downloaden.";
            
    alert(L_UnsupportedClient_ErrorMessage);
}

function Handle_Manual_Launch(isPrivate)
{
    //if private, we can't handle invites - redirect the
    //client to join instructions
    if ("1" == isPrivate)
    {
        Server_Invite();
    }
    else
    {
        L_StartClient_ErrorMessage = "Starten Sie Microsoft NetMeeting oder einen anderen T.120-Client, um eine Einladung zu der Datenkonferenz zu erhalten. Klicken Sie anschließend auf 'OK'.";
    
        Show_Info_Window();
        
        //Have the user start their T.120 client                
        if (window.confirm(L_StartClient_ErrorMessage))
            Server_Invite(); //Invite them into the conference
    }
}
