
var allDropDownMenus=false;

function preloadStupidMSIEElementsPosition() {
	allDropDownMenus = document.getElementsByTagName('select');
	preloadedPositions = new Array;
	for (var i=0; i < allDropDownMenus.length; i++) {
		index = preloadedPositions.length;
		p = getAbsolutePos(allDropDownMenus[i]);
		preloadedPositions[index] = new Array;
		preloadedPositions[index]['object'] = allDropDownMenus[i];
		preloadedPositions[index]['x'] = p.x;
		preloadedPositions[index]['y'] = p.y;
		preloadedPositions[index]['h'] = allDropDownMenus[i].offsetHeight;
		preloadedPositions[index]['w'] = allDropDownMenus[i].offsetWidth;
		preloadedPositions[index]['nohide'] = allDropDownMenus[i].getAttribute('nohide');
	}
}

function prelIsOver(dragElX, dragElY, dragElH, dragElW, i) {
	targetEl = preloadedPositions[i];
	if ((dragElX > targetEl['x']+targetEl['w']) || (dragElX+dragElW < targetEl['x']) || (dragElY > targetEl['y']+targetEl['h']) || (dragElY+dragElH < targetEl['y'])) {
		return false;
	} else {
		if (targetEl['nohide']=="1") {
			return false;
		} else {
			return true;
		}
	}
}



function getAbsolutePos(el) {
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}

var tempDiv = Array;
function hideStupidMSIEElements(dragEl) {
	dragElX = dragEl.offsetLeft;dragElY = dragEl.offsetTop;dragElH = dragEl.offsetHeight;dragElW = dragEl.offsetWidth;
	for (var i=0;i<allDropDownMenus.length;i++) {
		if(prelIsOver(dragElX,dragElY,dragElH,dragElW,i)) {
			/*
			if (!tempDiv[i]) {
				tempDiv[i] = document.createElement("div");
				tempDiv[i].style.border = '1px solid silver';
				tempDiv[i].style.backgroundColor = 'white';
				tempDiv[i].style.overflow = 'hidden';
				tempDiv[i].style.height = preloadedPositions[i]['h']+'px';
				tempDiv[i].style.width = preloadedPositions[i]['w']+'px';
				allDropDownMenus[i].parentNode.appendChild(tempDiv[i]);
				tempDiv[i].appendChild(allDropDownMenus[i]);
			}
			*/
			allDropDownMenus[i].style.visibility='hidden';
		} else {
		/*	
			if (tempDiv[i]) {
				if (tempDiv[i].firstChild) {
					tempDiv[i].parentNode.appendChild(tempDiv[i].firstChild);
				}
				allDropDownMenus[i].parentNode.removeChild(tempDiv[i]);
				tempDiv[i] = false;
			}*/
			
			allDropDownMenus[i].style.width = preloadedPositions[i]['w']+1;
			allDropDownMenus[i].style.height = preloadedPositions[i]['h']+1;
			allDropDownMenus[i].style.visibility='inherit';
		}
	}
}

function showStupidMSIEElements() {
	for (var i=0; i < allDropDownMenus.length; i ++) {
		allDropDownMenus[i].style.visibility='inherit';
	}
}
