﻿// JScript-Datei
var drop2 = null;
var drop3 = null;

// This function calls the Web service method and 
// passes the event callback function.  
function FillOrte1(list, control, control1)
{   
    var drop1 = $get(list);
    if( drop1 != null )
    {
        var option = drop1.options[drop1.selectedIndex]; 
        drop3 = $get(control1);
        if (drop3 != null) drop3.disabled = 'disabled'
        setContentLocation(option.text);
        drop2 = $get(control);
        LocationWS.FillOrt1(option.value, FillDrop2OnSucceeded);
    }
}

// This function calls the Web service method and 
// passes the event callback function.  
function FillOrte2(list, control, control1)
{   
    var drop1 = $get(list);
    var option = drop1.options[drop1.selectedIndex]; 
    drop3 = $get(control1);
    if (drop3 != null) drop3.disabled = 'disabled'
    setContentLocation(option.text);
    drop2 = $get(control);
    LocationWS.FillOrt2(option.value, FillDrop2OnSucceeded);
}

// This is the callback function invoked if the Web service
// succeeded.
// It accepts the result object as a parameter.
function FillDrop2OnSucceeded(result)
{   
   var list = drop2;  // retrieve raw DOM element
   var lastValue = list.value;
        
    // *** Clear the list first
    for (var x=list.options.length-1; x > -1; x--) 
    {
        list.remove(1);
    }

    for (var i=0;i<result.length;i++)
    {
        var option = document.createElement("option");
        option.text = result[i];
        option.value = result[i];
            
        if ( window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) 
            drop2.add(option);  
        else
            drop2.add(option, null);        
    } 
    
    list.value = lastValue;
    if( list.value != lastValue )
        list.selectedIndex = 0;   
}

function ActivateUmkreis(control, control1, control2)
{
    var drop1 = $get(control2);
    var drop2 = $get(control);
	var drop3 = $get(control1);
	
	if(!drop2)
	{
		return;
	}
	
	var	option1 = drop2.options[drop2.selectedIndex]; 
    
    if (drop1 == null) {setContentLocation(option1.text);}
    else {
    var option = drop1.options[drop1.selectedIndex]; 
    if (option.value == '-1')  setContentLocation(option1.text);
    else setContentLocation(option1.text + ' (' + option.text + ')'); }
    
    if (option1 != null && option1.value == '-1') 
    {   
        drop3.selectedIndex = 0;
        drop3.disabled = 'disabled';
    }
    else drop3.disabled = '' 
}




