

				function populateSelect(element, values) {

					j=0;
					element.options.length = 0;
//					element.options[j] = new Option('', 0);
					values.each(function(label,index) {
						if (typeof label != 'undefined') {
							element.options[j++] = new Option(label['label'], j);
						}
					});
				}


				function clearSelect(elt){
					elt.options.length = 0;
					elt.selectedIndex = 0;
				}

				Event.observe(window, 'load', function() {
					__chapter = document.getElementById("chapter");
					__chapterUid = document.getElementById("chapterUid");
					__subchapter = document.getElementById("subchapter");
					__subchapterUid = document.getElementById("subchapterUid");
					__subzone = document.getElementById("subzone");
					__subzoneUid = document.getElementById("subzoneUid");

					if (__subchapter != null) {
						__subchapter.options.length = 0;
						__subzone.options.length = 0;

						__chapter.onchange = function(){

							__subzoneUid.value = '';
							__subchapterUid.value = '';

							if (this.value == 0) {
								__chapterUid.value = '';
								__subchapter.options.length = 0;
								__subzone.options.length = 0;
							} else {
								__subzone.options.length = 0;
								__chapterUid.value = chapters[this.value]['uid'];
								populateSelect(__subchapter, chapters[this.value]['children']);
							}

							return false;
						}

						__subchapter.onchange = function(){

							if (this.value == 0) {
								__subzone.options.length = 0;
							} else {
								__subchapterUid.value = chapters[__chapter.value]['children'][this.value]['uid'];
								populateSelect(__subzone, chapters[__chapter.value]['children'][this.value]['children'])
							}

							return false;
						}

						__subzone.onchange = function(){

							__subzoneUid.value = chapters[__chapter.value]['children'][__subchapter.value]['children'][this.value]['uid'];

							return false;
						}
					}
				});



				function disableGroup(){

					__group.options.length = 0;
					__group.options[0] = new Option('Please choose Category', 0);
					__group.disabled = 0;
				}

				function enableSubchater(selectedChapter){
					populateSubchapter(__group, chapters[selectedChapter]);
					__group.value = selectedDepartement;
					__group.disabled = 0;
				}

				function initGroup(selectedSubCategory){
					if (selectedSubCategory==undefined) selectedSubCategory = 0;
					if (__chapter.value == 0) {
						disableGroup();
					} else {
						enableGroup(__chapter.value, selectedSubCategory);
					}
				}
