// JavaScript Document


$(function() {
	boldCurrent();
	var width = 0;
	$('#topnavi ul a.text').each(function() { width+=$(this).outerWidth(); });
	var padding = parseInt((980-230-width) / 2);
	
	$('#topnavi li.logo').css({'padding-right':padding});
	$('#topnavi li.lang.first').css({'padding-left':padding});

	$('#topnavi li.logo_small_hm').css({'padding-left':padding-30});
	$('#topnavi li.logo_small_eb').css({'padding-left':padding});

	$('#topnavi ul').css({'visibility':'visible'});

	positionFlags();
	$(window).bind('resize',function() { positionFlags(); })
});

function positionFlags() {
	var pageWidth = $(window).width();
	$('ul#language_select').css({'left': (pageWidth / 2)+350}).show();
	}

function boldCurrent() {
	var $links = $('#topnavi a, #pro_navi a');
	
	if(current_address == '/' || current_address == '/etusivu' || current_address == '/förstasidan' || current_address == '/home') {
		$('#topnavi .first').css({'font-weight' : 'bold'});
	}
	
	else {
		$links.each(function() {
			var href = $(this).attr('href');
			if(href.indexOf(current_address.substring(1)) != -1 && href.indexOf('#')==-1) {
				$(this).css({'font-weight' : 'bold'});
			}
		});
	}
}


function show_login_form() {
	document.getElementById("pro_login_link").style.display="none";
	document.getElementById("pro_login_form").style.display="block";
	document.getElementById("username").focus();
	
}

var cur_page = 1;

function show_page(index) {
	document.getElementById("page"+cur_page).style.display="none";
	document.getElementById("page"+index).style.display="block";			   
	cur_page = index;
	}			   


