You need to quote the text in the link tag, otherwise it tries and fails to find a variable with the name scotislands.
onClick="flag('scotislands');"
then change the assignment of the innerHTML to the following:
document.getElementById("flag").innerHTML="<img src='images/flags/" + nation + ".jpg'>"
Note the use of single quotes internally to set of the url, but double quotes around each of the inline text bits.
Generally, though, I'd prefer something unobtrusive (no code in markup). Using a framework, such as jQuery, I'd do something like:
<a href="#scotislands" class="flag-identifier">Scotislands</a>
Then using javascript, I'd add a handler for all such links:
$(function() {
$('a.flag-identifier').click( function() {
var flag = $(this).attr('href').replace('#','');
$('#flag').html( '<img src="images/flags/' + flag + '.jpg" />' );
return false;
});
});
This would add a click handler that gets the flag name from the href on the anchor, then replaces the named element flag's content with the image constructed by adding the name of the country to the image url. Note that I omitted the global variable nation, but you could easily set it from within the click handler as well if necessary.