// Javascriptbibliotek med fellesrutiner for Norform


// Til Slideshow

var slideShow
var slideShows = new Array();
var timeOuts   = new Array();

function StartSlide(slideShow, antall, start) {
	// Sjekk om dette slideshowet er initiert, hvis ikke: opprett
	if (eval(slideShows[slideShow])) { }
	else {
		slideShows.slideShow = new Array();
		// sett opp antall slides og status (play)
		slideShows.slideShow['finnes']      = 1;
		slideShows.slideShow['antall']  = antall;
		slideShows.slideShow['play']    = 1;
		slideShows.slideShow['ramme']   = 1;
		slideShows.slideShow['timeout'] = 5000;
		timeOuts.slideShow = window.setTimeout('slide("' + slideShow + '"); ',slideShows.slideShow['timeout']);
		}
	}

function play(slideShow) {
	slideShows.slideShow['play'] = 1;
	// Slett gammel timeout og sett ny, sŒ vi unngŒr doble
	clearTimeout(timeOuts.slideShow);
	timeOuts.slideShow = window.setTimeout('slide("' + slideShow + '"); ',100);
	return false;
	}

function pause(slideShow) {
	slideShows.slideShow['play'] = 0;
	clearTimeout(timeOuts.slideShow);
	return false;
	}

function slide(slideShow, ramme) {
	document.getElementById(slideShow + slideShows.slideShow['ramme']).style.display='none';
	
	if (ramme) { 
		nyRamme = ramme; 
		slideShows.slideShow['ramme'] = ramme;
		pause(slideShow);
		}
	else {
		slideShows.slideShow['ramme'] ++;
		if (slideShows.slideShow['ramme'] > slideShows.slideShow['antall']) {
			slideShows.slideShow['ramme'] = 1;
			}
		nyRamme = slideShows.slideShow['ramme'];
		}

	document.getElementById(slideShow + nyRamme).style.display='block';
	
	if (slideShows.slideShow['play'] == 1) {
		timeOuts.slideShow = window.setTimeout('slide("' + slideShow + '"); ',slideShows.slideShow['timeout']);
		}
	return false;
	}

function slideBack(slideShow, ramme) {
	document.getElementById(slideShow + slideShows.slideShow['ramme']).style.display='none';
	
	if (ramme) { 
		nyRamme = ramme; 
		slideShows.slideShow['ramme'] = ramme;
		pause(slideShow);
		}
	else {
		slideShows.slideShow['ramme'] --;
		if (slideShows.slideShow['ramme'] < 1) {
			slideShows.slideShow['ramme'] = slideShows.slideShow['antall'];
			}
		nyRamme = slideShows.slideShow['ramme'];
		}

	document.getElementById(slideShow + nyRamme).style.display='block';
	
	if (slideShows.slideShow['play'] == 1) {
		timeOuts.slideShow = window.setTimeout('slide("' + slideShow + '"); ',slideShows.slideShow['timeout']);
		}
	return false;
	}

function findPos(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];
}

function findVOff(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}
	return curtop;
}

function findHOff(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return curleft;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '1',
			'height', '1',
			'src', 'nattasang',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'bottom',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', 'nattasang',
			'bgcolor', '#ffffff',
			'name', 'nattasang',
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'nattasang',
			'salign', ''
			); //end AC code
	}
