function GetIndex(object)
{
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].selected == true)
		{
			return i;
		}	
	}
	return -1;
}

function SetIndex(object, index)
{
	if(index < object.length)
	{
		object.options[index].selected = true;
	}
	else
	{
		object.options[object.length - 1].selected = true;
	}
}

function GetValue(object)
{
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].selected == true)
		{
			return object.options[i].value;
		}	
	}
	return -1;
}

function GetText(object)
{
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].selected == true)
		{
			return object.options[i].text;
		}	
	}
	return -1;
}

function SetValue(object, aValue)
{
	var Result = -1;
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].value == aValue)
		{
			object.options[i].selected = true;
			Result = 1;
			break;
		}	
	}
	return Result;
}

function SetText(object, aText)
{
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].selected == true)
		{
			object.options[i].text = aText;
		}	
	}
}

function LocateText(object, aText)
{
	for( var i = 0; i < object.length; i++)
	{
		if(object.options[i].text == aText)
		{
			return object.options[i].value;
		}	
	}
	return -1;
}

/*

function ResetCombo(object, aValue, aText)
{
	object.options.length = 1;
	object.options[0].value = aValue;
	object.options[0].text = aText;
	object.options[0].selected = true;
}

function AddComboItem(object, aValue, aText)
{
	object.options.length = object.options.length + 1;
	object.options[object.options.length - 1].value = aValue;
	object.options[object.options.length - 1].text = aText;
	object.options[object.options.length - 1].selected = true;
}

*/
function ResetCombo(object, aValue, aText)
{
	while(object.options.length > 0)
	{
		object.remove(object.options.length - 1);
	}
	AddComboItem(object, aValue, aText);
}

function ClearCombo(object)
{
	while(object.options.length > 0)
	{
		object.remove(object.options.length - 1);
	}
}

function AddComboItem(object, aValue, aText)
{
	var opt = new Option(aText, aValue);
	object.options.add(opt);
}

function GetRadioValue(object)
{
	if(object.length != null)
	{
		for(var i = 0; i < object.length; i++)
		{
			if(object[i].checked)
			{
				return object[i].value;
			}	
		}
	}
	else
	{
			if(object.checked)
			{
					return object.value;
			}
	}
	return -1;
}

function SetDisabled(object, disabled)
{
	if(navigator.platform == "iPad")
	{
			object.disabled = disabled;
	}
	else
	{
		for(var i = 0; i < object.length; i++)
		{
			if(object.options[i].selected)
			{
				object.options[i].disabled = false;
			}
			else
			{
				object.options[i].disabled = disabled;
			}
		}
	}
	return 1;
}

function EnableMultiColumn(object)
{
	var maxLen = 0;
	for(var i = 0; i < object.length; i++)
	{
		data = object.options[i].text.split("|");
		if(data.length >= 2)
		{
			if(data[0].length > maxLen)
			{
				maxLen = data[0].length;
			}
		}
	}

	for(var i = 0; i < object.length; i++)
	{
		data = object.options[i].text.split("|");
		if(data.length >= 2)
		{
			var len = data[0].length; 
			while(len < maxLen)
			{
				data[0] += " ";
				len++;
			}
			object.options[i].text = data[0] + " - " + data[1];
		}
	}
}

function SetItemDisabled(object, aValue, disabled)
{
	var result = false;
	for(var i = 0; i < object.length; i++)
	{
		if(object.options[i].value == aValue)
		{
			object.options[i].disabled = disabled;
			result = true;
			break;
		}	
	}
	return result;
}
