Event.observe(window, 'load', init, false);
function init(){
    update_annotation_list();
    //update_annotation_div( 'comp0', 'example'  )
    //update_files();
    //error = new PeriodicalExecuter(get_errors,5);
}



function update_annotation_div( elem_name, model_name )
// put content to annotation box (the right box)
{
    // fill box
    var params='?elem_name='+elem_name+'&model_name='+model_name;
    var url = 'get_annotation_box'+params;      
    new Ajax.Updater('annotation_box', url, {method: 'get'});
    var url2 = 'get_annotation_search'+params;
    new Ajax.Updater('annotation_search', url2, {method: 'get'});

    // set 
    var select = $('annotationlist');
    var selected_index=0;
    try
    {
        selected_index = select.selectedIndex;
    } catch(err) {}
    new Ajax.Request( 'set_element_annotate_pos?pos='+selected_index, {onComplete: update_annotation_list } );
};




function update_annotation_list()
// update list (left box)
{
    var select = $('annotationlist');
    var selected_index=0;
    try
    {
        selected_index = select.selectedIndex;
    } catch(err) {}

    
    var url = 'get_annotation_list';
    new Ajax.Updater( 'annotation_list', url, {method: 'get' });


}

function annotationlist_select_index(index)
{
    var select = $('annotationlist');
    try
    {
        select.selectedIndex=3;
    } catch(err){alert('hallo');}
    alert(select);
}



function submitForm(frm)
{
    var d = document.createElement('DIV');
    d.innerHTML = '<iframe src="about:blank" height="1px" width="1px" id="ida" name="ida" onload="upd();"></iframe>';
    //d.innerHTML = '<iframe src="about:blank" height="1px" width="1px" id="ida" name="ida" ></iframe>';
    d.style.visibility="hidden";
    document.body.appendChild(d);
    frm.target='ida';
    return true;
};

function upd()
{
    //alert('wawa');
    var elem = document.getElementById('annotationlist').value;
    var model = document.getElementById('model_name').value;
    update_annotation_div(elem, model);
    
};


