function SchoolAssistant(assistant_school_list)
{
    /* meta information for jslint static verification: http://www.jslint.com/ */
	/*extern dojo */
    /*extern add_option_to_select_box, gettext, a_price_calculator, Option, selection_method */
	
	var self = this; // reference to itself
	
	/**
	 * The unfiltered school list
	 */
	var unfiltered_school_list = assistant_school_list;
	
	/**
	 * All assistant criterias
	 */
	var assistant_filters = ['', ''];
	
	/**
	 * The filtered assistant school selection box
	 */
	var assistant_school_select_box = dojo.byId('id_assistant_select_school');
	
	/**
	 * Loading indicator image
	 */
	var assistant_loading_span = dojo.byId('id_school_assistant_loading_span');
	
	/**
	 * Criteria select boxes
	 */
	var assistant_criterias = [];
	assistant_criterias[0] = dojo.byId('id_assistant_select_criteria_0');
	assistant_criterias[1] = dojo.byId('id_assistant_select_criteria_1');
	
	/**
	 * Assistant/Selection div elements
	 */
	var assistant_div = dojo.byId('id_school_assistant_div');
	var location_div = dojo.byId('id_location_div');
	
    
    /**
     * Hides the school box
     */
	var inactivate_school_box = function()
	{
		assistant_school_select_box.disabled = true;
		assistant_school_select_box.parentNode.className = 'price_calculator_inactive_element';
		assistant_school_select_box.style.display = 'none';
		
		assistant_loading_span.style.display = '';
	};
	
    /**
     * Shows the school box
     */
	var activate_school_box = function()
	{
		assistant_loading_span.style.display = 'none';
		
		assistant_school_select_box.disabled = false;
		assistant_school_select_box.parentNode.className = 'price_calculator_active_element';
		assistant_school_select_box.style.display = '';
	};
    
    
	/**
	 * Updates the assistant school select element
	 * with the filtered items
	 * @param {Object} schools
	 */
	var fill_assistant_schools = function(schools)
	{
		var a_select_box = assistant_school_select_box;
		var a_set = schools;
        var caption_str = null;
        
		/*
            Clear all options
        */
        a_select_box.innerHTML = '';
        
		/*
            Insert 'please choose' option
        */
		
		if (a_set.length == 1)
		{
			caption_str = '1 ' + gettext('School');
		}
		else
		{
			caption_str = a_set.length + ' ' + gettext('Schools') + ' - ' + gettext('Please choose');
		}
		
        var option = new Option( caption_str, '');
        add_option_to_select_box( a_select_box, option );
		
        /*
            Insert entries:  
            Make option groups for entries which have the same group name
        */
		var option_group;
		var prev_group_str = "";
        for (var j = 0; j < a_set.length; j ++ )
        {
			var group_str = a_set[j].country;
			if (group_str != prev_group_str) {
				option_group = document.createElement('optgroup');
				option_group.setAttribute('label', group_str);
				a_select_box.appendChild(option_group);
				prev_group_str = group_str;
			}
			
			var element_str = a_set[j].city + ' - ' + a_set[j].name;
			//option = new Option(element_str, a_set[j].id); --> DOES NOT WORK IN IE6!
			option = document.createElement("option");
			option.appendChild(document.createTextNode(element_str));
			option.value = a_set[j].id;
			option_group.appendChild(option);
        }
        
        /*
            Check if we have only one option 
            and if we would like to set it:
        */                        
        if (a_set.length === 1)
        {
            // The option with index 0 is a 'please choose':
            a_select_box.selectedIndex = 1;
            
            a_price_calculator.set_school(a_select_box.value);
			//self.fireEvent('change', a_select_box);
        }
		
		if (a_set.length === 0)
		{
			a_select_box.innerHTML = '';
			option = new Option( gettext('No schools found'), '');
        	add_option_to_select_box( a_select_box, option );
		}
		else
		{
	        /*
	            Enable the select box:
	        */
			a_select_box.disabled = false;
		}
	};
    
	/**
	 * Apply all filters to the school list,
	 * update the school select box
	 */
	var apply_assistant_filters = function()
	{
		inactivate_school_box();
		
		var filtered_schools = unfiltered_school_list.slice(); // copy the array
		var i = 0;
		var filter_str = null;
		
		for (var j = 0; j < assistant_filters.length; j++)
		{
			filter_str = assistant_filters[j];
			
			if (filter_str !== null && filter_str !== "")
			{
				var tmp = [];
				// only keep a school if it contains the item in
				for (i = 0; i < filtered_schools.length; i++)
				{
					if (filtered_schools[i].assistant[filter_str])
					{
						tmp.push(filtered_schools[i]);
					}
				}
				filtered_schools = tmp;
			}
		}
		
		fill_assistant_schools(filtered_schools);
		// wait 0.5 sec in order that the user realizes the list has updated
        var func = activate_school_box;
		setTimeout(func, 500);
	};
	
	/**
	 * Sets a criteria of the school assistant
	 * @param {Object} criteria_num
	 * @param {Object} value
	 */
	this.set_assistant_criteria = function(criteria_num, value)
	{
		assistant_filters[criteria_num] = value;
		
		apply_assistant_filters();
	};
	
	/**
	 * Sets the school to a value
	 * @param {Object} school_id
	 */
	this.set_school = function(a_school_id)
	{
		if (a_school_id !== null)
		{
		    a_price_calculator.set_school(a_school_id);
	    }
	};
	
	
	this.fireEvent = function(eventType, o) 
	{
        var evt = null;
		if (document.createEvent) { 
			evt = document.createEvent("Events"); 
			evt.initEvent(eventType, true, true); 
			o.dispatchEvent(evt); 
		}
		else if (document.createEventObject) { 
			evt = document.createEventObject(); 
			o.fireEvent('on' + eventType, evt); 
		} 
	};
	
	this.toggleView = function()
	{
		if (assistant_div.style.display == 'none')
		{
			assistant_div.style.display = '';
			location_div.style.display = 'none';
    		this.reset();
		}
		else
		{
			assistant_div.style.display = 'none';
			location_div.style.display = '';
			a_price_calculator.set_country('');
		}
	};
    
    this.reset = function()
    {
        assistant_criterias[0].selectedIndex = 0;
		assistant_criterias[1].selectedIndex = 0;
		assistant_school_select_box.selectedIndex = 0;
		apply_assistant_filters();
    };
	
	this.init = function()
	{
		//this.reset();
        
        if (selection_method == "assistent")
        {
            this.toggleView();
        }
	};
	
	this.init();
}

