function writeSelectBox(matrix, id, size, onchange, css, dropheight) {
	var d = window.document;

	var ie4 = (document.all != null);
	var userA = navigator.userAgent;
	var opera = userA.lastIndexOf("Opera")

	if (ie4 && opera == -1) {
//		alert("Before!");
		var s = createIEString(matrix, id, size, onchange, css, dropheight);
		document.write(s);
//		alert("After!");
//		alert(s);
	}

	else {
		document.write(createXString(matrix, id, size, onchange, css));
	}
}

function createIEString(matrix, id, size, onchange, css,dropheight) {
	var str = "";
	// Span startTag	
		str += '<span class="select"';
		if (size == null)
			size = 1;
		str += ' size="' + size + '"';	
		if (id != null)
			str += ' id="' + id + '"';
		if (id != null)
			str += ' name="' + id + '"';
		if (onchange != null)
			str += ' onchange="' + onchange + '"';
		if (css != null)
			str += ' style="' + css + '"';
		str += '>\n';
	
	// Table Tag
		str += '<table class="selectTable" border="0" 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="top" class="Button"\n';
		str += ' onmousedown="MM_swapImage(\'selImg\',\'\',\'../lr_maj05_pics/select-down.jpg\',1)"\n';
		str += ' onmouseup="MM_swapImgRestore()">\n';
		str += '<img src="../lr_maj05_pics/select.jpg" border="0" id="selImg"></td>\n';
		str += '</tr>\n';
		str += '</table>\n';
		
	// DropDown startTag
		str += '<div class="dropDown" style="height:' + dropheight + 'px;" onclick="optionClick()" onmouseover="optionOver()" onmouseout="optionOut()">\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;
			
		// Write option starttag
			str += '<div class="option"';
			if (value != null)
				str += ' value="' + value + '"';
			if (css != null)
				str += ' style="' + css + '"';
			if (selected != null)
				str += ' selected';
			str += '>\n';
			
		// Write HTML contents
			str += '<p>' + html + '</p>';
		// Write end tag
			str += '</div>\n';
		}
	
	//DropDown endtag
		str += '</div>\n';
		
	// Span endTag
		str += '</span>\n';
		
	return str;
}

function createXString(matrix, id, size, onchange, css) {
var str = ""
//	var str = "\n";
	// Select startTag
	str += '<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';
	// write options
	for (var i=0; i<matrix.length; i++) {
		html     = matrix[i].html;
		value    = matrix[i].value;
		css      = matrix[i].css;
		selected = matrix[i].selected;
		
	// Write option starttag
		str += '\n<option';
		if (value != null)
			str += ' value="' + value + '"';
//		if (css != null)
//			str += ' style="' + css + '"';
		if (selected != null)
			str += ' selected';
		str += '>';
		
	// Write HTML contents
		str += stripTags(html);
	// Write end tag
		str += '</option>\n';
	}
	str += '\n</select>\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;
}