var combodropimage='images/downbox.gif' //path to "drop down" image
var combodropoffsetY=2 //offset of drop down menu vertically from default location (in px)
var combozindex=100

if (combodropimage!="")
	combodropimage='<img class="downimage" src="'+combodropimage+'" title="Select an option" />'

function dselect(selectid, updatedId, selectwidth, optionwidth){
	var selectbox=document.getElementById(selectid)
	var d = document.getElementById('d_' + selectid)
	var zInd = 11212;
	if (d) {
		zInd = d.style.zIndex;
		var parent = document.getElementById(selectid + '_div_static');
		try {
			parent.removeChild(d);
		} catch (e) {
			d.parentNode.removeChild(d)
		}
		var temp = '<div id="d_'+selectid+'" class="dselect"><span>' + selectbox.options[selectbox.selectedIndex].text.substr(0, 27) + " </span>"+combodropimage+'<div class="dropdown">';
		for (var i=0; i<selectbox.options.length; i++)
			temp += "<a href=\"#\" onclick=\"doUpdate('" + updatedId + "', '" + selectbox.options[i].value + "', '" + selectbox.options[i].text + "'); return false;\">" + selectbox.options[i].text + '</a>';
		temp += '</div></div>';
		parent.innerHTML += temp;
	} else {
		document.write('<div id="d_'+selectid+'" class="dselect"><span>' + selectbox.options[selectbox.selectedIndex].text.substr(0, 27) + " </span>"+combodropimage+'<div class="dropdown">')
		for (var i=0; i<selectbox.options.length; i++)
			document.write("<a href=\"#\" onclick=\"doUpdate('" + updatedId + "', '" + selectbox.options[i].value + "', '" + selectbox.options[i].text + "'); return false;\">" + selectbox.options[i].text + '</a>')
		document.write('</div></div>')
	}
	selectbox.style.display="none"
	var dhtmlselectbox=document.getElementById("d_"+selectid)
	if (zInd == 11212) {
		dhtmlselectbox.style.zIndex=combozindex
		combozindex--;
	} else {
		dhtmlselectbox.style.zIndex = zInd;
	}
	if (typeof selectwidth!="undefined")
		dhtmlselectbox.style.width=selectwidth
	if (typeof optionwidth!="undefined")
		dhtmlselectbox.getElementsByTagName("div")[0].style.width=optionwidth
	dhtmlselectbox.getElementsByTagName("div")[0].style.top=dhtmlselectbox.offsetHeight-combodropoffsetY+"px"
	if (combodropimage!="")
		//dhtmlselectbox.getElementsByTagName("img")[0].style.left=dhtmlselectbox.offsetWidth+3+"px"
	dhtmlselectbox.onmouseover=function(){
		this.getElementsByTagName("div")[0].style.display="block";
	}
	dhtmlselectbox.onmouseout=function(){
		this.getElementsByTagName("div")[0].style.display="none";
	}
}
