/* dropdown boxes */
	var bolPreventDropDownHide = false ;
	var objCurrentDropDown = null ;
	var strCurrentOpenDropDown = '' ;
	var strCurrentFieldID = '' ;
	var strCurrentFieldName = '' ;
	
	String.prototype.fixLength = function() { 
			var strTMP = this ;
			if (strTMP.length>24) strTMP = Left(strTMP, 22) + '..' ;
			return strTMP ;
		}
	
	function Left(str, n){
		if (n <= 0)
		    return "";
		else if (n > String(str).length)
		    return str;
		else
		    return String(str).substring(0,n);
	}
	function initDropDowns() {
		var oCollection = xGetElementsByClassName('dropDownTarget', document, 'input') ;
		for (var i=0; i<oCollection.length; i++) {
			oCollection[i].onfocus = showDropDown ;
			oCollection[i].onblur = hideDropDown ;
			if (!oCollection[i].readonly) {
				oCollection[i].onchange = checkInputComboBox;
			}
		}
		initDropDownRows( document ) ;
	}
	function initDropDownRows(oParent) {
		var oCollection = xGetElementsByClassName('dropDown', oParent, 'div') ;
		for (var i=0; i<oCollection.length; i++) {
			var strCallBack = oCollection[i].title;
			oCollection[i].onscroll = function() {
						bolPreventDropDownHide = true;
						} ;
			oCollection[i].onmouseout = function() {
						bolPreventDropDownHide = false;
						} ;
			oCollection[i].onmouseover = function() {
						bolPreventDropDownHide = true;
						} ;
			var oCollectionRow = xGetElementsByClassName('dropDownRow', oCollection[i], 'div') ;
			if (oCollectionRow.length<6) oCollection[i].style.height = 'auto';
			for (var j=0; j<oCollectionRow.length; j++) {
				oCollectionRow[j].onmousedown = function() {selectRow(this, this.parentNode.title); } ;
				HoverElement(oCollectionRow[j], 'hoverMode' );
			}
		}
	}
	function HoverElement(node, className) {
		if(!node.hovers) node.hovers = {};
		if(node.hovers[className]) return;
		node.hovers[className] = true;
		if (node.attachEvent) {
			node.attachEvent('onmouseover',
				function() { node.className += ' ' + className; });
			}
		if (node.addEventListener) {
			node.addEventListener('mouseover',
				function() { node.className += ' ' + className; },false);
			}
		
		if (node.attachEvent) {
			node.attachEvent('onmouseout',
				function() { node.className = 
					node.className.replace((new RegExp('\\s+'+className)),''); });
			}
		
		if (node.addEventListener) {
			node.addEventListener('mouseout',
				function() { node.className = 
					node.className.replace((new RegExp('\\s+'+className)),''); },false);
			}
	}
	function showDropDown() {
		if (!objCurrentDropDown) {
			// need check if not another dropbox is open.
			objCurrentDropDown = document.getElementById('dropDownContainer_'+this.title) ;
			objCurrentDropDown.className = objCurrentDropDown.className + ' showRow' ;
			strCurrentFieldID = this.title ;
			strCurrentFieldName = this.id ;
		}
	}
	function hideDropDown() {
		if (bolPreventDropDownHide) {
			setTimeout( 'hideDropDown()', 50);
		} else {
			try {
			objCurrentDropDown.className = 'dropDown' ;
			} catch(e) {
				// for some reason object got invalid.
				var oCollection = xGetElementsByClassName('dropDown', document, 'div') ;
				for (var i=0; i<oCollection.length; i++) {
					oCollection[i].className = 'dropDown' ;
				}
			}
			bolPreventDropDownHide = false;
			objCurrentDropDown = null ;
			strCurrentFieldID = '' ;
			strCurrentFieldName = '' ;
		}
	}
	function selectRow(obj, strCallBack) {
		bolPreventDropDownHide = true;
		if (document.getElementById(strCurrentFieldID)) 
			document.getElementById(strCurrentFieldID).value = obj.title;
		if (document.getElementById(strCurrentFieldName)) {
			document.getElementById(strCurrentFieldName).value = obj.innerHTML.fixLength();
		}
		if (strCallBack!='') {
			try {
				strCallBack = eval(strCallBack);
				strCallBack( strCurrentFieldID );
			} catch(e) {
				alert(e.description + '\n' + strCallBack);
			}
		}
		bolPreventDropDownHide = false;
	}
	function checkInputComboBox() {
		document.getElementById(this.title).value=this.value;
//		hideDropDown();
	}
	
	function xGetElementsByClassName(c,p,t,f) {
		var found = new Array();
  		var re = new RegExp('\\b'+c+'\\b', 'i');
  		var list = xGetElementsByTagName(t, p);
  		for (var i = 0; i < list.length; ++i) {
    		if (list[i].className && list[i].className.search(re) != -1) {
      			found[found.length] = list[i];
      			if (f) f(list[i]);
    		}
  		}
  		return found;
	}
	
	function xGetElementsByTagName(t,p) {
  		var list = null;
  		t = t || '*';
  		p = p || document;
		////
  		if (p.getElementsByTagName) { // DOM1
    		list = p.getElementsByTagName(t);
    		if (t=='*' && (!list || !list.length)) list = p.all; // IE5 '*' bug
  		}
  		else { // IE4 object model
    		if (t=='*') list = p.all;
    		else if (p.all && p.all.tags) list = p.all.tags(t);
  		}
		////
  		return list || new Array();
	}