var combodropimage=''; //path to "drop down" image
var combodropoffsetY=2; //offset of drop down menu vertically from default location (in px)
var combozindex=100;
var openMeUp=false;

if (combodropimage!="")
	combodropimage='<img class="downimage" src="'+combodropimage+'" title="Select an option" />';

function dhtmlselect(selectid, selectwidth, optionwidth, url, openUp, btnClass, imgClass){
	if (cssDisabled()==true) return 0;
	if (openUp==true) openMeUp=true;
	else openMeUp=false;
	var selectbox=document.getElementById(selectid);
	document.write('<div id="dhtml_'+selectid+'" class="'+btnClass+'"><div id="dropdownitems_'+selectid+'" class="'+imgClass+'">')
	for (var i=0; i<selectbox.options.length; i++) {
		document.write('<a href="'+url+selectbox.options[i].value+'">'+selectbox.options[i].text+'</a>')
	}
	document.write('</div>'+selectbox.title+" "+combodropimage+'</div>');
	selectbox.style.display="none";
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid);
	dhtmlselectbox.style.zIndex=combozindex;
	combozindex--;
	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";
	if (openMeUp==true) {
		dhtmlselectbox.onmouseover=function(){
			var meH = this.offsetHeight - 5;
			var el = this.getElementsByTagName("div")[0];
			el.style.display="block";
			el.style.top=this.offsetHeight-combodropoffsetY-el.offsetHeight-meH+"px";	
		};
	} else {
		dhtmlselectbox.onmouseover=function(){
			var meH = this.offsetHeight - 5;
			var el = this.getElementsByTagName("div")[0];
			el.style.display="block";
		};
	}
	dhtmlselectbox.onmouseout=function(){
		this.getElementsByTagName("div")[0].style.display="none";
	};
}

function cssDisabled() {
	var cssdisabled = false; // must be proven otherwise
	var testcss = document.createElement('div');
	testcss.style.position = 'absolute';
	document.getElementsByTagName('body')[0].appendChild(testcss);
	if (testcss.currentStyle) var currstyle = testcss.currentStyle['position'];
	else if (window.getComputedStyle) var currstyle = document.defaultView.getComputedStyle(testcss, null).getPropertyValue('position');
	var cssdisabled = (currstyle == 'static') ? true : false;
	document.getElementsByTagName('body')[0].removeChild(testcss);
	return cssdisabled;
}