function updateWidget(wName, propName, propId, propValue, e) {
        
    // Rebuild the select
    var rselect = document.getElementById(wName);
    // Clear all previous options
    var l = rselect.length;
    while (l > 0){
        l--;
        rselect.remove(l)
    }

    var opt = document.createElement('option');

    opt.text = '-';
    opt.value = 0;
    try {
        rselect.add(opt, null)
        // standards compliant; doesn't work in IE
    } catch(ex) {
        rselect.add(opt) // IE only
    }
        
    // The response comes back as a bunch-o-JSON
    var items = eval("(" + e.responseText + ")");    
    
    // evaluate JSON
    if (items) {                        
        for (var i=0; i < items.length; i++) {
            var item = items[i];

            opt = document.createElement('option');
            opt.text = item[propName];
            opt.value = item[propId];

            if (item[propId] == propValue) {
                opt.selected = 'selected';
            }

            try {
                rselect.add(opt, null)
                // standards compliant; doesn't work in IE
            } catch(ex) {
                rselect.add(opt) // IE only
            }
        }
    }
}

$(function(){                    
    
    $( "#geoslider" ).slider({
        range: 'min',
        value: 20,
        max: 50,
        slide: function(event, ui) { 
            $("#s-right-info1").html(ui.value + ' km');
            $("#sgeovalue").val(ui.value);
        }
    });
    $( "#budgetslider" ).slider({
        range: true,
        max: 100,
        values: [0,100],
        slide: function(event, ui) {
            $("#s-right-info2").html(ui.values[0] + ' - ' + ui.values[1] + ' &#8364; p.P./T.')
            $("#sbudgetvaluemin").val(ui.values[0]);
            $("#sbudgetvaluemax").val(ui.values[1]);
        }
    });
    $( "#starslider" ).slider({
        max: 5,
        range: 'min',
        slide: function(event, ui) { 
            if (ui.value > 0) {
                $("#s-right-info3").html(ui.value + ' Sterne');
                $("#sstarvalue").val(ui.value);
            } else {
                $("#s-right-info3").html('- Sterne')
                $("#sstarvalue").val(0);
            }
        }
    });    
    
    $("#city").geo_autocomplete({
        select: function(_event, _ui) {
			if (_ui.item.location) {
                            $("#slat").val(_ui.item.location.lat());
                            $("#slng").val(_ui.item.location.lng());                           
                        }
		}
	}
    );    
    
    if ($('.fade').innerfade) {
        $('.fade').innerfade({
            speed: 1000,
            timeout: 5000,
            type: 'sequence',
            containerheight: '240px'
        })
    }    
    
    if ($('#dialogactivated')) {
        $( "#dialogactivated" ).dialog({ buttons: { "Ok": function() { $(this).dialog("close"); } },
                                         modal: true,
                                         resizable: false,
                                         width: 400,
                                         height: 230 });
    }       
});
