/* Fix for conflict in IE6 between Quickpicks and SELECT drop-down menus
 * See http://www.hedgerwow.com/360/bugs/css-select-free.html
 * 
 * University of Ottawa
 * Computing and Communications Services
 */
 
addDOMLoadEvent(initQuickpicksIE6SelectFix);

function initQuickpicksIE6SelectFix() {

	/* Require IE 6 */
	var IE6searchString = "MSIE";
	var indexOfMSIE = navigator.userAgent.indexOf(IE6searchString);
	if (indexOfMSIE == -1) return; /* It's not IE */
	
	var IEversion = parseFloat(navigator.userAgent.substring(indexOfMSIE+IE6searchString.length+1));
	if (IEversion >= 7 || IEversion < 6) return; /* It's not IE 6 */
	
	/* Find the Quickpicks dropdown to target for the fix */
	var objQp = document.getElementById(idList.quickPicksMenu);
	if (!objQp) return;

	/* Find dropdown, which should be the first <ul> inside the quickpicks div */
	var objQpDropdown = objQp.firstChild;
	if (!objQpDropdown || objQpDropdown.tagName.toLowerCase() != "ul") return;

	/* Create empty iframe */
	var objIframe = document.createElement("iframe");
	
	/* Give the iframe a title for accessibility purposes */
    var lang = document.getElementsByTagName('html')[0].lang;
    if (lang && locales) {
		objIframe.title = locales[lang]['empty-iframe'];
	}

	/* Add empty iframe to drop-down menu */
	objQpDropdown.appendChild(objIframe);

	/* Make iframe invisible, using IE's proprietary filter property */
	objIframe.style.filter = "mask()";
	
	/* Position iframe behind the dropdown (on z-axis) */
	objIframe.style.position = "absolute";
	objIframe.style.zIndex = -1;
	
	/* Align the iframe with the dropdown (x and y axis) */
	objIframe.style.top = 0;
	objIframe.style.left = 0;
	
	/* Correct positioning (account for padding and border) */
	objIframe.style.top = (-1) * objIframe.offsetTop;
	objIframe.style.left = (-1) * objIframe.offsetLeft;

	/* Match width and height */
	objIframe.style.width = objQpDropdown.offsetWidth;
	objIframe.style.height = objQpDropdown.offsetHeight;
	
	/* Make absolute position of iframe relative to the quickpicks section */
	objQpDropdown.style.position = "relative";
}
