﻿//
// JavaScript Java Object Library v1
//
// v1
// + Implementation of jsJavaObject
//

function jsJavaObject()
{
    var parameters = new Array();

    this.Archive = "";
    this.Class = "";
    this.Height = "100%";
    this.Width = "100%";
    this.Text = "";
    
    this.AddParameter = function(name, value)
    {
        var param = new Array(2);
        
        param[0] = name;
        param[1] = value;
        
        parameters.push(param);
    }
    
    
    this.Write = function(elementId)
    {
        var element = document.getElementById(elementId);
        
        if (element == null)
            return;
        
        var str = new String();
        
        str += "<!--[if !IE]>-->";
        str += "<object classid=\"java:" + this.Class + "\" type=\"application/x-java-applet\" archive=\"" + this.Archive + "\" height=\"" + this.Height + "\" width=\"" + this.Width + "\" >";
        str += "<param name=\"archive\" value=\"" + this.Archive + "\" />";
        
        for (var i = 0; i < parameters.length; i++)
        {
            str += "<param name=\"" + parameters[i][0] + "\" value=\"" + parameters[i][1] + "\" />";
        }
        
        str += "<!--<![endif]-->";

        str += "<object classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" height=\"" + this.Height + "\" width=\"" + this.Width + "\" >"
        str += "<param name=\"archive\" value=\"" + this.Archive + "\" />";
        str += "<param name=\"code\" value=\"" + this.Class + "\" />";

        for (var i = 0; i < parameters.length; i++)
        {
            str += "<param name=\"" + parameters[i][0] + "\" value=\"" + parameters[i][1] + "\" />";
        }

        str += this.Text;
        str += "</object>"
        
        str += "<!--[if !IE]>-->";
        str += "</object>"
        str += "<!--<![endif]-->";
        
        element.innerHTML = str;
    }
}
