/**
 * JAVAFN
 * @author Leon Syré
 */

if(typeof javafn == "undefined") var javafn = new Object();

javafn = function(applet, width, height, code)
{
	this.attributes = new Object();
	this.params = new Object();

	if(applet)
		this.addAttribute('archive', applet);
	if(width)
		this.addAttribute('width', width);
	if(height)
		this.addAttribute('height', height);
	if(code)
		this.addAttribute('code', code);
}

javafn.prototype.addAttribute = function(name, value)
{
	this.attributes[name] = value;
}

javafn.prototype.getAttribute = function(name)
{
	return this.attributes[name];
}

javafn.prototype.getAttributes = function()
{
	return this.attributes;
}

javafn.prototype.addParam = function(name, value)
{
	this.params[name] = value;
}

javafn.prototype.getParams = function()
{
	return this.params;
}

javafn.prototype.getParam = function(name)
{
	return this.params[name];
}

javafn.prototype.writeHTML = function(id)
{
	//void output if no jscript
	if(navigator.javaEnabled())
	{
		html = '<applet';
	
		var attributes = this.getAttributes();
		for(var key in attributes)
			html += ' ' + key + '="' + attributes[key] + '"';
	
		html += '>';
	
		var params = this.getParams();
		for(var key in params)
			html += '<param name="' + key + '" value="' + params[key] + '">';
	
		html += '</applet>';
	
		document.getElementById(id).innerHTML = html;
	}
}
