/* just a wrapper for get element */
function _el(objName)
{
	return document.getElementById(objName);
}

/**
 * Populate Options for a select box
 *
 * @param   string	 Id of the comboBox
 * @param   array    Array containing the keys and values for the combo
 * @param   int      Selected index of the combo
 *
 */
function populateCombo(comboId, optionArray, selectedIndex)
{
	var myObj = _el(comboId);
 	if (typeof(optionArray)!="undefined" && optionArray!=null)
	{
		myObj.options.length = optionArray.length;

		for(i = 0; i < optionArray.length; i++){
		   var fieldText			= (typeof(optionArray[i].text)=="undefined")?optionArray[i].label:optionArray[i].text;
		   myObj.options[i].text	= fieldText;
		   myObj.options[i].value	= optionArray[i].value;
		}
		
		myObj.selectedIndex = selectedIndex;
	}
	else
	{
		myObj.options.length = 0;
	}
}

/**
 * Remove Options for a select box
 *
 * @param   string	 Id of the comboBox
 *
 */
function emptyCombo(comboId){
	var myObj = _el(comboId);
	myObj.options.length = 0;
}
