///<reference path="init.js"/>
//------------------------------------------------------------------
//------------------------------------------------------------------
//## PAGE
//------------------------------------------------------------------
PAGE.Init = function() {

	this.PageTopic = $('container').getElementsByTagName('H1')[0].innerHTML.toString();
	this.ContentDiv = $('content');
	this.TextSize = (Cookie.Read('HHHR-TextSize') == 'big') ? 'big' : 'default';
	this.RenderMode = (Cookie.Read('HHHR-PageRender') == 'static') ? 'static' : 'dynamic';
	this.ListenToPage = $('listen-to-page');

	this.LayoutMode = ($('specialsida')) ? 'special' : 'column';
	this.LayoutMode = ($('financial-table')) ? 'table' : this.LayoutMode;

	this.Tools = $('tools');
	this.FlashArea = DOM.GetByClassName(document, 'DIV', 'flash-container');
	this.AreaCookieId = Cookie.Read('HH-AreaId');
	this.RunIntro = (Cookie.Read('HH-RunIntro') == 'true') ? 'true' : 'false';

	if (PAGE.Tools) {
		var ul = DOM.Create('UL');

		//## BUTTON FOR PRINT
		var li = DOM.Create('LI'), a = DOM.Create('A', 'tooltip', ''), t = '';
		t = TRANSLATE.GetValue('PrintTitle')
		DOM.SetAttribute(a, 'href', 'javascript:;');
		DOM.SetAttribute(a, 'title', t);
		a.innerHTML = '<img src="../../gfx/ico-print.png" alt="" /><span>' + t + '</span>';
		DOM.Add(a, li);
		addEvent(a, 'click', MENU.ShowPrintMenu);
		DOM.Add(li, ul);
		//jonell

		//## BUTTON FOR CHANGING TEXT SIZE
		var li = DOM.Create('LI'), a = DOM.Create('A', 'tooltip', ''), t = '';
		if (PAGE.TextSize == 'big') { t = TRANSLATE.GetValue('TextSizeStandardTitle') }
		else { t = TRANSLATE.GetValue('TextSizeBigTitle') }
		DOM.SetAttribute(a, 'href', 'javascript:;');
		DOM.SetAttribute(a, 'title', t);
		a.innerHTML = '<img src="../../gfx/ico-textsize.png" alt="" /><span>' + t + '</span>';
		DOM.Add(a, li);
		addEvent(a, 'click', PAGE.ChangeTextSize);
		DOM.Add(li, ul);

		//## BUTTON FOR CHANGING RENDERMODE
		var li = DOM.Create('LI'), a = DOM.Create('A', 'tooltip', 'btn-pagerender'), t = '';
		if (PAGE.RenderMode == 'static') { t = TRANSLATE.GetValue('RenderColumnLayoutTitle'); }
		else { t = TRANSLATE.GetValue('RenderBasicLayoutTitle'); }
		DOM.SetAttribute(a, 'href', 'javascript:;');
		DOM.SetAttribute(a, 'title', t);
		a.innerHTML = '<img src="../../gfx/ico-rendermode.png" alt="" /><span>' + t + '</span>';
		DOM.Add(a, li);
		addEvent(a, 'click', PAGE.ChangeRenderMode);
		DOM.Add(li, ul);

		if (location.href.indexOf('index.html') < 0)
			DOM.Add(ul, PAGE.Tools);

		//## ADD SEARCHFORM
		if (PAGE.RenderMode == 'dynamic') {
			var searchForm = DOM.Create('FORM', '', 'searchform');
			DOM.SetAttribute(searchForm, 'action', '/');
			DOM.SetAttribute(searchForm, 'method', 'post');
			var searchField = DOM.Create('INPUT', '', 'tbSearchBox');
			DOM.SetAttribute(searchField, 'type', 'text');
			DOM.SetAttribute(searchField, 'tabindex', '2');
			DOM.SetAttribute(searchField, 'value', '');
			DOM.Add(searchField, searchForm);
			var searchBtn = DOM.Create('INPUT', '', 'btnSearch');
			DOM.SetAttribute(searchBtn, 'type', 'submit');
			DOM.SetAttribute(searchBtn, 'tabindex', '3');
			DOM.SetAttribute(searchBtn, 'value', TRANSLATE.GetValue('BtnSearch'));
			DOM.Add(searchBtn, searchForm);
			DOM.AddBefore(searchForm, $('menu'));
		}

	}


	if (this.ListenToPage) {
		PAGE.InitListenToPage();
	}

	if (PAGE.RenderMode == 'dynamic') {
		VISITEDPAGESHANDLER.InitializeVisitedLinks();
		tmpClassName = 'dynamic';
		if (document.addEventListener) {
			tmpClassName = 'dynamic nonIE';
		}
		document.getElementsByTagName('html')[0].className = tmpClassName;
		document.getElementsByTagName('body')[0].className = tmpClassName;
	}
	if (PAGE.FlashArea.length > 0) {
		PAGE.InitFlash();
	}
	if (this.AreaCookieId) {
		var AreaCookieHref = Cookie.Read('HH-AreaHref').toString().toLowerCase();
		var CurrPageHref = location.href.toString().toLowerCase();
		AreaCookieHref = AreaCookieHref.substring(AreaCookieHref.lastIndexOf('/') + 1);
		CurrPageHref = CurrPageHref.substring(CurrPageHref.lastIndexOf('/') + 1);
		if (AreaCookieHref && AreaCookieHref == CurrPageHref) {
			var targetImage = $('content').getElementsByTagName('IMG')[0];
			if (!targetImage) {
				Cookie.Remove('HH-AreaId');
				Cookie.Remove('HH-AreaHref');
				return;
			}
			var viewPortHeight = getViewport.Height();
			var viewPortWidth = getViewport.Width();

			var areaImage = new Image();
			areaImage.src = '../../images/' + this.AreaCookieId.toString() + '_big.jpg';
			DOM.SetAttribute(areaImage, 'id', 'big-area-image');
			DOM.SetAttribute(areaImage, 'width', viewPortWidth);
			DOM.SetAttribute(areaImage, 'height', viewPortHeight);
			areaImage.style.top = '0';
			DOM.Add(areaImage, document.getElementsByTagName('BODY')[0]);

			iPOP.iPop = $('big-area-image');
			iPOP.TriggerX = getElmPosition.GetX(targetImage) + 7;
			iPOP.TriggerY = getElmPosition.GetY(targetImage) + 44;
			iPOP.Top = 0;
			iPOP.Left = 0;
			iPOP.Height = viewPortHeight;
			iPOP.Width = viewPortWidth;
			iPopAnimation.Animator = areaImage;
			iPopAnimation.Animation = { specialClose: true, time: 0, top: 0, left: 0, width: 0, height: 0, changeTop: 0, changeLeft: 0, changeHeight: 0, changeWidth: 0, duration: 0.0, timer: null, element: null };
			iPopAnimation.Close();

			Cookie.Remove('HH-AreaId');
			Cookie.Remove('HH-AreaHref');

		}
	}
	if (this.RunIntro == 'true') {
		PAGE.HideFlashArea(true);
		Cookie.Remove('HH-RunIntro');
		window.setTimeout("PAGE.ShowFlashArea();", 1500);
	}

	//## SEARCH HITS
	var pos = location.href.toString().indexOf('#');
	if (pos > 0) {
		var anc = unescape(location.href.substring(pos + 1));
		if (anc.length > 2) {
			$('tbSearchBox').value = anc;
			var words = anc.split(/\s+/g);
			var currPageContent = $('content').innerHTML.toString();
			for (var i = 0, n = words.length; i < n; i++) {
				anc = words[i].toString().replace(/[a-zA-Z0-9\?\&\=\%\#]+s\=(\w+)(\&.*)?/, '$1');
				var re = new RegExp('>([^<]*)?(' + anc + ')([^>]*)?<', 'ig');
				currPageContent = currPageContent.replace(re, '>$1<span class="highlight">$2</span>$3<');
			}
			$('content').innerHTML = currPageContent.toString();
		}
	}

	PAGE.CheckForOversize();
};
PAGE.StartReport = function() {
	if (TRANSLATE.Lang == 'en')
		location.href = "Introduction/ThisisTeliaSonera.html";
	else if (TRANSLATE.Lang == 'sv')
		location.href = "Introduktion/DettaarTeliaSonera.html";
	else
		location.href = "Johdanto/TamaonTeliaSonera.html";
};
PAGE.InitFlash = function() {
	for (var i = 0, n = PAGE.FlashArea.length; i < n; i++) {
		var FlashArea = PAGE.FlashArea[i];
		var FlashInput = '';
		var FlashSource = FlashArea.id.toString();
		var FlashHeight = '100%';
		var FlashWidth = '100%';
		var FlashPath = '../../gfx/flash/';
		var FlashQuality = 'high';
		var FlashScale = 'showall';
		var FlashWmode = '';

		if ($('specialsida').className == 'intro') {
			FlashPath = '../gfx/flash/';
			FlashWidth = getViewport.Width();
			FlashHeight = parseInt(FlashWidth * 0.345);
			FlashWmode = 'transparent';
			FlashScale = 'exactfit';
		}

		if (FlashSource.toLowerCase().indexOf('teliasoneraceovideo') != -1) {
			FlashHeight = '360';
			FlashWidth = '450';
			FlashWmode = 'transparent';
		}

		FlashSource = FlashPath + FlashSource;
		FlashInput += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + FlashWidth + '" height="' + FlashHeight + '">';
		FlashInput += '  <param name="movie" value="' + FlashSource + '" />';
		FlashInput += '  <param name="quality" value="' + FlashQuality + '" />';
		FlashInput += '  <param name="wmode" value="' + FlashWmode + '" />';
		FlashInput += '  <param name="scale" value="' + FlashScale + '" />';
		FlashInput += '  <embed src="' + FlashSource + '" quality="' + FlashQuality + '" wmode="' + FlashWmode + '" scale="' + FlashScale + '" width="' + FlashWidth + '" height="' + FlashHeight + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		//FlashInput += FlashArea.innerHTML.toString();
		FlashInput += '</object>';
		FlashArea.innerHTML = FlashInput;
	}
};
PAGE.HideFlashArea = function(bolPreload) {
	for (var i = 0, n = PAGE.FlashArea.length; i < n; i++) {
		var flashArea = PAGE.FlashArea[i];
		flashArea.style.visibility = 'hidden';
		if (bolPreload) {
			if (flashArea.parentNode.className.indexOf('left') != -1) {
				flashArea.parentNode.className = flashArea.parentNode.className + ' preload';
			}
		}
	}
};
PAGE.ShowFlashArea = function() {
	for (var i = 0, n = PAGE.FlashArea.length; i < n; i++) {
		var flashArea = PAGE.FlashArea[i];
		flashArea.style.visibility = 'visible';
		if (flashArea.parentNode.className.indexOf('preload') != -1) {
			flashArea.parentNode.className = flashArea.parentNode.className.replace('preload','');
		}
	}
};
PAGE.ChangeTextSize = function() {
	if (PAGE.TextSize == 'big') {
		PAGE.TextSize = 'default';
		Cookie.Create('HHHR-TextSize', 'default', '365');
	} else {
		PAGE.TextSize = 'big';
		Cookie.Create('HHHR-TextSize', 'big', '365');
	}
	if ($('specialsida'))
		if ($('specialsida').className == 'thisisteliasonera')
			location.reload();
	
	LAYOUT.ForceReset();
};
PAGE.ChangeRenderMode = function() {
	if (PAGE.RenderMode == 'dynamic') {
		PAGE.RenderMode = 'static';
		Cookie.Create('HHHR-PageRender', 'static', '365');
	} else {
		PAGE.RenderMode = 'dynamic';
		Cookie.Create('HHHR-PageRender', 'dynamic', '365');
	}
	document.location.reload();
};
PAGE.CheckForOversize = function() {
	if (parseInt($('content').offsetHeight + $('content').offsetTop) > getViewport.Height()) {
		document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
	}
	if (getViewport.Width() < 980) {
		$('container').style.width = '980px';
		document.getElementsByTagName('BODY')[0].style.width = '980px';
		document.getElementsByTagName('HTML')[0].style.width = '980px';
		document.getElementsByTagName('HTML')[0].style.overflowX = 'scroll';
	} else {
		$('container').style.width = 'auto';
		document.getElementsByTagName('BODY')[0].style.width = '100%';
		document.getElementsByTagName('HTML')[0].style.width = '100%';
		document.getElementsByTagName('HTML')[0].style.overflowX = 'hidden';
	}
};
PAGE.InitListenToPage = function() {
	var h1 = document.getElementsByTagName('H1')[0];
	h1.style.paddingLeft = '44px';
	DOM.Add(PAGE.ListenToPage, h1);
	var link = PAGE.ListenToPage.getElementsByTagName('A')[0];
	DOM.SetAttribute(link, 'title', TRANSLATE.GetValue('ListenToPageTitle'));
	DOM.SetAttribute(link, 'class', 'tooltip');
	addEvent(link, 'click', PAGE.Listen);
};
PAGE.CloseListenPlayer = function() {
	var divReadSpeaker = $('readspeaker');
	if (divReadSpeaker) DOM.Remove(divReadSpeaker);
};
PAGE.Listen = function(e) {
	if (!e) e = window.event;
	var Trigger = (e.srcElement) ? e.srcElement : e.target;
	Trigger.parentNode.blur();
	CancelEvent(e);
	var pageURL = document.location;
	encodedURL = escape(pageURL);
	var doubleencodedURL = escape(encodedURL);
	var pathToFlashPlayer = '../../gfx/flash/mp3player-telia.swf';
	var divReadSpeaker = $('readspeaker');
	if (divReadSpeaker) DOM.Remove(divReadSpeaker);

	divReadSpeaker = DOM.Create('div', '', 'readspeaker');
	DOM.Add(divReadSpeaker, this.parentNode.parentNode);

	var flashWidth = 255;
	var flashHeight = 22;

	var ReadspeakerCustomerId, ReadspeakerVoice, ReadspeakerLang;

	switch (TRANSLATE.Lang) {
		case 'sv':
			ReadspeakerCustomerId = '4481';
			ReadspeakerLang = 'sv_se';
			ReadspeakerVoice = 'elin22k';
			break;
		case 'fi':
			ReadspeakerCustomerId = '4481';
			ReadspeakerLang = 'fi_fi';
			ReadspeakerVoice = 'sanna22k';
			break;
		default:
			ReadspeakerCustomerId = '4481';
			ReadspeakerLang = 'en_us';
			ReadspeakerVoice = 'Paul';
			break;
	}

	var flashInput = '';
	flashInput += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="' + flashHeight + '" width="' + flashWidth + '">';
	flashInput += '	<param name="movie" value="' + pathToFlashPlayer + '">';
	flashInput += '	<param name="quality" value="high">';
	flashInput += '	<param name="scale" value="exactfit">';
	flashInput += '	<param name="wmode" value="transparent">';
	flashInput += '	<param name="flashvars" value="url=http%3A%2F%2Fapp.readspeaker.com%2Fcgi-bin%2Frsent%3Fcustomerid%3D' + ReadspeakerCustomerId + '%26lang%3D' + ReadspeakerLang + '%26voice%3D' + ReadspeakerVoice + '%26url%3D' + doubleencodedURL + '">';
	flashInput += '	<embed wmode="transparent" src="' + pathToFlashPlayer + '" flashvars="url=http%3A%2F%2Fapp.readspeaker.com%2Fcgi-bin%2Frsent%3Fcustomerid%3D' + ReadspeakerCustomerId + '%26lang%3D' + ReadspeakerLang + '%26voice%3D' + ReadspeakerVoice + '%26url%3D' + doubleencodedURL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="exactfit" height="' + flashHeight + '" width="' + flashWidth + '">';
	flashInput += '	</embed>';
	flashInput += '</object>';
	flashInput += '<a href="javascript:;" onclick="PAGE.CloseListenPlayer();" title="' + TRANSLATE.GetValue('Close') + '"><img src="../../gfx/btn-listen-close.png" alt="' + TRANSLATE.GetValue('Close') + '" /></a>';
	divReadSpeaker.innerHTML = flashInput;

};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## iPOP - INTERNALPOPUPS
//------------------------------------------------------------------
iPOP.Init = function() {
	this.iPop = null;
	this.extraWidth = 85;
	this.extraHeight = 10;
	this.Height = 0;
	this.Left = 0;
	this.Top = 105;
	this.isFlash = false;
	this.Test = null;
	var internalLinks = DOM.GetByAttribute($('content'), 'A', 'rel', 'inline');
	for (var i = 0, n = internalLinks.length, link = null; i < n; i++) {
		link = internalLinks[i];
		addEvent(link, 'click', iPOP.Open);
	}
};
iPOP.Open = function(e) {
	iPOP.Test = this;
	if (PAGE.RenderMode == 'dynamic') {
		PAGE.HideFlashArea();
		iPOP.Build(e);
		CancelEvent(e);
	}
};
iPOP.Close = function() {
	if (PAGE.RenderMode == 'dynamic') {
		PAGE.ShowFlashArea();
		var iPop = $('ipopper');
		if (iPop) {
			DOM.Remove(iPop);
			iPopAnimation.Close();
		}
	}
};
iPOP.AddTextContent = function(url, e) {
	if (!url) return;
	if (url.toString().indexOf('#bm_') != -1) {
		url = '../_popups/' + url.substring(url.indexOf('#bm_') + 4) + '.html';
	} else {
		var fileName = url.substring(url.lastIndexOf('/'));
		fileName = fileName.replace('/', '');
		if (iPOP.isFlash) {
			url = '../_popups/' + fileName + '?cache=' + Math.random();
		} else {
			url = '../_popups/' + fileName;
		}
	}
	if (url.indexOf('?') != -1) {
		url = url + '&cache=' + Math.random();
	} else {
		url = url + '?cache=' + Math.random();
	}

	var longUrl = 'http://' + document.domain;
	if (typeof XMLHttpRequest == 'undefined') {
		function XMLHttpRequest() {
			try { return new ActiveXObject("MSXML3.XMLHTTP") } catch (e) { }
			try { return new ActiveXObject("MSXML2.XMLHTTP.3.0") } catch (e) { }
			try { return new ActiveXObject("MSXML2.XMLHTTP.4.0") } catch (e) { }
			try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { }
			try { return new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { }
			return null;
		};
	}
	var responseXml = null;
	httpRequest = new XMLHttpRequest();
	if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml');
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
	httpRequest.onreadystatechange = function() {
		var thisFunction = arguments.callee;
		if (!thisFunction.loopCount) thisFunction.loopCount = 0;
		thisFunction.loopCount++;
		if (thisFunction.loopCount > 10) {
			oTopic.innerHTML = '404';
			oContent.innerHTML = '';
			return;
		}
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				if (httpRequest.responseXML == null) return;
				responseXml = httpRequest.responseXML.documentElement;
				if (!responseXml) {
					var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async = false;
					xmlDoc.loadXML(httpRequest.responseText);
					if (xmlDoc.documentElement !== null) {
						responseXml = xmlDoc.documentElement;
					}
				}
				if (responseXml) {
					var strTopic = '', strText = '', oContent;
					strTopic = responseXml.getElementsByTagName('title')[0].firstChild.nodeValue;
					oContent = responseXml.getElementsByTagName('content')[0]; //.getElementsByTagName('p');
					strText = oContent.xml;
					if (typeof strText == 'undefined') {
						strText = new XMLSerializer().serializeToString(oContent);
					}
					$('pop-topic').getElementsByTagName('A')[0].innerHTML = strTopic;
					$('pop-content').innerHTML = strText;
				}
			} else if (httpRequest.status == 404) {
				var ErrorUrl = longUrl + url.replace('..', '');
				$('pop-topic').getElementsByTagName('A')[0].innerHTML = '404 Page Not Found!';
				$('pop-content').innerHTML = '<p>The requested file was not found on this server.<br /><code>' + ErrorUrl + '</code></p>';
			}
		}
	};
};
iPOP.Build = function(e) {
	var Event = e;
	var Trigger = (e.srcElement) ? e.srcElement : e.target;
	var Parent = Trigger.parentNode;

	if (PAGE.LayoutMode != 'table') {
		while (Parent.parentNode && Parent.parentNode.className !== 'column') {
			Parent = Parent.parentNode;
		}
		Parent = Parent.parentNode;
	}

	if ((Trigger.tagName.toLowerCase() == 'span' && Trigger.className == 'zoom') || Trigger.tagName.toLowerCase() == 'img' || Trigger.tagName.toLowerCase() == 'strong' || Trigger.tagName.toLowerCase() == 'cite') {
		Trigger = Trigger.parentNode;
	}

	if (iPOP.Test && iPOP.Test.tagName.toLowerCase() == 'div' && iPOP.Test.className == 'wrapper') {
		Trigger = iPOP.Test;
	}

	iPOP.TriggerX = e.clientX;
	iPOP.TriggerY = e.clientY;
	if (PAGE.LayoutMode == 'table') {
		var ScrollPanel = $('tablescrollpanel');
		var wrapperLeft = $('tablescrollpanel').scrollLeft;
		iPOP.extraHeight = 42;
		iPOP.Width = 515;
		if (Parent.tagName == 'TD') {
			iPOP.Left = 480;
			iPOP.Top = 45;
			if ($('notes').childNodes[0].childNodes.length == 18) // this is the consolidated with 18 notes in the left hand column
				var wideNotes = '|6|13|14|15|16|17|21|22|24|25|28|29|30|32|35|';
			else
				var wideNotes = '|8|10|11|15|16|17|22|23|26|28|';
			if (wideNotes.indexOf('|' + Trigger.innerHTML + '|') > -1) {
				iPOP.Width = 800;
				if (getViewport.Width() < 1200)
					iPOP.Left = 0;
			}
		} else {
			iPOP.Left = -10;
		}
	} else if (PAGE.LayoutMode == 'special') {
		var ScrollPanel = $('content');
	} else {
		var ScrollPanel = $('scrollpanel');
		var wrapperLeft = ScrollPanel.scrollLeft;
		var parentLeft = parseInt(Parent.offsetLeft - wrapperLeft);
		if (Parent.nextSibling) {
			iPOP.Left = (parentLeft > 600) ? parseInt(Parent.previousSibling.offsetLeft - wrapperLeft) - 65 : parseInt(Parent.nextSibling.offsetLeft - wrapperLeft) - 20;
		}
		iPOP.Width = Parent.clientWidth + iPOP.extraWidth;
	}
	var topicLink = DOM.GetAttribute(Trigger, 'href');
	if (topicLink) {
		if (topicLink.toLowerCase().indexOf('flash') != -1) {
			iPOP.isFlash = true;
		}
	}
	if (Trigger.parentNode.parentNode.className.indexOf('illustration') != -1) {
		var ImageSrc = DOM.GetAttribute(Trigger, 'href');
		var bigImage = new Image();
		bigImage.src = ImageSrc.toString();
		if (ImageSrc.indexOf('illucorperategovernance') > -1) {
			bigImage.width = 798;
			iPOP.Width = 866;
			iPOP.Height = 610;
		}
		else {
			bigImage.width = 600;
			iPOP.Width = 668;
			iPOP.Height = 482;
		}
		var currContentWidth = parseInt(LAYOUT.ContentDiv.style.width);
		if ((iPOP.Left + iPOP.Width) > currContentWidth) {
			iPOP.Left = 0;
		}
	} else if ((Trigger.parentNode.parentNode.className.indexOf('additional') != -1) && (Trigger.parentNode.parentNode.className.indexOf('graph-box') != -1)) {
		if (PAGE.LayoutMode == 'special') {
			if (Trigger.parentNode.parentNode.parentNode.className.indexOf('leaderboard') != -1) {
				iPOP.Width = 960;
				iPOP.Height = 553;
			} else {
				iPOP.Width = 668;
			}
		} else {
			var tableWrapper = Trigger.parentNode.parentNode.getElementsByTagName('DIV')[1];
			tableWrapper.style.display = 'block';
			iPOP.Width = tableWrapper.getElementsByTagName('TABLE')[0].offsetWidth + 70;
			iPOP.Height = tableWrapper.scrollHeight + 210;
			iPOP.Width = 500;
			tableWrapper.style.display = 'none';
		}
		if (DOM.GetByClassName(Trigger.parentNode, 'table', 'double')[0]) {
			iPOP.Width = 970;
		}
		else if (DOM.GetByClassName(Trigger.parentNode, 'table', 'semidouble')[0]) {
			iPOP.Width = 600;
		}
	} else if ((Trigger.parentNode.parentNode.parentNode.className.indexOf('additional') != -1) && (Trigger.parentNode.parentNode.parentNode.className.indexOf('graph-box') != -1)) {
		var tableWrapper = Trigger.parentNode.parentNode.parentNode.getElementsByTagName('DIV')[1];
		tableWrapper.style.display = 'block';
		iPOP.Width = tableWrapper.getElementsByTagName('TABLE')[0].offsetWidth + 100;
		tableWrapper.style.display = 'none';
	} else if (Trigger.className == 'wrapper' && Trigger.parentNode.className.indexOf('factbox') != -1) {
		// Continue!
	} else {
		if (!topicLink) topicLink = Trigger.a;
		if (!topicLink) return;
	}
	if (iPOP.isFlash) {
		if ($('specialsida').className == 'thisisteliasonera') {
			iPOP.Width = 985;
			iPOP.Height = 657;
			iPOP.Left = -5;
			iPOP.Top = 0;
		} else {
			iPOP.Width = 600;
			iPOP.Left = 0;
		}
	}
	if (iPOP.Height == 0) {
		iPOP.Height = parseInt(ScrollPanel.clientHeight + iPOP.extraHeight);
	}
	iPOP.iPop = $('ipopper');
	if (iPOP.iPop) DOM.Remove(iPOP.iPop);
	iPOP.iPop = document.createElement('DIV');
	iPOP.iPop.id = 'ipopper';
	iPOP.iPop.style.top = iPOP.Top + 'px';
	iPOP.iPop.style.left = iPOP.Left + 'px';
	iPOP.iPop.style.width = iPOP.Width + 'px';
	iPOP.iPop.style.height = iPOP.Height + 'px';
	//##--
	DOM.Add(DOM.Create('DIV', 'pop-corner-tr'), iPOP.iPop);
	DOM.Add(DOM.Create('DIV', 'pop-corner-br'), iPOP.iPop);
	DOM.Add(DOM.Create('DIV', 'pop-corner-bl'), iPOP.iPop);
	DOM.Add(DOM.Create('DIV', 'pop-corner-tl'), iPOP.iPop);
	//##--
	var shade = DOM.Create('DIV', 'pop-top');
	shade.style.width = parseInt(iPOP.Width - 40) + 'px';
	DOM.Add(shade, iPOP.iPop);
	var main = DOM.Create('DIV', 'pop-main');
	main.style.width = parseInt(iPOP.Width - 40) + 'px';
	main.style.height = parseInt(iPOP.Height - 40) + 'px';
	DOM.Add(main, iPOP.iPop);
	var shade = DOM.Create('DIV', 'pop-bottom');
	shade.style.width = parseInt(iPOP.Width - 40) + 'px';
	DOM.Add(shade, iPOP.iPop);
	var shade = DOM.Create('DIV', 'pop-right');
	shade.style.height = parseInt(iPOP.Height - 40) + 'px';
	DOM.Add(shade, iPOP.iPop);
	var shade = DOM.Create('DIV', 'pop-left');
	shade.style.height = parseInt(iPOP.Height - 40) + 'px';
	DOM.Add(shade, iPOP.iPop);
	var close = DOM.Create('DIV', 'pop-close');
	close.title = 'Close';
	close.innerHTML = '<span>' + TEXTHANDLER.Close + '</span>';
	addEvent(close, 'click', iPOP.Close);
	DOM.Add(close, iPOP.iPop);
	//##--
	var popTopic = DOM.Create('H2', '', 'pop-topic');
	var popLink = DOM.Create('A');
	DOM.SetAttribute(popLink, 'HREF', topicLink);
	DOM.Add(popLink, popTopic);
	DOM.Add(popTopic, iPOP.iPop);
	//##--
	var popContent = DOM.Create('DIV', '', 'pop-content');
	popContent.style.height = parseInt(iPOP.Height - 85) + 'px';
	popContent.style.width = parseInt(iPOP.Width - 60) + 'px';
	//##--
	DOM.Add(popContent, iPOP.iPop);
	//##--
	iPOP.iPop.style.visibility = 'hidden';
	DOM.Add(iPOP.iPop, document.getElementsByTagName('BODY')[0]);
	//## INPUT CONTENT
	if (Trigger.parentNode.parentNode.className.indexOf('illustration') != -1 && !iPOP.isFlash) {
		CancelEvent(e);
		if (bigImage) {
			$('pop-content').appendChild(bigImage);
			//bigImage.style.width = '798px';
			bigImage.style.height = 'auto';
			if (Trigger.getElementsByTagName('STRONG')[0]) {
				iPOP.Topic = Trigger.getElementsByTagName('STRONG')[0].innerHTML;
				$('pop-topic').getElementsByTagName('A')[0].innerHTML = iPOP.Topic;
			}
			if (bigImage.src.toString().indexOf('/diagrams/') != -1) {
				//var linkBox = DOM.Create('DIV', 'diagram-linkbox');
				//var linkBoxList = DOM.Create('UL');
				//var linkToEmf = ImageSrc.replace('/FullSize/', '/Emf/').replace('.png', '.emf');
				//var linkToExcel = ImageSrc.replace('/FullSize/', '/excel/').replace('.png', '.xls');
				//linkBoxList.innerHTML = '<li class="excel"><a href="' + linkToExcel + '" target="_blank">' + TRANSLATE.GetValue("DownloadExcelText") + '</a></li>';
				//DOM.Add(linkBoxList, linkBox);
				//DOM.Add(linkBox, $('pop-content'));
			}
			if (Trigger.parentNode.getElementsByTagName('CITE')[0]) {
				var popCite = DOM.Create('CITE');
				var oCite = Trigger.parentNode.getElementsByTagName('CITE')[0]
				var strCite = oCite.innerHTML;
				if (strCite && DOM.GetAttribute(oCite, 'title')) {
					strCite = DOM.GetAttribute(oCite, 'title').toString();
				}
				popCite.innerHTML = strCite;
				DOM.Add(popCite, $('pop-content'));
			}
			if (Trigger.parentNode.parentNode.getElementsByTagName('P')[0]) {
				DOM.Add(Trigger.parentNode.parentNode.getElementsByTagName('P')[0].cloneNode(true), $('pop-content'));
			}
		}
	} else if (Trigger.parentNode.parentNode.className == 'additional graph-box') {
		var tables = Trigger.parentNode.parentNode.getElementsByTagName('TABLE');
		if (tables.length == 1) {
			table = tables[0];
			var tableClone = table.cloneNode(true);
			tableClone.getElementsByTagName('TH')[0].style.textAlign = 'left';
			$('pop-content').appendChild(tableClone);
			if (Trigger.getElementsByTagName('STRONG')[0]) {
				iPOP.Topic = Trigger.getElementsByTagName('STRONG')[0].innerHTML;
				$('pop-topic').getElementsByTagName('A')[0].innerHTML = iPOP.Topic;
			}
			if (Trigger.parentNode.getElementsByTagName('CITE')[0]) {
				var popCite = DOM.Create('CITE');
				var oCite = Trigger.parentNode.getElementsByTagName('CITE')[0];
				var strCite = oCite.innerHTML;
				if (strCite && DOM.GetAttribute(oCite, 'title')) {
					strCite = DOM.GetAttribute(oCite, 'title').toString();
				}
				popCite.innerHTML = strCite;
				DOM.Add(popCite, $('pop-content'));
			}
		} else {
			for (var i = 0, n = tables.length; i < n; i++) {
				var tableClone = tables[i].cloneNode(true);
				$('pop-content').appendChild(tableClone);
			}
			iPOP.Topic = Trigger.getElementsByTagName('STRONG')[0].innerHTML;
			$('pop-topic').getElementsByTagName('A')[0].innerHTML = iPOP.Topic;
			if (Trigger.parentNode.getElementsByTagName('CITE')[0]) {
				var popCite = DOM.Create('CITE');
				popCite.innerHTML = Trigger.parentNode.getElementsByTagName('CITE')[0].innerHTML;
				DOM.Add(popCite, $('pop-content'));
			}
		}
		CancelEvent(e);
	} else if (Trigger.className == 'wrapper' && Trigger.parentNode && Trigger.parentNode.className.indexOf('factbox') != -1) {
		iPOP.Topic = Trigger.getElementsByTagName('H3')[0].innerHTML;
		$('pop-topic').getElementsByTagName('A')[0].innerHTML = iPOP.Topic;
		var triggerContent = DOM.NextSibling(Trigger);
		$('pop-content').innerHTML = triggerContent.innerHTML;
	} else {
		iPOP.AddTextContent(topicLink, e);
	}
	DOM.SetAttribute($('pop-topic').getElementsByTagName('A')[0], 'TARGET', '_blank');
	if (typeof sC == "object" && typeof sC.hhLogPopup == "function") {
		if (iPOP.Topic) {
			popupName = iPOP.Topic;
		} else if (topicLink) {
			popupName = topicLink;
		} else {
			popupName = null;
		}
		sC.hhLogPopup(popupName);
	}


	//## ANIMATE VISIBILITY
	iPopAnimation.Start(iPOP.Left, iPOP.Top, iPOP.Width, iPOP.Height);
	TOOLTIP.Init();
};
var iPopAnimation = {
	Start: function(x, y, width, height, usableObject) {
		if (usableObject) {
			elmAnimator = usableObject;
			iPOP.iPop = usableObject;
		} else {
			var elmAnimator = $('pop-animator');
			if (elmAnimator) DOM.Remove(elmAnimator);
			elmAnimator = DOM.Create('DIV', '', 'pop-animator');
		}
		elmAnimator.style.left = iPOP.TriggerX - 3 + 'px';
		elmAnimator.style.top = iPOP.TriggerY - 3 + 'px';
		this.Animator = elmAnimator;
		this.Animation = { specialClose: false, time: 0, top: 0, left: 0, width: 0, height: 0, changeTop: 0, changeLeft: 0, changeHeight: 0, changeWidth: 0, duration: 0.0, timer: null, element: null };
		DOM.Add(elmAnimator, document.getElementsByTagName('BODY')[0]);
		iPopAnimation.Animation.time = 0;
		iPopAnimation.Animation.top = iPOP.TriggerY - 5;
		iPopAnimation.Animation.left = iPOP.TriggerX - 5;
		iPopAnimation.Animation.height = 10;
		iPopAnimation.Animation.width = 10;
		iPopAnimation.Animation.changeTop = y - iPopAnimation.Animation.top;
		iPopAnimation.Animation.changeLeft = x - iPopAnimation.Animation.left;
		iPopAnimation.Animation.changeWidth = width;
		iPopAnimation.Animation.changeHeight = height;
		iPopAnimation.Animation.duration = 25;
		iPopAnimation.Animation.element = elmAnimator;
		iPopAnimation.Animation.timer = setInterval("iPopAnimation.Animate();", 15);
	},
	Close: function() {
		iPopAnimation.Animator.style.visibility = 'visible';
		iPopAnimation.Animation.time = 0;
		iPopAnimation.Animation.top = iPOP.Top;
		iPopAnimation.Animation.left = iPOP.Left;
		iPopAnimation.Animation.height = iPOP.Height;
		iPopAnimation.Animation.width = iPOP.Width;
		iPopAnimation.Animation.changeTop = parseInt(iPOP.TriggerY - iPOP.Top);
		iPopAnimation.Animation.changeLeft = parseInt(iPOP.TriggerX - iPOP.Left);
		iPopAnimation.Animation.changeWidth = -iPOP.Width;
		iPopAnimation.Animation.changeHeight = -iPOP.Height;
		iPopAnimation.Animation.duration = 25;
		iPopAnimation.Animation.element = iPopAnimation.Animator;
		iPopAnimation.Animation.timer = setInterval("iPopAnimation.Animate();", 15);
	},
	Stop: function() {
		DOM.Remove(iPopAnimation.Animator);
		clearInterval(iPopAnimation.Animation.timer);
		iPopAnimation.Animation.timer = null;
	},
	Animate: function() {
		var move = null;
		if (iPopAnimation.Animation.specialClose) {
			if (iPopAnimation.Animator.id == 'big-area-image') {
				if (iPopAnimation.Animator.width < 320) {
					iPopAnimation.Animator.style.width = '300px';
					iPopAnimation.Animator.style.height = '200px';
					iPopAnimation.Animation.timer = null;
					DOM.Remove(iPopAnimation.Animator);
					return;
				}
			}
		}
		if (iPopAnimation.Animation.time > iPopAnimation.Animation.duration) {
			clearInterval(iPopAnimation.Animation.timer);
			iPopAnimation.Animation.timer = null;
			iPopAnimation.Animator.style.visibility = 'hidden';
			if (iPOP.iPop) iPOP.iPop.style.visibility = 'visible';
			if ($('pop-content')) {
				$('pop-content').style.overflowX = 'hidden';
			}
		} else {
			//## LEFT
			move = cubicOut(iPopAnimation.Animation.time, iPopAnimation.Animation.left, iPopAnimation.Animation.changeLeft, iPopAnimation.Animation.duration)
			iPopAnimation.Animation.element.style.left = parseInt(move) + 'px';
			//## TOP
			move = cubicOut(iPopAnimation.Animation.time, iPopAnimation.Animation.top, iPopAnimation.Animation.changeTop, iPopAnimation.Animation.duration)
			iPopAnimation.Animation.element.style.top = parseInt(move) + 'px';
			//## WIDTH
			move = cubicOut(iPopAnimation.Animation.time, iPopAnimation.Animation.width, iPopAnimation.Animation.changeWidth, iPopAnimation.Animation.duration)
			iPopAnimation.Animation.element.style.width = parseInt(move) + 'px';
			//## HEIGHT
			move = cubicOut(iPopAnimation.Animation.time, iPopAnimation.Animation.height, iPopAnimation.Animation.changeHeight, iPopAnimation.Animation.duration)
			iPopAnimation.Animation.element.style.height = parseInt(move) + 'px';
			iPopAnimation.Animation.time++;
		}
	}
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## LAYOUT
//------------------------------------------------------------------
LAYOUT.Init = function() {
	if (PAGE.RenderMode != 'dynamic') return;
	this.ContentDiv = $('content');
	this.TextLineHeight = 0;
	this.ColumnWidth = 0;
	this.ColumnMargin = 0;
	this.lastDimensions = getViewport.Height() + '.' + getViewport.Width()
	//## ENLARGE TEXT
	if (PAGE.TextSize == 'big') {
		LAYOUT.ColumnWidth = 390;
		LAYOUT.ColumnMargin = 20;
		LAYOUT.TextLineHeight = 22;
		LAYOUT.ContentDiv.className += ' large';
	} else {
		LAYOUT.ColumnWidth = 300;
		LAYOUT.ColumnMargin = 14;
		LAYOUT.TextLineHeight = 17;
		LAYOUT.ContentDiv.className = LAYOUT.ContentDiv.className.replace('large', '');
	}
	this.CurrentColumn = 0;
	this.Columns = 0;
	this.ColumnStartPosition = 0;
	this.VisibleColumns = 0;
	this.LastVisibleColumn = null;
	//##--
	this.ScrollDuration = 25;
	this.ScrollThread = null;
	this.ScrollLastPosition = 0;
	this.ScrollAnimation = { time: 0, begin: 0, change: 0.0, duration: 0.0, element: null, timer: null };
	//##--
	this.OriginalContent = '';
	this.isResizing = null;
	this.TableHeader = null;
	//##--
	if (PAGE.RenderMode == 'dynamic') {
		if (PAGE.LayoutMode == 'table') {
			LAYOUT.BuildTableLayout();
		} else if (PAGE.LayoutMode == 'special') {
			LAYOUT.BuildSpecialLayout();
		} else {
			LAYOUT.BuildColumnLayout();
		}
		LAYOUT.InitTableHack();
		addEvent(window, 'resize', LAYOUT.ResetLayout);
		addEvent(window, 'scroll', PAGE.CheckForOversize);
	}
};
LAYOUT.InitTableHack = function() {
	var tables = DOM.GetByClassName($('content'), 'table', 'datatable');
	for (var i = 0, n = tables.length; i < n; i++) {
		DOM.SetAttribute(tables[i], 'cellSpacing', '0');
		DOM.SetAttribute(tables[i], 'border', '0');
	}
};
LAYOUT.ToggleFinancialTableWidth = function(e) {
	CancelEvent(e);
	LAYOUT.ClearAllGraphs();
	var scrollPanel = $('tablescrollpanel');
	isWide = (scrollPanel.className == 'wide');
	if (isWide) {
		scrollPanel.className = '';
		$('submenu').style.display = 'block';
		scrollPanel.parentNode.className = '';
		DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(scrollPanel)[0])[0])[0])[3].style.display = 'none';
	} else {
		scrollPanel.className = 'wide';
		$('submenu').style.display = 'none';
		scrollPanel.parentNode.className = 'wide';
		if (!isIE) {
			DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(scrollPanel)[0])[0])[0])[3].style.display = 'table-cell';
		} else {
			DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(DOM.ChildNodes(scrollPanel)[0])[0])[0])[4].style.display = 'block';
		}
	}
};
LAYOUT.InitGraphs = function(e) {
	var table = $('financial-table');
	var tenYear = false;
	if (!table) {
		// this is the 10-year overview
		table = $('specialsida').getElementsByTagName('table')[0];
	}
	var rows = table.rows;
	for (var i = 0, n = rows.length, tr = null, td = null, newTd = null; i < n; i++) {
		row = rows[i];
		td = row.cells[1];
		if (!td.getElementsByTagName('IMG')[0]) {
			if (row.parentNode.tagName == 'TBODY') {
				newTd = LAYOUT.CreateCheckboxCell();
				newTd.style.cursor = 'pointer';
				if (row.cells[2].innerHTML.substring(0, 2).toLowerCase() == '<b' || row.cells[2].innerHTML.substring(0, 2).toLowerCase() == '<s')
					newTd.style.visibility = 'hidden';
				else
					newTd.className = 'radio';
				DOM.AddBefore(newTd, td);
				addEvent(newTd, 'click', LAYOUT.DisplayGraphBars);
			} else {
				if (td.className != 'radio') {
					DOM.AddBefore(DOM.Create('TH', 'radio'), td);
				}
			}
		}
	}
};
LAYOUT.CreateCheckboxCell = function() {
	var cell = DOM.Create('TD', 'radio');
	var box = DOM.Create('IMG', 'graph-radio');
	DOM.SetAttribute(box, 'SRC', '../../gfx/radio-off.png');
	DOM.SetAttribute(box, 'width', '11');
	DOM.SetAttribute(box, 'height', '9');
	DOM.Add(box, cell);
	return cell;
};
LAYOUT.ClearAllGraphs = function() {
	if ($('specialsida')) {
		var imgs = DOM.GetByClassName($('specialsida'), 'IMG', 'graph-radio');
		for (var i = 0, n = imgs.length; i < n; i++) {
			imgs[i].src = '../../gfx/radio-off.png';
		}
		var trs = $('specialsida').getElementsByTagName('tr');
		for (var i = 0, n = trs.length; i < n; i++) {
			trs[i].className = trs[i].className.replace('diagram', '');
		}
		if ($('bars')) DOM.Remove($('bars'));
	}
};
LAYOUT.DisplayGraphBars = function(e) {
	var imgs = DOM.GetByClassName($('specialsida'), 'IMG', 'graph-radio');
	for (var i = 0, n = imgs.length, img = null; i < n; i++) {
		img = imgs[i];
		img.src = '../../gfx/radio-off.png';
	}
	//## CLEAR ALLA DIAGRAM ROWS FROM TABLE
	var trs = $('specialsida').getElementsByTagName('TR');
	for (var i = 0, iLen = trs.length; i < iLen; i++) {
		trs[i].className = trs[i].className.replace('diagram', '');
	}
	if ($('bars')) $('bars').style.display = 'none';
	if (this == LAYOUT.CurrentRadio) {
		LAYOUT.CurrentRadio = null;
	} else {
		LAYOUT.CurrentRadio = this;
		this.getElementsByTagName('IMG')[0].src = '../../gfx/radio-on.png';
		LAYOUT.ShowDiagram(this.parentNode, e);
	}
};
LAYOUT.FinancialTableScroll = function(e) {
	if ($('bars')) DOM.Remove($('bars'));
};
LAYOUT.ShowDiagram = function(tr, e) {
	var table = $('specialsida').getElementsByTagName('TABLE')[0];
	if ($('bars')) DOM.Remove($('bars'));
	div = document.createElement('div');
	div.id = 'bars';
	for (var i = 0; i < 10; i++) {
		img = DOM.Create('img');
		img.width = '7';
		DOM.Add(img, div);
	}
	DOM.Add(div, $('specialsida'));
	el = table.getElementsByTagName('div')[0];
	diagrambars = $('bars').getElementsByTagName('IMG');
	tr.className = tr.className + ' diagram';
	diagramcells = tr.cells;
	cellvalue = new Array();
	max = -1000000;
	min = 1000000;
	label = diagramcells[0].childNodes[0];
	for (var i = 2; i < diagramcells.length; i++) {
		cellvalue[i] = diagramcells[i].innerHTML.ToString();
		if (TRANSLATE.Lang == 'en') {
			cellvalue[i] = cellvalue[i].replace(',', '');
		} else {
			cellvalue[i] = cellvalue[i].replace('&nbsp;', '').replace(' ', '').replace(',', '.');
		}
		cellvalue[i] = parseFloat(cellvalue[i]);
		if (cellvalue[i] < min) min = cellvalue[i];
		if (cellvalue[i] > max) max = cellvalue[i];
	}
	scale = 1;
	if (Math.abs(min) > max) {
		scale = -min;
	} else {
		scale = max;
	}
	scrollDivTop = $('specialsida').scrollTop;
	var left = 184;
	var startBarIndex = 0;
	if ($('financial-table'))
		startBarIndex = 1;

	var top = tr.offsetHeight + tr.offsetTop - 106 - scrollDivTop;
	for (var i = 2 + startBarIndex; i < diagramcells.length; i++) {
		if (isNaN(cellvalue[i])) cellvalue[i] = 0;
		height = parseInt((Math.abs(cellvalue[i]) / scale) * 100);
		diagrambars[i - 2].style.height = height + 'px';
		diagrambars[i - 2].style.left = left + 'px';
		if (cellvalue[i] < 0) {
			diagrambars[i - 2].className = 'negative';
			diagrambars[i - 2].style.top = top + 'px';
			diagrambars[i - 2].src = '../../gfx/diagramred.gif';
		} else {
			diagrambars[i - 2].className = '';
			diagrambars[i - 2].style.top = (top - height) + 'px';
			diagrambars[i - 2].src = '../../gfx/diagramblue.gif';
		}
		left += 68;
		diagrambars[i - 2].style.display = 'block';
	}
	$('bars').style.display = 'block';
};
LAYOUT.BuildTableLayout = function() {
	iPOP.Init();
	var tables = LAYOUT.ContentDiv.getElementsByTagName('TABLE');
	for (var i = 0, t = tables.length, table = null; i < t; i++) {
		table = tables[i];
		if (table.className.indexOf('datatable') > -1) {
			//## INIT MULTIYEAR
			/*if (table.className.indexOf('multiyear') > -1) {
			// all multiyear tabels should have the Excellink as well
			var ExcelLink = DOM.Create('DIV', '', 'excellink');
			DOM.SetAttribute(ExcelLink, 'class', 'button');
			var tmpA = DOM.Create('A');
			DOM.SetAttribute(tmpA, 'HREF', TEXTHANDLER.ExcellinkHref);
			tmpA.innerHTML = TEXTHANDLER.ExcellinkText;
			DOM.Add(tmpA, ExcelLink);
			DOM.Add(ExcelLink, LAYOUT.ContentDiv);

				var toogleMultiView = DOM.Create('DIV', '', 'headlinelink');
			DOM.SetAttribute(toogleMultiView, 'class', 'button');
			var toogleMultiViewTrigger = DOM.Create('A');
			DOM.SetAttribute(toogleMultiViewTrigger, 'HREF', 'javascript:;');
			toogleMultiViewTrigger.innerHTML = TEXTHANDLER.FinancialTableMultiViewTrigger;
			addEvent(toogleMultiViewTrigger, 'click', LAYOUT.ToggleFinancialTableWidth);
			DOM.Add(toogleMultiViewTrigger, toogleMultiView);
			DOM.Add(toogleMultiView, LAYOUT.ContentDiv);
			}*/
			if (table.getElementsByTagName('THEAD')) {
				var tHeadRows = table.getElementsByTagName('THEAD')[0].rows.length;
				var tHeadTopicRow = table.getElementsByTagName('THEAD')[0].rows[tHeadRows - 1].className = 'main-header-row';
			}
			var oldlevel = 1;
			for (var r = 1, nn = table.rows.length, row = null; r < nn; r++) {
				row = table.rows[r];
				var className = row.className;
				var pos = className.indexOf('lev') + 3;
				var level = className.substring(pos, pos + 1);
				if (level > oldlevel) {
					var cell = table.rows[r - 1].cells[0];
					var tmplevel = level;
					while (tmplevel > 1) {
						tmplevel--;
						cell = cell.childNodes[0];
					}
					cell = cell.parentNode;
					if (!cell.getElementsByTagName('A')[0]) {//## CHECK SO WE DONT APPEND MULTIPLE ITEMS
						a = document.createElement('a');
						a.innerHTML = cell.innerHTML;
						a.href = 'javascript:;';
						addEvent(a, 'click', LAYOUT.Swaprows);
						cell.innerHTML = '';
						cell.appendChild(a);
					}
				}
				oldlevel = level;
			}
		}
		var rowCount = Math.floor((document.documentElement.clientHeight - LAYOUT.ContentDiv.offsetTop) / LAYOUT.TextLineHeight) - 5;
		var maxHeight = LAYOUT.TextLineHeight * rowCount;
		var contentHeight = LAYOUT.ContentDiv.scrollHeight;
		var tableheight = maxHeight;
		var TableScrollPanel = $('tablescrollpanel');
		if (table.className.indexOf('scrollable') > -1) {
			table = document.createElement('table');
			table.className = table.className;
			table.cellSpacing = '0';
			table.appendChild(document.createElement('tbody'));
			table = table.childNodes[0];
			table.appendChild(tables[i].rows[0]); // append first row
			if (table.rows[0].cells[1].tagName == 'TH') {
				table.appendChild(tables[i].rows[0]); // append second row
			}
			table.parentNode.insertBefore(table.parentNode, table);
			tableheight -= table.offsetHeight;
			tablescrollpanel = document.createElement('div');
			tablescrollpanel.className = 'tablescrollpanel';
			table.parentNode.appendChild(tablescrollpanel);
			tablescrollpanel.appendChild(tables[i + 1]);
			return;
		} else {
			if (!TableScrollPanel) {
				TableScrollPanel = document.createElement('div');
				TableScrollPanel.id = 'tablescrollpanel';
				table.parentNode.insertBefore(TableScrollPanel, table.parentNode.firstChild);
				TableScrollPanel.appendChild(table);
			}
		}
		LAYOUT.CreateHeaderClone(table, false);
		LAYOUT.InitGraphs();
		if ($('specialsida').className.indexOf('equity') > -1) {
			addNotemenuButton();
			/*$('tablescrollpanel').style.width = '970px';*/
		}
	}
};
LAYOUT.CreateHeaderClone = function(table, override) {
	//## NO NEED FOR CLONE
	return;
	var tHeadClone = $('head-clone');
	var headCloneClass = ($('tablescrollpanel').className == 'wide') ? 'wide' : '';

	if (!tHeadClone || override) {
		if (tHeadClone) DOM.Remove(tHeadClone);
		var tHead = table.getElementsByTagName('THEAD')[0];
		tHead = tHead.cloneNode(true);
		tHeadClone = DOM.Create('DIV', headCloneClass, 'head-clone');
		tHeadClone.innerHTML = '<table id="financial-table" class="datatable"><thead>' + tHead.innerHTML + '</thead></table>';
		DOM.Add(tHeadClone, LAYOUT.ContentDiv);

		tHeadClone.style.top = $('tablescrollpanel').offsetTop + 'px';
		tHeadClone.style.left = $('tablescrollpanel').offsetLeft + 'px';

	}
	LAYOUT.TableHeader = tHeadClone;
};
LAYOUT.Swaprows = function(e) {
	if (document.addEventListener) {
		e.preventDefault();
		a = e.target;
		if (a.className != 'expanded') {
			a.className = 'expanded';
			viewtype = 'table-row';
		} else {
			a.className = '';
			viewtype = 'none';
		}
	} else {
		e.cancelBubble = true;
		a = e.srcElement;
		if (a.className != 'expanded') {
			a.className = 'expanded';
			viewtype = 'block';
		} else {
			a.className = '';
			viewtype = 'none';
		}
	}
	tr = a.parentNode;
	while (tr.tagName != 'TR') {
		tr = tr.parentNode;
	}

	if (a.className != 'expanded') {
		tr.className = tr.className.replace(' expanded', '');
	} else {
		tr.className += ' expanded';
	}
	var textindex = tr.className.indexOf('lev');
	startlevel = parseInt(tr.className.substring(textindex + 3, textindex + 4));
	level = startlevel + 1;
	var rowindex = tr.rowIndex;
	var lastrow = 0;
	if ($('specialsida').className == 'marketsandbrands') {
		rowindex += 2;
		lastrow = -1;
	}

	tr = tr.parentNode.rows[rowindex - 1];

	while (startlevel < level) {
		if (startlevel == (level - 1) || viewtype == 'none') {
			if (a.parentNode.parentNode != tr) tr.style.display = viewtype;
		}
		if (tr.parentNode.rows.length <= rowindex + 1 + lastrow) break;
		rowindex++;
		tr = tr.parentNode.rows[rowindex - 1];
		textindex = tr.className.indexOf('lev');
		level = parseInt(tr.className.substring(textindex + 3, textindex + 4));
	}
	LAYOUT.ClearAllGraphs();
	return false;
};
function addNotemenuButton() {
	// the widenote page hides the note menu. Attach a button to show it
	var notemenubutton = DOM.Create('div', 'button', 'notemenubutton');
	notemenubutton.innerHTML = '<a href="javascript:;" onclick="MENU.ShowNoteMenu();">' + TRANSLATE.GetValue("rakenskaperochnoter") + '</a>';
	DOM.Add(notemenubutton, document.getElementsByTagName('BODY')[0]);
	//if ($('specialsida').className == 'widenote') {
		//notemenubutton.className = 'button widenote';
	//}
}
LAYOUT.BuildSpecialLayout = function() {
	if ($('submenu')) {
		//## THIS IS A FINANCIAL TABLE (NOTE)
		if ($('specialsida').className == 'widenote') {
			addNotemenuButton();
		}
		else {
			document.getElementsByTagName('h1')[0].className = 'note';
		}
		if ($('submenu').offsetHeight > $('content').offsetHeight) {
			$('content').style.height = $('submenu').offsetHeight - 40 + 'px';
		}
		return;
	}
	if ($('specialsida').className == 'tenyearoverview') {
		$('content').style.width = '970px';
		LAYOUT.InitGraphs();
		return;
	}

	LAYOUT.ReplaceTablesWithIcon();
	$('content').style.width = '950px';
	if ($('micro-scroll')) {
		LAYOUT.ContentDiv = $('micro-scroll');
		LAYOUT.BuildMicroColumnLayout();
	}
	if ($('specialsida').className == 'intro') {
		$('content').className = 'no-pad';
		$('topic').style.display = 'none';
		$('container').getElementsByTagName('H1')[0].style.display = 'none';
		addEvent($('content'), 'click', PAGE.StartReport);
	};
	if ($('specialsida').className == 'thisisteliasonera') {
		$('container').className = 'wide';
		var firstH1 = $('container').getElementsByTagName('H1')[0];
		var secondH1 = $('content').getElementsByTagName('H1')[0];
		secondH1.parentNode.replaceChild(firstH1, secondH1);
	}
	if ($('specialsida').className == 'marketsandbrands') {
		var links = $('specialsida').getElementsByTagName('A');
		for (var i = 0, n = links.length; i < n; i++) {
			addEvent(links[i], 'click', LAYOUT.Swaprows);
		}
	}
	if ($('specialsida').className == 'areviewofouroperations' || $('specialsida').className == 'thisisteliasonera') {
		var links = $('specialsida').getElementsByTagName('A');
		if (links[0].id == 'btn-listen')
			j = 1;
		else
			j = 0;
		for (var i = 0, n = 3; i < n; i++) {
			var link = links[i + j];
			addEvent(link, 'click', INTROBOX.GrowBig);
			var areaImage1 = new Image();
			areaImage1.src = '../../images/' + DOM.GetAttribute(link, 'id').toString() + '_big.jpg';
			var areaImage2 = new Image();
			areaImage2.src = '../../images/areas/' + DOM.GetAttribute(link, 'id').toString() + '_norm.jpg';

		}
	}
	LAYOUT.SplitTextInTwoColumns();
	LAYOUT.InitInlineIllustrations();
	PAGE.CheckForOversize();
};
LAYOUT.SplitTextInTwoColumns = function() {
	var blocks = DOM.GetByClassName($('content'), 'div', 'split-in-two');
	for (var i = 0, n = blocks.length; i < n; i++) {
		var block = blocks[i];
		var text = block.innerHTML.toString();
		var arr = text.split(' ');
		var nn = arr.length;
		var cut = nn / 2;
		var col1 = '';
		var col2 = '';
		for (var ii = 0; ii < nn; ii++) {
			if (ii <= cut) {
				col1 += arr[ii] + ' ';
			} else {
				col2 += arr[ii] + ' ';
			}
		}
		var htmlColumns = DOM.Create('DIV');
		var htmlColLeft = DOM.Create('DIV', 'left pad-left');
		htmlColLeft.innerHTML = '<p>' + col1 + '</p>';
		DOM.Add(htmlColLeft, htmlColumns);
		var htmlColRight = DOM.Create('DIV', 'right pad-right');
		htmlColRight.innerHTML = '<p>' + col2 + '</p>';
		DOM.Add(htmlColRight, htmlColumns);
		block.parentNode.replaceChild(htmlColumns, block);
	}
};
LAYOUT.ReplaceTablesWithIcon = function() {
	if (PAGE.RenderMode == 'static') return;
	var tables = DOM.GetByClassName($('content'), 'table', 'datatable');
	for (var z = 0, n = tables.length; z < n; z++) {
		var table = tables[z];
		if ((table.className.indexOf('locked') == -1) && (table.className.indexOf('chain-previous') == -1)) {
			var tableBorder = DOM.GetAttribute(table, 'border');
			if (!tableBorder == '0') DOM.SetAttribute(table, 'border', '0');
			var tableWrapper = DOM.Create('DIV', 'additional graph-box');
			var container = DOM.Create('DIV', 'graph-container');
			var GraphBoxHeadline = ' ';
			if (table.previousSibling) {
				GraphBoxHeadline = DOM.PreviousSibling(table);
				if (GraphBoxHeadline && GraphBoxHeadline.tagName) {
					if (GraphBoxHeadline.tagName.toLowerCase() == 'h6') {
						GraphBoxHeadline.style.display = 'none';
						GraphBoxHeadline = GraphBoxHeadline.innerHTML.replace('<BR>', ' ');
					} else {
						GraphBoxHeadline = ' ';
					}
				} else {
					GraphBoxHeadline = ' ';
				}
			}
			var GraphBoxCite = ' ';
			if (table.nextSibling) {
				GraphBoxCite = DOM.NextSibling(table);
				if (GraphBoxCite && GraphBoxCite.tagName) {
					if (GraphBoxCite.tagName.toLowerCase() == 'cite') {
						GraphBoxCite.style.display = 'none';
						var strCite = GraphBoxCite.innerHTML;
						if (strCite.length > 50) {
							GraphBoxCite = strCite.substring(0, 53) + ' ...';
						} else {
							GraphBoxCite = strCite;
						}
					} else {
						GraphBoxCite = ' ';
					}
				} else {
					GraphBoxCite = ' ';
				}
			}
			var link = DOM.Create('A', '');
			link.innerHTML = '<strong>' + GraphBoxHeadline + '</strong><img src="../../gfx/icon-table.gif" alt="" />';
			DOM.SetAttribute(link, 'href', 'javascript:;');
			DOM.SetAttribute(link, 'rel', 'inline');
			DOM.Add(link, container);
			var btn = DOM.Create('span', 'zoom');
			btn.innerHTML = '';
			btn.title = 'Zoom';
			DOM.Add(btn, link);
			var wrapper = DOM.Create('DIV', 'ipop-table');
			wrapper.innerHTML = '<table class="' + table.className.toString() + '">' + table.innerHTML + '</table>';
			DOM.Add(wrapper, container);
			var cite = DOM.Create('cite');
			if (strCite) DOM.SetAttribute(cite, 'title', strCite);
			cite.innerHTML = GraphBoxCite.ToString();
			DOM.Add(cite, container);
			DOM.Add(container, tableWrapper);
			table.parentNode.replaceChild(tableWrapper, table);
		} else if (table.className.indexOf('chain-previous') != -1) {
			var tableSibling = DOM.ChildNodes(DOM.ChildNodes(DOM.PreviousSibling(table))[0])[1];
			DOM.Add(table, tableSibling);
		}
	}
	return;
};
LAYOUT.BuildMicroColumnLayout = function() {

	var elCount = 0;

	LAYOUT.ColumnWidth = 500;
	LAYOUT.ColumnMargin = 15;
	LAYOUT.TextLineHeight = 17;

	$('micro-scroll').style.width = '500px';
	LAYOUT.ContentDiv.className = '';
	LAYOUT.ContentDiv.style.padding = '0';
	LAYOUT.ContentDiv.style.overflow = 'hidden';

	if (LAYOUT.OriginalContent == '') {
		LAYOUT.OriginalContent = LAYOUT.ContentDiv.innerHTML;
	} else {
		LAYOUT.ContentDiv.innerHTML = LAYOUT.OriginalContent;
	}

	var rowCount = Math.floor((document.documentElement.clientHeight - LAYOUT.ContentDiv.offsetTop) / LAYOUT.TextLineHeight) - 5;
	var maxHeight = $('leftcontent').offsetHeight;
	var contentHeight = LAYOUT.ContentDiv.scrollHeight;
	if (contentHeight < maxHeight) return;
	var columns = DOM.Create('div', '', 'columns');
	columns.style.height = maxHeight - 14 + 'px';
	columns.style.overflow = 'hidden';

	//## SETUP DIVS FOR THE HORIZONTAL SCROLLING FEATURE
	LAYOUT.scrollPanel = DOM.Create('div', '', 'scrollpanel');
	DOM.Add(columns, LAYOUT.scrollPanel);
	DOM.Add(LAYOUT.scrollPanel, LAYOUT.ContentDiv);

	var nextOffset = 0;
	var lastColumnHeight = 0;
	var heightRemainder = 0;

	elCount = DOM.ChildNodes(LAYOUT.ContentDiv).length;

	if (elCount < 1) return;

	var backupItterator = 0;
	while ((elCount > 1) && (backupItterator < 100)) {
		backupItterator++;
		var column = DOM.Create('div', 'column', 'col-' + LAYOUT.Columns);
		column.style.marginTop = (-nextOffset) + 'px';
		columns.appendChild(column);
		while ((elCount > 1) && (backupItterator < 100)) {
			DOM.Add(DOM.ChildNodes(LAYOUT.ContentDiv)[0], column);
			elCount--;
			if (column.lastChild.tagName == 'P') {
				if (column.scrollHeight > (maxHeight + nextOffset)) { //## IF COL IS FULL
					if ((column.lastChild.className.indexOf('additional') != -1) || (column.lastChild.className.indexOf('illustration') != -1)) {
						LAYOUT.ContentDiv.insertBefore(column.lastChild, LAYOUT.ContentDiv.firstChild);
						elCount++;
						//## ADDED BY TED 2008-03-17 TO CIRCUMVENT BUG IN FIREFOX WHICH CAUSES AN INFINITE LOOP
						if (navigator.userAgent.indexOf("Firefox") != -1) { nextOffset = 1; }
						else { nextOffset = 0; }
					} else {
						var elHeight = (column.scrollHeight - lastColumnHeight);
						if (elHeight > maxHeight) {
							LAYOUT.ContentDiv.insertBefore(column.lastChild.cloneNode(true), DOM.FirstChild(LAYOUT.ContentDiv));
							elCount++;
							heightRemainder = (column.scrollHeight - (maxHeight + nextOffset));
							nextOffset = (elHeight - heightRemainder);
							lastColumnHeight = 0;
						} else if ((column.scrollHeight - (maxHeight + nextOffset) == LAYOUT.TextLineHeight) && (elHeight != LAYOUT.TextLineHeight)) {
							nextOffset = 0;
						} else {
							LAYOUT.ContentDiv.insertBefore(column.lastChild.cloneNode(true), LAYOUT.ContentDiv.firstChild);
							elCount++;
							column.lastChild.className = column.lastChild.className + ' noprint';
							heightRemainder = (column.scrollHeight - maxHeight);
							nextOffset = (elHeight) - (heightRemainder) + nextOffset;
							if (nextOffset == 0) {
								column.removeChild(column.lastChild);
								var lastElem = DOM.ChildNodes(column)[DOM.ChildNodes(column).length - 1];
								if (lastElem.tagName) {
									if (lastElem.tagName.toUpperCase().substring(0, 1) == 'H') {
										LAYOUT.ContentDiv.insertBefore(lastElem, LAYOUT.ContentDiv.firstChild);
										elCount++;
									}
								}
							}
						}
					}
				}
				break;
			}
			lastColumnHeight = column.scrollHeight;
		}
		LAYOUT.Columns++;
	}
	columns.style.width = parseInt(LAYOUT.ColumnWidth * LAYOUT.Columns + LAYOUT.ColumnMargin * (LAYOUT.Columns - 1)) + 'px';
	column.style.marginRight = '0';

	var screenWidth = $('specialsida').offsetWidth + 50;
	if (parseInt(columns.style.width) < screenWidth) {
		screenWidth = parseInt(columns.style.width);
	}

	LAYOUT.VisibleColumns = Math.floor(screenWidth / LAYOUT.ColumnWidth);
	LAYOUT.LastVisibleColumn = DOM.GetByClassName($('columns'), 'DIV', 'column')[LAYOUT.VisibleColumns - 1];
	LAYOUT.ContentDiv.style.width = 500 + 'px';
	LAYOUT.scrollPanel.style.width = LAYOUT.scrollPanel.parentNode.offsetWidth - (LAYOUT.ColumnMargin + LAYOUT.ColumnMargin) + 'px';
	LAYOUT.scrollPanel.style.overflowY = 'hidden';
	LAYOUT.scrollPanel.style.height = maxHeight + 'px';
	LAYOUT.ContentDiv.appendChild(LAYOUT.scrollPanel);
	addEvent(LAYOUT.scrollPanel, 'scroll', LAYOUT.adjustScroll);
	PAGE.CheckForOversize();
};
LAYOUT.InitInlineIllustrations = function() {
	//## INITIALIZE INLINE ILLUSTRATIONS
	if (PAGE.RenderMode == 'static') return;
	var divs = DOM.GetByClassName($('content'), 'div', 'illustration')
	for (var i = 0, iLen = divs.length; i < iLen; i++) {
		var div = divs[i];
		var link = DOM.GetByAttribute(div, 'A', 'rel', 'inline')[0];
		if (link) {
			var GraphBoxHeadline = null;
			if (div.previousSibling) {
				GraphBoxHeadline = DOM.PreviousSibling(div);
				if (GraphBoxHeadline && GraphBoxHeadline.tagName) {
					if (GraphBoxHeadline.tagName.toLowerCase() == 'h6') {
						GraphBoxHeadline.style.display = 'none';
						var strong = DOM.Create('STRONG');
						var strStrong = GraphBoxHeadline.innerHTML.replace('<BR>', ' ');
						strong.innerHTML = strStrong;
						DOM.AddFirst(strong, link);
					}
				}
			}
			var GraphBoxCite = null;
			if (div.nextSibling) {
				GraphBoxCite = DOM.NextSibling(div);
				if (GraphBoxCite && GraphBoxCite.tagName) {
					if (GraphBoxCite.tagName.toLowerCase() == 'cite') {
						GraphBoxCite.style.display = 'none';
						var cite = DOM.Create('CITE');
						var strCite = GraphBoxCite.innerHTML;
						if (strCite) {
							if (strCite.length > 50) {
								cite.innerHTML = strCite.substring(0, 55) + ' ...';
							} else {
								cite.innerHTML = strCite;
							}
							DOM.SetAttribute(cite, 'title', strCite);
						}
						DOM.Add(cite, link);
					}
				}
			}
			div.className = div.className + ' graph-box';
			var btn = DOM.Create('span', 'zoom');
			btn.innerHTML = ' ';
			btn.title = 'Zoom';
			DOM.Add(btn, link);
			var container = DOM.Create('DIV', 'graph-container');
			DOM.Add(link, container);
			DOM.Add(container, div);
			//## PRELOAD BIG ILLUSTRATIONS
			var thumbImageSrc = DOM.GetAttribute(link, 'href').toString();
			var bigImage = new Image();
			bigImage.src = thumbImageSrc.toString();
		}
	}
};
LAYOUT.EnableFactBoxes = function() {
	var facts = DOM.GetByClassName($('content'), 'div', 'facts');
	for (var i = 0, n = facts.length; i < n; i++) {
		var fact = facts[i];
		var h3 = fact.getElementsByTagName('H3')[0];
		var factTopic = '', factText = '';
		if (h3) {
			var newPlaceholder = DOM.Create('DIV', 'fact-placeholder');

			factTopic = h3.innerHTML.ToString().replace(new RegExp('/\r|\n|\f|\t|\r\n\f\t\v/g', 'gi'), '');
			factText = fact.innerHTML.ToString().replace(new RegExp('/\r|\n|\f|\t|\r\n\f\t\v/g', 'gi'), '').replace(factTopic, '');

			if (factTopic.length > 40) {
				factText = factText.substring(0, 50);
			} else {
				factText = factText.substring(0, 90);
			}

			DOM.Remove(h3);
			newPlaceholder.innerHTML = fact.innerHTML;

			var newInput = DOM.Create('DIV', 'wrapper');
			DOM.SetAttribute(newInput, 'title', TRANSLATE.GetValue('ReadMore'));
			newInput.innerHTML = '<h3>' + factTopic + '</h3><p>' + factText + '.. <span>' + TRANSLATE.GetValue('ReadMore') + '..</span></p>'.toString();
			addEvent(newInput, 'click', iPOP.Open);

			fact.innerHTML = '';
			fact.className = 'factbox additional';
			DOM.Add(newInput, fact);
			DOM.Add(newPlaceholder, fact);
			//$('content').className = $('content').className + ' factpop';
		}
	}
};
LAYOUT.BuildColumnLayout = function() {
	if (!LAYOUT.ContentDiv) LAYOUT.ContentDiv = $('content');
	LAYOUT.EnableFactBoxes();
	LAYOUT.ReplaceTablesWithIcon();
	var elCount = 0;
	if (PAGE.TextSize == 'big') {
		LAYOUT.ColumnWidth = 390;
		LAYOUT.ColumnMargin = 20;
		LAYOUT.TextLineHeight = 22;
		LAYOUT.ContentDiv.className = LAYOUT.ContentDiv.className + ' large';
	} else {
		LAYOUT.ColumnWidth = 300;
		LAYOUT.ColumnMargin = 14;
		LAYOUT.TextLineHeight = 17;
		LAYOUT.ContentDiv.className = LAYOUT.ContentDiv.className.replace('large', '');
	}
	LAYOUT.ContentDiv.style.padding = '0';
	LAYOUT.ContentDiv.style.overflow = 'hidden';
	if (LAYOUT.OriginalContent == '') {
		LAYOUT.OriginalContent = LAYOUT.ContentDiv.innerHTML;
	} else {
		LAYOUT.ContentDiv.innerHTML = LAYOUT.OriginalContent;
	}
	var rowCount = Math.floor((document.documentElement.clientHeight - LAYOUT.ContentDiv.offsetTop) / LAYOUT.TextLineHeight) - 4;
	var maxHeight = LAYOUT.TextLineHeight * rowCount;
	var contentHeight = LAYOUT.ContentDiv.scrollHeight;
	if (contentHeight < maxHeight) return;
	var columns = DOM.Create('div', '', 'columns');
	columns.style.height = maxHeight + 'px';
	columns.style.overflow = 'hidden';
	var pagenumbers = DOM.Create('div', '', 'pagenumbers');
	LAYOUT.scrollPanel = DOM.Create('div', '', 'scrollpanel');
	DOM.Add(columns, LAYOUT.scrollPanel);
	DOM.Add(pagenumbers, LAYOUT.scrollPanel);
	DOM.Add(LAYOUT.scrollPanel, LAYOUT.ContentDiv);
	LAYOUT.InitInlineIllustrations();
	var nextOffset = 0;
	var lastColumnHeight = 0;
	var heightRemainder = 0;
	elCount = DOM.ChildNodes($('content')).length;
	if (elCount < 1) return;
	var backupItterator = 0;
	while ((elCount > 1) && (backupItterator < 100)) {
		backupItterator++;
		var column = DOM.Create('div', 'column', 'col-' + LAYOUT.Columns);
		column.style.marginTop = (-nextOffset) + 'px';
		columns.appendChild(column);
		while ((elCount > 1) && (backupItterator < 100)) {
			if (DOM.ChildNodes(LAYOUT.ContentDiv)[0].id !== 'scrollpanel') {
				DOM.Add(DOM.ChildNodes(LAYOUT.ContentDiv)[0], column);
			}
			elCount--;
			if (column.scrollHeight > (maxHeight + nextOffset)) { //## IF COL IS FULL
				if ((DOM.LastChild(column).className.indexOf('additional') != -1) || (DOM.LastChild(column).className.indexOf('illustration') != -1) || (DOM.LastChild(column).tagName == 'ul')) {
					//DOM.AddBefore(DOM.LastChild(column), DOM.FirstChild(LAYOUT.ContentDiv));
					LAYOUT.ContentDiv.insertBefore(column.lastChild, LAYOUT.ContentDiv.firstChild);
					elCount++;
					//## ADDED BY TED 2008-03-17 TO CIRCUMVENT BUG IN FIREFOX WHICH CAUSES AN INFINITE LOOP
					if (navigator.userAgent.indexOf("Firefox") != -1) { nextOffset = 1; }
					else { nextOffset = 0; }
				} else {
					var elHeight = (column.scrollHeight - lastColumnHeight);
					if (elHeight > maxHeight) {
						LAYOUT.ContentDiv.insertBefore(column.lastChild.cloneNode(true), LAYOUT.ContentDiv.firstChild);
						elCount++;
						heightRemainder = (column.scrollHeight - (maxHeight + nextOffset));
						nextOffset = (elHeight - heightRemainder);
						lastColumnHeight = 0;
					} else if ((column.scrollHeight - (maxHeight + nextOffset) == LAYOUT.TextLineHeight) && (elHeight != LAYOUT.TextLineHeight)) {
						elCount++;
						nextOffset = 0;
					} else {
						LAYOUT.ContentDiv.insertBefore(column.lastChild.cloneNode(true), LAYOUT.ContentDiv.firstChild);
						elCount++;
						column.lastChild.className = column.lastChild.className + ' noprint';
						heightRemainder = (column.scrollHeight - maxHeight);
						nextOffset = (elHeight) - (heightRemainder) + nextOffset;
						if (nextOffset == 0) {
							column.removeChild(column.lastChild);
							var lastElem = DOM.ChildNodes(column)[DOM.ChildNodes(column).length - 1];
							if (lastElem.tagName) {
								if (lastElem.tagName.toUpperCase().substring(0, 1) == 'H') {
									LAYOUT.ContentDiv.insertBefore(lastElem, LAYOUT.ContentDiv.firstChild);
									elCount++;
								}
							}
						}
					}
				}
				break;
			}
			lastColumnHeight = column.scrollHeight;
		}
		LAYOUT.Columns++;
	}
	//## ADD THE PAGENUMBERS
	for (var i = 0, n = DOM.ChildNodes(columns).length; i < n; i++) {
		pagenumber = document.createElement('div');
		pagenumber.innerHTML = (i + 1) + ' (' + LAYOUT.Columns + ')';
		pagenumbers.appendChild(pagenumber);
	}
	columns.style.width = parseInt(LAYOUT.ColumnWidth * LAYOUT.Columns + LAYOUT.ColumnMargin * (LAYOUT.Columns - 1)) + 'px';
	column.style.marginRight = '0';
	pagenumber.style.marginRight = '0';
	pagenumbers.style.width = columns.style.width;
	var screenWidth = document.documentElement.clientWidth;
	if (PAGE.TextSize == 'big') {
		if (screenWidth >= 1620) { screenWidth = 1620 }
		else if (screenWidth >= 1210) { screenWidth = 1210 }
		else { screenWidth = 800 }
	} else {
		if (screenWidth >= 1870) { screenWidth = 1870 }
		else if (screenWidth >= 1556) { screenWidth = 1556 }
		else if (screenWidth >= 1242) { screenWidth = 1242 }
		else { screenWidth = 928 }
	}
	if (parseInt(columns.style.width) < screenWidth) {
		screenWidth = parseInt(columns.style.width);
	}
	LAYOUT.VisibleColumns = Math.floor(screenWidth / LAYOUT.ColumnWidth);
	LAYOUT.LastVisibleColumn = DOM.GetByClassName($('columns'), 'DIV', 'column')[LAYOUT.VisibleColumns - 1];
	LAYOUT.ContentDiv.style.width = screenWidth + 'px';
	LAYOUT.scrollPanel.style.width = screenWidth + 'px';
	LAYOUT.scrollPanel.style.height = ((rowCount * LAYOUT.TextLineHeight) + 55) + 'px';
	LAYOUT.ContentDiv.appendChild(LAYOUT.scrollPanel);
	addEvent(LAYOUT.scrollPanel, 'scroll', LAYOUT.adjustScroll);

	PAGE.CheckForOversize();
};
LAYOUT.adjustScroll = function(e) {
	if (LAYOUT.ScrollThread != null) clearTimeout(LAYOUT.ScrollThread);
	LAYOUT.ScrollThread = setTimeout("LAYOUT.doAdjustscroll()", 300);
};
LAYOUT.doAdjustscroll = function() {
	var adjustment = parseInt(LAYOUT.scrollPanel.scrollLeft % (LAYOUT.ColumnWidth + LAYOUT.ColumnMargin));
	if (adjustment != 0) {
		if (Math.abs(adjustment) <= 10) { //## LEFT			
			LAYOUT.ScrollNext();
		} else if (Math.abs(adjustment - (LAYOUT.ColumnWidth + LAYOUT.ColumnMargin)) <= 10) { //## RIGHT
			LAYOUT.ScrollPrevious();
		} else { //## NEAREST
			if (adjustment > (LAYOUT.ColumnWidth / 2)) { //## ADJUST TO RIGHT
				LAYOUT.ScrollTo(parseInt(LAYOUT.scrollPanel.scrollLeft / (LAYOUT.ColumnWidth + LAYOUT.ColumnMargin)) + 1);
			} else { //## ADJUST TO LEFT
				LAYOUT.ScrollTo(parseInt(LAYOUT.scrollPanel.scrollLeft / (LAYOUT.ColumnWidth + LAYOUT.ColumnMargin)));
			}
		}
	} else {
		LAYOUT.CurrentColumn = (LAYOUT.scrollPanel.scrollLeft / (LAYOUT.ColumnWidth + LAYOUT.ColumnMargin));
	}
	LAYOUT.ScrollLastPosition = LAYOUT.scrollPanel.scrollLeft;
};
LAYOUT.ScrollNext = function() {
	iPOP.Close();
	if (parseInt(LAYOUT.CurrentColumn + LAYOUT.VisibleColumns) >= LAYOUT.Columns) {
		LAYOUT.ScrollTo(LAYOUT.Columns - 1)
	} else {
		LAYOUT.OffsetScroll(LAYOUT.VisibleColumns - 1);
	}
};
LAYOUT.ScrollPrevious = function() {
	iPOP.Close();
	var targetColumn = (-(LAYOUT.VisibleColumns - 1));
	if (LAYOUT.VisibleColumns == 1)
		targetColumn--;
	if (LAYOUT.CurrentColumn > 1) {
		LAYOUT.OffsetScroll(targetColumn);
	} else {
		LAYOUT.OffsetScroll(-1);
	}
};
LAYOUT.OffsetScroll = function(offset) {
	var target = LAYOUT.CurrentColumn + offset;
	if (target < 0 || target > LAYOUT.Columns) return;
	LAYOUT.ScrollTo(target);
};
LAYOUT.ScrolltoPos = function(e) {
	var TagNameInContentForPortraits = 'h2';
	//## GET NAME OF PORTRAIT
	var em = this.parentNode.getElementsByTagName('em')[0];
	//## GET ELEMENT IN CONTENT DIV WITH CORRESPONDENT INNERHTML
	var elements = $('content').getElementsByTagName(TagNameInContentForPortraits);
	for (var i = 0, iLen = elements.length; i < iLen; i++) {
		if (elements[i] && elements[i].innerHTML.indexOf(em.innerHTML) > -1) {
			var column = elements[i].parentNode;
			LAYOUT.ScrollTo(column.id.replace('col-', ''));
			break;
		}
	}
};
LAYOUT.ScrollTo = function(target) {
	if (target < 0) return;
	LAYOUT.doScrollTo(target);
};
LAYOUT.doScrollTo = function(target) {
	if (target >= LAYOUT.Columns) return;
	LAYOUT.CurrentColumn = target;
	targetcol = $('col-' + target);
	var offsetLeft;
	if (target == (LAYOUT.Columns - 1)) {
		offsetLeft = LAYOUT.scrollPanel.scrollWidth - LAYOUT.scrollPanel.offsetWidth;
	} else {
		offsetLeft = 0;
		do {
			offsetLeft += targetcol.offsetLeft;
		} while (targetcol = targetcol.offsetParent)

		targetcol = $('col-0');
		LAYOUT.ColumnStartPosition = 0;
		do {
			LAYOUT.ColumnStartPosition += targetcol.offsetLeft;
		} while (targetcol = targetcol.offsetParent)
		offsetLeft -= LAYOUT.ColumnStartPosition;
	}
	if (LAYOUT.ScrollAnimation.timer != null) {
		clearInterval(LAYOUT.ScrollAnimation.timer);
		LAYOUT.ScrollAnimation.timer = null;
	}
	LAYOUT.ScrollAnimation.time = 0;
	LAYOUT.ScrollAnimation.begin = LAYOUT.scrollPanel.scrollLeft;
	LAYOUT.ScrollAnimation.change = offsetLeft - LAYOUT.scrollPanel.scrollLeft;
	LAYOUT.ScrollAnimation.duration = LAYOUT.ScrollDuration;
	LAYOUT.ScrollAnimation.element = LAYOUT.scrollPanel;
	LAYOUT.ScrollAnimation.timer = setInterval("LAYOUT.scrollHorizAnim();", 15);
};
LAYOUT.scrollHorizAnim = function() {
	if (LAYOUT.ScrollAnimation.time > LAYOUT.ScrollAnimation.duration) {
		clearInterval(LAYOUT.ScrollAnimation.timer);
		LAYOUT.ScrollAnimation.timer = null;
	} else {
		move = -LAYOUT.ScrollAnimation.change / 2 * (Math.cos(Math.PI * LAYOUT.ScrollAnimation.time / LAYOUT.ScrollAnimation.duration) - 1) + LAYOUT.ScrollAnimation.begin;
		LAYOUT.ScrollAnimation.element.scrollLeft = move;
		LAYOUT.ScrollAnimation.time++;
	}
};
LAYOUT.ResetLayout = function() {
	if (LAYOUT.isResizing != null) {
		clearTimeout(LAYOUT.isResizing);
	}
	LAYOUT.isResizing = setTimeout("LAYOUT.doResetLayout()", 300);
	if (MENU.Cover) MENU.Cover.style.height = getViewport.Height() + 'px';
};
LAYOUT.doResetLayout = function() {
	switch (PAGE.LayoutMode) {
		case 'table':
			LAYOUT.BuildTableLayout();
			break;
		case 'special':
			// NOTHING
			break;
		default:
			if (LAYOUT.lastDimensions != getViewport.Height() + '.' + getViewport.Width()) {

				LAYOUT.CurrentColumn = 0;
				LAYOUT.Columns = 0;
				LAYOUT.ColumnStartPosition = 0;
				LAYOUT.ScrollLastPosition = 0;
				LAYOUT.BuildColumnLayout();
				iPOP.Init();
			}
			break;
	}
	TOOLTIP.Init();
	PAGE.CheckForOversize();
	return;
};
LAYOUT.ForceReset = function() {
	switch (PAGE.LayoutMode) {
		case 'table':
			//LAYOUT.BuildTableLayout();
			break;
		default:
			LAYOUT.CurrentColumn = 0;
			LAYOUT.Columns = 0;
			LAYOUT.ColumnStartPosition = 0;
			LAYOUT.ScrollLastPosition = 0;
			LAYOUT.BuildColumnLayout();
			iPOP.Init();
			break;
	}
	TOOLTIP.Init();
	PAGE.CheckForOversize();
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## MENU
//------------------------------------------------------------------
MENU.Init = function() {
	if (PAGE.RenderMode == 'dynamic') {
		this.Menu = $('menu');
		this.MenuTabs = $('menutabs');
		this.CurrentActiveTab = null;
		this.LinkType = null;
		this.LinkId = null;
		this.CheckBoxes = 0;
		this.Cover = null;
		this.Height = 0;
		var menuHeadlines = MENU.Menu.getElementsByTagName('SPAN');
		var ul = DOM.Create('UL', '', 'menu-headline');
		if (TRANSLATE.Lang == 'fi') {
			ul.className = 'fi';
		}
		for (var i = 0, n = menuHeadlines.length, menuHeadline = null; i < n; i++) {
			menuHeadline = menuHeadlines[i];
			var menuHeadlineParent = menuHeadline.parentNode;
			var li = DOM.Create('LI');
			li.className = 'm' + i;
			var a = DOM.Create('A');
			var text = menuHeadline.innerHTML;
			var uId = text.EscapeString();
			menuHeadline.id = uId;
			DOM.SetAttribute(a, 'href', 'javascript:;');
			DOM.SetAttribute(a, 'rel', uId);
			if (menuHeadlineParent.className == 'selected') a.className = 'selected';
			addEvent(a, 'click', MENU.Show);
			a.innerHTML = text;
			DOM.Add(a, li);
			DOM.Add(li, ul);
			menuHeadline.innerHTML = text.replace('-', '');
		}
		DOM.AddBefore(ul, $('container'));
		addEvent($('content'), 'click', MENU.Hide);
	}
};
MENU.InitMenuTabs = function() {
	if (MENU.MenuTabs) return;
	MENU.MenuTabs = DOM.Create('div', '', 'menutabs');
	var ul = DOM.Create('UL', '', '');

	//## MENU ITEMS ['NAME','CLASSNAME','ID']
	MENU.MenuTabItems = [
		[TRANSLATE.GetValue('TabSearchResults'), 'tablinksearch', 'tablinksearch']
		, [TRANSLATE.GetValue('TabDownloadPdf'), 'checkboxes', 'download-pdf']
	//, [TRANSLATE.GetValue('TabDownloadMp3'), 'checkboxes', 'download-mp3']
		, [TRANSLATE.GetValue('TabVisitedPages'), 'tabvisitedpages', 'tabvisitedpages']
	//, [TRANSLATE.GetValue('TabStickyNotes'), 'tabstickynotes', 'tabstickynotes']
	];

	//## CREATE MENU STRUCTURE
	if (!MENU.MenuTabItems) return;
	for (var i = 0, n = MENU.MenuTabItems.length, item = null, itemClass = null; i < n; i++) {
		item = MENU.MenuTabItems[i][0];
		itemClass = MENU.MenuTabItems[i][1];
		itemId = MENU.MenuTabItems[i][2];
		var li = DOM.Create('LI', '', '');
		var link = DOM.Create('A', '', '');
		DOM.SetAttribute(link, 'href', 'javascript:;');
		DOM.SetAttribute(link, 'title', item);
		if (itemId) DOM.SetAttribute(link, 'ID', itemId);
		if (itemClass) DOM.SetAttribute(link, 'class', itemClass);
		if (i == 0) {
			DOM.SetAttribute(li, 'class', 'selected');
			MENU.CurrentActiveTab = li;
		}
		addEvent(link, 'click', MENU.OpenTab);
		link.innerHTML = item;
		DOM.Add(link, li);
		DOM.Add(li, ul);
	}

	var DownloadPdfLink = DOM.Create('LI');
	DownloadPdfLink.innerHTML = '<a target="_blank" href="' + TRANSLATE.GetValue('PDFLink') + '">' + TRANSLATE.GetValue('DownloadLegal') + '</a>';
	DOM.Add(DownloadPdfLink, ul);

	//## INIT SEARCHFORM 
	var searchDiv = DOM.Create('DIV', '', 'menu-searchform');
	var searchResultText = DOM.Create('DIV', '', 'menu-searchresult');
	searchResultText.innerHTML = "";
	DOM.Add(searchResultText, searchDiv);
	var searchResultNav = DOM.Create('DIV', '', 'menu-searchresultNav');
	searchResultNav.style.display = 'none';
	//## BUTTON
	var navPSpan = DOM.Create('span', '', '');
	DOM.SetAttribute(navPSpan, 'class', 'nav-button');
	var navPSpan2 = DOM.Create('span', '', '');
	var em = DOM.Create('em', '', '');
	DOM.SetAttribute(em, 'class', 'left');
	em.innerHTML = '&nbsp;';
	DOM.Add(em, navPSpan2);
	var btnP = DOM.Create('input', '', 'btn-nav-previous');
	DOM.SetAttribute(btnP, 'value', 'Find previous');
	DOM.SetAttribute(btnP, 'type', 'button');
	addEvent(btnP, 'click', SEARCHHANDLER.NavigateSearchResult);
	DOM.Add(btnP, navPSpan2);
	DOM.Add(navPSpan2, navPSpan);
	DOM.Add(navPSpan, searchResultNav);
	//## RIGHT BUTTON
	navPSpan = DOM.Create('span', '', '');
	DOM.SetAttribute(navPSpan, 'class', 'nav-button');
	navPSpan2 = DOM.Create('span', '', '');
	btnP = DOM.Create('input', '', 'btn-nav-next');
	DOM.SetAttribute(btnP, 'value', 'Find next');
	DOM.SetAttribute(btnP, 'type', 'button');
	addEvent(btnP, 'click', SEARCHHANDLER.NavigateSearchResult);
	em = DOM.Create('em', '', '');
	DOM.SetAttribute(em, 'class', 'right');
	em.innerHTML = '&nbsp;';
	DOM.Add(em, navPSpan2);
	DOM.Add(btnP, navPSpan2);
	DOM.Add(navPSpan2, navPSpan);
	DOM.Add(navPSpan, searchResultNav);

	var searchForm = DOM.Create('DIV', '', 'menu-searchfields');
	var inputText = DOM.Create('INPUT', '', 'tbSearchBoxInMenu');
	DOM.SetAttribute(inputText, 'type', 'text');
	DOM.SetAttribute(inputText, 'class', 'tbSearchBox');
	var searchButton = DOM.Create('INPUT', '', '');
	DOM.SetAttribute(searchButton, 'type', 'button');
	DOM.SetAttribute(searchButton, 'value', 'Search');
	DOM.SetAttribute(searchButton, 'class', 'btnSearch');
	addEvent(searchButton, 'click', SEARCHHANDLER.SearchForm);
	DOM.Add(inputText, searchForm);
	DOM.Add(searchButton, searchForm);
	DOM.Add(searchForm, searchDiv);
	DOM.Add(searchResultNav, searchDiv);
	//## INIT DOWNLOAD VISITED PAGES RESET BUTTON
	var wrapper = DOM.Create('DIV', '', 'resetvisitedpages');
	var btnVisitedPages = DOM.Create('button', '', 'resetvisitedpagesbtn');
	btnVisitedPages.innerHTML = 'Reset visited pages';
	addEvent(btnVisitedPages, 'click', VISITEDPAGESHANDLER.ResetVisitedPages);
	DOM.Add(btnVisitedPages, wrapper);
	//## INIT CHECKBOXES
	MENU.InitCheckboxes()
	var divCommentForm = GetCommentForm();
	DOM.Add(divCommentForm, $('menuadditions'));
	//## OUTPUT
	if (typeof closeButton != 'undefined') DOM.Add(closeButton, MENU.MenuTabs);
	DOM.Add(ul, MENU.MenuTabs);
	DOM.Add(searchDiv, $('menuadditions'));
	DOM.Add(wrapper, $('menuadditions'));
	MENU.Menu.insertBefore(MENU.MenuTabs, MENU.Menu.firstChild);
	TOOLTIP.Init();
	//$('menuadditions').style.display = 'block';

};
MENU.InitCover = function() {
	if (PAGE.RenderMode == 'dynamic') {
		if (MENU.Cover) return;
		MENU.Cover = DOM.Create('DIV', '', 'cover');
		MENU.Cover.style.height = document.documentElement.clientHeight + 'px';
		setOpacity(MENU.Cover, 75);
		DOM.Add(MENU.Cover, document.getElementsByTagName('body')[0]);
		addEvent(MENU.Cover, 'click', MENU.Hide);
	}
};
MENU.ShowPrintMenu = function() {
	// jonell
	MENU.Show();
	if(isIE) $('download-pdf').click();
};
MENU.Show = function() {
	iPOP.Close();
	LAYOUT.ClearAllGraphs();
	MENU.Menu.className = '';
	if (MENU.Menu.style.display != 'block') {
		MENU.InitMenuTabs();
		if (MENU.Cover) MENU.Cover.style.display = 'block';
		MENU.Menu.style.display = 'block';
		if (MENU.MenuTabs) MENU.MenuTabs.style.display = 'block';
		MENU.Height = MENU.Menu.offsetHeight + 10;
	}
	MENU.HilightHeading(this);
};
MENU.HilightHeading = function(elm) {
	var menuHeadlines = MENU.Menu.getElementsByTagName('SPAN');
	for (var i = 0, n = menuHeadlines.length, target = null; i < n; i++) {
		target = menuHeadlines[i];
		target.parentNode.className=target.parentNode.className.toString().replace('selected', '');
			var tmpUid = target.id;
		if (tmpUid) {
			var tmpTarget = DOM.GetByAttribute($('menu-headline'), 'A', 'rel', tmpUid)[0];
			if (tmpTarget)
				tmpTarget.className = '';
		}
	}
	if (elm.rel) {
		var uid = elm.rel;
		var target = $(uid).parentNode;
		target.className = 'selected';
	}
	elm.className = 'selected';
};
MENU.Hide = function() {
	if (PAGE.RenderMode == 'dynamic') {
		if (MENU.Menu) MENU.Menu.style.display = 'none';
		if (MENU.MenuTabs) MENU.MenuTabs.style.display = 'none';
		if (MENU.Cover) MENU.Cover.style.display = 'none';
	}
};
MENU.OpenTab = function(tabId) {
	if (!MENU.CurrentActiveTab) alert('Error!\n\nCould not find MENU.CurrentActiveTab');
	MENU.CurrentActiveTab.className = '';
	if (tabId && $(tabId)) {
		MENU.CurrentActiveTab = $(tabId).parentNode;
		MENU.LinkType = tabId;
	} else {
		MENU.CurrentActiveTab = this.parentNode;
		MENU.LinkType = this.className;
	}

	//## CLOSE ALL OPEN TOOLTIPS 
	var els = MENU.Menu.getElementsByTagName('div');
	for (var i = 0, iLen = els.length; i < iLen; i++) {
		if (els[i] && els[i].className == 'tooltip') {
			els[i].style.display = 'none';
		}
	}

	MENU.CurrentActiveTab.className = 'selected';
	MENU.LinkId = this.id;
	if (MENU.LinkType) {
		MENU.Menu.className = MENU.LinkType;
		if (MENU.LinkType.indexOf('checkboxes') != -1) {
			$('download-action-container').style.display = 'block';
			MENU.InitDownloadFunction();
		} else {
			$('download-action-container').style.display = 'none';
		}
	} else {
		MENU.Menu.className = '';
		MENU.Menu.removeAttribute('CLASS');
		$('download-action-container').style.display = 'none';
	}
	if ($('tryckord')) $('tryckord').style.display = 'none';
	$('menuadditions').style.display = 'none';
	$('menu-searchform').style.display = 'none';
	$('resetvisitedpages').style.display = 'none';
	$('menu-commentform').style.display = 'none';
	try {
		if ($('comment-tools')) $('comment-tools').style.display = 'none';
	}
	catch (exc) { }


	switch (MENU.CurrentActiveTab.getElementsByTagName('a')[0].id) {
		case 'navigation':
			$('tryckord').style.display = 'block';
			break;
		case 'download-pdf':
			$('menuadditions').style.display = 'block';
			break;
		case 'download-mp3':
			$('menuadditions').style.display = 'block';
			break;
		case 'tabvisitedpages':
			$('resetvisitedpages').style.display = 'block';
			//## COOKIE WITH VISITED PAGES DATA
			var visitedPages = (Cookie.Read('visitedpages')) ? Cookie.Read('visitedpages') : '';
			var li = $('menu').getElementsByTagName('li');
			for (var i = 0, iLen = li.length; i < iLen; i++) {
				if (li[i].getElementsByTagName('ul').length < 1) { //## MAKE SURE THIS IS BOTTOM LI IN HIEARARCHY				
					var ahref = li[i].getElementsByTagName('a')[0]; //## OBS!! JUST THE FIRST A HREF IN LIST ELEMENT IS CHECKED
					if (visitedPages.indexOf(ahref) > -1 && li[i].className.indexOf('visited') == -1) {
						li[i].className += ' visited';
					}
				}
			}
			break;
		case 'tablinksearch':
			var buttons = DOM.GetByClassName($('menu-searchresultNav'), 'span', 'nav-button');
			for (var i = 0, iLen = buttons.length; i < iLen; i++) {
				buttons[i].style.display = 'block';
			}
			$('menu-searchform').style.display = 'block';
			break;

		case 'tabstickynotes':
			//## MOVE COMMENT TOOLS
			var tools = $('comment-tools');
			if (tools) {
				tools.style.display = 'block';
				var menuOptions = $('menuoptions');

				//## MOVE COMMENT TOOLS TO MENU IF NOT ALREADY MOVED 
				var divs = menuOptions.getElementsByTagName('div');
				var found = false;
				for (var divCounter = 0, divLength = divs.length; divCounter < divLength; divCounter++) {
					if (divs[divCounter].id == 'comment-tools') {
						found = true;
					}
				}
				if (!found)
					DOM.Add(tools, $('menuoptions'));

				//## LOOP THROUGH ALL PAGES IN MENU 
				var li = menuOptions.getElementsByTagName('li');
				var c = COMMENTHANDLER.getComments();
				for (var i = 0, n = li.length; i < n; i++) {
					if (li[i].className.indexOf('section') == -1) {

						//GET A WITH HREF OF CURRENT PAGE
						var a = li[i].getElementsByTagName('a')[0];
						if (a) {
							var link = a.href;
							var stickynote = li[i].getElementsByTagName('span')[0];
							if (stickynote) {
								link = link.substring(link.lastIndexOf('/') + 1, link.length);
								link = link.substring(0, link.lastIndexOf('.'));
								for (var x = 0, xLen = c.length; x < xLen; x++) {
									if (c[x].Page.indexOf(link) > -1) {
										//STICKY NOTE FOUND										
										if (stickynote.className.indexOf('sticky-note-found') == -1)
											stickynote.className += ' sticky-note-found';
										break;
									}
								}
							}
						}
					}
				}
			}
			else { // the menu tools do not exist: the user is not logged in
				$('menu-commentform').style.display = 'block';
			}
			break;
	}
};
MENU.InitCheckboxes = function() {
	//## OUTPUT CHECKBOXES
	var li = $('menuoptions').getElementsByTagName('li');
	for (var i = 0, n = li.length; i < n; i++) {
		var liu = li[i];
		if (liu.className != 'lastmenuitem') {
			var chSpan = DOM.Create('span', 'checkbox', '');
			var ch = DOM.Create('input', '', '');
			DOM.SetAttribute(ch, 'type', 'checkbox');
			DOM.SetAttribute(ch, 'name', 'foo'+ i);
			DOM.SetAttribute(ch, 'value', DOM.FirstChild(liu).innerHTML);
			if (DOM.FirstChild(liu).tagName.toLowerCase() == 'span') DOM.SetAttribute(ch, 'class', 'group');
			DOM.Add(ch, chSpan);
			addEvent(chSpan, 'click', MENU.CheckboxFunctions);
			DOM.AddBefore(chSpan, DOM.FirstChild(liu));
		}
	}

	//## DOWNLOAD FUNCTIONS
	var downloadActionContainer = DOM.Create('DIV', '', 'download-action-container');
	DOM.Add(DOM.Create('SPAN', '', 'download-action-text'), downloadActionContainer);

	var spanContainer = DOM.Create('span', 'button', '');
	var spanInner = DOM.Create('span', '', '');
	var btn = DOM.Create('input', '', 'download-action-button');
	btn.setAttribute('type', 'button');
	btn.setAttribute('value', '');
	DOM.Add(btn, spanInner);
	DOM.Add(spanInner, spanContainer);
	DOM.Add(spanContainer, downloadActionContainer);
	if ($('menuadditions')) DOM.Add(downloadActionContainer, $('menuadditions'));

	var count = 0, pdfpages = 0;
	var firstLevel = DOM.ChildNodes($('menuoptions').getElementsByTagName('UL')[0]);
	for (var i = 0, n = firstLevel.length; i < n; i++) {
		var secondLevel = DOM.ChildNodes(firstLevel[i].getElementsByTagName('UL')[0]);
		for (var j = 0, o = secondLevel.length; j < o; j++) {
			var aTag = secondLevel[j].getElementsByTagName('A')[0];
			if (aTag != null) {
				if (aTag.rel != null) {
					if (aTag.rel == "") {
						pdfpages++;
					}
					else {
						pdfpages += parseInt(aTag.rel);
					}
				}
				else {
					pdfpages++;
				}
			}
		}
		//		count += secondLevel.length;
		//		if (i == 1) {
		//			count = count + 3;
		//		}
	}
	MENU.DownloadItems = pdfpages;

};
MENU.InitStickyNotes = function() {
	var li = $('menuoptions').getElementsByTagName('li');
	for (var i = 0, iLen = li.length; i < iLen; i++) {
		//## ADD SPANS OF NOTES
		var spanSticky = DOM.Create('span', 'sticky-note-container', '');
		if (li[i].className.indexOf('section') == -1) {
			li[i].insertBefore(spanSticky, li[i].firstChild);
		}
		//## WE WANT TO SHOW IF THE SPAN CONTAINS A NOTE OR NOT AS WELL
		//## THIS FUNCTION IS PLACED WHERE IT CAN BE TRIGGERED FRIQUENTLY FOR LIVE UPDATING
		//## I.E MENU.OpenTab		
	}
};
MENU.CheckboxFunctions = function() {

	var checkbox = this.getElementsByTagName('input')[0];
	if (!checkbox.checked) {
		this.className = this.className + '  checked';
	} else {
		this.className = this.className.replace('checked', '');
	}

	//## CHECKBOX GROUP LEADER
	if (checkbox.className == 'group') {
		var isGroupLeaderChecked = checkbox.checked;
		var boxes = checkbox.parentNode.parentNode.getElementsByTagName('INPUT');
		var next = DOM.NextSibling(checkbox.parentNode.parentNode);
		if (next != null && next.className == 'lastmenuitem') {
			var arr = boxes;
			var boxes = [];
			for (var i = 0, n = arr.length; i < n; i++) {
				boxes.push(arr[i]);
			}
			var arr2 = DOM.NextSibling(checkbox.parentNode.parentNode).getElementsByTagName('INPUT');
			for (var i = 0, n = arr2.length; i < n; i++) {
				if (arr2[i].parentNode.parentNode && arr2[i].parentNode.parentNode.className != 'hidden') {
					boxes.push(arr2[i]);
				}
			}
		}
		var n = boxes.length;
		for (var i = 0, box = null; i < n; i++) {
			box = boxes[i];
			if (isGroupLeaderChecked) {
				box.parentNode.className = 'checkbox checked';
				box.checked = true;
			} else {
				box.checked = false;
				box.parentNode.className = 'checkbox';
			}
		}
	} else {
		var checkboxGroupleader = checkbox.parentNode;
		while (checkboxGroupleader.getElementsByTagName('INPUT')[0].className != 'group') {
			checkboxGroupleader = checkboxGroupleader.parentNode;
		}
		var GroupLeader = checkboxGroupleader;
		if (GroupLeader.checked) GroupLeader.checked = false;
	}

	//## COUNT ALL CHECKED BOXES
	var boxes = $('menuoptions').getElementsByTagName('input');
	var n = boxes.length, z = 0, pdfpages = 0;
	for (var i = 0, box = null; i < n; i++) {
		box = boxes[i];
		if (box.checked == true) {
			if (box.className !== 'group') {
				z++;
				if (!box.parentNode || !box.parentNode.nextSibling) alert("!")
				var aTag = box.parentNode.nextSibling;
				if (aTag != null) {
					if (aTag.rel != null) {
						if (aTag.rel == "") {
							pdfpages++;
						}
						else {
							pdfpages += parseInt(aTag.rel);
						}
					}
					else {
						pdfpages++;
					}
				}
			}
		}
	}

	var downloadActionText = $('download-action-text');
	var downloadActionButton = $('download-action-button');
	switch (MENU.LinkId) {
		case 'download-pdf':
			//## ENABLE PDF DOWNLOAD
			downloadActionButton.parentNode.getElementsByTagName('span')[0].innerHTML = TRANSLATE.GetValue('DownloadPdfPages') + ' ' + pdfpages + ' (' + TRANSLATE.GetValue('DownloadPdfPagesOutOf') + ' ' + MENU.DownloadItems + ')';
			addEvent(downloadActionButton, 'click', PDFExporter);
			break;
		case 'download-mp3':
			//## ENABLE MP3 DOWNLOAD
			MENU.Mp3DefaultSize += MENU.Mp3DefaultSize;
			if (MENU.Mp3DefaultSize > 1024) {
				downloadActionText.innerHTML = TRANSLATE.GetValue('DownloadMp3Size') + (MENU.Mp3DefaultSize / 1024).toPrecision(3) + ' Mb';
			} else {
				downloadActionText.innerHTML = TRANSLATE.GetValue('DownloadMp3Size') + MENU.Mp3DefaultSize + ' Kb';
			}
			downloadActionButton.value = TRANSLATE.GetValue('DownloadMp3Text');
			addEvent(downloadActionButton, 'click', PDFExporter);
			break;
	}

};
MENU.InitDownloadFunction = function(FileType) {
	var downloadActionText = $('download-action-text');
	var downloadActionButton = $('download-action-button');

	switch (MENU.LinkId) {
		case 'download-pdf':
			//## ENABLE PDF DOWNLOAD
			if (downloadActionButton) {
				//downloadActionText.innerHTML = '<a target="_blank" href="' + TRANSLATE.GetValue('PDFLink') + '">' + TRANSLATE.GetValue('DownloadLegal') + '</a>';
				tmpText = '<span>' + TRANSLATE.GetValue('DownloadPdfPages') + ' 0 (' + TRANSLATE.GetValue('DownloadPdfPagesOutOf') + ' ' + MENU.DownloadItems + ')</span>';
				downloadActionButton.value = TRANSLATE.GetValue('DownloadPdfText');
				downloadActionButton.parentNode.innerHTML = tmpText + downloadActionButton.parentNode.innerHTML;
				addEvent(downloadActionButton, 'click', PDFExporter);
			}
			break;
		case 'download-mp3':
			//## ENABLE MP3 DOWNLOAD
			if (downloadActionText) {
				downloadActionText.innerHTML = TRANSLATE.GetValue('DownloadMp3Size') + ' 0 Kb';
				downloadActionButton.value = TRANSLATE.GetValue('DownloadMp3Text');
			}
			break;
	}
};
MENU.ShowNoteMenu = function() {
	$('submenu').className = 'visiblesubmenu';
	$('notemenubutton').style.display = 'none';
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## INTROBOX
//------------------------------------------------------------------
INTROBOX.Init = function() {
	if (!$('content')) return;
	this.Box = null;
	this.Image = null;
	this.Timer = null;
	this.Uri = '';
	var boxes = DOM.GetByClassName($('content'), 'div', 'introbox');
	if (boxes.length != 0) {
		for (var i = 0, n = boxes.length, box = null; i < n; i++) {
			box = boxes[i];
			var image = DOM.GetByClassName(box, 'img', 'hover-image')[0];
			if (image) {
				addEvent(image, 'mouseover', INTROBOX.MouseOver);
				addEvent(image, 'mouseout', INTROBOX.MouseOut);
			}
		}
	}
};
INTROBOX.MouseOver = function(e) {
	var imgSrc = DOM.GetAttribute(this, 'src');
	this.src = imgSrc.replace('_sv', '_norm');
};
INTROBOX.MouseOut = function(e) {
	var imgSrc = DOM.GetAttribute(this, 'src');
	this.src = imgSrc.replace('_norm', '_sv');
};
INTROBOX.Animate = function(border, aniType) {
	var shade = INTROBOX.Shade;
	var image = INTROBOX.Image;
	switch (aniType) {
		case 'contract':
			border += 2;
			if (border < 10) {
				shade.style.border = 'solid ' + border + 'px #fff';
				shade.style.width = shade.clientWidth - 4 + 'px';
				shade.style.height = shade.clientHeight - 4 + 'px';
				INTROBOX.Timer = window.setTimeout('INTROBOX.Animate(' + border + ',"' + aniType + '")', 10);
			} else {
				shade.style.border = 'solid 10px #fff';
				shade.style.width = shade.clientWidth - 4 + 'px';
				shade.style.height = shade.clientHeight - 8 + 'px';
			}
			break;
		case 'expand':
			border -= 2;
			if (border > 0) {
				shade.style.border = 'solid ' + border + 'px #fff';
				shade.style.width = shade.clientWidth + 4 + 'px';
				shade.style.height = shade.clientHeight + 4 + 'px';
				INTROBOX.Timer = window.setTimeout('INTROBOX.Animate(' + border + ',"' + aniType + '")', 10);
			} else {
				shade.style.border = '';
				shade.style.width = shade.clientWidth + 16 + 'px';
				shade.style.height = shade.clientHeight + 20 + 'px';
			}
			break;
	}
};
INTROBOX.GrowBig = function(e) {
	var trigger = (typeof e.target !== 'undefined') ? e.target.parentNode : e.srcElement.parentNode;
	iPOP.TriggerY = e.clientY;
	iPOP.TriggerX = e.clientX;

	CancelEvent(e);
	INTROBOX.Uri = DOM.GetAttribute(trigger, 'href').toString();
	var areaId = DOM.GetAttribute(trigger, 'id').toString();
	var bigImageName = areaId + '_big.jpg';

	Cookie.Remove('HH-AreaId');
	Cookie.Remove('HH-AreaHref');
	Cookie.Create('HH-AreaHref', INTROBOX.Uri, 20);
	Cookie.Create('HH-AreaId', areaId, 20);

	var viewPortHeight = getViewport.Height();
	var viewPortWidth = getViewport.Width();

	if ($('big-area-image')) DOM.Remove($('big-area-image'));

	var areaImage = new Image();
	areaImage.src = '../../images/' + bigImageName;
	DOM.SetAttribute(areaImage, 'id', 'big-area-image');
	DOM.SetAttribute(areaImage, 'width', 10);
	DOM.SetAttribute(areaImage, 'height', 10);
	addEvent(areaImage, 'click', INTROBOX.Redirect);
	DOM.Add(areaImage, document.getElementsByTagName('BODY')[0]);
	iPopAnimation.Start(0, 0, viewPortWidth, viewPortHeight, areaImage);
	window.setTimeout('INTROBOX.Redirect()', 1000);
	return;
};
INTROBOX.Redirect=function(){
	//if ($('big-area-image')) DOM.Remove($('big-area-image'));
	location.href = INTROBOX.Uri;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## TOOLTP
//------------------------------------------------------------------
TOOLTIP.Init = function() {
	this.Tooltip = null;
	this.Title = '';
	this.Rel = '';
	var tooltips = DOM.GetByClassName($('container'), '*', 'tooltip');
	for (var i = 0, n = tooltips.length, tooltip = null; i < n; i++) {
		tooltip = tooltips[i];
		if (tooltip.title) {
			addEvent(tooltip, 'mouseover', TOOLTIP.Display);
		}
	}

};
TOOLTIP.Display = function(e) {
	TOOLTIP.Title = this.getAttribute('title');
	if (!TOOLTIP.Title) TOOLTIP.Title = this.title;
	if (!TOOLTIP.Title) return;
	DOM.SetAttribute(this, 'rel', TOOLTIP.Title);
	DOM.SetAttribute(this, 'title', '');
	TOOLTIP.Tooltip = $('tooltip-container');
	if (!TOOLTIP.Tooltip) {
		TOOLTIP.Tooltip = DOM.Create('div', '', 'tooltip-container');
		DOM.Add(TOOLTIP.Tooltip, document.getElementsByTagName('body')[0]);
	} else {
		TOOLTIP.Tooltip.style.display = 'block';
	}
	if (document.all) { x = event.clientX + document.body.scrollLeft; y = event.clientY + document.documentElement.scrollTop; } else { x = e.pageX; y = e.pageY; }
	if (x < 0) { x = -5000; }
	if (y < 0) { y = -5000; }
	TOOLTIP.Tooltip.style.left = (x - 30) + 'px';
	TOOLTIP.Tooltip.style.top = (y + 5) + 'px';
	TOOLTIP.Tooltip.id = 'tooltip-container';
	TOOLTIP.Tooltip.zIndex = 10000;
	TOOLTIP.Tooltip.innerHTML = '<em>' + TOOLTIP.Title + '</em>';
	addEvent(this, 'mouseout', TOOLTIP.Hide);
};
TOOLTIP.Hide = function() {
	if (TOOLTIP.Tooltip) {
		TOOLTIP.Tooltip.innerHTML = '';
		DOM.SetAttribute(this, 'title', TOOLTIP.Title);
		DOM.SetAttribute(this, 'rel', '');
		TOOLTIP.Tooltip.style.display = 'none';
	}
};



//------------------------------------------------------------------
/* PDF EXPORTER
----------------------------------------------------*/
var PDFExporter = function(e) {
	var boxes = $('menuoptions').getElementsByTagName('input');
	var n = boxes.length, z = 0;
	var lang = TRANSLATE.GetValue("lang");
	url = "http://hhxen0103.halvarsson.se/getpdf.aspx?company=TeliaSonera_" + lang + "&p=";
	for (var i = 0, box = null; i < n; i++) {
		box = boxes[i];
		if (box.className !== 'group') {
			if (box.checked == true) {
				url = url + "t";
			}
			url = url + ",";
		}
	}
	document.location = url;
};


//------------------------------------------------------------------
//------------------------------------------------------------------
//## SEARCH
//------------------------------------------------------------------

SEARCHHANDLER.Init = function() {
	if (PAGE.RenderMode == 'dynamic') {
		SEARCHHANDLER.ClassNameForHightlightedListItems = 'highlight';
		SEARCHHANDLER.CurrentActiveSearchResult = 1;
		SEARCHHANDLER.Index = new Array();
		SEARCHHANDLER.Results = new Array();
		SEARCHHANDLER.LastSearchTerm = "";
		SEARCHHANDLER.Scope = 1;
		addEvent($('btnSearch'), 'click', SEARCHHANDLER.SearchForm);
		addEvent($('tbSearchBox'), 'keyup', SEARCHHANDLER.SearchForm);
		SEARCHHANDLER.InitIndex();
	}
};

//go through array and create index obj.
SEARCHHANDLER.InitIndex = function() {
	for (var i = 0; i < sData.length; i++) {
		SEARCHHANDLER.Index[i] = new SEARCHINDEXITEM(sData[i]);
	}
}

SEARCHHANDLER.SearchForm = function(e) {
	SEARCHHANDLER.HandleEvent(e);
	SEARCHHANDLER.LastSearchTerm = unescape(tb.value);
	if (SEARCHHANDLER.LastSearchTerm.length == 0) return;

	SEARCHHANDLER.SearchingQuote = false;
	if (SEARCHHANDLER.LastSearchTerm.charAt(0) == '"' && SEARCHHANDLER.LastSearchTerm.charAt(SEARCHHANDLER.LastSearchTerm.length - 1) == '"') {
		SEARCHHANDLER.SearchingQuote = true;
		SEARCHHANDLER.SearchQuote();
	} else {
		SEARCHHANDLER.SearchWords();
	}

	//	if (typeof sC == "object" && typeof sC.hhLogSearch == "function") {
	//		sC.hhLogSearch(d, numberOfInstances);
	//	}

	var hits = SEARCHHANDLER.Results.length;

	SEARCHHANDLER.PrintResult(hits);
	return false;
}

SEARCHHANDLER.SearchQuote = function() {
	var d = SEARCHHANDLER.LastSearchTerm.replace(/"/gi, "");
	var pat = new RegExp(d, "i");
	for (var c = 0, n = SEARCHHANDLER.Index.length; c < n; c++) {
		var CurrentIndex = SEARCHHANDLER.Index[c];
		CurrentIndex.Score = 0;
		var rn = CurrentIndex.Text.search(pat);
		if (rn >= 0) {
			// && SEARCHHANDLER.IsInScope(CurrentIndex, filterType)
			CurrentIndex.Score += 1;
		}
	}
}

SEARCHHANDLER.SearchWords = function() {
	//setup search terms
	var searchterms = new Array();
	var words = SEARCHHANDLER.LastSearchTerm.split(" ");
	for (var a = 0, n = words.length; a < n; a++) {
		searchterms[a] = new SEARCHTERM(words[a]);
	}

	SEARCHHANDLER.Results = new Array();

	//Search through index
	for (var IndexIterator = 0, n = SEARCHHANDLER.Index.length; IndexIterator < n; IndexIterator++) {

		//reset index hit score.
		var CurrentIndex = SEARCHHANDLER.Index[IndexIterator];
		CurrentIndex.Score = 0;
		for (var i = 0, nn = searchterms.length; i < nn; i++) {
			var CurrentTerm = searchterms[i];
			if (!CurrentTerm.Exclude) {
				var findTerm = new RegExp(CurrentTerm.Text, "i");

				var headingFound = CurrentIndex.Title.search(findTerm); //search heading
				if (headingFound >= 0) {
					CurrentIndex.Score += 10; //if term found in page title, add 10 to score
				}

				var rn = CurrentIndex.Text.match(findTerm);
				if (rn && rn.length > 0) {
					CurrentIndex.Score += rn.length; //add numner of matches to score.
				}
			} else {
				var findTerm = new RegExp(CurrentTerm.Text, "i");
				var rn = CurrentIndex.Text.match(findTerm);
				if (rn && rn.length > 0) {
					CurrentIndex.Score = -1000; //result page excluded.
				}
			}
		}

		if (CurrentIndex.Score > 0 && SEARCHHANDLER.IsInScope(CurrentIndex, SEARCHHANDLER.Scope)) {
			SEARCHHANDLER.Results[SEARCHHANDLER.Results.length] = CurrentIndex;
		}
	}
	SEARCHHANDLER.SortSearchResult();
}

SEARCHHANDLER.HandleEvent = function(e) {
	var trigger = (typeof e.target !== 'undefined') ? e.target : e.srcElement;
	CancelEvent(e);
	if (trigger.type == 'button') {
		if (trigger.id == 'btnSearch') {
			tb = $('tbSearchBox');
		} else {
			tb = $('tbSearchBoxInMenu');
		}
	} else if (trigger.type == 'submit') {
		tb = $('tbSearchBox');
	} else {
		tb = trigger;
	}
}



SEARCHHANDLER.IsInScope = function(row, type) {
	//## TYPE: 1=ALL, 2=SECTION, 3=PAGE
	if (type == 1) return true; //if 1, always return true(filter off)
	var section = "";
	var page = "";
	var url = window.location.toString();
	var aUrl = url.split("/");
	section = aUrl[aUrl.length - 2];
	if (type == 3) {
		page = aUrl[aUrl.length - 1];
		page = page.substring(0, page.indexOf("."));
		return row.BreadCrumb == (section + "/" + page);
	}

	if (row.BreadCrumb.indexOf(section) > 0) {
		return true;
	} else {
		if (page == "" || page == aRow[5]) return true;
		else {
			return false;
		}
	}
};
SEARCHHANDLER.PrintResult = function(hits) {

	if ($('resultPanel')) DOM.Remove($('resultPanel'));

	var resultPanel = DOM.Create('div', '', 'resultPanel');
	var resultTopic = DOM.Create('strong');
	var resultContainer = DOM.Create('div');
	DOM.Add(resultTopic, resultPanel);
	DOM.Add(resultContainer, resultPanel);
	DOM.Add(resultPanel, document.getElementsByTagName('BODY')[0]);

	if (hits == 0) {
		resultTopic.innerHTML = TRANSLATE.GetValue('SearchEmpty');
	} else {
		var strOutput = TRANSLATE.GetValue('Searchresult');
		strOutput = strOutput.replace('{SEARCHWORD}', SEARCHHANDLER.LastSearchTerm);
		strOutput = strOutput.replace('{RESULTS} on', '');
		strOutput = strOutput.replace('{RESULTS} på', '');
		strOutput = strOutput.replace('{RESULTS}', '');
		strOutput = strOutput.replace('{PAGES}', hits);
		resultTopic.innerHTML = strOutput;
		var ul = DOM.Create('ul');
		for (var i = 0, n = hits; i < n; i++) {
			var li = DOM.Create('li');
			li.innerHTML = '<a href="' + SEARCHHANDLER.Results[i].Url + '#' + escape(SEARCHHANDLER.LastSearchTerm) + '">' + SEARCHHANDLER.Results[i].Title + '</a>';
			DOM.Add(li, ul);
		}
		DOM.Add(ul, resultContainer);
		if (hits > 12) {
			resultContainer.style.height = '240px';
		}
	}
	return;

	/*

	OLD OLD OLD OLD OLD OLD

	var resultPanel = document.getElementById("resultPanel"); //namePrefix + 
	var ToolTipContainerClassName = 'tooltip';
	var resultHtml = "";
	var btnSearchPath = '../../gfx/searchfound.png';
	var btnSearchPathExpanded = '../../gfx/searchfound.png';
	var menuListElements = $('menuoptions').getElementsByTagName('li');
	var className = SEARCHHANDLER.ClassNameForHightlightedListItems;
	var classNameNoResult = 'faded';
	for (var i = 0, len = menuListElements.length; i < len; i++) { //reser result list
	menuListElements[i].className = menuListElements[i].className.replace(className, '');
	menuListElements[i].className = menuListElements[i].className.replace(classNameNoResult, '');
	menuListElements[i].className += ' ' + classNameNoResult;
	var images = menuListElements[i].getElementsByTagName('img');
	if (images.length > 0) {
	DOM.Remove(images[0]);
	}
	var tooltips = menuListElements[i].getElementsByTagName('div');
	for (var x = 0, xLen = tooltips.length; x < xLen; x++) {
	if (tooltips[x] && tooltips[x] != 'undefined' && tooltips[x].className == ToolTipContainerClassName)
	DOM.Remove(tooltips[x]);
	}
	}
	if (hits == 0) {
	MENU.Show();
	MENU.OpenTab('tablinksearch');
	standardSearchQuery = $('tbSearchBox').value;
	menuSearchQuery = $('tbSearchBoxInMenu').value;
	if (menuSearchQuery == '') {
	$('tbSearchBoxInMenu').value = standardSearchQuery;
	} else {
	if (menuSearchQuery !== SEARCHHANDLER.LastSearchTerm) {
	$('tbSearchBoxInMenu').value = SEARCHHANDLER.LastSearchTerm;
	}
	}
	$('menu-searchresult').innerHTML = "<strong>Your search did not match any documents.</strong><br />Make sure all keywords are spelt correctly. Try different or more general keywords.";
	} else {
	var pattern = SEARCHHANDLER.GetSearchPattern();
	var section = "";
	for (var elementCounter = 0, length = menuListElements.length; elementCounter < length; elementCounter++) {
	var aElement = menuListElements[elementCounter].getElementsByTagName('a');
	if (aElement.length == 1) {
	var currentMenuSection = aElement[0].innerHTML;
	for (var searchArraypos = 0, searchArrayLen = SEARCHHANDLER.Results.length; searchArraypos < searchArrayLen; searchArraypos++) {
	if (SEARCHHANDLER.Results[searchArraypos].BreadCrumb.indexOf(section + "/" + currentMenuSection) > -1 && SEARCHHANDLER.Results[searchArraypos].Score > 0) {
	var searchRowArrayPosTitle = 0, searchRowArrayPosText = 3;
	var ch = DOM.Create('img', '', '');
	ch.setAttribute('src', btnSearchPath);
	var posResult = SEARCHHANDLER.Results[searchArraypos].Text.search(pattern);
	if (posResult > -1) {
	ch.src = btnSearchPathExpanded;
	var tooltipTextPopup = DOM.Create('div', '', '');
	DOM.SetAttribute(tooltipTextPopup, 'class', ToolTipContainerClassName);
	tooltipTextPopup.style.display = 'none';
	var tooltipText = SEARCHHANDLER.Results[searchArraypos].Text.substr(posResult - 8, 120) + "...";
	tooltipTextPopup.innerHTML = '<span><span><span>' + tooltipText + '</span></span></span>';
	menuListElements[elementCounter].appendChild(tooltipTextPopup);
	addEvent(aElement[0], 'mouseover', viewTooltipForMenuList);
	addEvent(aElement[0], 'mouseout', hideTooltipForMenuList);
	}
	//menuListElements[elementCounter].insertBefore(ch, aElement[0]);
	DOM.AddBefore(ch, aElement[0]);
	menuListElements[elementCounter].className = menuListElements[elementCounter].className.replace(classNameNoResult, '');
	menuListElements[elementCounter].className = menuListElements[elementCounter].className + ' ' + className;
	var parentListElement = menuListElements[elementCounter].parentNode.parentNode;
	}
	}
	} else {
	//get section name
	if (menuListElements[elementCounter].firstChild.className == "checkbox")
	section = menuListElements[elementCounter].firstChild.nextSibling.innerHTML;
	else
	section = menuListElements[elementCounter].firstChild.innerHTML;
	}
	}
	}
	if (hits > 0) {
	MENU.Show();
	MENU.OpenTab('tablinksearch');
	$('menu-searchresultNav').style.display = 'block';
	$('menu-searchresult').innerHTML = 'Looking for "<em>' + SEARCHHANDLER.LastSearchTerm + '</em>"<br />Results: ' + hits + ' pages';
	}
	return;
	
	*/
};
SEARCHHANDLER.SortSearchResult = function() {
	var newResultArray = new Array();
	for (var pageIterator = 0, max = SEARCHHANDLER.Results.length; pageIterator < max; pageIterator++) {
		var maxScore = 0;
		var scorePos = 0;
		for (var scoreIterator = 0, n = SEARCHHANDLER.Results.length; scoreIterator < n; scoreIterator++) {
			if (SEARCHHANDLER.Results[scoreIterator].Score > maxScore) {
				maxScore = SEARCHHANDLER.Results[scoreIterator].Score;
				scorePos = scoreIterator;
			}
		}
		newResultArray[pageIterator] = SEARCHHANDLER.Results[scorePos];
		SEARCHHANDLER.Results[scorePos] = -1;
	}
	SEARCHHANDLER.Results = newResultArray;
};
SEARCHHANDLER.GetSearchPattern = function() {
	if (!this.SearchingQuote) {
		var criteria = SEARCHHANDLER.LastSearchTerm.split(" ")[0];
		return new RegExp(criteria, "i");
	} else {
		var l = SEARCHHANDLER.LastSearchTerm.replace(/"/gi, "");
		return new RegExp(l, "i");
	}
};

SEARCHINDEXITEM = function(data) {
	//title, url, breadcrumb, textmassa
	var splitRow = data.split("^");
	this.Title = splitRow[0];
	this.Url = splitRow[1];
	this.BreadCrumb = splitRow[2];
	this.Text = splitRow[3];
	this.Score = 0;
}

SEARCHTERM = function(data) {
	this.Exclude = false;
	if (data.charAt(0) == '-') this.Exclude = true;
	this.Text = data.replace(/^\-|^\+/gi, ""); //remove starting -+
}


/*
SEARCHHANDLER.Init = function() {
	if (PAGE.RenderMode == 'dynamic') {
		SEARCHHANDLER.ClassNameForHightlightedListItems = 'highlight';
		SEARCHHANDLER.CurrentActiveSearchResult = 1;
		addEvent($('btnSearch'), 'click', SEARCHHANDLER.SearchForm);
	}
};
SEARCHHANDLER.NavigateSearchResult = function(e) {
	if (this.id.indexOf('next') > -1) { //move forward 				
		SEARCHHANDLER.CurrentActiveSearchResult++;
	} else {
		if (SEARCHHANDLER.CurrentActiveSearchResult > -1) SEARCHHANDLER.CurrentActiveSearchResult--; //move backwards
	}
	SEARCHHANDLER.MoveToActiveSearchResultPosition(SEARCHHANDLER.CurrentActiveSearchResult);
};
SEARCHHANDLER.MoveToActiveSearchResultPosition = function(pos) {
	var divElements = $('menuoptions').getElementsByTagName('div');
	var noOfElements = 0;
	for (var i = 0, iLen = divElements.length; i < iLen; i++) {
		if (divElements[i].className.indexOf('tooltip') > -1) {
			if (noOfElements == pos) {
				divElements[i].style.display = 'block';
			} else {
				divElements[i].style.display = 'none';
			}
			noOfElements++;
		}
	}
	if (SEARCHHANDLER.CurrentActiveSearchResult + 1 == noOfElements) SEARCHHANDLER.CurrentActiveSearchResult = -1;
};
SEARCHHANDLER.SearchForm = function(e) {
	var filterType = 1, tb = null;
	var trigger = (typeof e.target !== 'undefined') ? e.target : e.srcElement;
	CancelEvent(e);
	if (trigger.type == 'button') {
		if (trigger.id == 'btnSearch') {
			tb = $('tbSearchBox');
		} else {
			tb = $('tbSearchBoxInMenu');
		}
	} else if (trigger.type == 'submit') {
		tb = $('tbSearchBox');
	} else {
		tb = trigger;
	}
	var d = unescape(tb.value);
	if (d.length == 0) return;
	var od = d; //od=value searched for
	var m = 0; //seach for a word or a full sentence
	if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') m = 1;
	var r = new Array(); //new array of results
	var pageScore = new Array();
	var co = 0;
	var numberOfInstances = 0;
	//search for word
	if (m == 0) {
		var woin = new Array(); //array holding if a word should be included or excluded
		var w = d.split(" ");
		for (var a = 0, n = w.length; a < n; a++) {
			woin[a] = 0;
			if (w[a].charAt(0) == '-') { //exclude word if it has a '-' in front
				woin[a] = 1;
			}
		}
		for (var a = 0, n = w.length; a < n; a++) { //remove odd caracters from search(remove -(minus sign) )
			w[a] = w[a].replace(/^\-|^\+/gi, "");
		}
		a = 0; //## RESET ITERATOR TO KEEP NUMBER OF PASSED LINES(RESULTS)
		for (var c = 0, n = sData.length; c < n; c++) {
			pa = 0; //## NUMBER OF PATTERNS PASSED
			nh = 0; //## NUMBER OF PATTERNS PROCESSED
			var score = 0;
			for (var i = 0, nn = woin.length; i < nn; i++) {
				if (woin[i] == 0) {
					sData[c] = sData[c].replace(/<strong>/gi, '');
					sData[c] = sData[c].replace(/<\/strong>/gi, '');
					var line = sData[c]; //## CURRENT LINE TO SEARCH					
					var subjRegexPat = "^(\\w| )*" + w[i];
					var regSubj = new RegExp(subjRegexPat, "i");
					var headingFound = line.search(regSubj);
					if (headingFound >= 0) {
						score += 10;
					}
					nh++;
					var pat = new RegExp(w[i], "i");
					var rn = line.match(pat);
					if (rn && rn.length > 0) {
						var tempArr = sData[c].split(rn);
						var tempString = "";
						for (var cnt = 0, cntLen = tempArr.length; cnt < cntLen; cnt++) {
							tempString += tempArr[cnt] + '<strong>' + rn + '</strong>';
						}
						numberOfInstances += tempArr.length - 1;
						sData[c] = tempString;
						pa++;
						score += rn.length;
					} else {
						pa = 0;
						break;
					}
				}
				if (woin[i] == 1) {
					nh++;
					var pat = new RegExp(w[i], "i");
					var rn = sData[c].search(pat);
					if (rn >= 0) {
						pa = 0;
						break;
					} else {
						pa++;
						score++;
					}
				}
			}
			if (pa == nh && SEARCHHANDLER.IsInScope(sData[c], filterType)) { //IF NUMBER OF PATTERNS IS EQUAL TO NUMBER OF PATTERNS PASSED, ADD LINE TO RESULTS								
				r[a] = sData[c];
				pageScore[a] = score;
				a++; //## INCREMENT RESULT COUNT
			}
		}
		co = a;
		r = SEARCHHANDLER.SortSearchResult(r, pageScore);
	}
	if (m == 1) {
		d = d.replace(/"/gi, "");
		var a = 0;
		var pat = new RegExp(d, "i");
		for (var c = 0, n = sData.length; c < n; c++) {
			var rn = sData[c].search(pat);
			if (rn >= 0 && SEARCHHANDLER.IsInScope(sData[c], filterType)) {
				r[a] = sData[c];
				a++;
			}
		}
		co = a;
	}
	if (typeof sC == "object" && typeof sC.hhLogSearch == "function") {
		sC.hhLogSearch(d, numberOfInstances);
	}

	SEARCHHANDLER.PrintResult(r, d, m, numberOfInstances);
	return false;
};
SEARCHHANDLER.IsInScope = function(row, type) {
	//## TYPE: 1=ALL, 2=SECTION, 3=PAGE
	if (type == 1) return true; //if 1, always return true(filter off)
	var section = "";
	var page = "";
	var url = window.location.toString();
	var aUrl = url.split("/");
	section = aUrl[aUrl.length - 2];
	if (type == 3) {
		page = aUrl[aUrl.length - 1];
		page = page.substring(0, page.indexOf("."));
	}
	var aRow = row.split("^");
	if (section != aRow[4]) {
		return false;
	} else {
		if (page == "" || page == aRow[5]) return true;
		else {
			return false;
		}
	}
};
SEARCHHANDLER.PrintResult = function(r, d, m, numberOfSearchResults) {
	var resultPanel = document.getElementById("resultPanel"); //namePrefix + 
	var ToolTipContainerClassName = 'tooltip';
	var resultHtml = "";
	var btnSearchPath = '../../gfx/searchfound.png';
	var btnSearchPathExpanded = '../../gfx/searchfound.png';
	var menuListElements = $('menuoptions').getElementsByTagName('li');
	var className = SEARCHHANDLER.ClassNameForHightlightedListItems;
	var classNameNoResult = 'faded';
	for (var i = 0, len = menuListElements.length; i < len; i++) {
		menuListElements[i].className = menuListElements[i].className.replace(className, '');
		menuListElements[i].className = menuListElements[i].className.replace(classNameNoResult, '');
		menuListElements[i].className += ' ' + classNameNoResult;
		var images = menuListElements[i].getElementsByTagName('img');
		if (images.length > 0) {
			DOM.Remove(images[0]);
		}
		var tooltips = menuListElements[i].getElementsByTagName('div');
		for (var x = 0, xLen = tooltips.length; x < xLen; x++) {
			if (tooltips[x] && tooltips[x] != 'undefined' && tooltips[x].className == ToolTipContainerClassName)
				DOM.Remove(tooltips[x]);
		}
	}
	if (r.length == 0) {
		MENU.Show();
		MENU.OpenTab('tablinksearch');
		standardSearchQuery = $('tbSearchBox').value;
		menuSearchQuery = $('tbSearchBoxInMenu').value;
		if (menuSearchQuery == '') {
			$('tbSearchBoxInMenu').value = standardSearchQuery;
		} else {
			if (menuSearchQuery !== d) {
				$('tbSearchBoxInMenu').value = d;
			}
		}
		$('menu-searchresult').innerHTML = "<strong>Your search did not match any documents.</strong><br />Make sure all keywords are spelt correctly. Try different or more general keywords.";
	} else {
		var pattern = SEARCHHANDLER.GetSearchPattern(d, m);
		for (var elementCounter = 0, length = menuListElements.length; elementCounter < length; elementCounter++) {
			var aElement = menuListElements[elementCounter].getElementsByTagName('a');
			if (aElement.length == 1) {
				var currentMenuSection = aElement[0].innerHTML;
				for (var searchArraypos = 0, searchArrayLen = r.length; searchArraypos < searchArrayLen; searchArraypos++) {
					var searchRowArray = r[searchArraypos].split("^");
					//if (r[searchArraypos].indexOf(currentMenuSection) > -1) {
					if (searchRowArray[0].indexOf(currentMenuSection) > -1) {
						var searchRowArrayPosTitle = 0, searchRowArrayPosText = 3;
						var ch = DOM.Create('img', '', '');
						ch.setAttribute('src', btnSearchPath);
						var posResult = searchRowArray[searchRowArrayPosText].search(pattern);
						if (posResult > -1) {
							ch.src = btnSearchPathExpanded;
							var tooltipTextPopup = DOM.Create('div', '', '');
							DOM.SetAttribute(tooltipTextPopup, 'class', ToolTipContainerClassName);
							tooltipTextPopup.style.display = 'none';
							var tooltipText = searchRowArray[searchRowArrayPosText].substr(posResult - 8, 120) + "...";
							tooltipTextPopup.innerHTML = '<span><span><span>' + tooltipText + '</span></span></span>';
							menuListElements[elementCounter].appendChild(tooltipTextPopup);
							addEvent(aElement[0], 'mouseover', viewTooltipForMenuList);
							addEvent(aElement[0], 'mouseout', hideTooltipForMenuList);
						}
						//menuListElements[elementCounter].insertBefore(ch, aElement[0]);
						DOM.AddBefore(ch, aElement[0]);
						menuListElements[elementCounter].className = menuListElements[elementCounter].className.replace(classNameNoResult, ''); 0
						menuListElements[elementCounter].className = menuListElements[elementCounter].className + ' ' + className;
						var parentListElement = menuListElements[elementCounter].parentNode.parentNode;
					}
				}
			}
		}
	}
	if (r.length > 0) {
		MENU.Show();
		MENU.OpenTab('tablinksearch');
		$('menu-searchresultNav').style.display = 'block';
		$('menu-searchresult').innerHTML = 'Looking for "<em>' + d + '</em>"<br />Results: ' + numberOfSearchResults + ' on ' + r.length + ' pages';
	}
	return;
};
SEARCHHANDLER.SortSearchResult = function(r, pageScore) {
	var newResultArray = new Array();
	for (var pageIterator = 0; pageIterator < r.length; pageIterator++) {
		var maxScore = 0;
		var scorePos = 0;
		for (var scoreIterator = 0, n = pageScore.length; scoreIterator < n; scoreIterator++) {
			if (pageScore[scoreIterator] > maxScore) {
				maxScore = pageScore[scoreIterator];
				scorePos = scoreIterator;
			}
		}
		newResultArray[pageIterator] = r[scorePos];
		pageScore[scorePos] = -1;
	}
	return newResultArray;
};
SEARCHHANDLER.GetSearchPattern = function(d, m) {
	if (m == 0) {
		var criteria = d.split(" ")[0];
		return new RegExp(criteria, "i");
	} else {
		return new RegExp(d, "i");
	}
};
*/



//------------------------------------------------------------------
//------------------------------------------------------------------
//## TRANSLATE
//------------------------------------------------------------------
TRANSLATE.Init = function() {
	this.Lang = 'en';
	this.Dictionary = null;
	if (typeof dictionary != 'undefined') {
		this.Dictionary = dictionary;
		this.Lang = TRANSLATE.GetValue('lang');
	}
};
TRANSLATE.GetValue = function(key) {
	if (this.Dictionary != null) {
		var dictLength = this.Dictionary.length;
		for (var ix = 0; ix < dictLength; ix++) {
			if (this.Dictionary[ix][0] == key) {
				return this.Dictionary[ix][1];
			}
		}
	}
	return key;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## VISITED PAGE HANDLER
//------------------------------------------------------------------
function VisitedPagesHandler() {
	this.NumberOfSecondsBeforePageIsCountedAsVisited = 5;
	this.ResetVisitedPages = function() {
		if (confirm('Really reset information about visited pages?')) {
			var li = $('menu').getElementsByTagName('li');
			for (var i = 0, iLen = li.length; i < iLen; i++) {
				li[i].className = li[i].className.replace('visited', '');
			}
			Cookie.Create('visitedpages', '', '365');
		}
	}
	this.InitializeVisitedLinks = function() {
		var documentName = document.location;
		setTimeout(this.SetPageAsVisited, this.NumberOfSecondsBeforePageIsCountedAsVisited * 1000);
	}
	this.SetPageAsVisited = function() {
		var cookieNameVisitedPages = 'visitedpages';
		var visitedPages = Cookie.Read(cookieNameVisitedPages);
		if (visitedPages != null) {
			visitedPages = visitedPages + '|'; //SEPARATOR OF URLS	
		} else {
			visitedPages = "";
		}
		if (visitedPages.indexOf(document.location) == -1) {
			visitedPages = visitedPages + document.location;
			Cookie.Create(cookieNameVisitedPages, visitedPages, '365');
		}
	}
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## TEXT HANDLER STUFF
//------------------------------------------------------------------
function InputOutput() {
	this.Alert = function(str) {
		if ($('alert')) return;
		var cover = document.createElement('div');
		cover.id = 'alertcover';
		cover.className = 'cover';
		cover.style.height = '1000px';
		cover.style.width = '2000px';
		cover.style.display = 'block';
		cover.style.zIndex = 100;
		setOpacity(cover, 75);
		document.body.appendChild(cover);
		var p = new POPUP();
		p.Width = 300;
		p.Height = 140;
		p.Id = 'alert';
		p.BodyText = str;
		p.CurrentXPos = parseInt(document.body.offsetWidth / 2) - parseInt(p.Width / 2);
		p.CurrentYPos = parseInt(document.body.offsetHeight / 2) - parseInt(p.Height / 2);
		p.Show();
		if (isIE) {
			$('alert').style.background = '#ccc';
		}
		$('alert').style.zIndex = 101;
		setTimeout('FadeElement("alert", 1000, 100, 0)', 3000);
		setTimeout('FadeElement("alertcover", 1000, 75, 0)', 3000);
	}
	this.Confirm = function(sr) {
		return confirm(sr);
	}
};
function TextHandler() {
	this.gv = function(val) { return TRANSLATE.GetValue(val) }
	this.TextWelcome = this.gv('Welcome to the comment tools');
	this.TextWelcomeBody = this.gv('Create your own personal comments, which only you and your invited friends can read');
	this.TextWelcomeLinkMoreInfo = this.gv('More info');
	this.TextWelcomeLinkSignUp = this.gv('I want to sign up');
	this.TextWelcomeLinkHaveAccount = this.gv('I already have an account');
	this.TextPopupClose = this.gv('Close');
	this.TextLoginHeader = this.gv('Login');
	this.TextLoginFieldEmail = this.gv('Email address');
	this.TextLoginFieldPassword = this.gv('Password');
	this.TextLoginFieldRemember = this.gv('Remember me');
	this.TextLoginButtonLogin = this.gv('Log in');
	this.TextLoginLinkNewUser = this.gv('New user?');
	this.TextLoginLinkLostPassword = this.gv('Lost password?');
	this.TextSignUpHeader = this.gv('Sign up');
	this.TextSignUpBody = this.gv('Create your own post-it comments directly in the text! The comments are personal and can only be seen by you and your invited friends and colleagues. <br /><br/>By signing up, you can read the annual report together with your comment on any computer connected to the Internet, just by logging in.');
	this.TextSignUpFieldFullName = this.gv('Full name');
	this.TextSignUpFieldYourEmail = this.gv('Your Email');
	this.TextSignUpFieldNewPassWord = this.gv('New password');
	this.TextSignUpFieldAccept = this.gv('I accept the <a href="#">terms of use</a>.');
	this.TextSignUpSubmitButton = this.gv('Sign up');
	this.TextCollaborateHeader = this.gv('Collaborate');
	this.TextCollaborateBody = this.gv('Is this web 2.0 or what? Now you can discuss the contents of the annual report without hassle with lost e-mails etc. ');
	this.TextCollaborateFieldEmailAddresses = this.gv('Enter your friends’ e-mail addresses, separated by comma');
	this.TextCollaborateButtonInvite = this.gv('Invite');
	this.TextCollaborateButtonSkip = this.gv('Skip');
	this.TextCommentFormHeader = this.gv('Welcome back {User.Firstname}!');
	this.TextCommentFormBodyInvitationUnused = this.gv('Your comments are visible to you only. Use the collaborate feature if you want to share your comments and interact with your friends and colleagues.');
	this.TextCommentFormBodyInvitedPerson = this.gv('Your comments are visible to you, {Users} and {LastUser}. Only {Moderator} can edit group members.');
	this.TextCommentFormBodyInvitationUsed = this.gv('Your comments are visible to you, {Users} and {LastUser}.');
	this.TextCommentFormStartCollaborate = this.gv('Start collaborate');
	this.TextCommentFormButtonLogout = this.gv('Logout');
	this.TextCommentFormButtonEditGroupMembers = this.gv('Edit group members');
	this.TextCommentFormButtonCreateComment = this.gv('Create new comment');
	this.TextCommentFormButtonShowComments = this.gv('Show all my comments');
	this.TextYourComment = this.gv('Your comment');
	this.TextDeleteComment = this.gv('Delete comment');
	this.TextUpdateComment = this.gv('Update comment');
	this.TextDeleteConfirm = this.gv('Are you sure you want to delete this comment?');
	this.ReadMore = this.gv('ReadMore');
	this.FinancialTableMultiViewTrigger = 'Show multiple years' //this.gv('FinancialTableMultiViewTrigger');
	this.ExcellinkText = 'Download Excel sheet';
	this.ExcellinkHref = 'en.xls';

};
function StringHandler() {
	this.GetCleanInput = function(str) {
		return str;
	}
};
function User() {
	this.Firstname = '';
	this.Username = '';
	this.Password = '';
	this.Hash = '';

	this.Save = function() {
		USERHANDLER.SaveUser(this);
	}
	this.LoadByCookie = function() {
		return USERHANDLER.LoadUserByCookie(this);
	}
};
function UserHandler() {
	this.CookieNameUsername = 'Username';
	this.CookieNameHash = 'LoginHash';
	this.Login = function(email, password) {
		var Hash = hex_md5(email + password);
		USER.Hash = Hash;
		USER.Username = email;
		this.SaveUser(USER);
		document.location.reload();
	}
	this.Logout = function() {
		Cookie.Create(USERHANDLER.CookieNameHash, null, -1);
		Cookie.Create(USERHANDLER.CookieNameUsername, null, -1);
		document.location.reload();
	}
	this.SaveUser = function(user) {
		Cookie.Create(this.CookieNameHash, user.Hash, 365);
		Cookie.Create(this.CookieNameUsername, user.Username, 365);

	}
	this.LoadUserByCookie = function(user) {
		user.Hash = Cookie.Read(this.CookieNameHash);
		user.Username = Cookie.Read(this.CookieNameUsername);
		return user.Hash;
	}
};
function Comment(page, section, offset, id, wordlength) {
	this.Page = page;
	this.Section = section;
	this.Offset = offset;
	this.WordLength = wordlength;
	this.ID = id;
	this.CommentSection = new Array();
	this.Editable = false;
	this.addSection = function(text, author, created) {
		this.CommentSection[this.CommentSection.length] = (new CommentSection(text, author, created));
	}
};
function CommentSection(text, author, created) {
	this.Text = text;
	this.Author = author;
	this.CreatedTime = created;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## CLASS FOR COMMENTS METHOD CALLS VIA SERVER (AJAX)
//------------------------------------------------------------------
function ServerConnection() {
	this.callBackCreateUser = null; //function(bool)
	this.callBackAuthenticateUser = null; //function(bool success, bool isGroupAdmin)
	this.callBackGetUsersInGroup = null; //function(bool,array of usernames)
	this.callBackInviteUsers = null; //function(bool)
	this.callBackKickUser = null; //function(bool)
	this.callBackCreateComment = null; //function(bool)
	this.callBackEditComment = null; //function(bool)
	this.callBackDeleteComment = null; //function(bool)
	this.callBackGetComments = null; //function(bool)
	this.encode = function(str) {
		return str;
	}
	this.CreateUser = function(username, name, password, callback) {
		this.callBackCreateUser = callback;
		var path = "/CreateUser.aspx?u=" + this.encode(username) + "&n=" + this.encode(name) + "&p=" + this.encode(password);
		callServer(path);
	}
	this.AuthenticateUser = function(username, password, callback) {
		this.callBackAuthenticateUser = callback;
		var path = "/Login.aspx?u=" + this.encode(username) + "&p=" + this.encode(password);
		callServer(path);
	}
	this.GetUsersInGroup = function(username, callback) {
		this.callBackGetUsersInGroup = callback;
		var path = "/GetUsersInGroup.aspx?u=" + this.encode(username);
		callServer(path);
	}
	this.InviteUsers = function(username, invite, callback) {
		this.callBackInviteUsers = callback;
		var path = "/InviteUser.aspx?u=" + this.encode(username) + "&i=" + this.encode(invite); //invite is email separated by , or ;
		callServer(path);
	}
	this.KickUser = function(username, callback) {
		this.callBackKickUser = callback;
		var path = "/KickUser.aspx?u=" + this.encode(username);
		callServer(path);
	}
	this.CreateComment = function(username, section, page, offset, wordlength, callback) {
		this.callBackCreateComment = callback;
		var path = "/CreateComment.aspx?u=" + this.encode(username) + "&s=" + this.encode(section) + "&p=" + this.encode(page) + "&o=" + this.encode(offset) + "&w=" + this.encode(wordlength);
		callServer(path);
	}
	this.EditComment = function(username, commentId, text, callback) {
		this.callBackEditComment = callback;
		var path = "/EditComment.aspx?u=" + this.encode(username) + "&id=" + this.encode(commentId) + "&t=" + this.encode(text);
		callServer(path);
	}
	this.DeleteComment = function(username, commentId, callback) {
		this.callBackDeleteComment = callback;
		var path = "/DeleteComment.aspx?u=" + this.encode(username) + "&id=" + this.encode(commentId);
		callServer(path);
	}
	this.GetComments = function(username, callback) {
		this.callBackGetComments = callback;
		var path = "/GetComments.aspx?u=" + this.encode(username);
		callServer(path);
	}
	var serverPath = "http://cybercom.commentserver.ar.halvarsson.se/test";
	var callServer = function(url) {
		var script = document.createElement('script');
		script.src = serverPath + url;
		script.type = 'text/javascript';
		document.getElementsByTagName('head')[0].appendChild(script);
	}
};
function CommentHandler() {
	var _comments = [];
	this.clearComments = function() {
		_comments.length = 0;
	}
	this.addComment = function(comment) {
		_comments[_comments.length] = comment;
	}
	this.getComments = function() {
		return _comments;
	}
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## ACTIVE COMMENT OBJECT
//------------------------------------------------------------------
ACTIVECOMMENT.Init = function() {
	ACTIVECOMMENT.ActiveCommentContainerId = 'activecomment';
	ACTIVECOMMENT.CommentId = ''; //Active commentid
	ACTIVECOMMENT.IsEditing = false;
	ACTIVECOMMENT.EditClassName = 'edit';
	ACTIVECOMMENT.TextAreaId = 'commenttext';
	ACTIVECOMMENT.Container = DOM.Create('div', '', ACTIVECOMMENT.ActiveCommentContainerId);
	strhtml =
	'<div class="pop-close" id="btn-comment-close" title="Close"><span>Close</span></div>' +
	'<p>' + TEXTHANDLER.TextYourComment + '</p>' +
	'<p>' +
		'<textarea id="' + ACTIVECOMMENT.TextAreaId + '"></textarea>' +
	'</p>' +
	'<p>' +
		'<a href="javascript:;" id="btn-comment-delete" >' + TEXTHANDLER.TextDeleteComment + '</a> ' +
		'<a href="javascript:;" id="btn-comment-update" >' + TEXTHANDLER.TextUpdateComment + '</a> ' +
	'</p>';
	ACTIVECOMMENT.Container.innerHTML = strhtml;
	DOM.Add(ACTIVECOMMENT.Container, $(COMMENTAREA.ContainerId));
	addEvent($('btn-comment-close'), 'click', ACTIVECOMMENT.Hide);
	addEvent($('btn-comment-delete'), 'click', ACTIVECOMMENT.DeleteComment);
	addEvent($('btn-comment-update'), 'click', ACTIVECOMMENT.UpdateComment);
};
ACTIVECOMMENT.SetCommentId=function(newcommentid){ACTIVECOMMENT.CommentId=newcommentid}
ACTIVECOMMENT.GetCommentId=function(){return ACTIVECOMMENT.CommentId}
ACTIVECOMMENT.UpdateComment = function() {
	var commentid = ACTIVECOMMENT.GetCommentId();
	var commenttext = STRINGHANDLER.GetCleanInput($(ACTIVECOMMENT.TextAreaId).value);
	SERVERCONNECTION.EditComment(USER.Username, commentid, commenttext,
		function(success) {
			if (success) {
				COMMENTS.FlushComments();
			}
		}
	);
	ACTIVECOMMENT.IsEditing = false;
	setTimeout("ACTIVECOMMENT.Hide()", 200);
};
ACTIVECOMMENT.DeleteComment = function() {
	if (ACTIVECOMMENT.GetCommentId() == '') return;
	if (confirm(TEXTHANDLER.TextDeleteConfirm)) {
		ACTIVECOMMENT.GetCommentId();
		SERVERCONNECTION.DeleteComment(USER.Username, ACTIVECOMMENT.GetCommentId(),
			function(success) {
				if (success) {
					COMMENTS.FlushComments();
					COMMENTPLACEHOLDER.SetAsDeleted(ACTIVECOMMENT.GetCommentId());
				}
			}
		);
		ACTIVECOMMENT.Hide();
		ACTIVECOMMENT.IsEditing = false;
	}
};
ACTIVECOMMENT.Show = function(obj) {
	if (obj.className != COMMENTPLACEHOLDER.ClassName) obj = this;
	if (obj.className != COMMENTPLACEHOLDER.ClassName) return;
	var commentid = obj.id.replace('commentid=', '');
	var mouseEvent = COMMENTAREA.MouseEvent;
	ACTIVECOMMENT.SetCommentId(commentid);
	objParent = obj;
	//TODO MAKE TOP WORK FOR BOTH IE AND FIREFOX		
	itop = 180;
	left = mouseEvent.screenX - 20;
	while (objParent != null && objParent.id != 'content') {
		itop += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	var commenttext = '';
	var comments = COMMENTHANDLER.getComments();
	for (var i = 0, iLen = comments.length; i < iLen; i++) {
		if (commentid == comments[i].ID) {
			var CommentSections = comments[i].CommentSection;
			for (var iCS = 0, iCSLen = CommentSections.length; iCS < iCSLen; iCS++) {
				commenttext = CommentSections[iCS].Text;
			}
		}
	}
	ACTIVECOMMENT.Container.style.left = left + 'px';
	ACTIVECOMMENT.Container.style.top = itop + 'px';
	ACTIVECOMMENT.Container.style.display = 'block';
	$(ACTIVECOMMENT.TextAreaId).value = commenttext;
};
ACTIVECOMMENT.Hide = function() {
	ACTIVECOMMENT.Container.className = '';
	ACTIVECOMMENT.Container.style.display = 'none';
};
ACTIVECOMMENT.StartEdit = function() {
	ACTIVECOMMENT.IsEditing = true;
	$(ACTIVECOMMENT.TextAreaId).focus();
	ACTIVECOMMENT.Container.className = ACTIVECOMMENT.EditClassName;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## COMMENT AREA OBJECT
//------------------------------------------------------------------
COMMENTAREA.Init = function() {
	COMMENTAREA.ContainerId = 'content';
	COMMENTAREA.Container = $(COMMENTAREA.ContainerId);
	COMMENTAREA.DoComment = false;
	COMMENTAREA.CommentIcon = DOM.Create('span', '', 'comment-icon');
	DOM.Add(COMMENTAREA.CommentIcon, COMMENTAREA.Container);
	addEvent(COMMENTAREA.Container, 'click', COMMENTAREA.Click);
	addEvent(COMMENTAREA.Container, 'mousemove', COMMENTAREA.MouseMove);
	addEvent(COMMENTAREA.Container, 'mouseout', COMMENTAREA.MouseOut);
};
COMMENTAREA.MouseMove = function(e) {
	COMMENTAREA.MouseEvent = e;
	if (COMMENTAREA.DoComment) {
		COMMENTAREA.CommentIcon.style.top = (e.clientY + 10) + 'px';
		COMMENTAREA.CommentIcon.style.left = (e.clientX + 10) + 'px';
		COMMENTAREA.CommentIcon.style.display = 'block';
		if (ie) {
			commentrange.moveToPoint(e.clientX, e.clientY);
			commentrange.expand("word");
			if (acceptedCommentTags.indexOf('|' + e.srcElement.tagName + '|') == -1 || commentrange.boundingLeft >= ((columnWidth + 100) * 2)) {
				commentout(e);
			} else {
				underline.style.left = (commentrange.boundingLeft - 4) + 'px';
				underline.style.top = (commentrange.boundingTop - 1) + 'px';
				underline.style.display = 'block';
			}
		}
	}
};
COMMENTAREA.MouseOut = function(e) {
	if (!ACTIVECOMMENT.IsEditing) ACTIVECOMMENT.Hide();
};
COMMENTAREA.Click = function(e) {
	var commentPlaceHolder;
	if (COMMENTAREA.DoComment) {
		var el;
		go = false;
		if (ie) {
			el = e.srcElement;
			if (COMMENTS.AcceptedCommentTags.indexOf('|' + el.tagName + '|') > -1) {
				if (el.parentNode.className != COMMENTPLACEHOLDER.ClassName) {
					go = true;
					var commentLength = commentrange.text.length;
					commentrange.pasteHTML('<span class="' + COMMENTPLACEHOLDER.ClassName + '" onmouseout="commentmouseout(this);" onmouseover="commenthover(this);" onclick="commentclick(this);" id="newcomment">' + commentrange.text + '</span>');
				}
			}
		} else {
			el = e.target;
			if (!el) el = e.srcElement;
			if (COMMENTS.AcceptedCommentTags.indexOf('|' + el.tagName + '|') > -1) {
				go = true;
				sel = window.getSelection();
				startpos = sel.anchorOffset;
				endpos = startpos;
				sel.collapse(sel.anchorNode, startpos);
				range = document.createRange();
				range.setStart(sel.anchorNode, startpos);
				range.setEnd(sel.anchorNode, endpos);
				while (startpos > 0) {
					startpos--;
					range.setStart(sel.anchorNode, startpos);
					if (range.toString().substring(0, 1) == ' ') {
						startpos++;
						range.setStart(sel.anchorNode, startpos);
						break;
					}
				}
				endpos = startpos + 1;
				while (true) {
					try {
						range.setEnd(sel.anchorNode, endpos);
					} catch (ex) {
						endpos -= 2;
						range.setEnd(sel.anchorNode, endpos);
						break;
					}
					if (range.toString().substring(range.toString().length - 1) == ' ') {
						endpos--;
						range.setEnd(sel.anchorNode, endpos);
						break;
					}
					endpos++;
				}
				commentLength = endpos - startpos;
				commentPlaceHolder = DOM.Create('span', COMMENTPLACEHOLDER.ClassName, '');
				DOM.SetAttribute(commentPlaceHolder, 'onmouseout', 'COMMENTPLACEHOLDER.MouseOut(this);');
				DOM.SetAttribute(commentPlaceHolder, 'onmouseover', 'COMMENTPLACEHOLDER.MouseOver(this);');
				DOM.SetAttribute(commentPlaceHolder, 'onclick', 'COMMENTPLACEHOLDER.Click(this);');
				DOM.SetAttribute(commentPlaceHolder, 'id', 'newcomment');
				commentPlaceHolder.innerHTML = range.toString();
				range.deleteContents();
				range.insertNode(commentPlaceHolder);
			}
		}
		if (go) {
			if (commentPlaceHolder != null) {
				var page = new PageHandler();
				var comment = new Comment();
				comment.Page = page.getPageHash();
				comment.Section = COMMENTAREA.GetSection(el);
				comment.Offset = COMMENTAREA.GetStartPosForComment(commentPlaceHolder);
				comment.WordLength = commentLength;
				SERVERCONNECTION.CreateComment(USER.Username, comment.Section, comment.Page, comment.Offset, comment.WordLength,
					function(success, id) {
						if (success) {
							ACTIVECOMMENT.SetCommentId(id);
							commentPlaceHolder.id = 'commentid=' + id;
						}
					}

				);
				COMMENTPLACEHOLDER.MouseOver(commentPlaceHolder);
				COMMENTPLACEHOLDER.Click(commentPlaceHolder);
			}
			COMMENTAREA.DoComment = false;
			COMMENTAREA.CommentIcon.style.display = 'none';
		}
	}
};
COMMENTAREA.GetStartPosForComment = function(commentPlaceHolder) {
	var parent = commentPlaceHolder.parentNode;
	return parseInt(parent.innerHTML.indexOf('<span id="newcomment"'));
};
COMMENTAREA.GetSection = function(commentPlaceHolder) {
	var content = $(COMMENTAREA.ContainerId);
	var elementCounter = 0;
	COMMENTAREA.nodeFound = false;
	elementCounter = COMMENTAREA.CalculateChildNodes(content, commentPlaceHolder, elementCounter, -1)
	return elementCounter;
};
COMMENTAREA.GetSectionElement = function(elPos) {
	var content = $(COMMENTAREA.ContainerId);
	COMMENTAREA.nodeFound = false;
	COMMENTAREA.currentElement = null;
	elementCounter = COMMENTAREA.CalculateChildNodes(content, null, 0, elPos)
};
COMMENTAREA.CalculateChildNodes = function(element, currentElement, elementCounter, elementToFindPos) {
	if (!COMMENTAREA.nodeFound) {
		var innerElements = element.getElementsByTagName('*');
		for (var i = 0, iLen = innerElements.length; i < iLen; i++) {
			var innerElement = innerElements[i];
			if (COMMENTS.AcceptedCommentTags.indexOf('|' + innerElement.nodeName + '|') > -1) {
				if (elementToFindPos > -1) {
					if (elementCounter == elementToFindPos) {
						COMMENTAREA.currentElement = innerElement;
						COMMENTAREA.nodeFound = true;
						return;
					}
				} else if (innerElement == currentElement) {
					COMMENTAREA.nodeFound = true;
					return elementCounter;
				}
				if (innerElement.className != 'noprint')
					elementCounter++;
			}
		}
	}
	return elementCounter;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## COMMENT PLACEHOLDER OBJECT
//------------------------------------------------------------------
COMMENTPLACEHOLDER.Init = function() {
	COMMENTPLACEHOLDER.ClassName = 'comment';
};
COMMENTPLACEHOLDER.MouseOver = function(obj) {
	if (!obj.innerHTML) obj = this;
	if (obj.className == '') return;
	ACTIVECOMMENT.Show(obj);
};
COMMENTPLACEHOLDER.MouseOut = function(obj) {
	if (!ACTIVECOMMENT.IsEditing) ACTIVECOMMENT.Hide();
};
COMMENTPLACEHOLDER.Click = function(obj) {
	ACTIVECOMMENT.StartEdit();
};
COMMENTPLACEHOLDER.SetAsDeleted = function(id) {
	var el = $('commentid=' + id);
	DOM.SetAttribute(el, 'class', 'comment-deleted');
	DOM.SetAttribute(el, 'onclick', 'javascript:;');
	DOM.SetAttribute(el, 'onmouseover', 'javascript:;');
	DOM.SetAttribute(el, 'onmouseout', 'javascript:;');
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## COMMENT AREA OBJECT
//------------------------------------------------------------------
COMMENTS.Init = function() {
	COMMENTS.AcceptedCommentTags = '|LI|P|H2|H3|H4|';
	COMMENTS.IsCommentScriptLoaded = false;
	if (isIE) commentrange = document.body.createTextRange();
	var res = USER.LoadByCookie();
	if (res != null) {
		COMMENTS.LoadCommentTools();
		COMMENTS.FlushComments();
		setTimeout('COMMENTS.LoadCommentPlaceHolders()', 100);
	}
	COMMENTAREA.Init();
	ACTIVECOMMENT.Init();
	COMMENTPLACEHOLDER.Init();
};
COMMENTS.FlushComments = function() {
	SERVERCONNECTION.GetComments(USER.Username,
		function(success) {
			if (success) {
			}
		}
	)
};
COMMENTS.LoadCommentPlaceHolders = function() {
	var c = COMMENTHANDLER.getComments();
	for (var i = 0, iLen = c.length; i < iLen; i++) {
		if (parseInt(c[i].ID) > 0 && c[i].Section.indexOf(':') == -1) {
			COMMENTS.PlaceCommentInPage(c[i]);
		}
	}
};
COMMENTS.PlaceCommentInPage = function(comment) {
	//## CHECK IF COMMENT BELONGS TO CURRENT PAGE
	var CurrentPage = new PageHandler();
	if (CurrentPage.getPageHash().indexOf(comment.Page) > -1) {
		targetParagraphNumber = comment.Section.replace(':', '');
		COMMENTAREA.GetSectionElement(targetParagraphNumber);
		var targetElement = COMMENTAREA.currentElement;
		var nextElement = null;
		start = parseInt(comment.Offset);
		wordlength = parseInt(comment.WordLength);
		var id = 'commentid=' + comment.ID;
		//GET CONTENT TEXT 		
		var contentTextBeforeComment = targetElement.innerHTML.substring(0, start);
		var contentTextAfterComment = targetElement.innerHTML.substring(start + wordlength, targetElement.innerHTML.length);
		var commentWord = targetElement.innerHTML.substring(start, start + wordlength);
		//GET DUPLACATED ELEMENT IF EXISTS
		if (targetElement.className = 'noprint') {
			var elements = COMMENTAREA.Container.getElementsByTagName(targetElement.nodeName);
			for (var i = 0, iLen = elements.length; i < iLen; i++) {
				if (elements[i] != targetElement) {
					if (elements[i].innerHTML == targetElement.innerHTML) {
						nextElement = elements[i];
						break;
					}
				}
			}
		}
		//CREATE A NEW COMMENT PLACEHOLDER						
		var span = '<span class="comment" id="' + id + '" >' + commentWord + '</span>';
		targetElement.innerHTML = contentTextBeforeComment;
		targetElement.innerHTML += span;
		targetElement.innerHTML += contentTextAfterComment;
		if (nextElement) {
			nextElement.innerHTML = targetElement.innerHTML;
			var spans = nextElement.getElementsByTagName('span');
			for (var i = 0, iLen = spans.length; i < iLen; i++) {
				if (spans[i].className == COMMENTPLACEHOLDER.ClassName) {
					addEvent(spans[i], 'mouseover', COMMENTPLACEHOLDER.MouseOver);
					addEvent(spans[i], 'mouseout', COMMENTPLACEHOLDER.MouseOut);
					addEvent(spans[i], 'click', COMMENTPLACEHOLDER.Click);

				}
			}
		}
		//LOOP TROUGH ALL SPANS IN ELEMENT AND ADD EVENTS (THEY'VE BEEN LOST AFTER INNERHTML)
		var spans = targetElement.getElementsByTagName('span');
		for (var i = 0, iLen = spans.length; i < iLen; i++) {
			if (spans[i].className == COMMENTPLACEHOLDER.ClassName) {
				addEvent(spans[i], 'mouseover', COMMENTPLACEHOLDER.MouseOver);
				addEvent(spans[i], 'mouseout', COMMENTPLACEHOLDER.MouseOut);
				addEvent(spans[i], 'click', COMMENTPLACEHOLDER.Click);

			}
		}
	}
};
COMMENTS.StartDoComment = function() {
	COMMENTAREA.DoComment = true;
};
COMMENTS.LoadCommentTools = function() {
	var popup = new POPUP();
	var headertext = TEXTHANDLER.TextCommentFormHeader.replace('{User.Firstname}', USER.Username);
	popup.HeaderText = headertext;
	popup.CurrentXPos = 400;
	popup.CurrentYPos = -10;
	popup.Width = 520;
	popup.Height = 150;
	var bodytext = TEXTHANDLER.TextCommentFormBodyInvitationUnused;
	//TODO ADD DIFFERENT FUNCTIONALITY DEPENDING ON INVITATION STATUS
	popup.BodyText = '<p>' + bodytext + '</p>' +
		'<p>' +
			'<a id="btn-logout" onclick="javascript:USERHANDLER.Logout();" href="javascript:;">' + TEXTHANDLER.TextCommentFormButtonLogout + '</a> ' +
			'<a id="btn-createcomment" onclick="javascript:COMMENTS.StartDoComment();" href="javascript:;">' + TEXTHANDLER.TextCommentFormButtonCreateComment + '</a>' +
		'</p>';

	popup.Show();
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## CLASS FOR SPECIAL POPUP
//------------------------------------------------------------------
var POPUPVARIABLES={};
POPUPVARIABLES.Counter=0;
POPUPVARIABLES.Width=400;
POPUPVARIABLES.Height=300;
POPUPVARIABLES.CurrentYPos=100;
POPUPVARIABLES.CurrentXPos=30;
POPUPVARIABLES.YPosInc=10;
POPUPVARIABLES.XPosInc=10;
POPUPVARIABLES.ZIndex=30;
POPUPVARIABLES.EventButtonClassName='popup-event-button';
POPUPVARIABLES.ClassName='popup';
POPUPVARIABLES.PopupHolderId='content';

function POPUP(BodyText) {
	this.HeaderText = '';
	this.BodyText = BodyText;
	this.Container = '';
	this.Counter = POPUPVARIABLES.Counter;
	this.Width = POPUPVARIABLES.Width;
	this.Height = POPUPVARIABLES.Height;
	this.CurrentYPos = POPUPVARIABLES.CurrentYPos;
	this.CurrentXPos = POPUPVARIABLES.CurrentXPos;
	this.YPosInc = POPUPVARIABLES.YPosInc;
	this.XPosInc = POPUPVARIABLES.XPosInc;
	this.Id = '';
	this.ZIndex = POPUPVARIABLES.ZIndex++;


	this.Show = function() {
		if (this.Id == '')
			this.Id = 'POPUP' + this.Counter;
		//## IF THIS POPUP ALREADY EXISTS MAKE IT FLOAT ON TOP BY INC ZINDEX
		var el = $(this.Id);
		if (el) {
			el.style.zIndex = this.ZIndex;
			return;
		}

		this.Container = DOM.Create('div', POPUPVARIABLES.ClassName, '');

		//## CORNERS
		DOM.Add(DOM.Create('DIV', 'pop-corner-tr'), this.Container);
		DOM.Add(DOM.Create('DIV', 'pop-corner-br'), this.Container);
		DOM.Add(DOM.Create('DIV', 'pop-corner-bl'), this.Container);
		DOM.Add(DOM.Create('DIV', 'pop-corner-tl'), this.Container);

		//## SHADES
		var shade = DOM.Create('DIV', 'pop-top');
		shade.style.width = parseInt(this.Width - 40) + 'px';
		DOM.Add(shade, this.Container);

		var main = DOM.Create('DIV', 'pop-main');
		main.style.width = parseInt(this.Width - 40) + 'px';
		main.style.height = parseInt(this.Height - 40) + 'px';
		DOM.Add(main, this.Container);

		var shade = DOM.Create('DIV', 'pop-bottom');
		shade.style.width = parseInt(this.Width - 40) + 'px';
		DOM.Add(shade, this.Container);

		var shade = DOM.Create('DIV', 'pop-right');
		shade.style.height = parseInt(this.Height - 40) + 'px';
		DOM.Add(shade, this.Container);

		var shade = DOM.Create('DIV', 'pop-left');
		shade.style.height = parseInt(this.Height - 40) + 'px';
		DOM.Add(shade, this.Container);

		//## CLOSE BUTTON
		var close = DOM.Create('DIV', 'pop-close');
		close.title = 'Close';
		close.innerHTML = '<span>' + TEXTHANDLER.TextPopupClose + '</span>';
		DOM.Add(close, this.Container);

		var popTopic = DOM.Create('H2', '', 'pop-topic');
		popTopic.innerHTML = this.HeaderText;
		DOM.Add(popTopic, this.Container);

		var popContent = DOM.Create('DIV', '', 'pop-content');
		popContent.style.width = this.Width - 68 + 'px';
		popContent.style.height = this.Height - 80 + 'px';
		popContent.innerHTML += this.BodyText;
		DOM.Add(popContent, this.Container);


		this.Container.style.top = this.CurrentYPos + 'px';
		this.Container.style.left = this.CurrentXPos + 'px';
		this.Container.style.width = this.Width + 'px';
		this.Container.style.height = this.Height + 'px';
		this.Container.id = this.Id;
		this.Container.style.zIndex = this.ZIndex;

		DOM.Add(this.Container, $(POPUPVARIABLES.PopupHolderId));
		addEvent(close, 'click', this.Close);

		//## ADD LISTENERS TO CONTENT IN POPUP
		this.AddListeners();

		POPUPVARIABLES.CurrentXPos += this.XPosInc;
		POPUPVARIABLES.CurrentYPos += this.YPosInc;
		POPUPVARIABLES.Counter++;
	}
	this.Close = function() {
		if (this.parentNode) DOM.Remove(this.parentNode);
	}
	//## ADDS LISTENERS TO CONTENT IN DIV, THIS IS REQUIERED WHEN innerHTML IS USED TO FILL CONTENT
	this.AddListeners = function() {
		var as = $(POPUPVARIABLES.PopupHolderId).getElementsByTagName('a');
		for (var i = 0, iLen = as.length; i < iLen; i++) {
			if (as[i].className == POPUPVARIABLES.EventButtonClassName) {
				addEvent(as[i], 'click', ActionHandler);
			}
		}
	};
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## ACTIONHANDLER
//------------------------------------------------------------------
var ActionHandler = function() {
	switch (this.id) {
		case 'moreinfo':
		case 'signup':
			var popup = new POPUP();
			popup.Id = 'popup-signup';
			popup.HeaderText = 'Sign up';
			popup.Width = 500; //special width for signup popup
			popup.Height = 340;
			popup.HeaderText = TEXTHANDLER.TextSignUpHeader;
			popup.BodyText = '<div class="left">' +
			'<p>' + TEXTHANDLER.TextSignUpBody + '</p>' +
			'</div>' +
			'<div class="right">' +
			'<p><label for="txtName">' + TEXTHANDLER.TextSignUpFieldFullName + ':</label>' +
			'<input type="text" class="text" id="txtName" /></p>' +
			'<p><label for="txtEmail">' + TEXTHANDLER.TextSignUpFieldYourEmail + ':</label>' +
			'<input type="text" class="text" id="txtEmail" /></p>' +
			'<p><label for="txtPassword">' + TEXTHANDLER.TextSignUpFieldNewPassWord + ':</label>' +
			'<input type="text" class="text" id="txtPassword" /></p>' +
			'<p><input type="checkbox" class="checkbox" id="chkAccept" />' +
			'<label for="chkAccept">' + TEXTHANDLER.TextSignUpFieldAccept + '</p>' +
			'<p><a class="' + POPUPVARIABLES.EventButtonClassName + '" id="button-signup" href="javascript:;">' + TEXTHANDLER.TextSignUpSubmitButton + '</a></p>' +
			'</div>';
			popup.Show();
			break;
		case 'haveaccount':
			var popup = new POPUP();
			popup.Id = 'popup-haveaccount';
			popup.HeaderText = TEXTHANDLER.TextLoginHeader;
			popup.BodyText = '<p><label for="txtEmail">' + TEXTHANDLER.TextLoginFieldEmail + ':</label>' +
			'<input type="text" class="text" id="txtEmail" /></p>' +
			'<p><label for="txtPassword">' + TEXTHANDLER.TextLoginFieldPassword + ':</label>' +
			'<input type="password" class="text" id="txtPassword" /></p>' +
			'<p><input type="checkbox" class="checkbox" id="chkRememberMe" />' +
			'<label for="chkRememberMe">' + TEXTHANDLER.TextLoginFieldRemember + '</label></p>' +
			'<p><a class="' + POPUPVARIABLES.EventButtonClassName + '" id="login" href="javascript:;">' + TEXTHANDLER.TextLoginButtonLogin + '</a> ' +
			'<a id="new-user" class="' + POPUPVARIABLES.EventButtonClassName + '" href="javascript:;">' + TEXTHANDLER.TextLoginLinkNewUser + '</a> ' +
			'<a id="lost-password" class="' + POPUPVARIABLES.EventButtonClassName + '" href="javascript:;">' + TEXTHANDLER.TextLoginLinkLostPassword + '</a>' +
			'</p>';
			popup.Show();
			break;
		case 'login':
			//## LOGIN USER
			var email = STRINGHANDLER.GetCleanInput($('txtEmail').value);
			var password = STRINGHANDLER.GetCleanInput($('txtPassword').value);
			SERVERCONNECTION.AuthenticateUser(email, password,
				function(success, isGroupAdmin) {
					if (success) { //## LOGIN IS SUCCESSFUL 
						USERHANDLER.Login(email, password);
					}
				}
			)
			break;
		case 'button-signup':
			var username = STRINGHANDLER.GetCleanInput($('txtEmail').value);
			var name = STRINGHANDLER.GetCleanInput($('txtName').value);
			var password = STRINGHANDLER.GetCleanInput($('txtPassword').value);
			SERVERCONNECTION.CreateUser(username, name, password,
				function(success) {
					if (success) { //USER HAS BEEN CREATED
						var popupInfo = new POPUP();
						popupInfo.BodyText = 'User has been created, login to use comment functionality';
						popupInfo.Show();
						//## OPEN POPUP FOR COLLABORATION
						var popup = new POPUP();
						popup.Id = 'popup-collaborate';
						popup.HeaderText = TEXTHANDLER.TextCollaborateHeader;
						popup.Width = 460;
						popup.Height = 240;
						popup.BodyText = '<div class="left">' +
						'<p>' + TEXTHANDLER.TextCollaborateBody + '</p>' +
						'</div>' +
						'<div class="right">' +
						'<p><label for="txtEmailAddresses">' + TEXTHANDLER.TextCollaborateFieldEmailAddresses + '</label>' +
						'<textarea id="txtEmailAddresses"></textarea></p>' +
						'<p><a class="' + POPUPVARIABLES.EventButtonClassName + '" href="javascript:;" id="invite">' + TEXTHANDLER.TextCollaborateButtonInvite + '</a> ' +
						'<a class="' + POPUPVARIABLES.EventButtonClassName + '" href="javascript:;" id="skip-collaborate">' + TEXTHANDLER.TextCollaborateButtonSkip + '</a></p>' +
						'</div>';
						popup.Show();
					}
				}

			);
			break;
		case 'skip-collaborate':
			DOM.Remove($('popup-collaborate'));
			break;
		case 'invite':
			alert('sending invitation...');
			break;
	};
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## COMMENT MAIN FORM TO GO IN MENU
//------------------------------------------------------------------
function GetCommentForm() {
	var div = DOM.Create('div', '', 'menu-commentform');
	div.innerHTML = '<h3>' + TEXTHANDLER.TextWelcome + '</h3>';
	div.innerHTML += '<p>' + TEXTHANDLER.TextWelcomeBody + '</p>';

	var aMoreInfo = DOM.Create('a', '', '');
	DOM.SetAttribute(aMoreInfo, 'href', 'javascript:;');
	DOM.SetAttribute(aMoreInfo, 'id', 'moreinfo');
	aMoreInfo.innerHTML = TEXTHANDLER.TextWelcomeLinkMoreInfo;

	var aSignUp = DOM.Create('a', '', '');
	DOM.SetAttribute(aSignUp, 'href', 'javascript:;');
	DOM.SetAttribute(aSignUp, 'id', 'signup');
	aSignUp.innerHTML = TEXTHANDLER.TextWelcomeLinkSignUp;

	var aHaveAccount = DOM.Create('a', '', '');
	DOM.SetAttribute(aHaveAccount, 'href', 'javascript:;');
	DOM.SetAttribute(aHaveAccount, 'id', 'haveaccount');
	aHaveAccount.innerHTML = TEXTHANDLER.TextWelcomeLinkHaveAccount;

	addEvent(aMoreInfo, 'click', ActionHandler);
	addEvent(aHaveAccount, 'click', ActionHandler);
	addEvent(aSignUp, 'click', ActionHandler);

	var ul = DOM.Create('ul', '', '');
	var li1 = DOM.Create('li', '', '');
	DOM.Add(aMoreInfo, li1);
	DOM.Add(li1, ul);

	var li2 = DOM.Create('li', '', '');
	DOM.Add(aSignUp, li2);
	DOM.Add(li2, ul);

	var li3 = DOM.Create('li', '', '');
	DOM.Add(aHaveAccount, li3);
	DOM.Add(li3, ul);

	DOM.Add(ul, div);

	return div;
};



//------------------------------------------------------------------
//------------------------------------------------------------------
//## MISC
//------------------------------------------------------------------


var viewTooltipForMenuList=function(e){var startElement=this.parentNode;if(startElement.parentNode.parentNode.parentNode.parentNode.parentNode.className=='tablinksearch'&&startElement.className.indexOf(SEARCHHANDLER.ClassNameForHightlightedListItems)>-1){startElement.getElementsByTagName('div')[0].className='tooltip'; viewTooltip(1, startElement);}};
var hideTooltipForMenuList=function(e){var startElement=this.parentNode;if(startElement.className.indexOf(SEARCHHANDLER.ClassNameForHightlightedListItems)>-1){viewTooltip(0, startElement)}};

//view: 1=view, view: 0=hide
function viewTooltip(view, startElement) {
	var toolTipElements = startElement.getElementsByTagName('div');
	for (var i = 0, iLen = toolTipElements.length; i < iLen; i++) {
		if (toolTipElements[i].className == 'tooltip') {
			if (view)
				toolTipElements[i].style.display = 'block';
			else
				toolTipElements[i].style.display = 'none';
		}
	}
}

currentFilter=1;
function filterButton(span, no, type) {
	if (no != currentFilter) {
		if (type == 'hover') {
			span.className = 'button';
		} else {
			span.className = 'button inactivebutton';
		}
	}
};

function applyInvitation() {
	var invited = location.href.indexOf('#user=');
	if (invited > -1) {
		var usrHash = location.href.substr(invited + 6, 32);
		saveHash(usrHash);
	}
};

function cubicOut(t, b, c, d){return c*((t=t/d-1)*t*t + 1) + b;}
function cubicIn(t, b, c, d){return c*(t/=d)*t*t + b;}

function interface() {
	PAGE.StartReport();
}