
var dlmCol = '||', dlmRow = '##';

function DropDownButton(text, items, btnID, btnClass, itmClass, btnOnclick, xoffset, yoffset) {
	var html = '', itemsHtml = '';	
	xoffset = xoffset ? xoffset : 0;
	yoffset = yoffset ? yoffset : 0;
	
	if (btnID == null || btnID == '') {
		if (typeof(window.ddbAutoID) == 'undefined')
			window.ddbAutoID = 0;
		else
			window.ddbAutoID ++;
		btnID = 'ddb_' + window.ddbAutoID;
	}

	var itemsID = btnID +'_items';

	html += '<a ID="'+ btnID +'" href=# style="cursor:hand" class="'+ btnClass +'" onmouseover="ddb_showItems('+ itemsID +', this, '+ xoffset +', '+ yoffset +')" onmouseout="ddb_hideItems('+ itemsID +', this)">';
	html += text;
	html += '</a>';

	itemsHtml += '<div style="position:absolute;display:none;" ID="'+ itemsID +'" onmouseover="ddb_showItems('+ itemsID +', '+ btnID +', '+ xoffset +', '+ yoffset +')" onmouseout="ddb_hideItems('+ itemsID +', '+ btnID +')">';
	itemsHtml += '<table class="'+ itmClass +'" cellspacing=1 cellpadding=0 bgcolor="#D4D0C8">';
	var i, arows = items.split(dlmRow);
	for (i=0; i<arows.length; i++) {
		if (arows[i] != '') {
			var acols = arows[i].split(dlmCol);
			if (acols.length > 1 && acols[0] != '') {
				itemsHtml += '<tr><td><a href="'+ acols[1] +'">'+ acols[0] +'</a></td></tr>';
			}
		}
		
	}
	itemsHtml += '</table></div>';
	document.write(html + itemsHtml);
//	alert(html + itemsHtml);
}

function ddb_showItems(oItems, oBase, xoffset, yoffset) {
	var y = ddb_getTop(oBase) + yoffset;
	var x = ddb_getLeft(oBase) + xoffset;
	oItems.style.left = x;
	oItems.style.top = y + oBase.offsetHeight;
	oItems.style.display = '';
}

function ddb_hideItems(oItems, oBase) {
	oItems.style.display = 'none';
}

function ddb_getTop (o) {
	var nTop=0;
	while (o.tagName != "BODY") {
		nTop += o.offsetTop;
		o = o.offsetParent;
	}
	return nTop;
}

function ddb_getLeft (o) {
	var nLeft=0;
	while (o.tagName != "BODY") {
		nLeft += o.offsetLeft;
		o = o.offsetParent;
	}
	return nLeft;
}
