if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
	window.onload = init;
}

var onLoads = new Array;

function init() {
	for (var i = 0; i < onLoads.length; i++) {
		eval(onLoads[i]);
	}
}

function addOnLoad(func) {
	onLoads[onLoads.length] = func;
}

function $(id) {
	return document.getElementById(id);
}

var posx = 0;
var posy = 0;
var overSearchBox = false;

function track_mouse(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	} else if (e.clientX || e.clientY) {
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
	}
};

// Init Mouse location discovery
document.onmousemove = track_mouse;
document.onmouseup = function() {
	if (!overSearchBox) {
		hide_searchBox();
	}
}

addOnLoad('init_searchBox()');
addOnLoad('init_textSize()');

function init_searchBox() {
	var lank;
	var box;
	if ((lank = $('soklank').firstChild) && (lank.tagName == 'A') && (box = $('sokruta'))) {
		lank.removeAttribute('href');
		lank.onclick = show_searchBox;
		lank.onmouseover = function() { overSearchBox = true; }
		lank.onmouseout = function() { overSearchBox = false; }
		box.onmouseover = function() { overSearchBox = true; }
		box.onmouseout = function() { overSearchBox = false; }
	}
}

function show_searchBox() {
	if ((lank = $('soklank').firstChild) && (lank.tagName == 'A') && (box = $('sokruta'))) {
		if (lank.parentNode.className != 'sok_selected') {
			lank.parentNode.className = 'sok_selected';
			box.className = 'show';
		} else {
			lank.parentNode.className = 'sok';
			box.className = null;
		}
	}
}

function hide_searchBox() {
	if ((lank = $('soklank').firstChild) && (lank.tagName == 'A') && (box = $('sokruta'))) {
		lank.parentNode.className = 'sok';
		box.className = null;
	}
}

function init_textSize() {
	if ((lank = $('textstorlek').firstChild) && (lank.tagName == 'A')) {
		lank.removeAttribute('href');
		lank.onclick = textSize;
	}
}

function textSize() {
	var bodytag;
	for (var i = 0; i < document.childNodes.length; i++) {
		if (document.childNodes[i].nodeName == 'HTML') {
			for (var k = 0; k < document.childNodes[i].childNodes.length; k++) {
				var curNode = document.childNodes[i].childNodes[k];
				if (curNode.nodeName == 'BODY') {
					bodytag = curNode;
				}
			}
		}
	}
	
	if (!bodytag.className.match('biggertext')) {
		bodytag.className += ' biggertext';
	} else {
		bodytag.className = bodytag.className.replace('biggertext', '');
	}
}