//Workaround for selectboxes
function getOverlappingSelects(frame, obj) {
	minX = getpos_left(obj);
	maxX = minX + getsize_width(obj);

	minY = getpos_top(obj);
	maxY = minY + getsize_height(obj);

	if (frame) {
		f = document.getElementById(frame);
		if (f == null)
			return new Array ();
		marginTop = whf_getPosY (document.getElementById(frame));
		minY -= marginTop;
		maxY -= marginTop;
		selects = document.frames(frame).document.getElementsByTagName('select');
	} else
		selects = document.getElementsByTagName('select');
	len = selects.length;
	hits = new Array();

	for(j = 0; j < len; j++) {
		hitArray = isOverlappingSelect (minX, maxX, minY, maxY, selects[j]);
		if (hitArray)
			hits.push (hitArray);
	}

	return hits;
}

function isOverlappingSelect (minX, maxX, minY, maxY, obj) {
	testMinX = getpos_left(obj);
	testMaxX = testMinX + getsize_width(obj);

	testMinY = getpos_top(obj);
	testMaxY = testMinY + getsize_height(obj);
//alert ('textMinX=' + testMinX + '; testMaxX=' + testMaxX + '; minX=' + minX + '; maxX=' + maxX);
//alert ('textMinY=' + testMinY + '; testMaxY=' + testMaxY + '; minY=' + minY + '; maxY=' + maxY);
	if( ((testMinX < minX) && (testMaxX > minX)) || ((testMinX >= minX) && (testMinX < maxX)) ) {
			
		if( ((testMinY < minY) && (testMaxY > maxY)) || ((testMinY >= minY) && (testMinY < maxY)) ) {
			hitArray = new Array(5);

			//The select
			hitArray[0] = obj;

			return hitArray;
		} 
	}
	return false;
}

function hideOverlappingSelects(obj) {
	selects = getOverlappingSelects(null, obj);
	for(k = 0; k < selects.length; k++)
		selects[k][0].style.visibility = 'hidden';
}

function showOverlappingSelects(obj) {
	selects = getOverlappingSelects(null, obj);
	for(k = 0; k < selects.length; k++)
		selects[k][0].style.visibility = 'visible';
}

function getpos_left (obj) {   
	var left = 0;
	while ( obj != null ) {
		left += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return left;
}

function getpos_top (obj) {   
	var top = 0;
	while ( obj != null ) {
		top += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return top;
}

function getsize_width(obj) {
	return obj.offsetWidth;
}

function getsize_height(obj) {
	return obj.offsetHeight;
}
