/*****************************************************
* ctkListItems
* 14/11/2004
*
* allow to drop items into their listbox.
*
* --Sébastien Brémond--
* http://www.tocra.org
*****************************************************/

		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// - | Manipulations des éléments de liste.
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

		function addNewItem(sTargetLstId,sOptValue,sOptLabel,sOptClass){
			len = getObj(sTargetLstId).options.length;
			
			getObj(sTargetLstId).options.length = getObj(sTargetLstId).options.length +1;
			getObj(sTargetLstId).options[len].text = sOptLabel;
			getObj(sTargetLstId).options[len].value = sOptValue;
			getObj(sTargetLstId).options[len].className = sOptClass;
		}
		
		function addThisItem(sLstId,sTargetLstId){
			len = getObj(sLstId).options.length;
			idx = getObj(sLstId).selectedIndex;
			
			if (getObj(sLstId).options[idx].selected == true && !isOptionExist(getObj(sLstId).options[idx].value,sTargetLstId) ){
				len2 = getObj(sTargetLstId).options.length;
				
				getObj(sTargetLstId).options.length = getObj(sTargetLstId).options.length +1;
				getObj(sTargetLstId).options[len2].text = getObj(sLstId).options[idx].text;
				getObj(sTargetLstId).options[len2].value = getObj(sLstId).options[idx].value;
			}
		}
	
		function delThisItem(sLstId){
			idx = getObj(sLstId).selectedIndex;
			if (idx != -1 && getObj(sLstId).options[idx].selected == true){
				getObj(sLstId).options[idx].text = null;
				getObj(sLstId).options[idx].value = null;
				getObj(sLstId).options[idx] = null;
			}
		}
		
		function isOptionExist(sValueRef,sObjSearchIn){
			oLst = getObj(sObjSearchIn);
			for(i=0;i<oLst.options.length;i++){
				if( oLst.options[i].value == sValueRef ){ return true; }
			}
			return false;
		}


		// Déplace un item dans la liste des rubrique
		// _Brems (c) 2005 Tocra.org		
		function moveItem(sObjName,sDirection,iLocked){
			var unmoveableItems = iLocked; // 2 tmpRubrik

			if( getObj(sObjName).selectedIndex == -1)return false;
			if( getObj(sObjName).options.length == unmoveableItems)return false;		
			// Teste si c'est le premier après les non-déplacables est qu'on veut le monter
			if( getObj(sObjName).selectedIndex <= (unmoveableItems)  && (sDirection=='up') ){return false}
			if( getObj(sObjName).selectedIndex < (unmoveableItems)  && (sDirection=='down') ){return false}
			// Teste si c'est le dernier est qu'on veut le descendre
			if( (getObj(sObjName).options.length-1) == getObj(sObjName).selectedIndex && (sDirection=='down') ){return false}
				
			// Alors on peut le déplacer
			idx=getObj(sObjName).selectedIndex;
			transText=getObj(sObjName).options[idx].text;
			transValue=getObj(sObjName).options[idx].value;
			transCSS=getObj(sObjName).options[idx].className;
			idx2=idx;
			if(sDirection == 'up'){idx2=idx-1}
			if(sDirection == 'down'){idx2=idx+1}

			getObj(sObjName).options[idx].text = getObj(sObjName).options[idx2].text;
			getObj(sObjName).options[idx].value = getObj(sObjName).options[idx2].value;
			getObj(sObjName).options[idx].className = getObj(sObjName).options[idx2].className;
			getObj(sObjName).options[idx2].text = transText;
			getObj(sObjName).options[idx2].value = transValue;
			getObj(sObjName).options[idx2].className = transCSS;
			
			getObj(sObjName).selectedIndex = idx2;			

			return true;
			/*
			setHighlightClass('modInputButtonHigh');
			ctkHighlight('BTN_SaveRubrikParameters');
			*/
		}

		function getChainOrder(sObjName){
			sJoiner=";"; if(arguments.length=2){ sJoiner=arguments[1]; }
			var oList = new Array();
			var nboption = getObj(sObjName).options.length;
			for(o=0;o<nboption;o++){
				optValue = getObj(sObjName).options[o].value;
				oList[oList.length] = optValue;
			}
			return oList.join(sJoiner);
			/**/
		}

		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
