window.springsikker = (function(){
	function getId(id) {
		return document.getElementById(id);
	};
	return {
		colorLinks: function() {
			var s = getId('sitemap'), n;
			var divs = s.getElementsByTagName('div');
			for (var i = 0; i < divs.length; i++) {
				n = divs[i];
				if (n.className.indexOf('link') !== -1) {
					s = n.getElementsByTagName('a')[0];
					if (s)
						n = s;
					n = n.firstChild;
					if (n && n.nodeType == 3) {
						var string = n.nodeValue;
						var m = string.match(/(.*?)(trampet)(.*)/i) || string.match(/(.*?)([0-9]+)(.*)/);
						if (m) {
							var frag = document.createDocumentFragment();
							if (m[1]) {
								frag.appendChild(document.createTextNode(m[1]));
							}
							frag.appendChild(document.createElement('em')).appendChild(document.createTextNode(m[2]));
							if (m[3]) {
								frag.appendChild(document.createTextNode(m[3]));
							}
							n.parentNode.replaceChild(frag, n);
						}
					}
				}
			}
		},
		showDescription: (function(){
			var lastElm = null, lastDesc, lastSkill, minHeight = 0, fx = null;
			function getElm(ref, className) {
				ref = ref.getElementsByTagName('div');
				for (var i = 0; i < ref.length; i++)
					if (ref[i].className == className)
						return ref[i];
				return null;
			};
			return function(ref, event) {
				if (ref != lastElm) {
					var desc = getElm(ref, 'description');
					var skill = getElm(ref, 'skill_view');
					var s = getId('sidebar');
					if (lastDesc) {
						lastElm.appendChild(lastDesc);
					}
					event = event || window.event;
					if (!window.core || event.ctrlKey || event.shiftKey) {
						while (s.firstChild)
							s.removeChild(s.lastChild);
					}
					if (desc)
						s.appendChild(desc);

					if (lastSkill) {
						lastElm.appendChild(lastSkill);
					}
					s = getId('skill_view');
					if (!s) {
						s = getId('overview');
						s = s.insertBefore(document.createElement('div'), s.firstChild);
						s.id = 'skill_view';
					}
					if (s) {
						while (s.firstChild)
							s.removeChild(s.lastChild);
						if (skill)
							s.appendChild(skill);
						if (minHeight < s.clientHeight) {
							fx = new secoya.fx({
								from: minHeight,
								to: s.clientHeight,
								duration: 0.5,
								type: secoya.fx.power,
								callback: function(x){
									s.style.height = x + 'px';
								},
								finish: function(){
									s.style.minHeight = minHeight+'px';
									s.style.height = '';
								}
							});
							minHeight = s.clientHeight;
							fx.start();
						}
					}
					lastDesc = desc;
					lastElm = ref;
					lastSkill = skill;
				}
			};
		})(),
		toggleFold: function(ref) {
			ref = ref.parentNode;
			ref.className = ref.className.indexOf('open') == -1 ? 'fold_item open' : 'fold_item';
		}
	};
})();
