//'------------------------------------------------------------------------------------------------//'     Routine for getting dates.//'     Item Consulting as \u00A9 17.3.2000//'------------------------------------------------------------------------------------------------var winses;function subpop(s) {if (!winses || winses.closed){		winses = window.open(s, "PoPUpWindow",		"toolbar=no,width=195,height=150,directories=no,dependent=no,status=no,"+		"scrollbars=no,resizable=no,menubar=no,screenX=500,screenY=200,left=500,top=200");	}else{		winses.location=s		winses.focus()	}}function relativePath() {	//databasen kan flyttes rundt slik administratorer \u00F8nsker	pageURL=window.location;	//full path	relPath=pageURL.pathname.toLowerCase( );	//gj\u00F8r om til sm\u00E5 bokstaver for sikkerhetsskyld	nsfPos=relPath.indexOf(".nsf");	//posisjonen til '.nsf'	relPath=relPath.substring(0, nsfPos+5);	//endelig relativ path til denne databasen	return relPath;}//****************************************************************************************************************************************//     Field addition, inparameters, name of sumfield, array with  fields to add/subtract//     Addition('InnSAar0',  ['Inn1Aar0','+', 'Inn2Aar0','+','Inn3Aar0','-']) - Item Consulting as \u00A9 Juli 2000//****************************************************************************************************************************************var sum = 0;function Addition(SumField, ArrFields) {	sum = 0	var docObj = document.forms[0]	len = ArrFields.length	for (i=0;i<len;i++) {		fild = ArrFields[i]		ret = chkContent(fild, 'num')		val = eval('docObj.' + fild + '.value.valueOf()')		if (ArrFields[i+1]=='+')			sum = parseFloat(sum) + parseFloat(val)		else			sum = parseFloat(sum) - parseFloat(val)		i++	}	var fieldO = eval('docObj.' + SumField)	fieldO.value = sum}//********************************************************************//     Field validation - check content//     Item Consulting as \u00A9 September 2000//********************************************************************function chkContent(fild, contType) {	if (contType=='num') {		val2 = eval('document.forms[0].' + fild)		//alert(fild + ' ' + val2.value)		chk = isNumberString(val2.value)		if (chk==false) {			alert('Du m\u00E5 legge inn tall')			val2.value = 0			val2.focus()		}		else return true	}}function isNumberString (InString)  {	if(InString.length==0) return (false);	var RefString="1234567890.,";	for (Count=0; Count < InString.length; Count++)  {		TempChar= InString.substring (Count, Count+1);		if (RefString.indexOf (TempChar, 0)==-1)  		return (false);	}	return (true);}var val2;function FieldValidate(fieldName, txt, valType, fieldType) {	// empty ensures that a field has value	if (valType=='empty') {		val2 = eval('document.forms[0].' + fieldName)		if (val2) {			if (fieldType=='select') {				sLen = val4.options.length				for (i=0;i<sLen;i++)					ver = val2.options[i].text;			}			else {				ver = val2.value			//	if (ver=='') ver = val2.text			}		}		if (ver==''){			alert(txt)			return false		}	} // end if (valType=='empty')} //end function//********************************************************************//     Replacesubstring//********************************************************************function replaceSubstring(inputString, badString, goodString, caseSensitive) {	fixedReplace = ''	UI = inputString	UB = badString	if ((caseSensitive!=1) && (caseSensitive!=true)) {		UI = inputString.toUpperCase()		UB = badString.toUpperCase()	} //if	badEnd = -1	badLoc = UI.indexOf(UB)	if (badLoc != -1) {		for (x=1; (badLoc != -1); x++) {			fixedReplace = fixedReplace + inputString.substring((badEnd + 1), badLoc) + goodString			badEnd = badLoc + UB.length - 1			badLoc = UI.indexOf(UB, (badLoc + 1))			} //for			fixedReplace = fixedReplace + inputString.substring((badEnd + 1), inputString.length)				}// if	else fixedReplace = inputString	return fixedReplace;} //end function//********************************************************************//     Sub window //********************************************************************var sesWin;function popUpWin (s,h,w,x,y) {	if (!sesWin || sesWin.closed) {		sesWin = window.open(s, 'PoPUpWindowGen','toolbar=no,width=' + w + ',height=' + h + ',directories=no,dependent=no,status=no,scrollbars=no,resizable=no,menubar=no,screenX=' + x + ',screenY=' + y +',left=' + x + ',top=' + y)		}	else{		sesWin.location=s		sesWin.focus()		}}function popUpWin2 (s,h,w,x,y) {	if (!sesWin || sesWin.closed) {		sesWin = window.open(s, 'PoPUpWindowGen2','toolbar=no,width=' + w + ',height=' + h + ',directories=no,dependent=no,status=no,scrollbars=no,resizable=no,menubar=no,screenX=' + x + ',screenY=' + y +',left=' + x + ',top=' + y)		}	else{		sesWin.location=s		sesWin.focus()		}}//******************************************************************************//  Adress dialog Item Consulting//******************************************************************************function address(fieldname, single){if (navigator.appVersion.indexOf('X11') != -1)  {	window.open(relativePath()+'DlgAddress?OpenForm&fieldname='+fieldname + '&single='+single,'Address','status=yes,resizable=yes,scrollbars=yes,screenX=100,screenY=100,width=600,height=600');} else {	if (navigator.appName =='Netscape') 	{		window.open(relativePath()+'DlgAddress?OpenForm&fieldname='+fieldname + '&single='+single,'Address','status=yes,resizable=yes,scrollbars=yes,screenX=120,screenY=100,width=540,height=440');		} else 	{		if (single=='1')		{					window.open(relativePath()+'DlgAddress?OpenForm&fieldname='+fieldname,'Address','status=yes,resizable=yes,scrollbars=no,top=120,left=100,width=310,height=400');		}		else		{			window.open(relativePath()+'DlgAddressMult?OpenForm&fieldname='+fieldname,'Address','status=yes,resizable=yes,scrollbars=no,top=120,left=100,width=500,height=400');		}}	}}/************************************************************************************Fieldhelp in forms************************************************************************************/var fieldName;var formName;function checkHelp(formName,fieldName) {      //alert(formName + fieldName);      top.frames[1].frames[0].frames[1].location = relativePath()  + "FieldHelpOpen?openform&Form=" + formName + "&FieldN=" + fieldName;}/********************************************************************************Copyright (C) 1999 Thomas BrattliThis script is made by and copyrighted to Thomas Brattli at www.bratta.comVisit for more great scripts. This may be used freely as long as this msg is intact!I will also appriciate any links you could give me.********************************************************************************///Default browsercheck, added to all scripts!function checkBrowser(){	this.ver=navigator.appVersion	this.dom=document.getElementById?1:0	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;	this.ie4=(document.all && !this.dom)?1:0;	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;	this.ns4=(document.layers && !this.dom)?1:0;	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)	return this}bw=new checkBrowser()//With nested layers for netscape, this function hides the layer if it's visible and visa versafunction showHide(div,nest){	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 	if(obj.visibility=='visible' || obj.visibility=='show') obj.visibility='hidden'	else obj.visibility='visible'}//Shows the divfunction show(div){	obj=document.getElementById(div).style	obj.visibility='visible'}//Hides the divfunction hide(div,nest){	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 	obj.visibility='hidden'}// Date calculationsvar SECOND = 1000; // the number of milliseconds in a secondvar MINUTE = SECOND * 60; // the number of milliseconds in a minutevar HOUR = MINUTE * 60; // the number of milliseconds in an hourvar DAY = HOUR * 24; // the number of milliseconds in a dayvar WEEK = DAY * 7; // the number of milliseconds in a weekfunction daysBetween(yr, mo, dy) {  var nDate = new Date(); // current date (local)  var nTime = nDate.getTime(); // current time (UTC)  var dTime = Date.UTC(yr, mo - 1, dy); // specified time (UTC)  var bTime = Math.abs(dTime - nTime)  // time difference  var dDays = Math.abs(bTime / DAY );	var dMonths = Math.abs(dDays / 365  );	return dMonths}// ************************************************// Adds a new value to an existing select// ************************************************function setOptionText(the_select, the_array) {	the_select.value = ''	the_select.length = the_array.length	for (loop=0; loop < the_array.length; loop++) {	 	the_select.options[loop].text = trim(the_array[loop]);	 }}function trim(inputstringTrim) {	fixedTrim = "";	lastCh = " ";	for (x = 0; x < inputstringTrim.length; x++) {		ch = inputstringTrim.charAt(x);		if ((ch != " ") || (lastCh != " ")) { fixedTrim +=ch; }		lastCh = ch;	}	if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {	fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); }	return fixedTrim;}function repositionAction(){	actionButtons.style.top = mainBody.scrollTop}/************************************************************************************Save/Close in forms************************************************************************************/function doDelete() //enkel funksjon for \u00E5 slette dokumentet.{	if ( confirm('Vil du virkelig slette dokumentet?') )	{		location.search = '?DeleteDocument';		//var prosjurl;		//prosjurl = '/<Computed Value>/bottomFrameStart?OpenPage';		//this.location.href=prosjurl;		//top.frames[1].location.href=prosjurl;	}}function doSave() //enkel funksjon for \u00E5 lagre dokumentet.{	if ( confirm('Vil du lagre dokumentet?') )	{		validateOnSave()	}}function doSend() //enkel funksjon for \u00E5 sende  til attestasjon lagre dokumentet.{	 	if ( confirm('Vil du sende dokumentet til attestasjon. Du vil ikke lenger ha tilgang til \u00E5 gj\u00F8re endringer?') )		{			document.forms[0].Status_2.value='Sendt til attestasjon';			document.forms[0].Status.value='Sendt til attestasjon';			document.forms[0].StatusDate_2.value=document.forms[0].Today.value;			document.forms[0].StatusRegAv_2.value=document.forms[0].MyName.value;			validateOnSave()		}		else if ( confirm('Vil du lagre dokumentet?') )		{			validateOnSave()		}}function toTop(){	var prosjurl;	prosjurl = '/<Computed Value>/bottomFrameStart?OpenPage';	if ( confirm('\u00D8nsker du avbryte uten \u00E5 lagre?') )		top.frames[1].location.href=prosjurl;}function toTopNew(){	var prosjurl;	prosjurl = '/<Computed Value>/bottomFrameStart?OpenPage';	if ( confirm('\u00D8nsker du avbryte uten \u00E5 lagre?') )		if (document.forms[0].Nytt.value==1)				location.search = '?DeleteDocument';		top.frames[1].location.href=prosjurl;}	//////////////////////////////// DHTML Expandable TOC Library// By Nicholas Skapura// Version 1.0// September 21, 2000//////////////////////////////////////// Toggle Menu //////////// Called locally (do not call in main page)// Object - The sub menu container//   to make visible./////////////////////////function ToggleMenu(Object){	if(!Object.ISOPEN)	{		Object.style.display = 'none';		Object.ISOPEN = true;	}	else	{		Object.style.display = 'block';		Object.ISOPEN = false;	}}////////// Add Menu //////////// Adds a Main Menu Item and// Begins the sub-menu container.// Name - Name label to display// SubName - ID of sub-menu container// Title - Optional title to assign/////////////////////////function AddMenu(Name,SubName,Title){	if(Title != null)		document.write("<DIV TITLE='" + Title + "' CLASS='MenuContainer' ONMOUSEOVER='Highlight(this);' ONMOUSEOUT='Highlight(this);' ONCLICK='ToggleMenu(" + SubName + ");'>" + Name + "</DIV>");	else		document.write("<DIV CLASS='MenuContainer' ONMOUSEOVER='Highlight(this);' ONMOUSEOUT='Highlight(this);' ONCLICK='ToggleMenu(" + SubName + ");'>" + Name + "</DIV>");	document.write("<DIV CLASS='SubMenu' ID='" + SubName + "' ISOPEN=false>");}////////// CloseMenu ////// Closes the sub-menu container/////////////////////////function CloseMenu(){	document.write("</DIV>");}////////// Add Sub-Menu //// Adds a sub-menu item.// Name - Name label to display// Address - document URL when clicked// Title - optional title to assign/////////////////////////function AddSubMenu(Name,Address,Title){	if(Title != null)		document.write("<A TITLE='" + Title + "' HREF='" + Address + "'>");	else		document.write("<A HREF='" + Address + "'>");	document.write("<DIV ONMOUSEOVER='Highlight(this);' ONMOUSEOUT='Highlight(this);'>" + Name + "</DIV>");	document.write("</A>");}/************************************************************************************Beregne timefobruk************************************************************************************/function isValidDate(dateStr) {var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit yearvar matchArray = dateStr.match(datePat); // is the format ok?if (matchArray == null) {alert(dateStr + " Date is not in a valid format.");return false;}month = matchArray[1]; // parse date into variablesday = matchArray[3];year = matchArray[4];if (month < 1 || month > 12) { // check month rangealert("Month must be between 1 and 12.");return false;}if (day < 1 || day > 31) {alert("Day must be between 1 and 31.");return false;}if ((month==4 || month==6 || month==9 || month==11) && day==31) {alert("Month "+month+" doesn't have 31 days!");return false;}if (month == 2) { // check for february 29thvar isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));if (day>29 || (day==29 && !isleap)) {alert("February " + year + " doesn't have " + day + " days!");return false;   }}return true;}function isValidTime(timeStr) {var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;var matchArray = timeStr.match(timePat);if (matchArray == null) {alert("Time is not in a valid format.");return false;}hour = matchArray[1];minute = matchArray[2];second = matchArray[4];ampm = matchArray[6];if (second=="") { second = 0; }if (ampm=="") { ampm = null }if  (hour > 12 && ampm != null) {alert("You can't specify AM or PM for military time.");return false;}if (minute < 0 || minute > 59) {alert ("Minute must be between 0 and 59.");return false;}if (second != null && (second < 0 || second > 59)) {alert ("Second must be between 0 and 59.");return false;}return true;}function sumFields(a,b){     	var aa;	var bb;	if (a=='') 		aa=0;	else		aa=parseFloat(a);	if (b=='')		bb=0;	else		bb=parseFloat(b);return aa+bb	}function dateDiff(hval1, hval2, dval1, dval2, difference, difference2, refField, Faktor, l) {date1 = new Date();date2 = new Date();diff  = new Date();if (isValidDate(dval1) && isValidTime(hval1)) { // Validates first date date1temp = new Date(dval1 + " " + hval1);date1.setTime(date1temp.getTime());}else return false; // otherwise exitsif (isValidDate(dval2) && isValidTime(hval2)) { // Validates first date date2temp = new Date(dval2 + " " + hval2);date2.setTime(date2temp.getTime());}else return false; // otherwise exits// sets difference date to difference of first date and second datediff.setTime(Math.abs(date1.getTime() - date2.getTime()));timediff = diff.getTime();weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));timediff -= weeks * (1000 * 60 * 60 * 24 * 7);days = Math.floor(timediff / (1000 * 60 * 60 * 24)); timediff -= days * (1000 * 60 * 60 * 24);hours = Math.floor(timediff / (1000 * 60 * 60)); timediff -= hours * (1000 * 60 * 60);mins = Math.floor(timediff / (1000 * 60)); timediff -= mins * (1000 * 60);secs = Math.floor(timediff / 1000); timediff -= secs * 1000;//document.forms[0].difference.value = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + //secs + " seconds";difference.value = days + " dgr, " + hours + " timer, " + mins + " min";switch (refField){	case 0:		l.value = (hours + (mins/60));		difference2.value=''		break;	case 1:		l.value = ''		difference2.value = (hours + (mins/60))*Faktor;		break;	default:		l.value= ((hours + (mins/60))*Faktor) - (hours + (mins/60));		difference2.value = (hours + (mins/60));		break;}document.forms[0].Avsp.value = sumFields(document.forms[0].L1.value ,document.forms[0].L2.value )document.forms[0].L50.value = sumFields(document.forms[0].L1_1.value ,document.forms[0].L2_2.value )document.forms[0].L100.value = sumFields(document.forms[0].L1_2.value ,document.forms[0].L2_1.value )return false; // form should never submit, returns false}function implode(arr, separator) {	fixedImplode = ""; 	separator = new String(separator);	if (separator == "undefined") { separator = " "; } for (x = 0; x < arr.length; x++) { fixedImplode += (separator + String(arr[x])); }fixedImplode = fixedImplode.substring(separator.length, fixedImplode.length); return fixedImplode;}function explode(inputstring, separators, includeEmpties ) { 	inputstring = new String(inputstring);  	separators = new String(separators);	if (separators == "undefined") { separators = " :;"; }	fixedExplode = new Array(1);	currentElement = "";	count = 0;	for(x = 0; x < inputstring.length; x++) {	c = inputstring.charAt(x);	if (separators.indexOf(c) != -1) {	if (((includeEmpties <= 0) || (includeEmpties ==false)) && (currentElement == "")) {}	else {fixedExplode[count] = currentElement;		count++;		currentElement = ""; } }else {currentElement += c; }}if ((!(includeEmpties <= 0) && (includeEmpties !=false)) || (currentElement != "")) {fixedExplode[count] = currentElement; }return fixedExplode;}function daysDiff(hval1, hval2, dval1, dval2){date1 = new Date();date2 = new Date();diff  = new Date();if (isValidDate(dval1) && isValidTime(hval1)) { // Validates first date date1temp = new Date(dval1 + " " + hval1);date1.setTime(date1temp.getTime());}else return false; // otherwise exitsif (isValidDate(dval2) && isValidTime(hval2)) { // Validates second date date2temp = new Date(dval2 + " " + hval2);date2.setTime(date2temp.getTime());}else return false; // otherwise exits// sets difference date to difference of first date and second datediff.setTime(Math.abs(date1.getTime() - date2.getTime()));timediff = diff.getTime();weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));timediff -= weeks * (1000 * 60 * 60 * 24 * 7);days = (weeks*7) + (Math.floor(timediff / (1000 * 60 * 60 * 24)))+ 1; return days;}