MainCat 		= new Array();
MainCatOpts		= new Array();
MainCatIDs		= new Array();
MainCatSelected = new Array();

SubCat			= new Array();
SubCatIDs		= new Array();
SubCatSelected	= new Array();


// The initial option values for MainCat and SubCat
function initForm (idx, empty) {

    var mainCat = document.getElementById('mc_' + idx);
    
    mainCat.length = 0;
	
	if (empty) {
		empty = 1;
		mainCat.options[0] = new Option('','');
	}
	
   	//loop through the MainCat array, creating MainCat options
    
    for(count = 0; count < MainCat[idx].length; count++)
        mainCat.options[count + empty] = new Option(MainCat[idx][count], MainCatIDs[idx][count]);
	
    if (MainCatSelected[idx] || MainCatSelected[idx] === 0)
    	mainCat.selectedIndex = MainCatSelected[idx]+empty;
    
    subCatOption(idx, empty);
}

//The subCategory options corresponds to the selected mainCategory
function subCatOption(idx, empty) {
	
	var mainCat	= document.getElementById('mc_' + idx);
	var subCat	= document.getElementById('sc_' + idx);
	
    subCat.length = 0;
    
    si = mainCat.selectedIndex;
    if (si && empty) si = si - 1;   
    
    reg = new String(MainCat[idx][si]);
	
	if (mainCat.value == '') {
    	subCat.disabled = true;
    } else {
	    subCat.disabled = false;
	    for(count = 0; count < SubCat[idx][reg].length; count ++)
	        subCat.options[count] = new Option(SubCat[idx][reg][count], SubCatIDs[idx][reg][count]);
	    
	    if (SubCatSelected[idx][reg] || SubCatSelected[idx][reg] === 0)	
	    	subCat.selectedIndex = SubCatSelected[idx][reg];
	}
}

function setDeleted(){
  var workflow = document.getElementById('workflow');
  workflow.options[workflow.length] = new Option('Geloescht', 'Geloescht', false, true);
  
  if (!confirm("Wollen Sie den Datensatz tatsächlich löschen?")){
  	return false;
	}
	else{
  	document.editAccount.submit();
 		return true;
	}
}

function realyDelete(){
  var workflow = document.getElementById('workflow');

	if (workflow.value == 'Geloescht'){
		/*
		check = confirm("Wollen Sie den Datensatz tatsächlich löschen?");
		if (!check){
				workflow.value = ' ';
		  	return true;
		 }else{
		 		return false;
		 }
		 */
		 return confirm("Wollen Sie den Datensatz tatsächlich löschen?");
	}
}

function realyStatus(){
	var workflow = document.getElementById('pub_status');
	
	if (workflow.value == 'Gesperrt'){
		if (!confirm('Daten werden nur MKN-intern genutzt und nicht über die öffentliche Suche nicht gefunden.')){
			workflow.value = "";
			}
		}
 if (workflow.value == 'Freigeschaltet'){
		if (!confirm('Ihre Daten werden veröffentlicht. Sie sind damit einverstanden, dass ihre Daten in der MKN-Suche gefunden werden.')){
			workflow.value = "";
			}
		}	
	
}

