function KeyValuePair(k, v) {
	this.key = k
	this.value = v;
}

function AppletParam(n, v) {
	this.name = n;
	this.value = v;
}

function writeAppletTag(attrs, params) {
	document.write('<applet');
	if (attrs.length) {
		for (i = 0; i < attrs.length; i++)
			writeKeyValuePair(attrs[i]);
	} else {
		writeKeyValuePair(attrs);
	}
	document.write('>\n');
	
	if (params) {
		if (params.length) {
		for (i = 0; i < params.length; i++)
			writeAppletParam(params[i]);
		} else {
			writeAppletParam(params);
		}
	}
	
	document.write('</applet>');
}

function writeKeyValuePair(kvp) {
	document.write(' ');
	document.write(kvp.key);
	if (kvp.value) {
		document.write('="');
		document.write(kvp.value);
		document.write('"');	
	}
}

function writeAppletParam(p) {
	document.write('<param name="' + p.name + '" value="' + p.value + '">\n');
}
