//-------------------------------------------------------------------------------------------------------------//  Global variables//-------------------------------------------------------------------------------------------------------------var thisForm;var thisDb;//-------------------------------------------------------------------------------------------------------------//	For all links (a hrefs or embedded files) - set the target to _blank to //	open them in a new window//-------------------------------------------------------------------------------------------------------------function setDocLinksTarget(target) {  for (var i = 0; i < document.links.length; i++) {     if (( "" + document.links[i] ).indexOf("$FILE" ) != -1 ) {        // document.links[i].target = "_blank";        document.links[i].target = target;     }  }}//-------------------------------------------------------------------------------------------------------------function check_radio(radioObject){	var value = "";	for (x=0; x<radioObject.length; x++){		if (radioObject[x].checked){			value = radioObject[x].value;		}	}	return(value);}//-------------------------------------------------------------------------------------------------------------//  Returns a comma separated string, with the values of the checked checkbox values//-------------------------------------------------------------------------------------------------------------function getCheckBoxValues(checkBox) {	if(!checkBox)		return "";	var checkBoxLength = checkBox.length;	//alert('checkBox.length: ' + checkBoxLength);	if(checkBoxLength == undefined) {		if(checkBox.checked) {			return checkBox.value;		} else {			return '';		}	}	var val = '';	var vals = '';		for(var i = 0; i < checkBoxLength; i++) {		if((checkBox[i].checked)) {			val = checkBox[i].value;			//alert('Checked val:= ' + val);			if(vals == '') {				vals = val;			} else {				vals = vals + ',' + val;			}		}	}	return vals;}//-------------------------------------------------------------------------------------------------------------// return the value of the radio button that is checked// return an empty string if none are checked, or// there are no radio buttonsfunction getCheckedValue(radioObj) {	if(!radioObj)		return "";	var radioLength = radioObj.length;	if(radioLength == undefined)		if(radioObj.checked)			return radioObj.value;		else			return "";	for(var i = 0; i < radioLength; i++) {		if(radioObj[i].checked) {			return radioObj[i].value;		}	}	return "";}//-------------------------------------------------------------------------------------------------------------// set the radio button with the given value as being checked// do nothing if there are no radio buttons// if the given value does not exist, all the radio buttons// are reset to uncheckedfunction setCheckedValue(radioObj, newValue) {	if(!radioObj)		return;	var radioLength = radioObj.length;	if(radioLength == undefined) {		radioObj.checked = (radioObj.value == newValue.toString());		return;	}	for(var i = 0; i < radioLength; i++) {		radioObj[i].checked = false;		if(radioObj[i].value == newValue.toString()) {			radioObj[i].checked = true;		}	}}//--------------------------------------------------------------------------------------------------------------------------function setCheckBoxes(checkBox, checkVal, keepCheckVal) {	//alert('checkVal: ' + checkVal);	for (var i=0;i<checkBox.length;i++) {		if((checkBox[i].checked) && (checkBox[i].value != checkVal) && keepCheckVal) {	// Uncheck all BUT checkVal			//alert('Vald avmarkeras: ' + checkBox[i].value);			checkBox[i].checked = false;		} else if((checkBox[i].checked) && (checkBox[i].value==checkVal) && keepCheckVal==false) {	// Uncheck ONLY checkVal			//alert('V\u00E4rde: ' + checkBox[i].value);			checkBox[i].checked = false;		}	}}//-------------------------------------------------------------------------------------------------------------function getFormFieldValue(Element){// this function returns the value of a Radiobutton or Checkbox field that is passed in as a parameter// if the field is not available, an empty string is returned// Element: Reference to a RadioButton or CheckBox field	if(typeof(Element)!="object"){return("")};	var result = "";	if (typeof(Element[0])!="object" && typeof(Element.checked) == "boolean" ) {//radiobutton or checkbox with one element		result = (Element.checked) ? Element.value:"";	} else {		for(i=0;typeof(Element[i])=="object";i++) {			if (Element[i].checked) {				result = (result =="") ? Element[i].value:(result + "," + Element[i].value)			}		}	}	return(result);}//--------------------------------------------------------------------------------------------------------------------------function redirect1(inStr) {	window.location.href = inStr + window.document.forms[0].ShowQS.value;}//-------------------------------------------------------------------------------------------------------------function searchReplace(sourceStr, fromStr, toStr) {	//r = new RegExp( "("+fromStr+")" ,"gi");	retStr = sourceStr;	retStr = retStr.replace(fromStr, toStr);	return retStr;}//-------------------------------------------------------------------------------------------------------------function searchReplace2(what, toStr) {	r = new RegExp( "("+what+")" ,"gi");	bodyStr = document.body.innerHTML;	bodyStr = document.body.innerHTML.replace(r, toStr);	document.body.innerHTML = bodyStr;}//-------------------------------------------------------------------------------------------------------------function findTags(tagname) {	var tags,i;	tags=document.getElementsByTagName(tagname);	for(i in tags)   {		if(tags[i].innerHTML.indexOf('472') > -1) {			//tags[i].style.align='center';			alert('found ' + tagname + ' ' + i + ' !');		}	}}//-------------------------------------------------------------------------------------------------------------function checkNoDocuments() { // function to replace the 'No documents found' message	if (document) {		if (document.getElementById("view")) {			if (document.getElementById("view").innerHTML.indexOf("No documents found") > 0) {				document.getElementById("view").innerHTML = ""				document.getElementById("msg").innerHTML = msg			}		}	}}//-------------------------------------------------------------------------------------------------------------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];}}//-------------------------------------------------------------------------------------------------------------// Code to make @DBLookup via Javascript and XML//-------------------------------------------------------------------------------------------------------------var path = ""function loadXmlView(xmlFile, cbFun ){   var xdoc;   path = xmlFile.split("?")[0] + "/"   if( window.ActiveXObject && /Win/.test(navigator.userAgent) ){      xdoc = new ActiveXObject("Microsoft.XMLDOM");      xdoc.async = false;      xdoc.load(xmlFile);      if (cbFun(xdoc) ) {      	return true;      }      else {      	return false;      }         }else if( document.implementation && document.implementation.createDocument ){      xdoc = document.implementation.createDocument("", "", null);      xdoc.load(xmlFile);     xdoc.onload = function(){        	retCode = cbFun(xdoc);        	      }	if (retCode) {		return true;	}	else {		return false;	}     }else{      return false;   }}//-------------------------------------------------------------------------------------------------------------function xmlLookup(xdoc){ 		viewHits 	= xdoc.getElementsByTagName("viewentries");	count 		= viewHits[0].getAttribute("rangeentries"); 		 	if (count > 0) { 		return true; 	} 	else { 		return false 	}}//-------------------------------------------------------------------------------------------------------------function replaceSubstring(origString, findTxt, replTxt) {	var pos = 0;	var len = findTxt.length;	pos = origString.indexOf(findTxt);	while (pos != -1) {		preString = origString.substring(0, pos);		postString = origString.substring(pos+len, origString.length);		origString = preString + replTxt + postString;		pos = origString.indexOf(findTxt);	}	return origString}//-------------------------------------------------------------------------------------------------------------/******************************************************************************* simulerar en dblookup								    **** sUrl url till vy t.ex. /mydb.nsf/LookupMe observera utel\u00E4mna ?openview   **** key nyckel att leta efter								    **** col kolumn att \u00E5terl\u00E4mna v\u00E4rde fr\u00E5n						    **** count antal v\u00E4rden att returnera, -1 alla					    **** exact, nyckeln m\u00E5ste matchas helt						    **** debug returnerar vyn i xml som funktionen berabtera, f\u00F6r debuggningssyfte*******************************************************************************/function DBLookup(sUrl,key,col,count,exact,debug) {	//alert('inne i DBLookup...Tjoho !');	var isView=false;	var v,v2;	var start=1;	var skey=(key==""?"":"&StartKey=" + escape(key));	//alert('skey = ' + skey);	if(count==-1){count=10000;}	if(sUrl.charAt(0)=="/"){sUrl=getServerUrl()+sUrl;}	if(sUrl.indexOf("?")==-1){isView=true;sUrl=sUrl+"?readviewentries&count=" + count + skey + "&preformat";}	if(sUrl.indexOf("?readviewentries")>-1 && sUrl.indexOf("&start=")==-1){isView=true;}	var a=new Array;	//alert('sUrl = ' + sUrl); 	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");	xmlDoc.async=false; 	if(typeof(debug)!="undefined" && debug==true){document.write(sUrl);window.location=sUrl;return a;}	if(typeof(exact)=="undefined" || key==""){exact=false;}	var efield;	do{		if(isView & skey==""){			if(count>=1000) {				window.status="Loading data:" + start;			}			xmlDoc.load(sUrl+"&Start="+start);		} else {			xmlDoc.load(sUrl);		}		viewentries=xmlDoc.getElementsByTagName("viewentry");		n_viewentries=viewentries.length;		//alert('n_viewentries = ' + n_viewentries);		if(count<n_viewentries) {			n_viewentries=count;		}		var nocols=0;		if (n_viewentries>0) {			nocols=viewentries.item(0).childNodes.length;			if(col>nocols) { 				alert('to big col:'+col+' value, no view columns:'+nocols)			}		}		for(i=0;i<n_viewentries;i++) {			viewentry=viewentries.item(i);			entrydata=viewentry.childNodes;			//alert('entrydata(0).text / key = ' + entrydata(0).text + ' / ' + key);			if((exact && entrydata(0).text==key) || (!exact)){				v=unescape(entrydata(col).text);				//alert('entrydata(col).text = ' + v);       				a[i]=v;        			} // end if		} // end for   		start=start+1000;   	} // end do	while(n_viewentries==1000 & isView & skey=="")		window.status="";	return(a)}//-------------------------------------------------------------------------------------------------------------