var tabs;
var tab_cont;

window.addEvent('domready', function() { // ustawienie przegladarki
		
	tabs = $$('#link_list a');
	tab_cont = $$('div.list_table');
	tab_cont.each( function(t) {
		t.setStyle('display', 'none');	
	});
	
	$('link_list').addEvent('mouseover', function(ev) {
			var el = $(ev.target);
			var l = el.getProperty('href');
			if ( l != undefined )	{
				l = l.substring(l.lastIndexOf('/')+1.0, l.length );
				overCountry(l);
			}
	});
	$('link_list').addEvent('mouseout', function(ev) {
			var el = ev.target;
			var l = el.getProperty('href');
			if ( l != undefined )	{
				l = l.substring(l.lastIndexOf('/')+1.0, l.length );
				outCountry(l);
			}
	});
	
	$('link_list').addEvent('click', function(ev) {
		ev.preventDefault();
		var el = ev.target;
		var l = el.getProperty('href');
		if ( l != undefined )	{
			l = l.substring(l.lastIndexOf('/')+1.0, l.length );
			show(l);
		}
	});
});

function flashloaded( v )	{
		if ( document.URL.indexOf('#') > 0)	{
			var is_input = document.URL.substring(document.URL.lastIndexOf('#')+1.0,document.URL.length);
			var l = is_input.substring(is_input.lastIndexOf('_')+1.0, is_input.length );
			show(l);
		} else {
			var l = tabs[0].getProperty('href');
			l = l.substring(l.lastIndexOf('/')+1.0, l.length );
			show(l);
		}
};

function setCountry(id) {
	var obj = swfobject.getObjectById("mapa_swf");
	if (obj) {
		obj.setCountry(links[id]);
	}
}

function overCountry(id) {
	var obj = swfobject.getObjectById("mapa_swf");
	if (obj) {
		obj.overCountry(links[id]);
	}
}

function outCountry(id) {
	var obj = swfobject.getObjectById("mapa_swf");
	if (obj) {
		obj.outCountry(links[id]);
	}
}

function show(id) {
	if ( id != parseInt(id)) {
		links.each( function(item,index) {
				if ( item == id ) {
					id = index;
					return true;
				}
		});
	}
	tab_cont.each( function(t) {
		t.setStyle('display', 'none');	
	});
	tabs.each( function(t) {
		var l = t.getProperty('href');
		l = l.substring(l.lastIndexOf('/')+1.0, l.length );
		t.removeClass('selected');
		if ( l == id ) {
			t.addClass('selected');
			$('d_'+l).setStyle('display', 'block');
			setCountry(id);
		}
	});
}
