function populateList(listobj,indx,strKeys,strNames,defSel){
  //alert(strKeys + '////' + strNames);
  arrSubCatAllKeys = createArrayFromString('@',strKeys);
  
  arrSubCatAllNames = createArrayFromString('@',strNames);
  arrSubCatSelectedKeys = createArrayFromString(';',arrSubCatAllKeys[indx]);
  arrSubCatSelectedNames = createArrayFromString(';',arrSubCatAllNames[indx]);
  
	resetListBox(listobj);
	for (j=0; j<arrSubCatSelectedKeys.length-1; j++) {
			//alert(arrSubCatSelectedKeys[j] + '-' + arrSubCatSelectedNames[j]);
			addListElement(listobj,arrSubCatSelectedKeys[j],arrSubCatSelectedNames[j], defSel);
		} 	
	
}

function getSelectedIndex(listobj){
		
	for (i=0; i<listobj.options.length; i++) {
		if (listobj.options[i].selected) {
			return i;
		}
	}
}

function createArrayFromString(separator,arrString){
	
	stringObj = new String(arrString);
	
	return stringObj.split(separator);
}

function addListElement(listObj,value,text,defSel){
  var s = false;
  if (value == defSel) {
	s=true;
  }
  listObj.options[listObj.length] =  new Option(text, value, s, s);
}

function resetListBox(listobj){

	// Delete them from original
	for (var i=(listobj.options.length-1); i>=0; i--) {
			var o = listobj.options[i];		
			listobj.options[i] = null;		
	}
}
