// se till att www finns med
var h=location.href
if(h.indexOf("http://studentlitteratur.se")>=0){
	h=h.split("http://studentlitteratur.se").join("http://www.studentlitteratur.se")
	location.replace(h)
}

// try to get top location
try {
	 var topLocHref=top.location.href
}
catch(e){
	var topLocHref="nono"
}


if(top.location==location || topLocHref!="nono"){


// Sessionsvariabelhantering via window.name
sessvars=function(){

	var x={};
	
	x.$={
		prefs:{
			memLimit:2000,
			autoFlush:true,
			crossDomain:false,
			includeProtos:false,
			includeFunctions:true
		},
		parent:x,
		clearMem:function(){
			for(var i in this.parent){if(i!="$"){this.parent[i]=undefined}};
			this.flush();
		},
		usedMem:function(){
			x={};
			return Math.round(this.flush(x)/1024);
		},
		usedMemPercent:function(){
			return Math.round(this.usedMem()/this.prefs.memLimit);
		},
		flush:function(x){
			var y,o={},j=this.$$;
			x=x||top;
			for(var i in this.parent){o[i]=this.parent[i]};
			o.$=this.prefs;
			j.includeProtos=this.prefs.includeProtos;
			j.includeFunctions=this.prefs.includeFunctions;
			y=this.$$.make(o);
			if(x!=top){return y.length};
			if(y.length/1024>this.prefs.memLimit){return false}
			x.name=y;
			return true;
		},
		getDomain:function(){
				var l=location.href
				l=l.split("///").join("//");
				l=l.substring(l.indexOf("://")+3).split("/")[0];
				while(l.split(".").length>2){l=l.substring(l.indexOf(".")+1)};
				return l
		},
		debug:function(t){
			var t=t||this,a=arguments.callee;
			if(!document.body){setTimeout(function(){a(t)},200);return};
			t.flush();
			var d=document.getElementById("sessvarsDebugDiv");
			if(!d){d=document.createElement("div");document.body.insertBefore(d,document.body.firstChild)};
			d.id="sessvarsDebugDiv";
			d.innerHTML='<div style="line-height:20px;padding:5px;font-size:11px;font-family:Verdana,Arial,Helvetica;'+
						'z-index:10000;background:#FFFFCC;border: 1px solid #333;margin-bottom:12px">'+
						'<b style="font-family:Trebuchet MS;font-size:20px">sessvars.js - debug info:</b><br/><br/>'+
						'Memory usage: '+t.usedMem()+' Kb ('+t.usedMemPercent()+'%)&nbsp;&nbsp;&nbsp;'+
						'<span style="cursor:pointer"><b>[Clear memory]</b></span><br/>'+
						top.name.split('\n').join('<br/>')+'</div>';
			d.getElementsByTagName('span')[0].onclick=function(){t.clearMem();location.reload()}
		},
		init:function(){
			var o={}, t=this;
			try {o=this.$$.toObject(top.name)} catch(e){o={}};
			this.prefs=o.$||t.prefs;
			if(this.prefs.crossDomain || this.prefs.currentDomain==this.getDomain()){
				for(var i in o){this.parent[i]=o[i]};
			}
			else {
				this.prefs.currentDomain=this.getDomain();
			};
			this.parent.$=t;
			t.flush();
			var f=function(){if(t.prefs.autoFlush){t.flush()}};
			if(window["addEventListener"]){addEventListener("unload",f,false)}
			else if(window["attachEvent"]){window.attachEvent("onunload",f)}
			else {this.prefs.autoFlush=false};
		}
	};
	
	x.$.$$={
		compactOutput:false, 		
		includeProtos:false, 	
		includeFunctions: true,
		detectCirculars:true,
		restoreCirculars:true,
		make:function(arg,restore) {
			this.restore=restore;
			this.mem=[];this.pathMem=[];
			return this.toJsonStringArray(arg).join('');
		},
		toObject:function(x){
			eval("this.myObj="+x);
			if(!this.restoreCirculars || !alert){return this.myObj};
			this.restoreCode=[];
			this.make(this.myObj,true);
			var r=this.restoreCode.join(";")+";";
			eval('r=r.replace(/\\W([0-9]{1,})(\\W)/g,"[$1]$2").replace(/\\.\\;/g,";")');
			eval(r);
			return this.myObj
		},
		toJsonStringArray:function(arg, out) {
			if(!out){this.path=[]};
			out = out || [];
			var u; // undefined
			switch (typeof arg) {
			case 'object':
				this.lastObj=arg;
				if(this.detectCirculars){
					var m=this.mem; var n=this.pathMem;
					for(var i=0;i<m.length;i++){
						if(arg===m[i]){
							out.push('"JSONcircRef:'+n[i]+'"');return out
						}
					};
					m.push(arg); n.push(this.path.join("."));
				};
				if (arg) {
					if (arg.constructor == Array) {
						out.push('[');
						for (var i = 0; i < arg.length; ++i) {
							this.path.push(i);
							if (i > 0)
								out.push(',\n');
							this.toJsonStringArray(arg[i], out);
							this.path.pop();
						}
						out.push(']');
						return out;
					} else if (typeof arg.toString != 'undefined') {
						out.push('{');
						var first = true;
						for (var i in arg) {
							if(!this.includeProtos && arg[i]===arg.constructor.prototype[i]){continue};
							this.path.push(i);
							var curr = out.length; 
							if (!first)
								out.push(this.compactOutput?',':',\n');
							this.toJsonStringArray(i, out);
							out.push(':');                    
							this.toJsonStringArray(arg[i], out);
							if (out[out.length - 1] == u)
								out.splice(curr, out.length - curr);
							else
								first = false;
							this.path.pop();
						}
						out.push('}');
						return out;
					}
					return out;
				}
				out.push('null');
				return out;
			case 'unknown':
			case 'undefined':
			case 'function':
				out.push(this.includeFunctions?arg:u);
				return out;
			case 'string':
				if(this.restore && arg.indexOf("JSONcircRef:")==0){
					this.restoreCode.push('this.myObj.'+this.path.join(".")+"="+arg.split("JSONcircRef:").join("this.myObj."));
				};
				out.push('"');
				var a=['\n','\\n','\r','\\r','"','\\"'];
				arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
				out.push(arg);
				out.push('"');
				return out;
			default:
				out.push(String(arg));
				return out;
			}
		}
	};
	
	x.$.init();
	return x;
}();

JSONstring={
	compactOutput:false, 		
	includeProtos:false, 	
	includeFunctions: false,
	detectCirculars:true,
	restoreCirculars:true,
	make:function(arg,restore) {
		this.restore=restore;
		this.mem=[];this.pathMem=[];
		return this.toJsonStringArray(arg).join('');
	},
	toObject:function(x){
		eval("this.myObj="+x);
		if(!this.restoreCirculars || !alert){return this.myObj};
		this.restoreCode=[];
		this.make(this.myObj,true);
		var r=this.restoreCode.join(";")+";";
		eval('r=r.replace(/\\W([0-9]{1,})(\\W)/g,"[$1]$2").replace(/\\.\\;/g,";")');
		eval(r);
		return this.myObj
	},
	toJsonStringArray:function(arg, out) {
		if(!out){this.path=[]};
		out = out || [];
		var u; // undefined
		switch (typeof arg) {
		case 'object':
			this.lastObj=arg;
			if(this.detectCirculars){
				var m=this.mem; var n=this.pathMem;
				for(var i=0;i<m.length;i++){
					if(arg===m[i]){
						out.push('"JSONcircRef:'+n[i]+'"');return out
					}
				};
				m.push(arg); n.push(this.path.join("."));
			};
			if (arg) {
				if (arg.constructor == Array) {
					out.push('[');
					for (var i = 0; i < arg.length; ++i) {
						this.path.push(i);
						if (i > 0)
							out.push(',\n');
						this.toJsonStringArray(arg[i], out);
						this.path.pop();
					}
					out.push(']');
					return out;
				} else if (typeof arg.toString != 'undefined') {
					out.push('{');
					var first = true;
					for (var i in arg) {
						if(!this.includeProtos && arg[i]===arg.constructor.prototype[i]){continue};
						this.path.push(i);
						var curr = out.length; 
						if (!first)
							out.push(this.compactOutput?',':',\n');
						this.toJsonStringArray(i, out);
						out.push(':');                    
						this.toJsonStringArray(arg[i], out);
						if (out[out.length - 1] == u)
							out.splice(curr, out.length - curr);
						else
							first = false;
						this.path.pop();
					}
					out.push('}');
					return out;
				}
				return out;
			}
			out.push('null');
			return out;
		case 'unknown':
		case 'undefined':
		case 'function':
			out.push(this.includeFunctions?arg:u);
			return out;
		case 'string':
			if(this.restore && arg.indexOf("JSONcircRef:")==0){
				this.restoreCode.push('this.myObj.'+this.path.join(".")+"="+arg.split("JSONcircRef:").join("this.myObj."));
			};
			out.push('"');
			var a=['\n','\\n','\r','\\r','"','\\"'];
			arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
			out.push(arg);
			out.push('"');
			return out;
		default:
			out.push(String(arg));
			return out;
		}
	}
}

} else {
	sessvars={}
	sessvars.$={}
	sessvars.$.$=false
	sessvars.$.flush=function(){}
}

move_layer=function(){}
//if(location.href.indexOf("/o.o.i.s/84")>=0 && location.href.indexOf("https:")<0){location.replace(location.href.replace(/http/g,"https"))}
document_loaded=false;broadlook=true

huvudsitestyle="<STYLE> .nmeny a:link {color: #990000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmeny a:visited {color: #990000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmeny a:hover {color: #999999; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmeny a:active {color: #990000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosen a:link {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosen a:visited {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosen a:hover {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosen a:active {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenyline {color: #990000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenyii a:link {color: #000000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenyii a:visited {color: #000000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenyii a:hover {color: #999999; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenyii a:active {color: #000000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosenii a:link {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosenii a:visited {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosenii a:hover {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenychosenii a:active {color: #7D7E7F; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nmenylineii {color: #000000; text-decoration: none; font-weight: bold; font-size: 9px}\n"+
" .nway a:link {color: #000000; font-size: 9px}\n"+
" .nway a:visited {color: #000000; font-size: 9px}\n"+
" .nway a:hover {color: #000000; font-size: 9px}\n"+
" .nway a:active {color: #000000; font-size: 9px}\n"+
" .nway {color: #000000; font-size: 9px}\n"+
" .nbutton a:link {color: #000000; text-decoration: none; font-weight: normal; font-size: 11px}\n"+
" .nbutton a:visited {color: #000000; text-decoration: none; font-weight: normal; font-size: 11px}\n"+
" .nbutton a:hover {color: #AAAAAA; text-decoration: none; font-weight: normal; font-size: 11px}\n"+
" .nbutton a:active {color: #000000; text-decoration: none; font-weight: normal; font-size: 11px}\n"+
".td_ram {border-style:solid;\n"+
"border-width: 1px;\n"+
"border-color: #000000;\n"+
"border-right-width: 0px;\n"+
"border-bottom-width: 0px\n"+
"}\n"+
".table_ram {border-style:solid;\n"+
"border-width: 1px;\n"+
"border-color: #000000;\n"+
"border-left-width: 0px;\n"+
"border-top-width: 0px\n"+
"}\n"
"</STYLE>"
//"a img{border:none}\n"+


mybar_imgpath='/images/general/mybar/'
browsercontrol=function(){
Opera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1)
Safari=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)
Explorer=(document.all && (!(Opera || Safari)))
Explorer6=(Explorer && (navigator.userAgent.indexOf("MSIE 6.0")>=0))
Explorer7=(Explorer && (navigator.userAgent.indexOf("MSIE 7.0")>=0))
Explorer8=(Explorer && (navigator.userAgent.indexOf("MSIE 8.0")>=0))
Netscape4=(document.layers && (!(Opera || Safari)))
Mozilla=(document.getElementById && (!Explorer) && (!(Opera || Safari)))
Netscape_Mozilla=(Mozilla && navigator.userAgent.toLowerCase().indexOf("netscape")!=-1)
Firefox=(Mozilla && navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)
Windows=(navigator.appVersion.indexOf("Win")!=-1)
MacOS=(navigator.appVersion.indexOf("Mac")!=-1)
Linux=(navigator.appVersion.indexOf("X11") != -1)
Netscape6=Mozilla 
iPodTouch=navigator.userAgent.indexOf("iPod")>=0
iPhone=!iPodTouch && navigator.userAgent.indexOf("iPhone")>=0

if(Explorer){window.onerror=function(){return true}}

operativsys="unknown"
if (MacOS){operativsys="MacOS"}
if (Linux){operativsys="Linux"}
if (Windows){operativsys="Windows"}

lasare="unknown"
if (Explorer){lasare="Explorer"}
if (Netscape4){lasare="Netscape4"}
if (Netscape6){lasare="Netscape6"}
if (Opera){lasare="Opera"}
if (Safari){lasare="Safari"}

temp=navigator.userAgent.substring(navigator.userAgent.lastIndexOf(".")-1)+"*"
lasarversion=""
while("0123456789.".indexOf(temp.substring(0,1))>=0){lasarversion+=temp.substring(0,1);temp=temp.substring(1)}
if(lasarversion==""){lasarversion="unknown"}
}
browsercontrol()

hasmouseovermenu=function(){

	mm_over=function(x){
		if (x>1 && x!=last_over){
			var d=getdiv("mainmenu")
			if (mm_content==""){mm_content=d.innerHTML}
			var cox="iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"
			cox=cox.substring(0,x-1)
			d.innerHTML=getdiv("shadowmenu"+cox).innerHTML
			last_over=x
		}
	}

	mm_out=function(x){
			last_over=0
			var d=getdiv("mainmenu")
			d.innerHTML=mm_content
	}

	mm_content='';last_over=0
}

check_top=function(){
	var x=0
	if (Explorer){
		x=document.body.scrollTop
		if (document.compatMode=='CSS1Compat'){
			x=document.documentElement.scrollTop
		}
	} 
	else {x=window.pageYOffset}
	return x
}

old_where_layer=0; ml_co=5



function clean_links(){
	if(window["document_loaded"]){
		for (var i=0;i<document.links.length;i++){
			if(document.links[i].href.indexOf("chart")<0){
			document.links[i].href="javascript:utskriftslage()"
			document.links[i].target="_self"
			}
		}
	}
	else {setTimeout("clean_links()",500)}
}

function utskriftslage(){
	alert("Det här fönstret har öppnats enbart för utskrift av en sida.\n"+
	"\nVill du följa olika länkar på sidan växlar du först till huvudfönstret.")
}

function url_create(minurl){
	  var newurl=minurl
	  var fragetecken=minurl.indexOf("?")
	  var q_vars=new Array()
	  var q_values=new Array()
	  if (fragetecken!=-1){
		newurl=minurl.substring(0,fragetecken+1)
		var temp=minurl.substring(fragetecken+1,10000)+"&"
		var ettecken=temp.indexOf("&")
		while (ettecken!=-1){
		  var likatecken=temp.substring(0,ettecken).indexOf("=")
		  q_vars[q_vars.length]=temp.substring(0,likatecken)
		  q_values[q_values.length]=temp.substring(likatecken+1,ettecken)
		  temp=temp.substring(ettecken+1,10000)
		  ettecken=temp.indexOf("&")
		}
		for (var i=0;i<q_vars.length;i++){
		  if (q_vars[i]!="lasare" && q_vars[i]!="whojd" && q_vars[i]!="resize" && q_vars[i]!="NS4" && q_vars[i]!="operativ"){
			newurl+=q_vars[i]+"="+q_values[i]+"&"
		  }
		}
		newurl=newurl.substring(0,newurl.length-1)
	  }
	  if (newurl.indexOf("?")<0){newurl+="?"} else {newurl+="&"}
	  return newurl
	}

	function url_cleaner(urlen,prop,varde){
		urlen+="&"
		var x=urlen.indexOf(prop+"=")
		if(x>=0){
			var p1=urlen.substring(0,x)
			var p2=urlen.substring(x)
			p2=p2.substring(p2.indexOf("&")+1)
			urlen=p1+p2
		}
		urlen=urlen.substring(0,urlen.length-1)
		if(urlen.indexOf("?")<0){urlen+="?"}
		else {urlen+="&"}
		urlen+=prop+"="+varde
		return urlen
	}

function byt_bakgrund(bilden) {
		  bdy[0].style.backgroundImage = 'url('+bilden+')';
		}
		
		function initiera_bakgrund() {
		  bdy = document.getElementsByTagName("body");
		  bdy[0].style.width = "100%";
		  bdy[0].style.height = "100%";
		  bdy[0].style.margin = "0px";
		  bdy[0].style.backgroundImage = 'url('+bakgrund+')';
		  binitierad=true
		}

		function check_hori_scroll(){
		   if (!Netscape4){
		   if(!binitierad && !Explorer){initiera_bakgrund()}
			 if (Explorer){
				scroll_left=document.body.scrollLeft
				if (document.compatMode=='CSS1Compat'){
					scroll_left=document.documentElement.scrollLeft
				}
			 }
			 else {scroll_left=window.pageXOffset}
			 if (scroll_left>gransvarde && old_scroll_left<=gransvarde){
			   if (Explorer){document.body.style.backgroundImage = 'url()'}
			   else {byt_bakgrund()}
			 }
			 if (scroll_left<=gransvarde && old_scroll_left>gransvarde){
			   if (Explorer){document.body.style.backgroundImage = 'url('+bakgrund+')'}
			   else {byt_bakgrund(bakgrund)}
			 }
			 old_scroll_left=scroll_left
		  }
}

	getdiv=function(x){
		var y=null
		if (document.getElementById){y=document.getElementById(x)}
		else if (document.all){y=eval('document.all.' + x)}
		else if (document.layers){var y=document.layers[x]}
		return y
	}
	
	slutfor_varning=function(x){
		var m=getdiv("slutforvarningdiv")
		var s=getdiv("slutforvarningdivskugga")
		m.innerHTML='<p align="center">'+x+'</p>'
		m.style.top=(klienthojd-200)+"px"
		s.style.top=(klienthojd-198)+"px"
		m.style.visibility="visible"
		s.style.visibility="visible"
	}
	
	draw_slutfor_varning=function(){
		var d='<div id="slutforvarningdiv" style="visibility:hidden;border-style:solid;border-width:1px;position:absolute; top:100px; left:150px; width:200px; height:125px; background-color: #DDDDDD; layer-background-color: #DDDDDD; z-index:500;border-width: 1px none #000000;"></div>'
		var e=d.replace(/(slutforvarningdiv)/g,"$1skugga").replace(/100px/g,"102px").replace(/500/g,"499").replace(/DDDDDD/g,"000000")
  		return d+e
	}
	
	
	inhousekeepalive=function(){
		if(document_loaded){location.replace(location.href)}
		setTimeout("inhousekeepalive()",1000*60*20)
	}

openWin=function(x){
	
		 if(x.indexOf("?")<0){x+="?"}
		 else {x+="&"}
		 x+='template=mainempty.t&withmargin=yes'
		 
	open(x,"","width=500,height=400,scrollbars=yes")	
}

objectWriter=function(x){document.write(x)}

scriptRPC=function(url,nocache){
		// anropar servern
		var script_filename=url+(nocache?"&nocache="+Math.random():'');
		if(script_filename.indexOf("?")<0){script_filename=script_filename.replace(/\&/,"?")}
		var html_doc = document.getElementsByTagName('head').item(0);
		var js = document.createElement('script');
		js.setAttribute('language', 'javascript');
		js.setAttribute('type', 'text/javascript');
		js.setAttribute('src', script_filename);
		html_doc.appendChild(js);
		return false;	
}
//Mvw: lagt till 'extra' för att kunna skicka med queries
scriptRPCPage=function(pageID,returnFunc,startSplit,endSplit,template,nocache,extra,jsrub){
	var url='/o.o.i.s/'+pageID+"?template=asJS.t"
	if(returnFunc){url+='&jsfunc='+returnFunc}
	if(startSplit){url+='&startsplit='+startSplit}
	if(endSplit){url+='&endsplit='+endSplit}
	if(template){url+='&realtemplate='+template}
	if(nocache){url+='&noasjscache=1'}
	if(extra){url+='&'+extra}
	scriptRPC(url)
}

inputControl={ // (c)2006 tf
	rules:{},
	addRules:function(formName,controlObj){
		this.rules[formName]=controlObj;
		this.init(formName);
	},
	init:function(formName){
		if(!document || !document.forms || !document.forms[formName]){
			setTimeout('inputControl.init("'+formName+'")',200);
			return;
		};
		var f=document.forms[formName];
		var r=this.rules[formName];
		for(var i in r){
			var e=f.elements[i];
			if(!e){continue};
			if(e.type!="text" && e.type!="textarea"){continue};
			e.onkeypress=function(e){
				var key=window.event?event.keyCode:e.which;
				if(key<13){return true};
				var keychar=String.fromCharCode(key);
				var reg=new RegExp(r[this.name]);
				return reg.test(keychar)
			}
		}
	}
}


// THE GOOD STUFF  STARTS HERE ;-)

popUpBox={
	show:function(obj,contentDiv,foldLeft,foldUp,selectsToHideShow){
		var hideOnMouseOut=obj
		var o=0
		var o2=0
		var o3=0
		//positionering av explainboxar.
		if(Safari){o2=6;o3=-5;if(!foldLeft){o2=6;o3=6}}
		if(Explorer){o2=5;o3=-7;if(!foldLeft){o2=5;o3=6}}
		if(Firefox){o2=6;o3=-5;if(!foldLeft){o2=6;o3=6}}
		if(Opera){o2=5;o3=-5;if(!foldLeft){o2=5;o3=6}}
		
		var x=getdiv(contentDiv)
		var pdiv=getdiv("popUpBoxDiv")
		if(!x){x=pdiv}
		var hider=hideOnMouseOut?'onmouseout="popUpBox.hide()"':''
		if(selectsToHideShow){
			var s2=""
			var sels=selectsToHideShow.split("#")
			//hide selects
			if(Explorer && !Explorer7){
				for(var i=0;i<sels.length;i++){
					if(getdiv(sels[i])){hideSelect(sels[i])}
				}
			}
			var hider=hideOnMouseOut?'onmouseout="popUpBox.hide()'+s2+'"':''	
				for(var i=0;i<sels.length;i++){
					if(getdiv(sels[i])){
						if(getdiv(sels[i]).style.display!="none"){
							// hårdfix för giltighetsmonth- ch giltighetsyer-selectboxar som 
							// bara ska visas åter om divid Cardfields inte är hidden.
							if(sels[i]=="giltighetMonth"||sels[i]=="giltighetYear"){
								if(getdiv("cardFields").style.visibility!="hidden"){
									s2+=';showSelect(\''+sels[i]+"\');"
								}
							}else{
							s2+=';showSelect(\''+sels[i]+"\');"
							}
						}
					}
				}
			var hider=hideOnMouseOut?'onmouseout="popUpBox.hide()'+s2+'"':'onclick="disableEnableForm(false);popUpBox.hide()'+s2+'"'	
		}
		pdiv.innerHTML='<table cellspacing=0 cellpadding=0 '+
			'border=0 '+hider+'><tr><td>'+x.innerHTML+'</td></tr></table>'
		if(obj){
			var pos=findPos(obj)
		}
		else {
			// placera i mitten av fönstret om obj saknas
			var w=windowSize()
			var pos=[603-pdiv.offsetWidth/2,check_top()+w[1]/2-pdiv.offsetHeight/2]
			//alert("Fönsterstorlek:"+w+"\nScroll pos i höjdled:"+check_top()+"\nObjektstorlek:"+pdiv.offsetWidth+","+pdiv.offsetHeight+"\nUträknad positionering"+pos)
			//pos=[0,0]
		}
		var left=pos[0]; var top=pos[1]-o
		if(foldLeft && obj){
			left-=pdiv.offsetWidth
			left+=obj.offsetWidth
		}
		if(foldUp && obj){
			top-=pdiv.offsetHeight
			top+=obj.offsetHeight
		}
		pdiv.style.left=(left-o3)+"px"
		pdiv.style.top=(top-o2)+"px"
		pdiv.style.visibility="visible"
		if(!obj){
			this.lastCheckTop=check_top()
			this.moveOnScroll()
		}
	},
	hide:function(){
		var pdiv=getdiv("popUpBoxDiv")
		pdiv.style.visibility="hidden"
	},
	isShown:function(){
		var pdiv=getdiv("popUpBoxDiv")
		if(!pdiv){return}// 070110Mvw: fix för scriptbugg i 8470
		return pdiv.style.visibility=="hidden"?false:true
	},
	moveOnScroll:function(){
		var pdiv=getdiv("popUpBoxDiv") 
		if(pdiv && pdiv.style.visibility!="hidden"){
				setTimeout("popUpBox.moveOnScroll()",200)
				if(this.lastCheckTop!=check_top()){
						this.show()
				}
		}
	}
}

findPos=function(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

windowSize=function(){
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x,y]
}

checkResize=function(){
	if(window["oldWindowHeight"] && windowSize()[1]!=oldWindowHeight && popUpBox.isShown()){
		popUpBox.show()
	}
	oldWindowHeight=windowSize()[1]
}
setInterval(checkResize,500)

hideSelect=function(x){
	if(getdiv(x)){getdiv(x).style.visibility="hidden"}
}
showSelect=function(x){
	if(getdiv(x)){getdiv(x).style.visibility="visible"}
}


confirmer=function(funcToDo,confirmText,doText,dontDoText,storlek){
//funcToDo: om 'ok', text, knapptexter, ev 'Small' för at få en mindre confirmruta
	var y=(storlek)?storlek:'' 
	getdiv("confirmDivText"+y).innerHTML=confirmText
	getdiv("confirmDivOkKnapp"+y).innerHTML=makeButton('green',doText,funcToDo)
	getdiv("confirmDivAvbrytKnapp"+y).innerHTML=makeButton('green',dontDoText)
	divAttVisa='confirmDiv'+y
	popUpBox.show(false,divAttVisa,true,true)
}

makeButton=function(color,knappText,funcToDo){
	var divider=''
	var funko =''
	if(funcToDo){divider='();'; funko=funcToDo}
	var enableDisable=""
	if(getdiv("mainPubSysContent").innerHTML.indexOf('regForm')>0){
		var enableDisable=";disableEnableForm(false)"
	}
	var x = '<table border="0" cellpadding="0" cellspacing="0" onClick="'+funko+divider+'popUpBox.hide()'+enableDisable+'" style="cursor:pointer"><tr><td><img src="/images/general/confirm_button/left_'+color+'.jpg"></td><td background="/images/general/confirm_button/bg_'+color+'.jpg">'+knappText+'</td><td><img src="/images/general/confirm_button/right_'+color+'.jpg"></td></tr></table>'
	return x
}

// oppna flashfonster (via lank fran FileMaker)
oppna_flashfonster=function(){
		if(!window["document_loaded"]){setTimeout("oppna_flashfonster()",211);return}
		if(!window["flashfonster"]){flashfonster=[]}
		var l=document.links
		var x=""
		for(var i=0;i<l.length;i++){
			var a=l[i].href+""
			if(a.indexOf("flashfonster_")>=0){
				a=a.split("flashfonster_")[1]
				var b="=,".split("")
				while(a.indexOf("_")>=0){a=a.replace(/_/,b[0]);var c=b[0];b[0]=b[1];b[1]=c}
				l[i].href="javascript:oppna_ff("+flashfonster.length+")"
				flashfonster.push(a)
				l[i].target="_self"
			}
		}
}
oppna_ff=function(x){
		var x=flashfonster[x]
		x=x.toLowerCase().replace(/ja/g,"yes").replace(/nej/g,"no")
		x=x.replace(/bredd/g,"width").replace(/hojd/g,"height")
		x=x.replace(/helskarm/g,"fullscreen").replace(/skalbar/g,"resizable")
		var y=x.substring(x.indexOf(",")+1)
		var x=x.substring(0,x.indexOf(",")).replace(/sida=/g,"/o.o.i.s/")
		open(x,"",y)
}

oppna_flashfonster()


// inloggningsuppgifter vid glomska
glomtInlogg=function(){
	location.href="/o.o.i.s/1712?csid="+currentSiteID+"&mp="+currentPageID
}

// skapa ooisrubrik direkt från javascript
var ooisRubCo=0
ooisRub=function(divName,rubLevel,textContent){
	textContent=escape(textContent)
	var startcut='<div id="ooisobjectHeadline1"'
	var f=function(x){
		x=startcut+x
		var d=getdiv(divName)
		if(d){d.innerHTML=x}
	}
	eval("ooisRubBack"+ooisRubCo+"=f")
	scriptRPCPage(
		9863,"ooisRubBack"+ooisRubCo,
		startcut,'<!--End of div: ooisobjectHeadline1-->',"mainempty.t",true,
		"rubLevel="+rubLevel+"&textContent="+textContent,true
	)
	ooisRubCo++
}

// flippa författarnamn så att förnamn kommer först
AuthorNameFlipper=function(x){
	x=x.split("–").join("-")
	x=x.split("m. fl.").join("m.fl.")
	x=x.split("m fl").join("m.fl.")
	if(x.split(", ").length==3 && x.indexOf(" - ")>=0){
		x=x.split(" - ")
		x=AuthorNameFlipper(x[0])+" - "+AuthorNameFlipper(x[1])
		return x
	}
	if(x.split(", ").length!=2){return x}
	var tx=x
	var p=""
	x=x.split("m.fl.").join("")
	if(tx!=x){p=" m.fl."}
	x=x.split("(")
	if(x[1]){p=" ("+x[1]+p}
	x=x[0]
	x=x.split(", ")
	x=x[1]+" "+x[0]
	x+=p
	while(x.indexOf("  ")>=0){x=x.split("  ").join(" ")}
	return x
}

// För att kunna skala upp en swf:s längd efter behov som den vet om
setHeightFromFlash=function(divNamn,hojd){
	
	    // behövs för att inte klick på andra saker ska påverka i mac
		var l=getdiv("mainPageLeftBlob")
		var r=getdiv("mainPageRightBlob")
		if(l){
			l.style.visibility=hojd>300?"hidden":"visible"	
		}
		if(r){
			r.style.visibility=hojd>300?"hidden":"visible"	
		}
	
	
		var d=getdiv(divNamn)
		if(d){d.style.height=hojd+"px"}
		var m=document.getElementsByTagName("embed")
		for(var i=0;i<m.length;i++){
			n=m[i]
			while(n.parentNode && n.parentNode!==d){n=n.parentNode}
			if(n.parentNode===d){
					m[i].style.height=hojd+"px"
			}
		}
}

// Mina genvägar
minaGenvagar={
	laggTill:function(){
		scriptRPC("/o.o.i.s/1?template=../includes/minaGenvagarAdd.i&user="
				  +authuser+"&pageid="+currentPageID,true)	
	},
	tillagd:function(){
		var d=getdiv('genvagdTillagd')
		if(d){d.style.display="block";d.style.marginBottom="6px"};
		setTimeout(function(){d.style.display='none'},1500)
		this.visaReal();return
		/*var d=getdiv("minaGenvagarDiv")
		this.orgDivContent=d.innerHTML
		d.innerHTML="Genvägen tillagd..."
		this.visaReal()
		setTimeout("minaGenvagar.orgRestore()",1000)*/
	},
	orgRestore:function(){
		var d=getdiv("minaGenvagarDiv")
		d.innerHTML=this.orgDivContent
	},
	visa:function(){
		location.href="/o.o.i.s/10037"	
	},
	visaReal:function(divName,showRemoveThing){
		var d=false
		if(divName){d=getdiv(divName)}
		if(!d){d=getdiv("visaGenvagarMedDelete");showRemoveThing=true}
		if(!d){d=getdiv("visaGenvagarUtanDelete");showRemoveThing=false}
		if(!d){return}
		showRemoveThingGenvagar=showRemoveThing
		this.visningsDiv=d
		scriptRPC("/o.o.i.s/1?template=../includes/minaGenvagarVisa.i&user="
				  +authuser,true)			
	},
	attVisa:function(x,remove){
		this.lastContent=x
		var y=''
		if(x){
			x=x.split(",")
			x=x.sort()
			y=''
			if(remove){y='Klicka på genvägen du vill ta bort:<br/><br/>'}
			for(var i=0;i<x.length;i++){
				var a=x[i].split(":")
				var linky='/o.o.i.s/'+a[1]
				if(remove){linky="javascript:minaGenvagar.remove("+a[1]+");void(0)"}
				y+='<div style="margin-bottom:6px"><a href="'+linky+'" class="link">'+a[0]+'</a></div>'
			}
			if(!remove && showRemoveThingGenvagar){y+='<div style="width:120px;text-align:center;margin-top:24px;padding:3px;border-color:#000;border-style:solid;border-width:1px;cursor:pointer" onclick="minaGenvagar.attVisa(minaGenvagar.lastContent,true)">Ta bort en genväg</div>'}
		}
		else {y="Du har för tillfället inga genvägar inlagda."}
		this.visningsDiv.innerHTML=y
	},
	remove:function(x){
		scriptRPC("/o.o.i.s/1?template=../includes/minaGenvagarRemove.i&user="
				  +authuser+"&pageid="+x,true)	
	}
}

// Länkbevakning

bevakaLank=function(){
	if(!window["document_loaded"]){setTimeout(bevakaLank,170);return}
	var cupi=0
	if(window["currentPageID"]){cupi=currentPageID}
	scriptRPC("/o.o.i.s/1?template=../includes/bevakaKlickScript.i&thePage="+cupi,true)
	if(window["valjLankAttBevaka"] && window["valjLankAttBevaka"]!="0" && window["currentPageID"]!=10079){
		var l=document.links
		for(var i=0;i<l.length;i++){
			var x=document.createElement('div')
			x.innerHTML='[Bevaka]'
			x.style.color="#999999"
			x.style.fontSize="9px"
			x.style.cursor="pointer"
			var f=function(){
				var href=l[i].href
				href=href.split("/o.o.i.s")
				if(href.length>1){href="/o.o.i.s"+href[1]}
				x.onclick=function(){
						location.replace("/o.o.i.s/10079?act=laggtill&href="+escape(href)+"&page="+currentPageID)
				}
			}
			f()
			l[i].parentNode.insertBefore(x,l[i])
		}
	}
}
bevakaLank()

bevakaLankChangeLinks=function(x){
		x.pop()
		if(x.length<1){return}
		var l=document.links
		for(var i=0;i<l.length;i++){
			for(var j=0;j<x.length;j++){
				var hrefi=l[i].href
				hrefi=hrefi.split("/o.o.i.s")
				if(hrefi.length>1){hrefi="/o.o.i.s"+hrefi[1]}
				if(hrefi==x[j]){
					var f=function(){
						var href=hrefi
						var target=l[i].target
						if(target!="_blank"){l[i].href="#"}
						l[i].onclick=function(){
							globalHREF=href
							globalHREFuse=target!="_blank"
							scriptRPC("/o.o.i.s/1?template=../includes/bevakaKlickLoggare.i&href="+escape(href)+"&page="+currentPageID+"&inhouse="+inhouse,true)
						}
					}
					f()
				}
			}
		}
}

fix_nyhetsglidning=function(){
   var l=location.href+"end"
   if(l.indexOf("19end")<0 && l.indexOf("4916end")<0){return}
   if(l.indexOf("mp=")>=0){return}
   if(!window["document_loaded"]){setTimeout(fix_nyhetsglidning,100);return}
	  var x=getdiv("ooisobjectNews1")
	  if(!x){return}
	  var ih=x.innerHTML
	  var pos=ih.indexOf("/cache/")
	  if(pos<0){return}
	  var y=ih.substring(pos)
	  var z=ih.substring(0,ih.indexOf("ooisobjectHeadline")+20)+' style="display:inline"><img src="'+y
	  z=z.replace(/20/,'0')
	  x.innerHTML=z
}
fix_nyhetsglidning()

// buy from widget
function jsbuy(){
	if(!window["shopBasketObj"] || !window["document_loaded"]){setTimeout(jsbuy,200);return}
	var what=location.href.split("jsbuy=")[1].split("_")[0]
	setTimeout(function(){shopBasketObj.buy(what,1)},1000)
}
if(location.href.indexOf("jsbuy=")>=0){jsbuy()}


// Spara data från Flash-övningar
FlaServerStore={
	done:{},
	stored:{},
	json:sessvars.$.$$,
	esc:function(x){
			x=escape(x)
			x=x.split("%").join("$")
			return x
	},
	unesc:function(x){
			x=x.split("$").join("%")
			x=unescape(x)
			return x		
	},
	save:function(fileName,objData,uId){
		var t=this;
		t.stored[uId]=t.esc(t.json.make(objData));
		scriptRPC("/o.o.i.s/1?template=../includes/FlaServerStoreSave.i&ruid="+uId+"&fileName="+fileName,true)
	},
	load:function(fileName,uId){
		var t=this;
		scriptRPC("/o.o.i.s/1?template=../includes/FlaServerStoreLoad.i&ruid="+uId+"&fileName="+fileName,true)
	},
	check:function(uId){
		var x=this.done[uId];
		if(x){
			this.done[uId]=undefined;
			return x
		}
	}
}

// Öppna läromedelsdemos
oppnaLDemo=function(url,w,h){
	open(url,"","width="+w+",height="+h+",resizable=1")
}

// Dynamiskt lägga till CSS-filer
addCSS=function(url){
	if(url=="/html/css/forstasidor.css" && window.currentPageID && (currentPageID==4918 || currentPageID==4916 || currentPageID==22 || currentPageID==19)){return}
	if(!window["document_loaded"]){setTimeout(function(){addCSS(url)},200);return}
	var el=document.createElement('link')
	el.rel='stylesheet'
	el.href=url
	document.getElementsByTagName('head')[0].appendChild(el)
}

// pagetracker kod när Google Analytics är avstängt (för att undvika error vid anrop)
pageTracker={
	_trackPageview:function(){}	
}

/*
	Den inre fönsterstorleken
*/
var fonsterStorlek = function(){
	var w = window, d = document.documentElement, b = document.body;
	return {
		bredd: w.innerWidth || d && d.clientWidth || b.clientWidth,
		hojd: w.innerHeight || d && d.clientHeight || b.clientHeight
	}
};
	

// Resize (för nya centreringen)
var x=function(){
	var spaceNeeded=window.facelift2009?190:70
	var ho=fonsterStorlek().hojd;
	var v=getdiv("vansterSkugga");
	var h=getdiv("hogerSkugga");
	var iv=getdiv("innerVansterSkugga");
	var ih=getdiv("innerHogerSkugga");
	var cm=getdiv("centrera")
	var c=getdiv("centreratContent")
	var espace=getdiv("extraSpaceBeforeSidfot")
	
	/*if(window.document_loaded && (Explorer6 || Explorer7)){
		var utskriftscontent=getdiv("utskriftscontentdiv"), maincontent=getdiv("mainPubSysContent")
		var mscH=maincontent.offsetHeight
		if(window.lastMainPubSysContentHeight && lastMainPubSysContentHeight==mscH){return}
		var minusOffset=0;
		var ao=maincontent.getElementsByTagName('embed')
		for(var i=0;i<ao.length;i++){minusOffset+=ao[i].offsetHeight}
		ao=maincontent.getElementsByTagName('object')
		for(var i=0;i<ao.length;i++){minusOffset+=ao[i].offsetHeight}
		utskriftscontent.style.height=(mscH-minusOffset)+"px"
		lastMainPubSysContentHeight=mscH
	}*/
	
	if(Explorer && window.currentPageID==3236 && document && document.body){document.body.scroll="yes"}
	
	var sidfContent=getdiv("sidfotContent")
	if(c && c.offsetHeight>ho){
		ho=c.offsetHeight	
	}
	if(ho && x && v && h && ih && iv && cm && c){
		cm.style.height=iv.style.height=ih.style.height=v.style.height=h.style.height=ho+"px";
	}
	if(sidfContent && espace && c && c.offsetHeight>200){
		if(window.orgho && orgho==ho){return}
		orgho=ho
		if(c.offsetHeight+spaceNeeded>ho){
			if(Explorer){document.body.scroll="yes"}
		}
		espace.style.display="block"
		espace.style.height=(spaceNeeded-(c.offsetHeight-ho))+"px"
		if(!window.facelift2009){sidfContent.style.visibility="visible"}
		else {
			setTimeout(function(){sidfContent.style.visibility="visible"},500)	
		}
		if(location.href.indexOf("edit.")>=0){
			sidfContent.style.display="none"
			if(Explorer){document.body.scroll="yes"}
		}
	}
};


x.oldOnresize=window["onresize"];
onresize=x;
setTimeout(x,300);
setInterval(x,500)

// Flytta innehåll till printutseende
moveContentToPrint = function(eventDriven){
	
	if(Explorer && !eventDriven){return true}
	
	if(location.href.indexOf("o.o.i.s/8100?showshopbasket=1&showpageafterbasket=1")>=0){return}
	
	if(!window.document_loaded || !getdiv("utskriftscontentdiv") || !getdiv("mainPubSysContent")){
		setTimeout(arguments.callee,110)	
		return
	}
	
	
	var ucontent=getdiv("utskriftscontentdiv"), maincontent=getdiv("mainPubSysContent");
	
	
	if(!Explorer){setTimeout(arguments.callee,2000)}
	if(window.lastMainContent == maincontent.innerHTML){
		return	
	}
	
	lastMainContent=maincontent.innerHTML
	
	ucontent.innerHTML = maincontent.innerHTML
	
	// de-id, avoiding identity crisis and don't print flash content (object, embed)
	var els=ucontent.getElementsByTagName("*")
	for(var i=0;i<els.length;i++){
		try {
			if(els[i].id){els[i].id+="_print"}
			if(els[i].name){els[i].name+="_print"}
		} catch(e){}
		var t=els[i].tagName.toLowerCase();
		var c=els[i].className;
		if(t=="embed" || t=="object"){els[i].style.display="none"}
		if((Explorer6 || Explorer7) && c=="content-right"){els[i].style.position="absolute"}
	}
	
	
}
moveContentToPrint()
if(Explorer){
	window.onbeforeprint=function(){
		moveContentToPrint(true)	
	}
	window.onafterprint=function(){
		var ucontent=getdiv("utskriftscontentdiv")
		if(ucontent){ucontent.innerHTML=""}
	}
}


// basket menu
showvkorgmenu=function(){
	var m=getdiv("basketholder")
      var n=getdiv("basketMenu")
	var x=getdiv("popUpLitenVansterKorg")
	x.innerHTML=n.innerHTML
	nohidebmenu=false
	x.style.visibility=(x.style.visibility=="visible")?"hidden":"visible"
	x.style.top=(20+findPos(m)[1])+"px"
	x.style.left=findPos(m)[0]+"px"
	//x.style.display=(x.style.display!="none")?"none":""
	var x=document.forms["vbasket"].elements
	x[1].style.display="inline"
	x[1].focus()
	x[1].style.display="none"
	x[1].blur()
	x.onmouseover=function(){nohidebmenu=true}
	x.onmouseout=function(){nohidebmenu=false}
	document.onclick=function(){}
	setTimeout("setbmenuhider()",500)
}
setbmenuhider=function(){
	document.onclick=function(){
		if(!nohidebmenu){getdiv("popUpLitenVansterKorg").style.visibility="hidden";
		getdiv("basketMenu").style.display="none"
	}}
}
