var docURL		// the full URL to the document
var lastSlash	// the position of the last slash in the path
var docDot		// the position of the dot in the file name
var lang		// the last two characters before the last dot
var resource	// the file resource, including possible GET parameters
var fileName	// the file name, excluding possible GET parameters
var fileBase	// the file name, excluding file and extension possible GET parameters
var extension	// the resource name, excluding file base (e.g. ".shtml?var=1")

docURL		= document.URL
lastSlash	= docURL.lastIndexOf("/")
resource	= docURL.substring(lastSlash + 1, docURL.length)

if (resource.indexOf("?") >= 0)
	{
	fileName	= resource.substring(0, resource.indexOf("?"))
	}
else
	{
	fileName = resource
	}

extension	= resource.substring(fileName.lastIndexOf("."), resource.length)

docDot		= fileName.lastIndexOf(".")
lang		= fileName.substr(docDot - 2, 2)
fileBase	= fileName.substring(0, docDot)

function svenska()
	{
	var newURL
	if (lang == "fi")
		{
		newURL = fileBase.substring(0, fileBase.length - 3).concat(extension)
		window.location=newURL;
		}
	}

function finska()
	{
	var newURL
	if (lang != "fi")
		{
		newURL = fileBase.concat("_fi").concat(extension)
		window.location=newURL;
		}
	}


