this.highlightStartColor = '#FFFCDF';
this.highlightEndColor   = '#76BF5F';
this.current_length      = 0;
this.field_id            = 0;

/*
 * callback function of window.setInterval("doProgressUpdate()", 100);
 *
 *
 */
function doProgressUpdate()
{

    new Insertion.Bottom(this.informer_id, ":");

    this.current_length++;
    if( this.current_length > this.length_of_dots )
    {
        this.current_length = 0;
        while( $(this.informer_id).hasChildNodes() )
            $(this.informer_id).removeChild($(this.informer_id).firstChild);

        this.base_string    = this.original_base_string;
        new Insertion.Top(this.informer_id, this.base_string);
    }
}

/*
 * Disables a form-field and renderes a kind of progress bar
 */
function progressInSubmitFormFields( field_id, base_string, length_of_dots )
{
    $(field_id).disabled        = true;
    this.field_id               = field_id;
    this.informer_id            = 'informer_' + field_id;
    new Insertion.Top(this.informer_id, base_string);
    this.progressStarted        = true;
    this.base_string            = base_string;
    this.original_base_string   = base_string;
    this.length_of_dots         = length_of_dots;
    this.current_length         = 0;
    this.interval = window.setInterval("doProgressUpdate()", 100);
}

/*
 * Clears the content of the informer and enables the submit button
 */
function clearProgressInformer()
{
    while( $(this.informer_id).hasChildNodes() )
        $(this.informer_id).removeChild($(this.informer_id).firstChild);

    $(this.field_id).disabled        = false;
}

/*
 * Deletes all of a dropdown which is specified by target_select_id
 * and redraws the option tag by parsing the XML of originalRequest.
 * The XML must have the structure:
 * <?xml version="1.0" encoding="UTF-8"?>
 * <select>
 *     <option>Value</option>
 *     <option>OtherValue</option>
 * </select>
 *
 */
function reWriteDropdowns( originalRequest, target_select_id )
{
    //var target_select = document.getElementById( target_select_id );
    var target_select = $( target_select_id );
    var current_value = target_select.value;
    var length        = target_select.length;
    var highlight_id  = target_select_id + '_highlight';

    target_select.length = 0;

    root_nodes = originalRequest.responseXML.childNodes;

    for ( i = 0 ; i < root_nodes.length ; i++ )
        if( root_nodes.item(i).nodeName == "select" )
            options = root_nodes.item(i).childNodes;


    for ( i = 0 ; i < options.length ; i++ )
    {
        if( options.item(i).nodeName == "option" )
        {
            isSelected = false;
            if(options.item(i).firstChild.nodeValue == current_value )
                isSelected = true;

            NewOption = new Option(options.item(i).firstChild.nodeValue, options.item(i).firstChild.nodeValue, false, isSelected);
            target_select.options[target_select.length] = NewOption;
        }
    }
    new Effect.Highlight( highlight_id, {startcolor:this.highlightStartColor, endcolor:this.highlightEndColor});

}

/*
 * shows one block and hides the other
 */
function switchBlock( show_id, hide_id )
{
    Effect.Fade( hide_id, { duration: 0.1 });
    Effect.Appear( show_id, { duration: 1.0 });
}
/*
 * shows the red narrow
 */
function showNarrow( show_id)
{
    Effect.Appear( show_id, { duration: 1.0 });
}