var richtextField;var richtextDiv;var richtextLang;var editorDb;var internalLinkField;var lastUrl;function addressLookupSingle(fieldName) {	var pathname = (window.location.pathname);	url=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'wAddressSingle?OpenForm&rf=' + fieldName;	AddressSingle=window.open(url ,'Address','status=no,resizable=yes,scrollbars=no,width=232,height=455');}//Open dialog to insert internal link in xlink fieldfunction linkLookup(fieldName) {	if(checkTargets()==false) return;	internalLinkField=fieldName;//	alert(internalLinkField);	var pathname = (window.location.pathname);	url=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'vwLookupInternalLinksField?OpenView&CollapseView&Count=-1';	link=window.open(url ,'InternalLinks','status=no,resizable=yes,scrollbars=yes,width=450,height=450');}//Paste result of dialog into the link field//function insertLink(link,linkFieldName,descr,descrFieldName,descr_nl,descr_fr,descr_de,descr_en) {function insertLink(link,linkFieldName,descrFieldName,descr_nl,descr_fr,descr_de,descr_en,descrLang,doctype) {	//Fill out fields first	if(document.forms[0].elements[linkFieldName].value=='') {		document.forms[0].elements[linkFieldName].value=link;//		document.forms[0].elements[descrFieldName].value=descr;		document.forms[0].elements[descrFieldName+'_nl'].value=descr_nl;		document.forms[0].elements[descrFieldName+'_fr'].value=descr_fr;		document.forms[0].elements[descrFieldName+'_de'].value=descr_de;		document.forms[0].elements[descrFieldName+'_en'].value=descr_en;				document.forms[0].elements['DocInternalLinksTypes'].value=doctype;		} else {		document.forms[0].elements[linkFieldName].value=document.forms[0].elements[linkFieldName].value+'; ' +link;//		document.forms[0].elements[descrFieldName].value=document.forms[0].elements[descrFieldName].value+'; ' +descr;		document.forms[0].elements[descrFieldName+'_nl'].value=document.forms[0].elements[descrFieldName+'_nl'].value+'; '+descr_nl;		document.forms[0].elements[descrFieldName+'_fr'].value=document.forms[0].elements[descrFieldName+'_fr'].value+'; '+descr_fr;		document.forms[0].elements[descrFieldName+'_de'].value=document.forms[0].elements[descrFieldName+'_de'].value+'; '+descr_de;		document.forms[0].elements[descrFieldName+'_en'].value=document.forms[0].elements[descrFieldName+'_en'].value+'; '+descr_en;		document.forms[0].elements[linkFieldName+'Types'].value=document.forms[0].elements['DocInternalLinksTypes'].value+'; '+doctype;		}	//Build links in computed-for-display like way	readLinks(linkFieldName,descrFieldName+'_'+descrLang,linkFieldName+'Types');}//Show manual internal linksfunction readLinks(linkFieldName,descrFieldName,doctype) {	if(document.forms[0].elements[linkFieldName].value!=='') {		links=document.forms[0].elements[linkFieldName].value.split('; ');		descriptions=document.forms[0].elements[descrFieldName].value.split('; ');		doctypes=document.forms[0].elements[doctype].value.split('; ');			displayLinks=new Array(links.length);			for(i=0;i<links.length;i++) {				displayLinks[i]='<li>'+doctypes[i]+': <a href="' + links[i] + '" target="_blank">' + descriptions[i] + '</a>';			}			document.getElementById('linksDisplay').innerHTML='<ul>'+displayLinks.join('</li>')+'</ul>';	} else document.getElementById('linksDisplay').innerHTML='';}//Open dialog to insert image pathfunction imageLookup(fieldName) {	if(checkTargets()==false) return;	var pathname = (window.location.pathname);	url=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'wInsertImagePath?OpenForm&id='+docID+'&field=' + fieldName;	link=window.open(url ,'CustomObjects','toolbar=no,status=no,resizable=yes,scrollbars=yes,width=560,height=300');}//Paste result of dialog in image path fieldfunction insertImagePath(link,fieldName,lang) {	 document.forms[0].elements[fieldName].value=urlEasyDoorToPortal(link,lang);}//Show and hide workflowfunction showFlow() {	for(i=0;i<=3;i++) {		if(document.all.flow[i]!=null) document.all.flow[i].style.display='';	}}function hideFlow() {	for(i=0;i<=3;i++) {		if(document.all.flow[i]!=null) document.all.flow[i].style.display='none';	}}function setWorkflowVisibility(obj) {	if(obj.value=='1') showFlow(); else hideFlow();	if(document.forms[0].DocStatus.value=='Waiting for review') {		document.getElementById('reviewer').style.display='none';		document.getElementById('reviewsender').style.display='';	} else {		document.getElementById('reviewer').style.display='';		document.getElementById('reviewsender').style.display='none';	}//	adjustLayout();}function setVisibilityOnLoad() {	//Workflow	if(document.forms[0].DocReview[0].checked) showFlow(); else hideFlow();	if(document.forms[0].DocStatus.value=='Waiting for review') {		document.getElementById('reviewer').style.display='none';		document.getElementById('reviewsender').style.display='';	} else {		document.getElementById('reviewer').style.display='';		document.getElementById('reviewsender').style.display='none';	}	//Search	if(document.forms[0].xreference!=null) {		if(document.forms[0].xreference[0].checked) document.getElementById('search').style.display=''; else document.getElementById('search').style.display='none';	}	//Publish	}function setSearchVisibility(obj) {	if(obj.value=='true') document.getElementById('search').style.display=''; else document.getElementById('search').style.display='none';//	adjustLayout();}//Show targetsfunction readTargets() {	if(document.forms[0].DocTargets1!=null) {		targets1=document.forms[0].DocTargets1.value.split('; ');		targets2=document.forms[0].DocTargets2.value.split('; ');		targets3=document.forms[0].DocTargets3.value.split('; ');		targets4=document.forms[0].DocTargets4.value.split('; ');		if(targets1[0]!='') {			allTargets=new Array(targets1.length);			for(i=0;i<targets1.length;i++) {				var target2='';				if(targets2[i]=='protected') target2='internet protected';				if(targets2[i]=='private') target2='intranet';				if(targets2[i]=='public') target2='internet anonymous';				allTargets[i]=targets1[i]+' > '+target2+' > '+targets3[i]+' > '+targets4[i];			}			document.getElementById("targets").innerHTML=allTargets.join('<br/>');		}	}/*	else {		hidePublish();	}*/}//Show keywordsfunction readKeywords() {	if(document.getElementById('themes')==null || document.getElementById('themes').innerHTML=='') return;	if(document.getElementById('keywords')==null || document.getElementById('keywords').innerHTML=='') return;		kwords1=document.getElementById('themes').innerHTML.split('; ');	kwords2=document.getElementById('keywords').innerHTML.split('; ');	var kwords=new Array(kwords2.length);	for(i=0;i<kwords2.length;i++) {		kwords[i]=kwords1[i]+' > '+kwords2[i];	}	if(kwords!='') {		document.getElementById('keywordsDisplay').innerHTML=kwords.join('<br/>');	}}//Show topicsfunction readTopics() {	var topic='';	if(document.forms[0].DocTopic!=null) topic=document.forms[0].DocTopic.value;	if(topic!='') document.getElementById('topic').innerHTML=topic;}//Show richtextfunction readRichText() {	for(i=0;i<languages.length;i++) {		var richtextFieldObj=eval('document.forms[0].richtext_'+languages[i]);		if (richtextFieldObj!=null) {//			richtextFieldObj.value=urlPortalToEasyDoor(richtextFieldObj.value,languages[i])			var uCaseLang=languages[i].toUpperCase();			if(document.getElementById('Body'+uCaseLang)!=null) document.getElementById('Body'+uCaseLang).innerHTML=richtextFieldObj.value;		}	}}function markRequired() {	var errorFields=document.forms[0].DocErrorFields.value.split('; ');	if (document.forms[0].DocErrorFields.value!='') {		for (i=0;i<errorFields.length;i++) {			document.getElementById(errorFields[i]).className=document.getElementById(errorFields[i]).className+' errorCell';		}	}}//Open attachment windowfunction openAttach(attachLang){	dbShortName=dbName.substring(0,(dbName.lastIndexOf('.nsf')));/*	if(dbpath.indexOf('be')==-1) { 		attachPath='/attcenter.nsf'; 	} else {		attachPath='/be/attcenter.nsf';	}*/	/*The below lines have been commented out, because the dev environment for attachments does not work properly, because the database is not registered in the securex.eu domainso, we have to refer to sln406, but this causes errorsYou can uncomment these lines to test particular things in the test_attcenter, before putting them in the prod attcenter*///	if(environment=='D'){						//development environment//		attachPath='http://sln406/test_attcenter_lexgo.nsf'; //	}//	else if(dbpath.indexOf('be')==-1) { 	if(dbpath.indexOf('be')==-1) { 		attachPath='/attcenter_lexgo.nsf'; 	} else {		attachPath='/be/attcenter_lexgo.nsf';	}		var attWnd=window.open(attachPath + '/Attach?OpenForm&ParentUNID='+docID+'&ParentDb='+dbShortName+'&Lang='+attachLang,'att','width=300,height=400,scrollbars=auto,toolbar=no');	attWnd.focus();}function importAttach(attachLang) {	var pathname = (window.location.pathname);	url=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'vwLookupCAODepots_'+attachLang.toLowerCase()+'?OpenView&CollapseAll';	link=window.open(url ,'InternalLinks','status=no,resizable=yes,scrollbars=yes,width=450,height=450');}//Field: textarea where to save the richtext//Div: name of div where to display the richtext//Lang: language of richtextfunction openEditor(field,div,lang) {//	if(checkTargets()==false) return;	richtextField=field;	richtextDiv=div;	richtextLang=lang;//	editorDb='Editor.nsf';//	window.showModalDialog('/'+editorDb+'/wConfigs/'+editorID+'?OpenDocument&UserLang='+currentLang,window,'dialogWidth:'+parseInt(screen.width-40)+'px;dialogHeight:'+parseInt(screen.height-70)+'px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;maximize:Yes');//	if(dbpath.indexOf('be')==-1) editorDb='/Editor.nsf'; else editorDb='/be/Editor.nsf';		if(dbpath.indexOf('be')==-1) editorDb='/Editor_l4y.nsf'; else editorDb='/be/Editor_l4y.nsf';	window.showModalDialog(editorDb+'/wConfigs/'+editorID+'?OpenDocument',window,'dialogWidth:'+parseInt(screen.width-40)+'px;dialogHeight:'+parseInt(screen.height-70)+'px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;maximize:Yes');}function replaceAll( str, from, to ) {    var idx = str.indexOf( from );    j=0;    while ( idx > -1 ) {        str = str.replace( from, to );         j=j+1;        idx = str.indexOf( from );    }    return str;}//Translate urls on loadfunction urlPortalToLexGo(xHTMLSource,sourceLang) {	var pathname = (window.location.pathname);	var dbpath=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5));	//Translate image links	xHTMLMutated=replaceAll(xHTMLSource,'../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang,dbpath+'vwAllDocs/'+docID+'/$File');	return xHTMLMutated;}//Translate urls on submitfunction urlLexGoToPortal(xHTMLSource,sourceLang) {	var pathname = (window.location.pathname);	var dbpath=pathname.substring(0,(pathname.lastIndexOf('.nsf')+5));	//Translate image links	xHTMLMutated=replaceAll(xHTMLSource,'http://www.securex.be'+dbpath+'vwAllDocs/'+docID+'/$File','../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang);	xHTMLMutated=replaceAll(xHTMLMutated,'http://www.securex.eu'+dbpath+'vwAllDocs/'+docID+'/$File','../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang);	//xHTMLMutated=replaceAll(xHTMLMutated,'http://www.securex.eu/lex-go.nsf/vwAllDocsRead/'+docID+'/$File','../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang);	xHTMLMutated=replaceAll(xHTMLMutated,dbpath+'vwAllDocs/'+docID+'/$File','../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang);	xHTMLMutated=replaceAll(xHTMLMutated,'/lex-go.nsf/vwAllDocsRead/'+docID+'/$File','../../'+document.forms[0].DocPubDir.value+'/'+docID+'_'+sourceLang);	xHTMLMutated=replaceAll(xHTMLMutated,'<p></p>','<p>&nbsp;</p>');	return xHTMLMutated;}//Fill out field that contains "most public" (most accessible) publication directoryfunction makeDocPubDir() {	var dirIndex=0;	var publicIndex=0;	var protectedIndex=0;	var targets1=document.forms[0].DocTargets1.value.split('; ');	var targets2=document.forms[0].DocTargets2.value.split('; ');	if(targets1[0]!='') {		for(i=0;i<targets1.length;i++) {			if(targets2[i]=='public') publicIndex=i;			if(targets2[i]=='protected') protectedIndex=i;		}	}	if(protectedIndex>0) dirIndex=protectedIndex;	if(publicIndex>0) dirIndex=publicIndex;	document.forms[0].DocPubDir.value=targets1[dirIndex]+'/'+targets2[dirIndex];}function validDate(obj,checkString,alertString) {	// If incorrect	data=obj.value.split('/');	var thisDate = new Date(data[2],data[1]-1,data[0]);	if (thisDate=='NaN') {		NotDate='Please enter a valid date! (dd/mm/yyyy)';		alert(NotDate);		obj.focus();		return(false);	}	if(checkString!='') {		var check=checkString.split('/');		var checkDate=new Date(check[2],check[1]-1,check[0]);		// If before checkdate		if(thisDate<checkDate) {			NotDate='Please enter a date after '+alertString+' date!';			alert(NotDate);			obj.focus();			return(false);		}	}	return(true);}function validate() {	//Dates//	if(validDate(document.forms[0].xportaldate,document.getElementById('creationDate').innerHTML,'creation')==false) return;//	if(validDate(document.forms[0].xportaldate,'','creation')==false) return;	if(validDate(document.forms[0].xreviewdate,document.forms[0].xportaldate.value,'publication')==false) return;	//Publication time	if (isNaN(document.forms[0].xportalhour.value) || isNaN(document.forms[0].xportalminute.value)) {		alert('Publication time must be numeric!');		document.forms[0].xportalhour.focus();		return;	}	if (document.forms[0].xportalhour.value<0 || document.forms[0].xportalhour.value>23) {		alert('Publication time must be valid! (0-23 hours)');		document.forms[0].xportalhour.focus();		return;	}	if (document.forms[0].xportalminute.value<0 || document.forms[0].xportalminute.value>59) {		alert('Publication time must be valid! (0-59 minutes)');		document.forms[0].xportalminute.focus();		return;	}	//Ordernr/*	orderNr=document.forms[0].xorder_nr.value;	if(orderNr!='') {		if(isNaN(orderNr)) {			alert('Ordernumber must be numeric!');			document.forms[0].xorder_nr.focus();			return;		};	}*/	showWait();	document.forms[0].submit();}//See if there are targets, before using richtext editor etc.function checkTargets() {	if(document.getElementById('targets')!=null) {		if(document.getElementById('targets').innerHTML=='') {			alert('Please fill out at least one target before using this function!');			return(false);		}	}}function expandCollapseSection(obj,div) {	if(obj.src=='http://www.securex.eu/be/icons/collapse.gif') {		obj.src='http://www.securex.eu/be/icons/expand.gif';		document.getElementById(div).style.display='none';	}	else {		obj.src='http://www.securex.eu/be/icons/collapse.gif';		document.getElementById(div).style.display='';	}//	adjustLayout();}//Richtext submitfunction rtSubmit() {	canUnlock=false;/*	document.forms[0].DocStatus.value='Saved temporary';	document.forms[0].xpub_action.value='';	document.forms[0].xpub_mode.value='';	document.forms[0].DocValidate.value='0';*/	writeRichText();	document.forms[0].$$Return.value='[/'+dbName+'/vwAllDocs/'+docID+'?EditDocument]';	document.forms[0].submit();}//Write richtextfunction writeRichText() {	if(docType=='news') {		if(document.forms[0].DocNewsToPortal[0].checked==true) {			languages=new Array('nl','fr','de','en') ;			for(i=0;i<languages.length;i++) {			var richtextFieldObj=eval('document.forms[0].richtext_'+languages[i]);			var portalFieldObj=eval('document.forms[0].portaltext_'+languages[i]);			if (richtextFieldObj!=null) {				portalFieldObj.value=urlLexGoToPortal(richtextFieldObj.value,languages[i])			}		}		}	}}// Some little debug aid window (tnx to Mar Custers)var dwin = null;function debug(msg) {    if ((dwin == null) || (dwin.closed)) {      dwin = window.open("","debugconsole","scrollbars=yes,resizable=yes,height=100,width=300");      dwin.document.open("text/html", "replace");    }    dwin.document.writeln('<br/>'+msg);    dwin.scrollTo(0,10000);    dwin.focus();    // dwin.document.close();  // uncomment this if you want to see only last message , not all the previous messages}