﻿function PopupMap(url) {
	window.open(url, null, 'height=284,width=414,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');
}

function Popup(url) {
	window.open(url, null, 'height=400,width=450,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');
}

function swap(id, type, lang) {
	lang = lang.toUpperCase();
	if (type == 'fullyear') {
		document.getElementById(id + 'quarters' + lang).style.display = 'none';
		document.getElementById(id + 'fullyear' + lang).style.display = 'block';
	}
	else {
		document.getElementById(id + 'fullyear' + lang).style.display = 'none';
		document.getElementById(id + 'quarters' + lang).style.display = 'block';
	}
}

function showNews(intID) {
	if (document.getElementById('moreNews' + intID).style.display == 'block') {
		document.getElementById('moreNews' + intID).style.display = 'none';
	}
	else {
		document.getElementById('moreNews' + intID).style.display = 'block';
	}
}


function swfmc(movie, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="');
	// Width for Object TAG
	document.write(width);
	document.write('" height="');
	// Height for Object TAG
	document.write(height);
	document.write('">\n');
	// File for Object TAG
	document.write('<param name="movie" value="');
	document.write(movie);
	document.write('">\n');

	// Params for Object TAG

	document.write('<param name="wmode" value="transparent">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="menu" value="false">\n');

	// File for EMBED TAG
	document.write('<embed wmode="transparent" src="');
	document.write(movie);
	document.write('" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
	// Width for EMBED TAG
	document.write(width);
	document.write('" height="');
	// Height for EMBED TAG
	document.write(height);

	// Params for Object TAG
	document.write('" menu="false"></embed>\n');
	document.write('</object>');
}

function swfmc2(movie, width, height, xmlurl) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="');
	// Width for Object TAG
	document.write(width);
	document.write('" height="');
	// Height for Object TAG
	document.write(height);
	document.write('">\n');
	// File for Object TAG
	document.write('<param name="movie" value="');
	document.write(movie);
	document.write('">\n');

	// Params for Object TAG

	document.write('<param name="wmode" value="transparent">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="menu" value="false">\n');
	document.write('<param name="flashvars" value="xmlurl=' + xmlurl + '">\n');

	// File for EMBED TAG
	document.write('<embed wmode="transparent" src="');
	document.write(movie);
	document.write('" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
	// Width for EMBED TAG
	document.write(width);
	document.write('" height="');
	// Height for EMBED TAG
	document.write(height);

	// Params for Object TAG
	document.write('" menu="false" flashvars="xmlurl=' + xmlurl + '"></embed>\n');
	document.write('</object>');
}


function swfmc3(movie, width, height, xmlurl, pieslice) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="');
	// Width for Object TAG
	document.write(width);
	document.write('" height="');
	// Height for Object TAG
	document.write(height);
	document.write('">\n');
	// File for Object TAG
	document.write('<param name="movie" value="');
	document.write(movie);
	document.write('">\n');

	// Params for Object TAG

	document.write('<param name="wmode" value="transparent">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="menu" value="false">\n');
	document.write('<param name="flashvars" value="xmlurl=' + xmlurl + '&parameter=' + pieslice + '">\n');

	// File for EMBED TAG
	document.write('<embed wmode="transparent" src="');
	document.write(movie);
	document.write('" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
	// Width for EMBED TAG
	document.write(width);
	document.write('" height="');
	// Height for EMBED TAG
	document.write(height);

	// Params for Object TAG
	document.write('" menu="false" flashvars="xmlurl=' + xmlurl + '&parameter=' + pieslice +'"></embed>\n');
	document.write('</object>');
}

/* REGFORM
----------------------------------------------------*/
var REGFORM = {};
REGFORM.Init = function() {

	this.LastBox = null;

	var forms = getElementsByClassName(document, 'DIV', 'formbox');
	if (!forms) return;
	for (var i = 0, n = forms.length, form = null; i < n; i++) {

		form = forms[i];
		var formTitle = form.getElementsByTagName('H3')[0];
		var formWrap = form.getElementsByTagName('DIV')[0];

		if (i !== 0) {
			formWrap.style.display = 'none';
			formTitle.className = 'disabled';
		}

		var buttonWrap = DOM.Create('P', 'buttonwrapper');
		var nextButton = DOM.Create('BUTTON', 'regbutton-next');
		nextButton.innerHTML = 'Framåt &gt;';
		addEvent(nextButton, 'click', REGFORM.Next);

		var prevButton = DOM.Create('BUTTON', 'regbutton-prev');
		prevButton.innerHTML = '&lt; Bakåt';
		addEvent(prevButton, 'click', REGFORM.Prev);

		if (i == 0) {
			DOM.Add(nextButton, buttonWrap);
		} else if (i == n - 1) {
			DOM.Add(prevButton, buttonWrap);
			this.LastBox = form;
		} else {
			DOM.Add(prevButton, buttonWrap);
			DOM.Add(nextButton, buttonWrap);
		}
		DOM.Add(buttonWrap, formWrap);
	}
	REGFORM.deActiveSubmit();

};
REGFORM.Next = function(e) {
	CancelEvent(e);
	var myParent = this.parentNode.parentNode.parentNode;
	var myParentSibling = DOM.NextSibling(myParent.nextSibling);
	var parentFormTitle = myParent.getElementsByTagName('H3')[0];
	var parentFormWrap = myParent.getElementsByTagName('DIV')[0];
	var siblingFormTitle = myParentSibling.getElementsByTagName('H3')[0];
	var siblingFormWrap = myParentSibling.getElementsByTagName('DIV')[0];
	parentFormWrap.style.display = 'none';
	siblingFormWrap.style.display = 'block';
	parentFormTitle.className = 'disabled';
	siblingFormTitle.className = '';
	if (REGFORM.LastBox) {
		if (myParentSibling == REGFORM.LastBox) REGFORM.ActiveSubmit();
	}
};
REGFORM.Prev = function(e) {
	CancelEvent(e);
	var myParent = this.parentNode.parentNode.parentNode;
	var myParentSibling = DOM.PreviousSibling(myParent.previousSibling);
	var parentFormTitle = myParent.getElementsByTagName('H3')[0];
	var parentFormWrap = myParent.getElementsByTagName('DIV')[0];
	var siblingFormTitle = myParentSibling.getElementsByTagName('H3')[0];
	var siblingFormWrap = myParentSibling.getElementsByTagName('DIV')[0];
	parentFormWrap.style.display = 'none';
	siblingFormWrap.style.display = 'block';
	parentFormTitle.className = 'disabled';
	siblingFormTitle.className = '';
	REGFORM.deActiveSubmit();
};
REGFORM.ActiveSubmit = function() {
	var submits = getElementsByClassName(document, 'INPUT', 'submit');
	for (var x = 0, nn = submits.length, submit = null; x < nn; x++) {
		submit = submits[x];
		submit.disabled = false;
	}
};
REGFORM.deActiveSubmit = function() {
	var submits = getElementsByClassName(document, 'INPUT', 'submit');
	for (var x = 0, nn = submits.length, submit = null; x < nn; x++) {
		submit = submits[x];
		submit.disabled = true;
	}
};


/* GET ELEMENTS BY CLASS NAME
/* EX: getElementsByClassName(Parent,Tag,Class)
----------------------------------------------------*/
var getElementsByClassName = function(a, b, c) { var d = (b == '*' && a.all) ? a.all : a.getElementsByTagName(b), arrReturnElements = new Array(); c = c.replace(/\-/g, '\\-'); var e = new RegExp('(^|\\s)' + c + '(\\s|$)'), oElement = null; for (var i = 0, n = d.length; i < n; i++) { oElement = d[i]; if (e.test(oElement.className)) arrReturnElements.push(oElement) }; return (arrReturnElements) };


/* EVENTHANDLER FOR ADDING EVENTS TO OBJECTS
----------------------------------------------------*/
var addEvent = function(obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); EventCache.add(obj, type, fn) } else if (obj.attachEvent) { obj['e' + type + fn] = fn; obj[type + fn] = function() { obj['e' + type + fn](window.event) }; obj.attachEvent('on' + type, obj[type + fn]); EventCache.add(obj, type, fn); } else { obj['on' + type] = obj['e' + type + fn] } }
var EventCache = function() { var listEvents = []; return { listEvents: listEvents, add: function(node, sEventName, fHandler) { listEvents.push(arguments) }, flush: function() { var i, item; for (i = listEvents.length - 1; i >= 0; i = i - 1) { item = listEvents[i]; if (item[0].removeEventListener) { item[0].removeEventListener(item[1], item[2], item[3]) } if (item[1].substring(0, 2) != 'on') { item[1] = 'on' + item[1] }; if (item[0].detachEvent) { item[0].detachEvent(item[1], item[2]) }; item[0][item[1]] = null } } } } ();
var removeEvent = function(obj, type, fn) { if (obj.removeEventListener) { obj.removeEventListener(type, fn, false) } else if (obj.detachEvent) { obj.detachEvent('on' + type, obj[type + fn]); obj[type + fn] = null; obj['e' + type + fn] = null } }


/* CANCEL EVENT
----------------------------------------------------*/
var CancelEvent = function(e) {
	if (e.preventDefault) { e.preventDefault() }
	else { e.returnResult = false }
	if (e.stopPropagation) { e.stopPropagation() }
	else { e.cancelBubble = true; event.returnValue = false; }
};


/* DOM HELPER
----------------------------------------------------*/
var DOM = {
	Get: function(el) { if (typeof el === 'string') { return document.getElementById(el); } else { return el; } },
	Add: function(el, dest) { var el = this.Get(el); var dest = this.Get(dest); dest.appendChild(el); },
	Remove: function(el) { var el = this.Get(el); el.parentNode.removeChild(el) },
	Create: function(tag, cssClass, id) { var tmp = document.createElement(tag); if (cssClass) { tmp.className = cssClass; } if (id) { tmp.id = id; } return tmp; },
	SetAttribute: function(parent, type, value) { var t = document.createAttribute(type); t.nodeValue = value; parent.setAttributeNode(t); },
	NextSibling: function(node) { while (node.nodeType == 3) { node = node.nextSibling; }; return node; },
	PreviousSibling: function(node) { while (node.nodeType == 3) { node = node.previousSibling; }; return node; },
	ChildNodes: function(obj) { var children = obj.childNodes; for (var ii = 0, nn = children.length, node = null, tmp = []; ii < nn; ii++) { node = children[ii]; if (node.nodeType == 1) tmp.push(node); }; return tmp; }
};


/* EVENTHANDLER FOR DOMONLOAD
//## ADD FUNCTIONS THAT SHOULD RUN ON DOM LOAD
----------------------------------------------------*/
var onPageLoad = function() {
	//##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>##

	REGFORM.Init();

	//##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>##
};


/* ON DOM LOAD
----------------------------------------------------*/
var onDOMload = function() { if (arguments.callee.done) return; arguments.callee.done = true; if (_timer) clearInterval(_timer); onPageLoad() };
/*@cc_on
@if(@_win32 || @_win64)if (document.getElementById) { document.write("<script id=\"ieScriptLoad\" defer src=\"//:\"><\/script>"); document.getElementById("ieScriptLoad").onreadystatechange = function() { if (this.readyState == "complete") { onDOMload() } } } @end@*/
if (document.addEventListener) { document.addEventListener('DOMContentLoaded', onDOMload, false) }; if (/KHTML|WebKit|iCab/i.test(navigator.userAgent)) { var _timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { onDOMload() } }, 10) } window.onload = onDOMload;


/* Cision Subscription functions
----------------------------------------------------*/

function ClearViewState() {
	var viewState;
	for (i = 0; i < document.forms.length; i++) {
		viewState = document.forms[i].__VIEWSTATE;
		if (viewState != null) {
			viewState.name = "__VIEWSTATE_Disabled";
			viewState.value = "";
		}
	}
}

function SendRequest(action) {
	//lang = lang.toUpperCase();
	var obj = document.forms['PageForm']; //
	//obj.action = "http://feed.ne.cision.com/client/billerud/Subscribe/subscribe.aspx";
//	if (lang == 'SE'){
		obj.action = "http://feed.ne.cision.com/client/billerud/templates/aktieprenumeration.aspx?wpytickersymbol=BILL";
//	}
//	else{
//		obj.action = "http://feed.ne.cision.com/client/billerud/templates/sharesubscription.aspx?wpytickersymbol=BILL";
//	}	

	obj.elements['wpySubscribeAction'].value = action;
	ClearViewState();
	obj.submit();
}

function UnSubscribe() {
	SendRequest('end');
}

function Subscribe() {
	SendRequest('begin');
}



