var currtab = "tab1";function deselectAll(frame){	var formLeft = top.frames[frame].document.forms[0]	for (var i = 0; i < formLeft.elements.length; i++)	{		if (formLeft.elements[i].type == "checkbox")		{      		if (formLeft.elements[i].name == "$$SelectDoc")			{        			if (formLeft.elements[i].checked)        			{        				formLeft.elements[i].checked = false           		}      		}		} 	}}function getSelectedDocument(frame){	var formLeft = top.frames[frame].document.forms[0]	var found = 0	var retval	for (var i = 0; i < formLeft.elements.length; i++)	{		if (formLeft.elements[i].type == "checkbox")		{      		if (formLeft.elements[i].name == "$$SelectDoc")			{        			if (formLeft.elements[i].checked)        			{        				if(found == 0)        				{        					retval = formLeft.elements[i].value        				}        				found++           		}      		}		} 	}	if(found != 1)	{		retval = ""  //Only one doc. should be selected	}	return retval}function getSelectedDocuments(frame){	var formLeft = top.frames[frame].document.forms[0]	var retval = ""	for (var i = 0; i < formLeft.elements.length; i++)	{		if (formLeft.elements[i].type == "checkbox")		{      		if (formLeft.elements[i].name == "$$SelectDoc")			{        			if (formLeft.elements[i].checked)        			{        				retval += formLeft.elements[i].value +"-"           		}      		}		} 	}	return retval}function getSaveOptiondDlg(url){	popup = window.open(url,"Header","width=300,height=100")	}function getDbAbsURL(pattern){	href = location.href	idx  = href.indexOf(pattern)	retval = href.substr(0,idx)	return retval + pattern + "/"}function getDbRelURL(pattern){	path = location.pathname	idx  = path.indexOf(pattern)	return path.substring(0,idx) +pattern + "/"}function changeStatus(){	try	{		frm = document.forms[0]		frm.SelDoc.value =  getSelectedDocuments("left")		if(frm.SelDoc.value.length == 0) return;				var t1 = getDbAbsURL(".nsf") + ".admDlgChangeStatus?OpenForm"		var retval = window.showModalDialog(t1,null,"dialogHeight:250px;dialogWidth:350px;dialogLeft:10px;dialogTop:100px")				frm.ChangeStatus.value = (retval == null ) ? "0":retval							top.frames["session"].document.forms[0].RefreshFlag.value = "1"		frm.submit()		}	catch(e)	{		showError("changeStatus",e)	}	}function deleteDocuments(){	var arr1	var nr	var msg1	try	{		frm = document.forms[0]		frm.SelDoc.value =  getSelectedDocuments("left")		if(frm.SelDoc.value.length == 0) return;				arr1 = frm.SelDoc.value.split("-" );		nr = arr1.length -1;		msg1 = (nr == 1) ? "Vil du slette det valgte dokumentet":"Vil du slette de " + nr + " valgte dokumentene"		if (!confirm (msg1)) return;				top.frames["session"].document.forms[0].RefreshFlag.value = "1"		frm.submit()		}	catch(e)	{		showError("deleteDocument",e)	}}function button_close(){	resetCurrTab()	path1 = getDbRelURL(".nsf");	location.href = path1+"/.lookupFolders/DOC_NOT_IN_MENU?Open"}function button_edit(unid){	location.href = getDbRelURL(".nsf") + ".EditForm/" + unid + "?EditDocument"	if (inFrameset())	{			top.frames['session'].document.forms[0].CurrTab.value = "1"	}}function button_save(frm){	var t1	var templName	if (allowSave() == false)	{		alert("Denne l\u00F8sningen bruker arbeidsflyt og du har ikke rettigheter til \u00E5 lagre dette dokumentet")		return false	}	try	{				var formThis = document.forms[0];		if (inFrameset())		{			if (formThis.SaveMethod != null) 	formThis.SaveMethod.value = "";			if (formThis.SelDoc != null) formThis.SelDoc.value = getSelectedDocument("left")						top.frames["session"].document.forms[0].RefreshFlag.value = "1";  // Should reload sitmap frame			if(formThis.SelDoc != null)			{				if(formThis.SelDoc.value.length == 32)				{					t1 = getDbAbsURL(".nsf") + ".admDlgPlaceInMenu?OpenForm"					retval = window.showModalDialog(t1,null,"dialogHeight:250px;dialogWidth:350px")					if (formThis.SaveMethod.value != null) 	 formThis.SaveMethod.value = retval				}			}		}		if (formThis.TemplateName != null)			templName = formThis.TemplateName.value		else			templName = ""					if(templName  == "DOKUMENT" || templName == "NET-DIALOG")		{			var ret = editor_getHTML('dhtmlEditor')			if(ret.length > 3)			{				formThis.hidEditor.value = ret			}			else			{				if (confirm('Det er ikke data i editoren. Vil du lagre'))					formThis.hidEditor.value = ret				else					location.reload()							}						}		formThis.submit()	}	catch(e)	{		showError('.admJSLib:button_save',e )	}}function showError( msg,e){	alert(msg + "  "  +e.message)}function inFrameset(){	try	{return  (top.frames["left"] == null) ? false:true}	catch(e)	{return false;}}function removeImg( idx){	frm = document.forms[0]	frm['img' + idx].value = ""		button_save(frm)}function setCurrTab(tnr){	if (!inFrameset()) return;	var frmLeft = top.frames['session'].document.forms[0]	if (frmLeft != null)	{		frmLeft.CurrTab.value = tnr	}	}function loadCurrTab(){	if (!inFrameset()) return;	var frmLeft = top.frames['session'].document.forms[0]	if (frmLeft != null)	{			if (frmLeft.CurrTab.value < 1)  return ;		showtab(frmLeft.CurrTab.value)	}	}function getCurrTab(){	if (!inFrameset()) return 1;	var frmLeft = top.frames['session'].document.forms[0]	if (frmLeft != null)	{			return frmLeft.CurrTab.value	}	}function showtab( tabnum ) { 	setCurrTab(tabnum)	tabname = "tab" + tabnum	if ( tabname != currtab ) 	{ 		if (window.document.layers) 		{ 			handle="window.document.layers";			stylevar="";		}		else		{ 			handle="document.all";			stylevar=".style";		}		eval(handle+'["'+currtab+'"]'+stylevar+'.display = "none"');		eval(handle+'["'+tabname+'"]'+stylevar+'.display = "inline"');		currtab = tabname;	}}function admDocLoad(){	if (inFrameset())	{		if(top.frames["session"].document.forms[0].RefreshFlag.value == "1") 		{				nr = getCurrTab()			top.frames["left"].window.history.go()						top.frames["session"].document.forms[0].RefreshFlag.value = ""			setCurrTab(nr)			showtab(nr)		}		}}function resetCurrTab(){	if (inFrameset())	{			top.frames['session'].document.forms[0].CurrTab.value = "1"	}}function trim(inputString) {   // Removes leading and trailing spaces from the passed string. Also removes   // consecutive spaces and replaces it with one space. If something besides   // a string is passed in (null, custom object, etc.) then return the input.       if (typeof inputString != "string") { return inputString; }   var retValue = inputString;   var ch = retValue.substring(0, 1);   while (ch == " ") { // Check for spaces at the beginning of the string      retValue = retValue.substring(1, retValue.length);      ch = retValue.substring(0, 1);   }   ch = retValue.substring(retValue.length-1, retValue.length);   while (ch == " ") { // Check for spaces at the end of the string      retValue = retValue.substring(0, retValue.length-1);      ch = retValue.substring(retValue.length-1, retValue.length);   }   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings   }   return retValue; // Return the trimmed string back to the user} // Ends the "trim" functionfunction getSavedStatus(){	try	{		frm = document.forms[0]		alert(frm.wfStatus.value)	}	catch(e)	{		showError('.admJSLib:getSavedStatus',e )	}			}function getUIStatus(){	try	{		frm = document.forms[0]		return frm.Status.value	}	catch(e)	{		return 'error'	}}function allowSave(){	//Called by button_save and possibly prevents saving due to workflow constraints	try	{		frm = document.forms[0]		if(frm.workflowEnabled.value != "1") 		{			return true		}					if(frm.wfAllowSave.value == "0") 		{			return false  //Non editors returns here becuse of the saved status > 30				}		if(frm.wfIsCurrUserEditor.value == "1") 			return true;  //Editors returns here		else if(frm.wfSuperUser.value == "1") 			return true;  //Superusers returns here		else			return (getUIStatus() > 30)  ? false:true;  //Non editors retun false if they try to set status above 30	}	catch(e)   //Some forms might not have workwlow designelements	{		return true	}			}function getValueById(id){	//Get an elements innerHTML value based on the elements id attribute	try	{		return document.getElementById(id).innerHTML	}	catch(e)	{		return ""	}}function getElementById(id){	//Get an elements with a given id	try	{		return document.getElementById(id)	}	catch(e)	{		return null	}}function getFirstElementByName(name){	//Get first element with a given element name	try	{		x = document.getElementsByName(name)		return x[0]	}	catch(e)	{		return null	}}function getElementsByName(name){	try	{		return document.getElementsByName(name)	}	catch(e)	{		return null	}}function getCheckBoxValues(name){	var strTmp	cb = getElementsByName(name)	if (cb == null) return null	for(i = 0;i<cb.length;++i)	{		if (cb[i].checked) strTmp+= cb[i].value+","	}	strTmp = strTmp.left(strTmp.length-1)	return strTmp.split(",").trim()}function getPersonFromDomDir(nab) {	var sReturnName = new String();	var sDialogOptions = "dialogHeight:520px; dialogWidth:375px; resizable: no; status: no; help: no";	var url =  getDbRelURL('.nsf') + "addressbook?OpenAgent&" + nab;	sReturnName = window.showModalDialog(url, null, sDialogOptions);	return sReturnName ? sReturnName.substring(3, sReturnName.indexOf('/')):"";}
