// $Revision: 4027 $ $Date: 2006-08-21 11:50:15 -0300 (seg, 21 ago 2006) $
	function LumisDouiValidateSelection(strSelectionType, strFormName, strControlName, strNoItemMsg, strOneItemMsg)
	{
		var pForm = document.forms[strFormName];
		var pElement, pElements;
		var bFoundOne = false;
		var bFoundMoreThanOne = false;
		
		if(strSelectionType == "selectedOne" || strSelectionType == "selectedMany")
		{
			pElements = pForm.elements[strControlName];
	
			if(pElements && !pElements.length)
			{
				if(pElements.checked)
					bFoundOne = true;
			}
			else if(pElements)
			{
				for(var i=0; i<pElements.length; i++)
				{
					if(pElements[i].checked)
					{
						if(bFoundOne)
						{
							bFoundMoreThanOne = true;
							break;
						}
	
						bFoundOne = true;
					}
				}
			}
	
			if(!bFoundOne)
			{
				if(strNoItemMsg)
					alert(strNoItemMsg);
					
				return false;
			}
	
			if(strSelectionType == "selectedOne" && bFoundMoreThanOne)
			{
				if(strOneItemMsg)
				{
					alert(strOneItemMsg); 
					return false;
				}
			}
		}
		
		return true;
	}
	
	function LumisDouiGetSelectedItems(strFormName, strControlName)
	{
		var elementValues = "";
		var pForm = document.forms[strFormName];
		var bFoundOne = false;
	
		pElements = pForm.elements[strControlName];
		
		if(pElements && !pElements.length)
		{
			if(pElements.checked)
				elementValues += pElements.value;
		}
		else if(pElements)
		{
			for(var i=0; i<pElements.length; i++)
			{
				if(pElements[i].checked)
				{
					if(bFoundOne)
						elementValues += ";";
					elementValues += pElements[i].value;
					
					bFoundOne = true;
				}
			}
		}
		
		return elementValues;
	}

	// TODO: Kishnan either this or the same function in LumisDouiClientSideReadable.js must GO
	function LumisDouiGetValueByName(strFormName, strControlName)
	{
		var pForm = document.forms[strFormName];
		var strValue = null;
	
		for(var i=0; i<pForm.elements.length; i++)
		{
			var pElement = pForm.elements[i];
			
			if(!pElement.name || !pElement.name.length || pElement.name != strControlName)
				continue;
	
			if(pElement.type == "select-one" && pElement.selectedIndex != -1)
			{
				strValue = pElement.options[pElement.selectedIndex].value;
			}
			else if(pElement.type == "select-multiple")
			{
				var strValue = "";
				for(var j=0; j<pElement.options.length; j++)
				{
					if(pElement.options[j].selected && strValue.length)
					{
						if(strValue && strValue.length)
							strValue += ",";
						strValue = pElement.options[j].value;
					}
				}
			}
			else
			{
				strValue = pElement.value;
			}
		}
	
		return strValue;
	}
	
	function LumisDouiToggleSelection(formId, checkBoxName, checked)
	{
		var form = document.forms[formId];
		var items = form.getElementsByTagName("input");
		for(var i=0; i<items.length; i++)
		{
			if (items[i].name == checkBoxName && items[i].type == 'checkbox')
				items[i].checked = checked;
		}
	}
