from trac.core import *
from trac.web.chrome import INavigationContributor
from trac.util import Markup


class LinkNav(Component):
        implements(INavigationContributor)

        #INavigationContributor method
        def get_active_navigation_item(self, req):
                return ''

        def get_navigation_items(self, req):
		html = '<select name="url" onchange="location.href=this.value"><option value="#" selected="selected">Choose Site</option>'

		add = self.env.config.get('linknav', 'add_items', ''). \
			replace(',', ' ').split()
	
		for a in add:
			url = self.env.config.get('linknav', '%s.url' % a)
			html = html + ('<option value="%s">%s</option>' % (url, a))
		html = html + '</select>'	
                yield('mainnav' , 'link' , Markup(html))

