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


function select_tab(pos)
{
    var tabs = document.getElementById('tabs');
    var nav =  document.getElementById('tabnav'); 
    var count;

    for ( i=0; i< nav.childNodes.length; i++ )
        if ( nav.childNodes[i].toString() == '[object HTMLUListElement]' )
        {
            count=0;
            for ( j=0; j<nav.childNodes[i].childNodes.length; j++ )
            {
                if ( nav.childNodes[i].childNodes[j].toString() == '[object HTMLLIElement]' )
                {
                    var link = nav.childNodes[i].childNodes[j].childNodes[1] ;
                    if ( count++ == pos )
                    {
                        link.style.color = 'white';
                        link.style.backgroundColor = '#4080FF' ;
                    }
                    else
                    {
                        link.style.color = '';
                        link.style.backgroundColor = '' ;
                    }
                        
                }
            }
        }
    // make selected tab visible and the others invisible
    for ( i=0; i< tabs.childNodes.length; i++ )
    {
        if (tabs.childNodes[i].className=='tab')
        {
            tabs.childNodes[i].style.visibility ='hidden';
            if ( tabs.childNodes[i].id == 'tab'+pos)
            {
                tabs.childNodes[i].style.visibility = 'visible';
            }
        }        
    }
    if (pos==0) // main tab
    {
        self.frames[0].update_files();
    }  
    if (pos==2) // sbmlfill tab
    {
        self.frames[2].location.reload(true);
    }
    if (pos==3) // annotate tab
    {
        self.frames[3].location.reload(true);
    }
    if (pos==4)
    {
        self.frames[4].location.reload(true);
    }

};

function get_errors(){

    url = 'get_error';
    new Ajax.Request(url, {
            method: 'get',
            onSuccess: function(transport) 
            {
                if (!((transport.responseText == null) || (transport.responseText == ''))){
                    alert( transport.responseText );
                }
            }
});
};


