/* (c)HearMe, 1999. All rights reserved.  Modifications to and reproduction
 * of this script is strictly forbidden without explicit written permission
 * from HearMe.  www.hearme.com
 */

// -------------------- Config Variables ------------------------

script_version = "a";
client_version = "1,2,0,11";

root = "http://www.hearme.com/products/vp/embedded/";

classid = "CLSID:73020B72-CDD6-4F80-8098-1B2ECD9CA4CA";
mimetype = "application/x-hearme-evp";

ie_url = root + "plugins/evp.cab#version=" + client_version;
ns_url = root + "plugins/evp.jar";

border=1;
hmimg = root + "images/hearme.gif";
help_url = "http://www.hearme.com/products/vp/evp_help.html?version="+client_version+script_version;
hml="http://www.hearme.com/company/products/";

// -------------------- Code Starts Here ------------------------
if( navigator.appVersion.charAt( 0 ) < 4 )
{
    document.writeln( "<font face=arial size=-1>To voice chat with other users, ",
        "you must have Netscape 4.0 and above or Internet Explorer 4.0 and above",
        "</font><a href=",hml,"><img src=",hmimg,"></a>");

} else if( navigator.userAgent.indexOf( "Win" ) == -1 )
{
    document.writeln("<font face=arial size=-1>To voice chat with other users, ",
        "you must have a PC with Microsoft Windows installed",
        "</font><a href=",hml,"><img src=",hmimg,"></a></TD></TR>");

} else if( navigator.userAgent.indexOf( "MSIE 3" ) == -1 )
{
    // -------------------- Detect Variables ---------------------
    var paramSettings  = new Array("Service","Domain","Vendor","Application","Deployment","Channel","Username","Talklimit","Border","Color","Width","Height","Background","Cookie","OptionsButton","StatusArea","TalkButton","TextChatButton","TextChatWindow","UserList","VUMeter");

    paramSettings["Channel"] = "";
    paramSettings["Username"] = "";
    paramSettings["Talklimit"] = 60000;

    paramSettings["Border"] = 1;
    paramSettings["Color"]  = "#aaaaaa";
    paramSettings["Width"]  = 140; 
    paramSettings["Height"] = 200;

    paramSettings["Background"] = "";
    paramSettings["Cookie"] = "";
    paramSettings["OptionsButton"] = "";
    paramSettings["StatusArea"] = "";
    paramSettings["TalkButton"] = "";
    paramSettings["TextChatButton"] = "";
    paramSettings["TextChatWindow"] = "";
    paramSettings["UserList"] = "";
    paramSettings["VUMeter"] = "";

    // ------------------- Read Parameters -----------------------

    if( document.HearMeVCC ) 
    {
        for( i=0; i<document.HearMeVCC.length; i++ )
        {
            paramSettings[document.HearMeVCC[i].name] = document.HearMeVCC[i].value;
        }
    }

    // ------------------- Hardcoded Parameters ---------------------

    paramSettings["Service"] = "EVP";

    paramSettings["Domain"] = "audiochat.hearme.com";
    paramSettings["Vendor"] = "HEARME";
    paramSettings["Application"] = "EVP";

    // ------------------- Print the HTML code ----------------------

    if( paramSettings["Border"] == 1 || paramSettings["Color"] != "" )
    {
        document.writeln( "<TABLE BORDER=", paramSettings["Border"], ">" );
        document.write( "<TR><TD width=",120 );

        if( paramSettings["Color"] != "" ) 
        {
            document.write(" bgcolor='",paramSettings["Color"],"'");
        }

        document.write( ">" );
    }

    document.writeln( "<TABLE BORDER=0>" );
    document.writeln( "<TR>" );

    if( navigator.appVersion.charAt( 0 ) < 4 || navigator.userAgent.indexOf( "MSIE 3" ) != -1 )
    {
        document.writeln( "<font face=arial size=-1>To voice chat with other users, ",
            "you must have Netscape 4.0 and above or Internet Explorer 4.0 and above",
            "</font><a href=",hml,"><img src=",hmimg,"></a>" );

    } else if( navigator.userAgent.indexOf( "Win" ) == -1 )
    {
        document.writeln( "<font face=arial size=-1>To voice chat with other users, ",
            "you must have a PC with Microsoft Windows installed",
            "</font><a href=",hml,"><img src=",hmimg,"></a></TD></TR>" );

    } else  
    {

        // ------------------- Functions ----------------------

        document.writeln("<TD align=left><A HREF='",hml,
            "' target=hearme>",
            "<IMG SRC='",hmimg,"' border=0></a></TD>",
	    "<TD align=right>",
	    "<font size=1 face=arial>",
	    "<a href='",help_url,"' target=help><b>HELP</b></a><br>",
	    "</font></TD>");

        document.writeln("</TR>");
        document.writeln("<TR><TD colspan=2>");

        // -------------------- Control ------------------------
        if( navigator.appName == "Netscape" )
        {
            if( navigator.javaEnabled() )
            {
                trigger = netscape.softupdate.Trigger;
                if( trigger.UpdateEnabled() ) 
                {
                    vi = new netscape.softupdate.VersionInfo( 1,2,0,11 );
                    trigger.ConditionalSoftwareUpdate( ns_url, 
                        "plugins/HearMe/EVP", vi, trigger.DEFAULT_MODE);

                } else alert( "Enable SmartUpdate before running this script." );

            } else {
		alert( "Enable Java before running this script." );
	    }
            document.write( "<EMBED NAME='EVP'",
                "  TYPE='",mimetype,"'",
                "  PLUGINURL='",ns_url,"'",
                "  PLUGINSPAGE=''",
                "  WIDTH='",paramSettings["Width"],"'",
                "  HEIGHT='",paramSettings["Height"],"'" );

            for( i=0; i<paramSettings.length; i++ )
            {
	        document.write("  ",paramSettings[i],"='",
                    paramSettings[paramSettings[i]],"'" );
            }

            document.write( "></EMBED>" );

        } else 
        {
            document.write("<OBJECT ID='EVP'",
                " CLASSID='",classid,"'",
                " CODEBASE='",ie_url,"'",
                "  WIDTH='",paramSettings["Width"],"'",
                "  HEIGHT='",paramSettings["Height"],"'",
                " BORDER='",border,"'>" );
            for( i=0; i<paramSettings.length; i++ ) 
            {
	        document.write( "<PARAM NAME='",paramSettings[i],"'",
                    " VALUE='",paramSettings[paramSettings[i]],"'></PARAM>" );
            }

            document.writeln("</OBJECT>");
        }
    }

    document.writeln("</TD></TR></TABLE>");

    if( paramSettings["Border"] == 1 || paramSettings["Color"] != "" )
    {
        document.writeln( "</TD></TR></TABLE>" );
    }
}

