//global varsvar frm = document.forms[0];//openbrowserwindowfunction popUp(theURL,winName,features) { //v2.0   window.open(theURL,winName,features);}//in event of errorfunction handleError(a,b,c) {	alert("[Error message]\n\nwhat(" + a +")\nline(" + c +")\nwhere\n"+ b);	return true;}function viewUser(u) {  location.href= dbPath+"/u/"+u;  return false;}function isLoggedIn(u){if(u==username){return true;}else{return false;}}function editUser() {  location.href= dbPath+"/edit.user.login"  return false;}//- submit after efter validatefunction sendForm(fields) {	frm = document.forms[0];	complete = true ;	if(fields!=null){		for(i=0 ; i<fields.length ; i++) {			if(eval("frm."+fields[i]+".value")==""){				eval("frm."+fields[i]+".style.background= '#FF9999'");				complete = false;			}		}	}	if(complete){		frm.submit();	}else{		alert("Du m\u00E5ste komplettera formul\u00E4ret f\u00F6r att kunna spara!")	}}//Cookies	function setCookie(name, value, expires, path, domain, secure) {	  var defaultexpires = new Date();	  defaultexpires.setTime(defaultexpires.getTime());	  var curCookie = name + "=" + escape(value) +	      ((expires) ? "; expires=" + expires.toGMTString() : "") +	      ((path) ? "; path=" + path : "") +	      ((domain) ? "; domain=" + domain : "") +	      ((secure) ? "; secure" : "");	  document.cookie = curCookie;	}		function getCookie(name) {	  var dc = document.cookie;	  var prefix = name + "=";	  var begin = dc.indexOf("; " + prefix);	  if (begin == -1) {	    begin = dc.indexOf(prefix);	    if (begin != 0) return null;	  } else	    begin += 2;	  var end = document.cookie.indexOf(";", begin);	  if (end == -1)	    end = dc.length;	  return unescape(dc.substring(begin + prefix.length, end));	}function getQuery (source, s) {	q = source.location.search	start =0	stop=0	if ((start=q.indexOf(s,0)) != -1) {		if ((stop=q.indexOf("&",start+s.length ) ) != -1) {			return q.substring(start+s.length+1,stop);		}		return q.substring(start+s.length+1,q.length);	}	return null;}// - return a random image from given Attachment archive// - image dimensions is set herefunction randomImage(ID, align) {	arraySize = eval("ImageArray"+ID+".length");	r1=Math.round(Math.random()*(arraySize-1));	document.writeln(eval("ImageArray"+ID+"["+r1+"]") + "\""+align+"\">");}function printStaticPage(doc_id) {  window.open(dbPath+"/page.items.print/"+doc_id+"?open");}function openURL(URL) {  window.open(URL);}function editRandom(doc_id){  location.href= dbPath+"/0/"+doc_id+"?edit"}function editAttachmentContainer(doc_id){  location.href= dbPath+"/attachmentitels/"+doc_id+"?edit"}//-open static page//- if doc_id is not a valid @DocumentUniqueId, assume that this is a URL//- then open the relative link or direct linkfunction openStaticPage(doc_id){  if(doc_id.length == 32){ 	 location.href= dbPath+"/page.items.www/"+doc_id+"?open"  }else{  	location.href= doc_id;  }}function openResourceLink(ID,newWindow,type){var linkStr='';  if(ID.length == 32){ 	 linkStr = dbPath+"/page.items.www/"+ID+"?open"  }else{  	 linkStr=ID;  }  if(newWindow){  	window.open(linkStr);  }else{	  location.href=linkStr;  }}//openbrowserwindowfunction openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}//- edit static page//- redirect = 1, opens the document in read mode after submit//- redirect = 0, opens the default admin viewfunction editStaticPage(doc_id, redirect){	if(redirect=="1") {		  location.href= dbPath+"/page.items.edit/"+doc_id+"?edit&view=1";	 }else{		 location.href= dbPath+"/page.items.edit/"+doc_id+"?edit";	 }}//- edit compilationpagefunction editCompilationPage(doc_id){  		  location.href= dbPath+"/compilation.items.edit/"+doc_id+"?edit";}//simple validation for emailfunction isValidEmail(str) {   if((str.indexOf(".") > 0) && (str.indexOf("@") > 0)) {   	return true;   }   return false;}//login functionfunction login(page){  setCookie('Login.BackPage',page,'','/','','');  location.href= dbPath+"/user.login?openform&rnd="+Math.random();}function logout(){  location.href= dbPath+"/user.logout" ;}function registerUser(){  location.href= dbPath+"/register.user.login";}function edit_user(page){  if(page!="") {		  document.cookie="Login.BackPage="+page;  }  location.href= dbPath+"/edit.user.login";}function extractlinks(){	if (document.all||document.getElementById){		if (document.all)			var links=document.all.tags("A");		else if (document.getElementById)			var links=document.getElementsByTagName("A");			var total=links.length;			var win2=window.open("","","menubar,scrollbars,status");			win2.document.write("<h2>Total Links="+total+"</h2><br>");			for (i=0;i<total;i++){				win2.document.write('<a href="'+links[i]+'">'+links[i].innerHTML+'</a><br>');			}		win2.document.close();	}}function commentPanelWriter(unid, buttontitle){		document.writeln("<br><input type=button value="+buttontitle+" onClick=location.href=\'"+dbPath+"/comment?open&id="+unid+"\'><br>");     document.writeln("<sc"+"ript src=\""+dbPath+"/comments?openview&restricttocategory="+unid+"\" charset=\"ISO-8859-1\"></sc"+"ript>"); }function doSearch(){  var theForm=document.forms["search"];  var query = theForm.query.value;  if(query==""){    alert("Var god ange s\u00F6ktext.");    theForm.query.focus();    return;  }  location.href=dbPath+"/search?searchview&query="+escape(query)+"&start=1&count=15";}if(getCookie('viewaction')==null) {  	vact = "" ; }else{  	vact = getCookie('viewaction') ; }document.writeln("<sc"+"ript src="+dbPath+"/navigator.items.js?OpenView"+vact+" charset=\"ISO-8859-1\"></sc"+"ript>"); 