/* Functies:- mouse(menuoption,newimg,statustext)- mouseclick(menuoption,newimg,stdimg,statustext) - getCurrentDBName()- left(pString,pLeftOf, pReturn)- leftback(pString,pLeftOf, pReturn)- rebuildURL(pUrl)- secureWindow(pSecure, pHref)- link(url,target,pSecure) - CheckStatus()- NewWindow(link,w,h) - CheckType(veld)- CheckValue(fld) - openURLinFrame(url,target)- OpenNewWindow(naam,url,propsOpties) - statusBalk(tekst) *//* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Changes the images of the menuoptions on mouse-over/out Author:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: Menu-------------------------------------------------------------------------------------------------------------------------------------------------------------- */var selectedstdimg = "";var selectedmenuoption = "";function mouse(menuoption,newimg,statustext) {	window.status=statustext;	if (selectedmenuoption!=menuoption) {	 if (document.images[menuoption]) document.images[menuoption].src = newimg;	}	return true;}function mouseclick(menuoption,newimg,stdimg,statustext) {	if (selectedmenuoption!="") {  		if (document.images[selectedmenuoption]) document.images[selectedmenuoption].src = selectedstdimg	}  	if (document.images[menuoption]) document.images[menuoption].src = newimg;	selectedstdimg=stdimg; 	selectedmenuoption=menuoption;	return true;}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Retrieve current database name and pathAuthor:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:	Returns database name and path, based on the current url-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function getCurrentDBName() {	startPath = location.pathname;	mark = startPath.indexOf(".nsf");	mark = mark + 4;	dbname = startPath.substring(0,mark);	return(dbname);} /*=================================================================================functie		: 	leftparameters	:	pString = totale string				pLeftOf= vanaf deze tekst				pReturn = geef de string terug als het patroon niet gevonden is(true)				geef een lege string terug als het patroon niet gevonden is(false)				Default is falsedoel			:	creatie		:	25-04-2003	auteur		:	Kris van Kootengewijzigd		:	door			:	reden		:	=================================================================================*/function left(pString,pLeftOf, pReturn){	if(pReturn==null) pReturn = false;	iPos=pString.indexOf(pLeftOf);	iResult = pString.substring(0,iPos);	if(iResult=="" && pReturn) return pString;	return iResult} /*--------------------------------------------------------------------------------------------------------------------------------functie		: 	leftbackparameters	:	pString = totale string				pLeftOf= vanaf deze tekst				pReturn = geef de string terug als het patroon niet gevonden is(true)				geef een lege string terug als het patroon niet gevonden is(false)				Default is falsedoel			:	creatie		:	25-04-2003	auteur		:	Kris van Kootengewijzigd		:	door			:	reden		:	--------------------------------------------------------------------------------------------------------------------------------*/function leftback(pString,pLeftOf, pReturn){	if(pReturn==null) pReturn = false;	iPos=pString.lastIndexOf(pLeftOf);	iResult = pString.substring(0,iPos);	if(iResult=="" && pReturn) return pString;	return iResult} /* --------------------------------------------------------------------------------------------------------------------------------------------------------------Functie		:	rebuildURLDoel			:vertalen van ../ naar totale urlCreatie		:	12-10-05 1.5.2 KRISUitleg		:	Voorbeelden: start nsf: http://brein.nl/dir/subdir/webgen.nsf../view?openview >		: http://brein.nl/dir/subdir/webgen.nsf/view?openview ../../test.nsf?opendatabase > 	: http://brein.nl/dir/subdir/test.nsf?opendatabase../../../test.nsf?opendatabase>	: http://brein.nl/dir/test.nsf?opendatabase/xxx.nsf				: http://brein.nl/xxx.nsf(Publ+paginas+op+Unid)/etc..	: http://brein.nl/dir/subdir/webgen.nsf/(Publ+paginas+op+Unid)/etc..-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function rebuildURL(pUrl) {	var iPreUrl="http://" +window.location.host +curdbPad;	var iPath = leftback(iPreUrl,"/",true);	if(pUrl.indexOf("..")>-1) {		var iArray = pUrl.split("../")		if(iArray.length==2) {		//---- ../view?openview >		: http://brein.nl/dir/subdir/webgen.nsf/view?openview 			pUrl = iPreUrl +"/" +iArray[iArray.length-1]		} else {			// overig			var iNewPath=iPath;			for (var k=3;k<iArray.length;k++){				iNewPath = leftback(iNewPath,"/");			}			pUrl = iNewPath+"/" +iArray[iArray.length-1]		}		} else {		//--- /xxx.nsf		: http://brein.nl/xxx.nsf		if(pUrl.indexOf("/")==0) pUrl="http://" + window.location.host+pUrl;		// (Publ+paginas+op+Unid)/etc..		if(pUrl.indexOf("(")==0) pUrl=iPreUrl+"/"+pUrl;	}		return pUrl}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Functie		:	secureWindowDoel			:	Link openen via http of httpsCreatie		:	11-10-05 1.5.2 KRIS-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function secureWindow(pSecure, pHref) {	if(pHref.indexOf("http")==-1) {		if(pHref.indexOf("javascript")>-1) {			// link verpakt in javascript, splitsen van script			var iArray = pHref.split('","');			pHref="";			for(var j=0;j<iArray.length;j++) {				if(j==0) {					pHref = rebuildURL(iArray[j])				} else {					pHref += "\" ,\"" + rebuildURL(iArray[j])					}			}		} else {			// vaste url			pHref = rebuildURL(pHref)		}	}	if(pSecure=="1") {		if(pHref.indexOf("https")==-1) pHref = pHref.replace("http","https");	} else {		if(pHref.indexOf("https")>-1) pHref = pHref.replace("https","http");	 }	 return pHref;}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Opens the given url in the given target after checking url for being from 'linkbeheer'Author:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: MenuAangepast	:	11-10-05 1.5.2 KRISDoesn't return anything-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function link(url,target,pSecure) {	if (url.length==4) {		jsarr=jsstring.split("^")		for (j=0;j<jsarr.length;j++){			linkdata=jsarr[j].split('#') //split linkdata in linknr & url			linknr=linkdata[0] 			linkurl=linkdata[1]			if (url==linknr) { //check whether the name attribute value is equal to the linknr	 	     	actie=linkurl			}    		} 	}else{		actie=url.replace(/\$#%/g,"'")	}		if (target.indexOf('_blank^^')>=0) {		blankwindowprops=target.substring(target.indexOf('^^')+2,target.length)		target='_blank'	} else {		blankwindowprops=""	}		if(target=="" || target=="_top") {		//11-10-05 2.5.2 KRIS: controle op secure openen van linkje		if(target=="_top") actie = secureWindow(pSecure, actie);		top.location=actie	} else if (target=="_self") {   		document.location=actie	} else if (target=="_blank") {	//11-10-05 2.5.2 KRIS: controle op secure openen van linkje 			actie = secureWindow(pSecure, actie)			if (blankwindowprops!='') {				OpenNewWindow('newWindow2',actie,blankwindowprops) 			} else {				window.open(actie)			}	} else if (top.frames[target]) {		top.frames[target].location=actie;	} else {		openURLinFrame(actie,target)		return false;		}}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Checks the status of the page Author:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: Page (onLoad)When the page does not have the status 'Publiceren', it may not be displayed in the browser. The last5 charachters of the URL are removed to force an errorpage to be opened, instead of the page. Whena page is opened using the preview button it should be displayed.-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function CheckStatus(){	if (paginastatus!='Publiceren') {		urlstring=document.URL.toLowerCase();		preview=urlstring.indexOf("all+op+id")		//the page is not opened thru preview, therefor the page $FoutPagina must be opened.		if (preview==-1) {			foutpagina=curdbPad+"/pagenames/$FoutPagina?opendocument"			location=foutpagina;			return false;		} 	} }/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Opens a new window centered on the screenAuthor:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: PageUsed by 'afdrukversie'-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function NewWindow(link,w,h) {	var winl = (screen.width - w) / 2;	var wint = (screen.height - h) / 2;	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',directories=0,menubar=0,scrollbars=0,location=0,status=0,toolbar=0,resizable=0'	win = window.open(link, 'Print', winprops)} /* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Determine the type of the given fieldAuthor:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: Search						function CheckValue()Returns the type of the given field:- radio- checkbox- text- textarea- select-one- select-multiple-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function CheckType(veld) {  var ftype = veld.type;  if (ftype == null) {  		var flength = veld.length;       	if (flength != null) {            ftype = 'radio'         }  }	return ftype}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Retrieve the value of the given fieldAuthor:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: SearchReturns 'false' when radiobuttons, checkboxes, select & mulitple select fields do not have a selected option,otherwise it returns the value of the selected optionIn case of radiobuttons and checkboxes, first step is checking whether there are 1 or multiple options.When there is 1 option, it's checked whether this option is selected. If so, the value of the selected optionis returned. If it isn't selected, the function returns 'false'.When there are multiple options, the functions loops through them until the selected one is found, after whichthe value of that option is returned by the function. If nothing is selcted, the function returns 'false'.In case of select-one or select-mulitple, the functions loops through them until the selected one is found, after which the value of that option is returned by the function. If nothing is selcted, the function returns 'false'.The values of text and textarea fields are returned immediatly. An empty field is returned as een empty string------------------------------------------------------------------------------------------------------------------------------------------------------------------*/function CheckValue(fld) {if ((fld==undefined) || (fld==null)) {return null} else {	aFldType=CheckType(fld) 	var bFound=false	switch (aFldType){		case "radio":		case "checkbox":			checkboxValuesArray = new Array() 				if (fld.length==null){ 					// there is only 1 option, so check immediatly whether it's selected					if (fld.checked) {						bFound=true						checkboxValuesArray[0]=fld.value					}				} else { 					// there are multiple options present, so loop through them					for (var counter=0; counter<fld.length;counter++){						if (fld[counter].checked){							bFound=true							checkboxValuesArray[checkboxValuesArray.length]=fld[counter].value						} 					}  				} 			// if an option is selected, the variable found has the value 'true'			if (bFound) {				return checkboxValuesArray			} else {				 return false			}	 		case "select-one":		case "select-multiple":			selectValuesArray = new Array()  			for (var counter=0; counter<fld.options.length;counter++){			// loop through all the options and check whether something is selected				if (fld.options[counter].selected){					bFound=true					selectValuesArray[selectValuesArray.length]=fld.options[counter].value				} 			}			// if an option is selected, the variable found has the value 'true'			if (bFound) {				return selectValuesArray			} else {				return false			}		case "text":		case "textarea":			// the value is returned immediatly			return fld.value	} }}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Opens a given url in the given target (a frame name)Author:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		function Search()Doesn't return anything-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function openURLinFrame(url,target) {	for(var i = 0; i < 4; i++) 	{		if(top.frames[i]){	  		if( top.frames[i].frames[target]) {	 			top.frames[i].frames[target].location=url;			     return true;			}		}	}		// not found, one level deeper	for(var i = 0; i < 4; i++) {		if(top.frames[i]){			for(var j = 0; j < 4; j++) {	  			 if( top.frames[i].frames[j]) {	  	 			if(top.frames[i].frames[j].frames[target]){			     	   		top.frames[i].frames[j].frames[target].location=url;					     return true;					}				 }			}		}	};		// still not found, another level deeper	for(var i = 0; i < 4; i++) {		if(top.frames[i]){			for(var j = 0; j < 4; j++) {		     	 if( top.frames[i].frames[j]) {					for(var k = 0; k < 4; k++) {						 if( top.frames[i].frames[j].frames[k]) {		     	 			if(top.frames[i].frames[j].frames[k].frames[target]){				     	   			top.frames[i].frames[j].frames[k].frames[target].location=url;						     	return true;							}				   		}					}				}			}		}	};	// finally try level 4	for(var i = 0; i < 4; i++) {		if(top.frames[i]){			for(var j = 0; j < 4; j++) {				if( top.frames[i].frames[j]) {		 			for(var k = 0; k < 4; k++) {				 		if( top.frames[i].frames[j].frames[k]) {		 					for(var l = 0; l < 4; l++) {								if( top.frames[i].frames[j].frames[k].frames[l]) {				     	 					if(top.frames[i].frames[j].frames[k].frames[l].frames[target]){								     	top.frames[i].frames[j].frames[k].frames[l].frames[target].location=url;											return true;										}									}							}						}					}						}			}		}							}}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Opens a new window using the defined setting from the field "BlankWindowProps" on the form[0]Author:			Liza TopCreated:		29-10-2002 (dd-mm-yyyy)Used in:		Form: Search						Form: $$SearchTemplate for SearchDoesn't return anything-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function OpenNewWindow(naam,url,propsOpties) {opties=propsOpties.split("#")	var breedte=opties[0]	var hoogte=opties[1]	var centreren=opties[2]	var scrollen=opties[3]	var locatie=opties[4]	var status=opties[5]var menu=opties[6]	var resize=opties[7]	var toolbar=opties[8]	var cen=''	if (centreren=='1') {		posL=(screen.width - breedte) / 2;		posT=(screen.height - hoogte) / 2;		cen=',top='+posT+',left='+posL	}	//de naam van het venster moet altijd uniek zijn, ander worden verschillende dingen alsnog in hetzelfde venster geopendiToday=new Date()naam=iToday.toLocaleTimeString().replace(/:/g,"")window.open(url,naam,'width='+breedte+',height='+hoogte+cen+',scrollbars='+scrollen+',location='+locatie+',resizable='+resize+',menubar='+menu+',status='+status+',toolbar='+toolbar)}/* --------------------------------------------------------------------------------------------------------------------------------------------------------------Purpose:		Changes the statusbar textAuthor:			Liza TopCreated:		2-12-2002 (dd-mm-yyyy)-------------------------------------------------------------------------------------------------------------------------------------------------------------- */function statusBalk(tekst) {	if (tekst==undefined) {		tekst=" "	}	window.status=tekst.replace(/##/g,"'");	return true}