// add value to combo box
function ComboBoxAddValue (objCbo, iPosition, sValue, sLabel, sCboDefaultValue) {
  objCbo.options[iPosition] = new Option(sLabel,sValue);
	
	for (var i=0; i<objCbo.options.length; i++) {
	  if (objCbo.options[i].value == sCboDefaultValue) {
			objCbo.options[i].selected = true;
		}	
		else {
			objCbo.options[i].selected = false;
		}
	}
}

// empty the combo box and fill it with array values
function fillComboBox (objCbo, arrArray, sDefault) {
  objCbo.options.length = 0;
	
  for (i = 0; i < arrArray.length; i++)
    ComboBoxAddValue (objCbo, i, arrArray[i][0], arrArray[i][1], sDefault);
}

// check sWhat and fill objCboToFill with array values
// (array must be defined before calling this function!!!)
function fillCboAccordingToWhat(sWhat, objCboToFill, sDefault) {
	switch(sWhat) {
		case 'hangup':
			fillComboBox(objCboToFill, Array(), '');
			break;
		
		case 'internal':
			fillComboBox(objCboToFill, arrInternals, sDefault);
			break;
		
		case 'group':
			fillComboBox(objCboToFill, arrGroups, sDefault);
			break;
		
		case 'ivr_menu':
			fillComboBox(objCboToFill, arrIvrMenus, sDefault);
			break;
		
		case 'queue':
			fillComboBox(objCboToFill, arrQueues, sDefault);
			break;
		
		case 'outbroute':
			fillComboBox(objCboToFill, arrOutbRoutes, sDefault);
			break;
		
		case 'voice_mail':        
			fillComboBox(objCboToFill, arrVoiceMails, sDefault);
			break;
		
		case 'confroomext':
			fillComboBox(objCboToFill, arrConfRooms, sDefault);
			break;
		
		case 'audiomsg':
			fillComboBox(objCboToFill, arrAudioRep, sDefault);
			break;

		case 'context':
			fillComboBox(objCboToFill, arrContexts, sDefault);
			break;

		case 'fax':
			fillComboBox(objCboToFill, arrFaxs, sDefault);
			break;

		default:
			fillComboBox(objCboToFill, Array(), '');
			break;
	}
}