// require: /_js/dom/event.jsfunction RichSelect(objName, dumpIdName) {var me = this;// [START] MUST BE DEFINED BEFORE this.init();this.conId;// [END]// [START] can optionally defined before this.init();this.optionClickTarget = 'ghostFrame'; //['ghostFrame'|'_self']this.openListTrigger = 'onmousedown'; //['onmousedown'|'onmouseover']// ENDthis.rand = 0;this.closeListTimer;this.closeListTime = 50; // millisecvar _conId = this.conId;this.init = function() {	_conId = this.conId;	var aa = this.getLinks();	var sel = this.getSelectedElem();	var hd = this.getHandleElem();	var list = this.getListElem();	for (var i=0;i<aa.length;i++) {		aa[i].onmousedown = this.fireOption;/*		if (this.openListTrigger == 'onmouseover') {			aa[i].onmouseover = this.cancelDelayCloseList;			aa[i].onmouseout = this.delayCloseList;		}*/	}	if (this.openListTrigger == 'onmouseover') {		list.onmouseover = this.cancelDelayCloseList;		list.onmouseout = this.delayCloseList;	}	switch(this.openListTrigger) {		case 'onmousedown':			sel.onmousedown = this.swListAuto;			if (hd) {				hd.onmousedown = this.swListAuto;			}		break;		case 'onmouseover':			sel.onmouseover = this.openList;			sel.onmouseout = this.delayCloseList;				sel.onmousedown = this.openList;			if (hd) {				hd.onmouseover = this.openList;				hd.onmouseout = this.delayCloseList;				hd.onmousedown = this.openList;			}		break;	}	addListener(document, 'mousedown', function() { eval(objName + '.trackClick()'); });}this.genRand = function() {	me.rand = Math.random().toString();	return me.rand;}// switch the display of the listthis.swList = function(display) { // display:[1:show|0:hidden|-1:switch]	var display = (display==null)?-1:display;	var list = me.getListElem();	var doShow = false;	var doHide = false;	if (list) {		switch (display) {			case 1:				// show only when currently is "hidden"				if (list.style.display == 'none' || list.style.display == '') {					doShow = true;				}			break;			case 0:				// hide only when currently is "shown"				if (list.style.display == 'block') {					doHide = true;				}			break;			case -1: 				if (list.style.display == 'none' || list.style.display == '') {					doShow = true;				} else {					doHide = true;				}			break;		}	}	if (list) {		if (doShow) {			list.style.display = 'block';//			me.createFocusTrap();			// hide all <select>s in the document, which will otherwise stay ontop of the richselect list//			alert(objName + '.closeSelects');			me.swDocSelect(false);		}		if (doHide) {			list.style.display = 'none';//			me.removeFocusTrap();//			me.offLinks();			// un-hide all <select>s//			alert(objName + '.openSelects');			me.swDocSelect(true);		}	}}this.swListAuto = function () {	me.swList(-1);}this.openList = function() {	me.swList(1);}this.closeList = function() {	me.swList(0);}this.delayCloseList = function() {	clearTimeout(me.closeListTimer);	eval(objName + '.closeListTimer = setTimeout(objName+\'.closeList()\', me.closeListTime)');}this.cancelDelayCloseList = function() {	clearTimeout(me.closeListTimer);}// if click out-of-list area, close the listthis.trackClick = function(e) {	var e = (window.event)?window.event:e;	if(typeof e == 'undefined' ||		typeof e.srcElement == 'undefined' && typeof e.srcElement == 'undefined') {		return false;	}	var src = (e.srcElement)?e.srcElement:e.target;	var clickingOnSelf = false;	do {		if (src.id == _conId) {			clickingOnSelf = true;		}		src = src.parentNode;	} while (src.parentNode);	if (!clickingOnSelf) {		me.closeList();		return false;	}}this.getListElem = function() {	return _getElem('div', 'list');}this.getSelectedElem = function() {	return _getElem('div', 'selected');}this.getHandleElem = function() {	return _getElem('div', 'handle');}this.getLinks = function() {	return _getElemArray('a', 'itemlink');}var _getElem = function(tag, className) {	var par = _getParentCon();	var aTag = par.getElementsByTagName(tag);	var returnTag;	for (var ii=0;ii<aTag.length;ii++) {		if (aTag[ii].className == className) {			// return aTag[ii];			returnTag = aTag[ii];		}	}	return returnTag;}var _getElemArray = function(tag, className) {	var par = _getParentCon();	var aTag = par.getElementsByTagName(tag);	var aa = new Array();	for (var ii=0;ii<aTag.length;ii++) {		if (aTag[ii].className == className) aa[aa.length] = aTag[ii];	}	return aa;}var _getParentCon = function() {	return 	document.getElementById(_conId);}this.fireOption = function(e) {	var e = (window.event)?window.event:e;	var src = (e.srcElement)?e.srcElement:e.target;	var url = '';	var elemA = src;	var counter = 0;	var fuseBreak = 20;	while (counter < fuseBreak && elemA.tagName.toLowerCase() != 'a') {		elemA = elemA.parentNode;		counter++;	}	var url = elemA.href;	var label = elemA.innerHTML;	switch(me.optionClickTarget) {		case 'ghostFrame':			// get dept name string from the dept list			var onloadFunStr = 'parent.'+objName+'.writeSelected(\''+label+'\');';			onloadFunStr += 'parent.'+objName+'.delayRemoveFrame();';			var frm = me.createFrame();			var op = (url.match(/\?/))?'&':'?';			frm.location = url + op + 'onload=' + escape(onloadFunStr);			me.writeSelected('saving...');			me.swList(0);		break;		case '_self':			// me.writeSelected(label);			me.writeSelected('loading...');			me.swList(0);			window.location = url;		break;	}}this.writeSelected = function(name) {	var sel = this.getSelectedElem();	sel.innerHTML = name;}this.offLinks = function() {	var aa = this.getLinks();	for (var i=0;i<aa.length;i++) {//		aa[i].style.backgroundColor = 'none';	}}this.createFrame = function() {	var frmElem = document.createElement('iframe');	var u = 'fireFrame_' + objName + Math.random().toString();	frmElem.id = u;	frmElem.name = u;	frmElem.setAttribute('src', 'about:blank');	var frmCon = document.getElementById(dumpIdName);	frmCon.appendChild(frmElem);	var frm = self.frames[frmElem.name];	return frm;}this.removeFrame = function() {	var frmElem = document.getElementById('fireFrame_' + objName);	if (frmElem) {		frmElem.parentNode.removeChild(frmElem);	}}this.delayRemoveFrame = function() {	setTimeout(objName + '.removeFrame()', 500);}/*this.createFocusTrap = function() {	var input = document.createElement('input');	input.id = 'focusTrap_' + objName + me.genRand();	input.className = 'focusTrap';	input.onblur = function() {eval(objName + '.closeList()');}	var con = _getParentCon();	con.appendChild(input);	// focus the input so that when clicking somewhere else on the browser,	// input will become blurred, and thus trigger the blur function = close the item list	// but in FF, opening the item list immediately blur the input... thus focus it AFTER (by delaying) the list opens	this.delayFocusTrap(input.id);	return input;}this.removeFocusTrap = function() {	var input = document.getElementById('focusTrap_' + objName + me.rand);	if (input) {		input.parentNode.removeChild(input);	}}this.delayFocusTrap = function(inputId) {	var timer = setTimeout(objName+'.focusTrap(\''+inputId+'\')', 100);}this.focusTrap = function(inputId) {	var i = document.getElementById(inputId);	if (i) i.focus();}*/this.swDocSelect = function(display) {	// function is disabled:	return;	// display: boolean	var aSel = document.getElementsByTagName('select');	var disp = (display)?'inline':'none';	for (var ii=0;ii<aSel.length;ii++) {		aSel[ii].style.display = disp;	}}}