function writeSelectBox(matrix, id, size, onchange, css) {
	var d = window.document;

	var ie4 = (document.all != null);

	if (ie4) {

		var s = createIEString(matrix, id, size, onchange, css);
		document.write(s);

	}

	else {
		document.write(createXString(matrix, id, size, onchange, css));
	}
}

function createIEString(matrix, id, size, onchange, css) {
	var str = "";
	
		str += '<span class="select"';
		if (size == null)
			size = 1;
		str += ' size="' + size + '"';	
		if (id != null)
			str += ' id="' + id + '"';
		if (onchange != null)
			str += ' onchange="' + onchange + '"';
		if (css != null)
			str += ' style="' + css + '"';
		str += '>\n';
	
		str += '<table class="selectTable" cellspacing="0" cellpadding="0"\n';
		str += ' onclick="toggleDropDown(this.parentElement)">\n';
		str += '<tr>\n';
		str += '<td class="selected">&nbsp;</td>\n';
		str += '<td align="CENTER" valign="MIDDLE" class="select2"\n';
		str += ' "\n';
		str += ' >\n';
		str += '<span style="position: relative; left: 0; top: 0; width: 100%;"><IMG SRC=\'.\/bilder\/down.gif\' BORDER=0></span></td>\n';
		str += '</tr>\n';
		str += '</table>\n';
		
		str += '<div class="dropDown" onclick="optionClick()" onmouseover="optionOver()" onmouseout="optionOut()" style="width:622px;">\n';
		
		for (var i=0; i<matrix.length; i++) {
			html     = matrix[i].html;
			value    = matrix[i].value;
			css      = matrix[i].css;
			selected = matrix[i].selected;
			
			str += '<div class="option"';
			if (value != null)
				str += ' value="' + value + '"';
			if (css != null)
				str += ' style="' + css + '"';
			if (selected != null)
				str += ' selected';
			str += '>\n';
			

			str += html;

			str += '</div>\n';
		}
	

		str += '</div>\n';
		
		str += '</span>\n';
		
	return str;
}

function createXString(matrix, id, size, onchange, css) {

	var str = '<form>\n';

	str += '<select ';
	if (size == null)
		size = 1;
	str += ' size="' + size + '"';	
	if (id != null)
		str += ' id="' + id + '"';
	if (onchange != null)
		str += ' onchange="' + onchange + '"';


	str += '>\n';

	for (var i=0; i<matrix.length; i++) {
		html     = matrix[i].html;
		value    = matrix[i].value;
		css      = matrix[i].css;
		selected = matrix[i].selected;
		

		str += '\n<option';
		if (value != null)
			str += ' value="' + value + '"';
		if (selected != null)
			str += ' selected';
		str += '>';
		

		str += stripTags(html);

		str += '</option>\n';
	}
	str += '\n</select>\n';
	str += '</form>\n';

	return str;
}

function stripTags(str) {
	var s = 0;
	var e = -1;
	var r = "";

	s = str.indexOf("<",e);	

	do {
		r += str.substring(e + 1,s);
		e = str.indexOf(">",s);
		s = str.indexOf("<",e);
	}
	while ((s != -1) && (e != -1))

	r += str.substring(e + 1,str.length);

	return r;
}

function Option(html, value, css, selected) {
	this.html = html;
	this.value = value;
	this.css = css;
	this.selected = selected;
}
