PageSourceSearch

https://ithappensinaddison.com/revize/util/snippet_helper.js

js ithappensinaddison.com collected 2026-09-26 00:02:39 UTC 219,258 bytes, 6,359 lines download raw bytes

1/*
2#############################################################################
3##
4## 	file: .../util/snippet_helper.js
5##
6## 	JavaScript Library used on all Revize html pages
7##
8## 	Copyright (C) 2000-2014 Revize Software Systems All rights reserved.
9##
10##	--------------------------------------------
11##	Source Code Changes Required for Doc-O-Matic
12##	--------------------------------------------
13##
14##	Separate text with blank lines to force new link on output
15##
16##	Use ## to ignore lines in Doc-O-Matic (like these comments)
17##
18##	Bracket initialization code with the following:
19##		//DOM-IGNORE-BEGIN
20##		//DOM-IGNORE-END
21##
22##	Below are sample sections used:
23##
24##		For RZ.*** input arguments use one of the following section names
25##
26##			RZ Parameters:
27##			RZ Input Parameters:
28##
29##		Internal: Called by
30##		then start description with (Internal Function) ...
31##
32##		Future: under development (may be available in a later release)
33##
34##		Parameters:
35##		  	None: (no input parameters)
36##
37##		Returns:
38##		  	no value currently returned
39##
40## Add the following as preceeding comment for deprecated functions
41## 		Same as RZcalleditlist (retained for backward compatibility)
42*/
43/****************************************************************************
44##	First part of code below executes before the onload handler
45****************************************************************************/
46
47/*---------------------------------------------------------------------------
48Define RZ object and variables if not already defined.
49----------------------------------------------------------------------------*/
50if (!window.EZ) EZ = {};
51if (!EZ.isFeature) EZ.isFeature = function() {return false};
52
53if (typeof RZ == 'undefined') var RZ = new Object();
54if (typeof RZ.pagetype == 'undefined') RZ.pagetype = '';
55if (typeof RZ.jsversion == 'undefined') RZ.jsversion = '1.2';
56
57//********************************************************\\
58RZ.snippet_helper_version = '02-20-2014';
59//********************************************************//
60
61//-----	Define additional RZ objects used by javascript library functions
62if (typeof RZ.rte == 'undefined') RZ.rte = new Object();
63if (typeof RZ.link == 'undefined') RZ.link = new Object();
64if (typeof RZ.icons == 'undefined') RZ.icons = new Array();
65if (typeof RZ.image == 'undefined') RZ.image = new Object();
66if (typeof RZ.setvalues == 'undefined') RZ.setvalues = new Object();
67if (typeof RZ.control == 'undefined') RZ.control = new Object();
68if (typeof RZ.permits == 'undefined') RZ.permits = new Object();
69if (typeof RZ.permits.modules == 'undefined') RZ.permits.modules = new Object();
70if (typeof RZ.linkpagekey == 'undefined') RZ.linkpagekey = new Object();
71if (typeof RZ.linkparentnew == 'undefined') RZ.linkparentnew = new Object();
72if (typeof RZ.linkparentreset == 'undefined') RZ.linkparentreset = new Object();
73if (typeof RZ.linktemplates == 'undefined') RZ.linktemplates = new Object();
74if (typeof RZ.badlinks == 'undefined') RZ.badlinks = new Object();
75if (typeof RZ.warning == 'undefined') RZ.warning = '';
76if (typeof RZ.alert == 'undefined') RZ.alert = '';
77RZ.linklevel = -1
78RZ.nextseq = {linknames:{},modules:{}};	//can be removed after all channels published
79
80// For very old backward compatibility (probably build 27-) on templates
81RZ.webSpaceName = RZ.webspace;
82var rzRecordID = RZ.editrecordid;
83/*---------------------------------------------------------------------------
84Call additional setup functions as soon as JavaScript is compiled.
85
86TODO: all inline code should be moved to onload handler to eliminate race
87	  conditions mostly using image mananger with Firefox as of 08-01-2009
88	  Of course some code is needed to hide or display buttons so that login
89	  would need reworking (probably display:none until page loads)
90
91	  Consider RZeventadd(..) allowing this file in head for all scenaios
92----------------------------------------------------------------------------*/
93RZpageSetup();		// get page into
94RZpermits();		// setup module permissions
95RZpagepermission()	// determine page permission
96RZactionReset();  	// clear all action button input arguments
97RZpageLoaded();		// final page setup
98
99/****************************************************************************
100Remaining code defines javaScript library functions
101****************************************************************************/
102/*!
103  * Bowser - a browser detector
104  * https://github.com/ded/bowser
105  * MIT License | (c) Dustin Diaz 2013
106  * DCO 11-18-2015: function renamed by code not changed
107  */
108function RZbowser()
109{
110 /**
111    * navigator.userAgent =>
112    * Chrome:  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24"
113    * Opera:   "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; en) Presto/2.7.62 Version/11.01"
114    * Safari:  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
115    * IE:      "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
116    * IE>=11:  "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; rv:11.0) like Gecko"
117    * Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
118    * iPhone:  "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
119    * iPad:    "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
120    * Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
121    * Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
122    * PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34"
123    */
124
125  var ua = navigator.userAgent
126    , t = true
127    , ie = /(msie|trident)/i.test(ua)
128    , chrome = /chrome/i.test(ua)
129    , phantom = /phantom/i.test(ua)
130    , safari = /safari/i.test(ua) && !chrome && !phantom
131    , iphone = /iphone/i.test(ua)
132    , ipad = /ipad/i.test(ua)
133    , touchpad = /touchpad/i.test(ua)
134    , android = /android/i.test(ua)
135    , opera = /opera/i.test(ua) || /opr/i.test(ua)
136    , firefox = /firefox/i.test(ua)
137    , gecko = /gecko\//i.test(ua)
138    , seamonkey = /seamonkey\//i.test(ua)
139    , webkitVersion = /version\/(\d+(\.\d+)?)/i
140    , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
141    , o
142
143  function detect() {
144
145    if (ie) return {
146        msie: t
147      , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
148      }
149    if (opera) return {
150        opera: t
151      , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1]
152      }
153    if (chrome) return {
154        webkit: t
155      , chrome: t
156      , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
157      }
158    if (phantom) return {
159        webkit: t
160      , phantom: t
161      , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]
162      }
163    if (touchpad) return {
164        webkit: t
165      , touchpad: t
166      , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
167      }
168    if (iphone || ipad) {
169      o = {
170        webkit: t
171      , mobile: t
172      , ios: t
173      , iphone: iphone
174      , ipad: ipad
175      , version: (ua.match(/CPU iPhone OS ([0-9_]+) like Mac OS X/i)[1] || '1.1.1').replace('_', '.')
176      }
177      return o
178    }
179    if (android) return {
180        webkit: t
181      , android: t
182      , mobile: t
183      , version: (ua.match(/Linux; Android ([0-9.]+)/i) || ua.match(firefoxVersion))[1]
184      }
185    if (safari) return {
186        webkit: t
187      , safari: t
188      , version: ua.match(webkitVersion)[1]
189      }
190    if (gecko) {
191      o = {
192        gecko: t
193      , mozilla: t
194      , version: ua.match(firefoxVersion)[1]
195      }
196      if (firefox) o.firefox = t
197      return o
198    }
199    if (seamonkey) return {
200        seamonkey: t
201      , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
202      }
203    return {}
204  }
205
206  var bowser = detect()
207
208  // Graded Browser Support
209  // http://developer.yahoo.com/yui/articles/gbs
210  if ((bowser.msie && bowser.version >= 8) ||
211      (bowser.chrome && bowser.version >= 10) ||
212      (bowser.firefox && bowser.version >= 4.0) ||
213      (bowser.safari && bowser.version >= 5) ||
214      (bowser.opera && bowser.version >= 10.0)) {
215    bowser.a = t;
216  }
217
218  else if ((bowser.msie && bowser.version < 8) ||
219      (bowser.chrome && bowser.version < 10) ||
220      (bowser.firefox && bowser.version < 4.0) ||
221      (bowser.safari && bowser.version < 5) ||
222      (bowser.opera && bowser.version < 10.0)) {
223    bowser.c = t
224  } else bowser.x = t
225
226  return bowser
227}
228/*---------------------------------------------------------------------------
229(Internal Function) Set page information and display in trace window
230Internal: Called by onload handler
231----------------------------------------------------------------------------*/
232function RZpageSetup()
233{
234	//----- Set flags
235	RZ.revizepreview = false
236
237	//----- Set browser settings
238	RZ.MSIE = false       // MS explorer mode
239	RZ.isnavigator = true // Netscape
240	RZ.pos = navigator.appVersion.indexOf('MSIE')
241	if(RZ.pos != -1)
242	{
243		RZ.MSIE = true
244		RZ.isnavigator = false
245	}
246	if (RZ.isnavigator)
247	{
248		RZ.language = navigator.language.substring(0,2)
249		RZ.browserversion = parseFloat(navigator.appVersion)
250	}
251	else
252	{
253		RZ.language = navigator.userLanguage.substring(0,2)
254		RZ.browserversion = parseFloat(navigator.appVersion.substring(RZ.pos+4))
255	}
256	if (navigator.appVersion.toLowerCase().indexOf('windows') != -1)
257	{
258		RZ.platform = 'win'
259		RZ.newline = '\r\n'
260	}
261	else
262	{
263		RZ.newline = '\r'
264		RZ.platform = 'mac'
265	}
266	//CREDIT: http://stackoverflow.com/questions/17447373/how-can-i-target-only-internet-explorer-11-with-javascript
267	//		  probably copied incorrectly because true/false switched (see not below)
268	//Following 2 lines depreciated
269	RZ.isIE11 = !navigator.userAgent.match(/Trident.*rv 11\./)	//true for any browser
270	RZ.isIEstandards = !navigator.userAgent.match(/Trident/)	//false for any IE ver; true if not any IE
271
272	//DCO 01-23-2014 (CREDIT: tiny_mce.3.5.10/tiny_mcs)
273	RZ.isIEstandardsMode = navigator.userAgent.match(/Trident/)	//array for any IE ver (i.e. true)
274
275	//DCO 03-26-2014: latest attempt at code that will pass the test of time
276	RZ.isIEw3c = !RZ.MSIE && navigator.userAgent.indexOf('Trident') != -1 && navigator.appCodeName.indexOf('Mozilla') != -1;
277
278	//DJO 04-22-2016: add MS edge user agent detection
279	RZ.isMSEdge = navigator.userAgent.match(/Edge/);
280
281	//DCO 12-16-2015: refactor w/o calling RZbowser() -- gets js error on iPad
282	var results, ua = navigator.userAgent
283	RZ.isMSIE = /(msie|trident)/i.test(ua);
284	RZ.isChrome = /chrome/i.test(ua);
285	RZ.isFirefox = /firefox/i.test(ua);
286	if (RZ.isMSIE)
287	{				//nogo for IE5 returns 7 but who cares
288		results = ua.match(/(msie |rv:)(\d+(\.\d+)?)/i);
289		if (results && results[2])
290			RZ.browserversion = results[2];
291	}
292	else if (RZ.isChrome)
293	{
294		results = ua.match(/chrome\/(\d+(\.\d+)?)/i)
295		if (results && results[1])
296			RZ.browserversion = results[1];
297	}
298	else if (RZ.isFirefox)
299	{				//seems to work but not 100% sure
300		results = ua.match(/firefox\/(\d+(\.\d+)?)/i)
301		if (results && results[1])
302			RZ.browserversion = results[1];
303	}
304
305	//----- Does browser support css (only old versions of navigator did not support)
306	//		Assume true to avoid race condition with image manager on Firefox
307	RZ.css = true;
308
309	//----- Parent window if accessable (otherwise current window)
310	//		TODO: susceptible to race condition with image_frame.jsp on Firefox
311	RZ.parent = window;
312	if (RZwinaccess(window.parent)) RZ.parent = window.parent;
313
314	//----- Set page information, login webspace and display page properties
315	RZ.page = RZgetfileinfo( location.href )
316
317	/* disabled 08-15-2012; causing issues on some versions of chrome, trace not
318	// enabled yet so it never prints AND superceeded by AdminPanel enhancements.
319	RZ.message = 'RZ.webspace: ' + RZ.webspace + '\n'
320			   + 'RZ.page.domain: ' + RZ.page.domain + '\n'
321			   + 'RZ.page.pathname: ' + RZ.page.pathname + '\n'
322			   + 'RZ.page.filename: ' + RZ.page.filename + '\n'
323			   + 'RZ.page.extension: ' + RZ.page.extension + '\n'
324			   + 'RZ.page.query: ' + RZ.page.query + '\n'
325			   + 'RZ.page.hash: ' + RZ.page.hash + '\n'
326			   + 'RZ.page.home: ' + RZ.page.home + '\n'
327			   + 'window.name: ' + window.name + '\n'
328			   + 'document.referrer: ' + document.referrer + '\n'
329			   + 'opener: '
330	if (RZwinaccess(RZ.parent.opener))
331	{
332		RZ.message += RZ.parent.opener.location.href + '\n'
333		if (RZ.parent.opener.name != '')
334			RZ.message += 'opener.name: ' + RZ.parent.opener.name
335	}
336	else if (typeof RZ.parent != 'undefined')
337		RZ.message += 'no access to opener'
338	else
339		RZ.message += 'no opener'
340
341	RZtrace("Initializing Page", RZ.message)
342	*/
343
344	RZ.login = RZgetCookieValue('RZlogin', RZ.page.domain);
345
346	//----- Determine trace and debug mode
347	RZ.trace = false;	//RZcheckHash('trace');		//issues on some versions of chrome...
348	RZ.debug = false;	//RZcheckHash('debug');		//...superceeded by enhanced adminpanel
349
350	if (RZ.webspace && RZ.webspace != 'REVIZE')
351	{
352		var trace = RZgetcookie('RZtrace',RZ.page.domain);
353		if (trace == RZ.webspace)
354			RZ.trace = true;
355		else if (trace != RZ.webspace)
356			RZsetcookie('RZtrace', (RZ.trace ? RZ.webspace : '') ,RZ.page.domain);
357
358		var debug = RZgetcookie('RZdebug',RZ.page.domain);
359		if (debug == RZ.webspace)
360			RZ.debug = true;
361		else if (debug != RZ.webspace)
362			RZsetcookie('RZdebug', (RZ.debug ? RZ.webspace : '') ,RZ.page.domain);
363	}
364
365	//----- Determine if called from workflow preview
366	if (RZwinaccess(parent))
367	{
368		if (parent.window.name=='revizepreview')
369			RZ.revizepreview = true
370
371		if ((parent.window.name != window.name			//must be in frames
372		&& parent.window.name=='revizepreview') || window.name == 'workflowCompare1' || window.name == 'workflowCompare2' )
373		{
374			RZ.login = ''
375			//RZ.revizepreview = true
376			RZsetuphandler( 'onpagehide', 'return RZtemplateclose()' )
377		}
378	}
379	else
380	{
381		// if standard permissions button and logged in as admin, treat as "Admin Panel"
382		// TODO: can be removed once break keyup is solid
383 		var permisisonButton = document.getElementById('RZadminwinButton')
384		if (permisisonButton
385		//&& RZisadmin()
386		//&& navigator.userAgent.indexOf("Firefox") == -1
387		&& !RZcheckoptions(RZ.webspacedesc,"noadminpanel")
388		&& permisisonButton.src.search('images/edit/permissions\\.(jpg|gif)') != -1)
389		{
390			permisisonButton.href = 'javascript:RZadminwin()';
391			permisisonButton.alt = 'Admin Panel';
392		}
393	}
394
395	/**********************************************************/
396	/*BOOKMARK RZpageSetup() DONE if AdminPanel not supported*/
397	/********************************************************/
398	if (RZ.revizepreview) return;
399	if (location.pathname.search(/(calendar_app\/index.html|calendar_app\/?$)/) != -1) return;
400	if (location.pathname.search(/.*\/calendar_app\/(editpages\/)?calendar_.*\.(html|jsp)/) != -1) return;
401
402	if (location.pathname.indexOf('/revize/admincenter/') == 0) return;
403	if (location.pathname.indexOf('/revize/debug/') == 0) return;
404	if (location.pathname.indexOf('/revize/trace/') == 0) return;
405	//if (location.pathname.indexOf('/revize/plugins/') == 0) return;
406	if (location.pathname.indexOf('/revize/security/') == 0) return;
407	if (location.pathname.indexOf('/revize/util/') == 0) return;
408
409	//----- "Pause/Break" keyup event monitor
410	RZadminwin.keypressCount = 0;
411	RZadminwin.toggle = function(e,win)
412	{
413		RZadminwin.keypressCount++;
414		/* use following to capture F1 key
415		document.onhelp = function() {return(false);}
416		window.onhelp = function() {return(false);}
417		processF1()
418		*/
419		var keycode = (window.event) ? event.keyCode : e.keyCode;
420		if (keycode == 19 || keycode == 3 || keycode == 135)
421		{
422			if (RZ.login && RZisadmin())
423			{
424				// Show more buttons if Ctrl key also pressed
425							var more = (keycode == 3) ? 'more' : '';
426				RZadminwin('',more);
427			}
428			else if (!RZ.login && RZadminwin.keypressCount >= 2)
429			{
430				if (!confirm('Login to Revize?')) return;
431				var url = '/revize/security/index.jsp?webspace=' + RZ.webspace
432						+ '&filename=/' + RZ.page.filenameFull;
433				parent.location = url;
434			}
435			/*
436			else
437			{
438				var msg = 'Must login as Administrator to open AdminPanel';
439				if (RZadminwin.keypressCount >= 2) alert(msg);
440				window.status = msg;
441			}
442			*/
443		}
444	}
445
446	//----- After page loads, complete AdminPanel setup
447	RZeventadd(window, "load", function()
448	{
449		// Open AdminPanel if needed
450		if (RZisadmin()
451		&& (location.hash.indexOf('adminpanel') == 1 || RZ.debug || RZ.trace))
452			RZadminwin();
453
454		// Activate "Pause/Break" keyup event monitor
455		RZeventadd(document, "keyup", function(e) {RZadminwin.toggle(event,window)});
456	});
457}
458/*---------------------------------------------------------------------------
459----------------------------------------------------------------------------*/
460/*function RZpublishcalendars()
461{
462	var fileinfo = RZgetfileinfo(location.href);
463	var url = fileinfo.domain + location.pathname;
464	var msg = 'Publishing Calendar Templates';
465	document.getElementById(RZ.adminwinId).innerHTML = msg;
466	location.href = '/revize/debug/PublishCalendarTemplates.jsp'
467				  + '?webspace=' + RZ.webspace
468				  + '&hash=' + 'RZadminwin'
469				  + '&returnurl=' + escape(url);
470}*/
471/*---------------------------------------------------------------------------
472Show or hide updated Admin Panel
473if adminpanel.html not yet loaded, load into new absolute <div> as iframe;
474otherwise if loaded, call adminpanel.html::RZadminwin(...)
475----------------------------------------------------------------------------*/
476function RZadminwin(msg,action)
477{
478	RZadminwin.width = 680;		//outer width (iframe & its container)
479	//if (!RZisadmin()) return;
480
481	// Open adminpanel.html iframe in absolute div at top of body
482	// RZ.adminwin set to iframe window object once initialized
483	if (!RZ.adminwin)
484	{
485		RZ.adminwin = 'setup';
486		RZadminwin.action = action;			//Save for adminpanel.html
487
488		var adminDiv = document.createElement('div');
489		adminDiv.setAttribute('id','RZadminpanelContainer');
490		adminDiv.style.position = "fixed";
491		adminDiv.style.zIndex = "999999999999";
492		adminDiv.style.left = '0px';
493		adminDiv.style.top = '0px';
494		adminDiv.style.margin = '0';
495		adminDiv.style.padding = '0';
496		adminDiv.style.boxShadow = '0 0 6px rgba(0,0,0,.175)';
497		adminDiv.style.width = '100%';
498		adminDiv.style.height = '80px';		//loading height
499/* 		adminDiv.style.border = '0px none #FFF'; */
500		adminDiv.style.font = '13px Arial,Helvetica,sans-serif';
501		adminDiv.style.lineHeight = '21px';
502/* 		adminDiv.style.color = 'black'; */
503		adminDiv.style.margin = '0';
504		adminDiv.style.padding = '20px 0';
505		adminDiv.style.textAlign = 'center';
506		adminDiv.style.backgroundColor = "#ffffff";
507		adminDiv.innerHTML = '<br><b id="RZadminwin-loading">&nbsp;&nbsp;&nbsp;Loading Admin Panel...</b>';
508
509		document.body.insertBefore(adminDiv,document.body.firstChild);
510		RZadminwin.container = adminDiv;	//save for adminpanel.html
511
512		var iframe = document.createElement('iframe');
513		var	src = '/revize/admincenter/adminpanel.jsp'
514		//if (RZ.webspace == 'RostraverTownship')
515		//	src = '/revize/admincenter/adminpanel.work.jsp'
516		iframe.setAttribute('id','RZadminpanel');
517		iframe.setAttribute('src',src);
518		iframe.setAttribute('width','100%');
519		iframe.setAttribute('height','20');			//loading height
520		iframe.setAttribute('scrolling','no');
521		iframe.setAttribute('frameborder','0');
522		iframe.setAttribute('marginwidth','0');
523		iframe.setAttribute('marginheight','0');
524		iframe.style.margin = '0';
525		iframe.style.padding = '0';
526		iframe.style.border = '0px none';
527		iframe.style.visibility = "hidden"; 		//hide IE inset borders while loading
528		adminDiv.replaceChild(iframe, adminDiv.firstChild);
529		return false;
530	}
531
532	// Ignore calls after loading starts until it completes
533	else if (RZ.adminwin == 'setup')
534		return false;
535
536	return RZ.adminwin.RZadminwin('',action);
537}
538/*---------------------------------------------------------------------------
539Add a new style rule or cssRule based on browser
540
541var rules = RZaddrules('.someClass, {color:'black', zIndex:99});
542----------------------------------------------------------------------------*/
543function RZaddrules(stylesheet,selector,selectorRules)
544{
545	var cssStyle, rule, rules = '';
546	for (rule in selectorRules)
547	{
548		if (!selectorRules.hasOwnProperty(rule)) continue;
549		cssStyle = RZcssfromstyle(rule)
550		if (document.all)
551			stylesheet.addRule(selector, cssStyle + ':' + selectorRules[rule]);
552		else
553			rules +=  cssStyle + ':' + selectorRules[rule] + ';';
554	}
555	if (!document.all)
556		stylesheet.insertRule(selector + '{' + rules + '}', 0);
557}
558/*
559* converts a css style name FROM a camelCase style property
560*/
561function RZcssfromstyle(style)
562{
563	return style.replace(/([A-Z])/g,'-$1').toLowerCase();
564}
565/*
566* converts a css style name TO a camelCase style property
567*/
568function RZcsstostyle(style)
569{
570	var results;
571	while (results = style.match(/(-)(\w)/))
572	{
573		style = style.substring(0,results.index)
574			  + results[2].toUpperCase()
575			  + style.substring(results.index+results[0].length)
576	}
577	return style;
578}
579/*-----------------------------------------------------------------------------------
580Returns specified element current specified style
581
582Paramenter:
583	el 			html element or element id
584	style		css style e.g. display, backgroundColor
585
586
58702-20-2014 DCO
588	Updated code based on: http://help.dottoro.com/ljscsoax.php
589
590	Prior cos document.defaultView.getComputedStyle(el,'') returning null
591	for chrome and FF (not sure of original reference used as base)
592
593	Updated code much more bullet-proff and accomodates IE11+)
594-----------------------------------------------------------------------------------*/
595function RZelementCurrentStyleValue(el,style)
596{
597	var value = '';
598
599	/* 02-20-2014 DCO: disabled see notes above
600	if (document.all)
601		value = el.currentStyle[style];
602	else
603		value =  document.defaultView.getComputedStyle(el,'').getPropertyValue(style);
604	*/
605
606	// 02-20-2014 DCO start \\
607	var currentStyle = null;
608	if (typeof(el) == 'string')
609		el = document.getDocumentById(el);
610
611	if (typeof(el) == 'object')
612	{
613		if (window.getComputedStyle)	//chrome & FF work (others TBD per Ray)
614			currentStyle = window.getComputedStyle;
615
616		else if (el.currentStyle)		//pre IE11
617			currentStyle = el.currentStyle
618
619		if (currentStyle && currentStyle[style])
620			value = currentStyle[style];
621	}
622	// 02-20-2014 DCO end //
623
624	return value;
625}
626/*-----------------------------------------------------------------------------------
627Return array of all values found for specified CSS selector (e.g. .left, #top)
628Array is filled as selector are discovered; CSS priority is not considered.
629Upgraded to return object containing array of all values for each specified selector.
630-----------------------------------------------------------------------------------*/
631function RZselectorValues(selectors)
632{
633	// if single selector specified as string, convert to array
634	if (typeof selectors == 'string')
635		selectors = selectors.split(',');
636
637    var values = {};
638	var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules
639    for (var x=0;x<classes.length;x++)
640	{
641        var cssSelector = classes[x].selectorText;
642		if (RZcheckoptions(selectors,cssSelector))
643		{
644            var value = (classes[x].cssText)
645					  ? (classes[x].cssText)
646					  : (classes[x].style.cssText);
647			if (!values[cssSelector])
648				values[cssSelector] = [];
649			values[cssSelector].push(value);
650        }
651    }
652	return values;
653}
654/*---------------------------------------------------------------------------
655* Set style to value for one or more rules
656* IE can only define single selector so rules is an array
657* (for Firefox it is a single element array)
658----------------------------------------------------------------------------*/
659function changeStyle(rules,style,value)
660{
661	for (var i=0;i<rules.length;i++)
662		rules[i]['style'][style] = value;
663}
664/*---------------------------------------------------------------------------
665(Internal Function) Disables links on workflow preview page.
666Internal: Called when trying to leave workflow preview page
667or onclick for Firefox (TODO: allow html popup by checking the event target).
668----------------------------------------------------------------------------*/
669function RZtemplateclose(value)
670{
671	if (!RZ.revizepreview) return
672	var msg = 'Links disabled during preview of content changes'
673	alert(msg)
674	location.href = location.href	//cancels hyperlink
675	return false
676}
677/*---------------------------------------------------------------------------
678(Internal Function) Look for specific hash (e.g. debug or trace) on current
679window, opener, referrer hash and associated cookie
680
681Internal: Diagnostic Support
682----------------------------------------------------------------------------*/
683function RZcheckHash(value)
684{
685	var key = false
686	if (!RZwinaccess(top))
687		return key;
688
689	//TODO: below has issues on some versions of chrome
690	//		(window.top.location.hash may be undefined)
691	if(window.top.location.hash.indexOf('#'+value) != -1
692	|| location.hash.indexOf('#'+value) != -1
693	|| RZ.parent.location.hash.indexOf('#'+value) != -1
694	|| RZgetCookieValue('RZ'+value) == 'ON' )
695	{
696		key = true
697	}
698	else if (RZwinaccess(RZ.parent.opener))
699	{
700		if( RZ.parent.opener.location.hash.indexOf('#'+value) != -1)
701			key = true
702		else if (typeof RZ.parent.opener.top != 'undefined'
703		&& RZ.parent.opener.top.location.hash.indexOf('#'+value) != -1)
704			key = true
705	}
706	else if (typeof document.referrer != 'undefined')
707	{
708		if (document.referrer.indexOf('#'+value) != -1) key = true
709	}
710	return key
711}
712/*---------------------------------------------------------------------------
713(Internal Function) Sets final variables based on page type
714Internal: Called after page loads and all initialzation is done.
715----------------------------------------------------------------------------*/
716function RZpageLoaded()
717{
718	window.focus()		//insure window gets focus() after loaded
719	if (RZ.pagetype == 'template')
720	{
721		//----- Display trace information
722		var recordid;
723		if (typeof RZ.record != 'undefined')
724			recordid = RZ.record.id
725		else
726			recordid = RZ.editrecordid
727
728		RZ.string = 'RZ.webspace: ' + RZ.webspace + '\n'
729				  + "RZ.editrecordid: (" + recordid + ")\n"
730				  + "Clearing Return URLs ..."
731		RZtrace( "Published Page Now Loaded", RZ.string )
732
733		//----- Update cookies
734		if (RZgetCookieValue('RZeditFormReturnUrl') != '')
735			RZsetCookieValue('RZeditFormReturnUrl','')
736
737		/*	deactivated when list allowed as popup
738			(better supports template as list page)
739		if (RZgetCookieValue('RZeditListReturnUrl') != '')
740			RZsetCookieValue('RZeditListReturnUrl','')
741		*/
742
743		if (location.hash == '#logout') return
744
745		//----- Save webSpace name in cookie unless logout call
746		RZsetCookieValue('RZwebspace',RZ.webspace + "#" + document.location)
747
748		if (RZlogin())
749		{
750			//----- Display page username and role in status bar
751			if (RZ.pagetype == 'template')
752				window.status = 'Logged in User is ' + RZ.username
753							  + ' (roles: ' + RZ.roles + ')'
754
755			//----- Call onload handler if permission warning enabled and logged in
756			if (RZcheckoptions(RZ.permissions_options,"warnings"))
757				RZsetuphandler( 'onload', 'RZshowIcons()' )
758
759			//----- Display critical and warnings for templates
760			if (RZ.alert != '') RZalert( RZ.alert );
761			RZwarning();
762		}
763
764		//----- Create login button for page permission testing
765		if (RZcheckoptions(RZ.permissions_options,"warnings")) document.write(
766			'<div id="RevizeLogin" style="visibility:visible; position:absolute; z-index:1; top:30">',
767			/* TODO: autoclick
768			'  <a href="javascript:RZautoClick();"><img border="0"',
769			'   src="/revize/images/warning-auto.gif" alt="Auto Click"></a>',
770			'  <br>',
771			*/
772			'  <a href="/revize/security/"><img border="0"',
773			'   src="/revize/images/RevizeRzSmall.gif" alt="Revize Login"></a>',
774			'</div>',
775			'')
776	}
777
778	//----- TODO: document why RZ.loaded not set true for edit forms
779	//		(perhaps we did not want to use onload handler)
780	if (RZ.pagetype != 'editform')
781	{
782		RZsetuphandler( 'onload', 'RZprocessHash()' )
783	}
784}
785/*---------------------------------------------------------------------------
786(Internal Function) position page on hash set by save
787Internal: Runs after page is loaded
788----------------------------------------------------------------------------*/
789function RZprocessHash()
790{
791	if(location.hash.indexOf('_rz') != -1
792	&& location.hash.indexOf('#trace') == -1
793	&& location.hash.indexOf('#debug') == -1)
794		location.hash = location.hash.substring(1);
795	RZ.loaded=true;
796}
797/*---------------------------------------------------------------------------
798(Internal Function) Displays stack trace(s) from rz.setup()
799Internal: NOT YET USED
800----------------------------------------------------------------------------*/
801function RZprintStackTrace(msg)
802{
803	RZ.tracewin = RZpopupUrl('RevizeTrace');
804	var msg = '<pre>' + msg + '</pre>'
805	RZ.tracewin.document.write(msg);
806}
807/*---------------------------------------------------------------------------
808(Internal Function) Repair bad page permission link
809Internal: Recovery Support
810Future: under development (currently placeholder with no functionality)
811----------------------------------------------------------------------------*/
812function RZbadlink(module,recordid,url)
813{
814}
815/*---------------------------------------------------------------------------
816(Internal Function) Displays page permissions warning on templates. NOT COMPLETED
817Called as onload handler only
818
819Internal: Called by onload handler permission warning are enabled and user is
820currently logged in.
821
822Future: under development (may be available in a later release)
823
824Parameters:
825  	None - no input parameters
826
827Returns:
828  	There is currently no value returned
829----------------------------------------------------------------------------*/
830function RZautoClick()
831{
832	var msg = 'Automatically click on every bad link to define parents.     '
833	if (!confirm(msg)) return
834
835return
836	RZ.msg = ''
837	var tag = 'A'
838	if (tag == '')
839		RZnodeProperties( 0, dw.getDocumentDOM("document").documentElement )
840	else
841	{
842		var allTags = document.getElementsByTagName(tag);
843		for (var i=0; i<allTags.length; i++)
844		{
845			RZ.msg += tag.toLowerCase() + '[' + i + ']:\n'
846			if (allTags[i].hasChildNodes())
847				for (var j=0; j<allTags[i].childNodes.length; j++)
848					RZnodeProperties( 1, allTags[i].childNodes[j] )
849		}
850	}
851
852	RZ.msg = RZ.msg.replace( /\t/g, '     ' )
853	var pattern = /(.*\n){0,40}/g
854	var matchArray = RZ.msg.match(pattern)
855	alert('Written to ' + RZ.constant.tempDOM + '\n\n'
856	     +'Up to 40 lines below:' + '\n' + matchArray[0])
857
858}
859/*---------------------------------------------------------------------------------------------
860Parse a DOM node
861Future: under development (may be available in a later release)
862---------------------------------------------------------------------------------------------*/
863function RZnodeProperties( level, childObj )
864{
865	var i,text
866	var tab = ''
867	var Node = new Object()
868	Node.TEXT_NODE = 2
869	Node.ELEMENT_NODE = 1
870	Node.COMMENT_NODE = 1
871
872
873	for (i=0; i<level; i++) tab += '\t'
874
875	if ( childObj.nodeType == Node.TEXT_NODE)
876	{
877		RZ.msg += tab + 'TEXT NODE:\n'
878		text = childObj.data
879		text = text.replace(/\r/g,'\\r')
880		text = text.replace(/\n/g,'\\n')
881		RZ.msg += tab + '\t' + text + '\n'
882	}
883	else if (childObj.nodeType == Node.ELEMENT_NODE)
884	{
885		var name = ''
886		if ( typeof childObj.getAttribute('name') != 'undefined')
887			name = ' ' + childObj.getAttribute('name')
888		RZ.msg += tab + '<' + childObj.tagName + '>'+name+':\n'
889	}
890	else if (childObj.nodeType == Node.COMMENT_NODE)
891	{
892		RZ.msg += tab + 'COMMENT NODE:\n'
893		text = childObj.data
894		text = text.replace(/\n/g, '\n\t' + tab )
895		RZ.msg += tab + '\t' + text + '\n'
896	}
897	else
898	{
899		RZ.msg += tab + 'UKNOWN nodeType=' + childObj.nodeType + ':\n'
900		RZ.msg += tab + 'Properties:\n'
901		for (i in childObj)
902			RZ.msg += tab + '-->' + i + '<--:' + childObj[i]
903	}
904
905	//----- Chase child nodes
906	if (childObj.hasChildNodes())
907		for (i=0; i<childObj.childNodes.length; i++)
908			RZnodeProperties( level+1, childObj.childNodes[i] )
909}
910/*---------------------------------------------------------------------------
911(Internal Function) Displays page permissions warning on templates.
912Internal: Called by onload handler if warning are active and a user logged in
913----------------------------------------------------------------------------*/
914function RZshowIcons()
915{
916	//----- Show top left icon
917	var icon = document.getElementById('RevizePageMessage')
918	if (icon != null)
919		icon.style.visibility = "visible";
920
921	//----- Show frown icon if button must specify a template
922	for (var i=0; i<RZ.icons.length; i++)
923	{
924		var module = RZ.icons[i]
925		if(typeof RZ.linktemplates[module] == 'undefined'
926		|| RZ.linktemplates[module] == '')
927		{
928			var icon = document.getElementById('RevizeButtonWarning' + i)
929			if (icon != null)
930				icon.style.visibility = "visible";
931		}
932	}
933}
934
935/*---------------------------------------------------------------------------
936Get File Info for specifiec URL or file.
937
938Description:
939	Parses either a url or file and breaks apart into individual fully
940	qualified components.  By default the input pathname is assumed to be a
941	file if the	syntax is ambigious.  To intepret first component as domain
942	as browsers do on the address line specify domain as an option.
943
944	If port 80 is specified on input, it is omitted like IE location functions
945	TODO: have not verified if Netscape location omits port 80
946
947Parameters:
948	pathname-		fully or partially qualified url or path/filename
949	options-		=domain treat everything up to first / as domain
950					(if protocol not specified e.g. http://)
951
952Return Value List:
953	page.domain     = 'http://localhost:8080'		//no trailing slash
954	page.pathname   = '/revize/demositeIII'	//with leading slash but not trailing
955	page.filename   = 'contacts'
956	page.extension  = 'html'
957	page.query      = '?webSpace=demositeII&recordid=1'	//contains leading ?
958	page.hash       = 'trace'						//leading # omitted
959	page.home       = 'http://localhost:8080//revize/demositeIII/index.html'
960
961Notes:
962	Regression test at .../revize/util/snippet_helper_getfileinfo_test
963
964	TODO: some scenarios noted as in above test do not currently work properly.
965	Many scenarios of domains ARE ONLY intrepreted correctly if domain option
966	is specified and the input pathname ends with a slash when no filename.
967	(remember page.href however is never returned with ending slash by design)
968	See: .../revize/util/snippet_helper_getfileinfo_test for details.
969----------------------------------------------------------------------------*/
970/* Same as RZgetfileinfo (retained for backward compatibility) */
971function RZgetFileInfo(pathname, options)
972{return RZgetfileinfo(pathname, options)}
973function RZgetfileinfo(pathname, options)
974{
975	var pos,idx,results
976	var href=''
977	var domain=''
978	var filename=''
979	var sep=''
980	var extension=''
981	var query=''
982	var hash=''
983	var home=''
984	if (typeof options == 'undefined')
985		options = '';
986	else
987		options += ','
988	if (!pathname) pathname = '';
989	if (pathname == '#') pathname = location.href
990	if (pathname != '')
991	{
992		pathname = pathname.split('\\').join('/');
993
994		//----- Determine domain
995		domain = ''
996		pos = pathname.indexOf(':')				//check for first colon :
997
998		//----- If domain option & protocol is missing, prepend to pathname
999		if (options.indexOf('domain,') != -1
1000		&& RZsubstring(pathname,pos+1,pos+3) != '//')
1001		{
1002			if (location.protocol != '')
1003				pathname = location.protocol + '//' + pathname
1004			else
1005				pathname = 'http://' + pathname
1006			pos = pathname.indexOf(':')			//reset colon pos
1007		}
1008
1009		//----- If protocol present, e.g. //http:// https:// ftp://
1010		if (RZsubstring(pathname,pos+1,pos+3) == '//')
1011		{
1012			pos += 3
1013			if (pathname.indexOf('/',pos) != -1)	//if first slash following //:
1014				pos = pathname.indexOf('/',pos)		//domain goes up to slash
1015			else if (RZsubstring(pathname,0,4).toLowerCase() != 'file')
1016				pos = pathname.length				//assume domain is all of pathname
1017		}
1018		else if (pos == -1)		//not file type (e.g. C:) so use current page domain
1019		{
1020			if (options.indexOf('domain,') != -1
1021			|| RZsubstring(pathname,0,4).toLowerCase() == 'www.')
1022			{
1023				pos = pathname.indexOf('/')
1024				if (pos >= 0)
1025				{
1026					domain = pathname.substring(0,pos)
1027					pathname = pathname.substring(pos+1)
1028				}else
1029				{
1030					domain = pathname
1031					pathname = ''
1032				}
1033			}
1034			else
1035			{
1036				domain = document.location.host			//blank if file
1037				if (document.location.protocol != '')	//if not file
1038				{
1039					domain = document.location.protocol + '//' + domain
1040					pos = domain.length
1041					if (RZsubstring(pathname,0,1) != '/')
1042						pathname = '/' + pathname
1043					pathname = domain + pathname
1044				}
1045			}
1046		}
1047
1048		//-----  if : found, file format of C: (split into domain and pathname)
1049		if (pos != -1)
1050		{
1051			if (pathname.substring(pos,pos+1) == ':')
1052				domain = pathname.substring(0,pos+1)
1053			else
1054				domain = pathname.substring(0,pos)
1055
1056			pathname = pathname.substring(pos)
1057			if (pathname.substring(0,1) == ':')
1058				pathname = pathname.substring(1)
1059		}
1060
1061		//----- Strip port 80 if present in domain
1062		pos = (domain+'/').indexOf(':80/')
1063		if (pos != -1)
1064			domain = domain.substring(0,pos);
1065
1066		//----- Parse pathname and filename
1067		//		DCO 03-09-2012 previously simple lastIndexOf('/') incorecctly
1068		//		               found slash past hash "#" or query "?"
1069		//		e.g. /calendar_app/index.html#Master,03/09/2012
1070		//			 (both results[0] & results[1] have pathname
1071		results = pathname.match(/^([^#?]*\/)[^#?]*?/m);
1072
1073		if (results)	//found slash PRECEEDING query "?" or hash "#"
1074
1075		{	//results.lastIndex NA on IE9
1076			pos = results.index + results[1].length;
1077			filename = pathname.substr(pos);
1078			pathname = pathname.substr(0,pos-1);
1079			if (pathname.substr(0,1) != '/')
1080				pathname = '/' + pathname;
1081		}
1082		else			//safe to use lastIndexOf() when no query or hash
1083		{
1084			filename = pathname;
1085			pathname = '';
1086		}
1087
1088		//------ Parse search (query)
1089		pos = filename.indexOf('?')
1090		if (pos == -1)
1091			query = ''
1092		else
1093		{
1094			query = filename.substring(pos)
1095			filename = filename.substring(0,pos)
1096		}
1097
1098		//------ Parse hash
1099		pos = filename.indexOf('#')
1100		if (pos != -1)
1101		{
1102			hash = filename.substring(pos+1)
1103			filename = filename.substring(0,pos)
1104		}
1105
1106		//------ Parse filename extension
1107		pos = filename.lastIndexOf('.')
1108		if (pos == -1)
1109			extension = ''
1110		else
1111		{
1112			extension = filename.substring(pos+1)
1113			filename = filename.substring(0,pos)
1114		}
1115		if (filename == '')		// use index.html when filename is blank
1116		{
1117			filename = ''
1118			extension = ''
1119		}
1120
1121		//----- home page (questionable value)
1122		home = domain + pathname
1123		if (RZright(home,1) != '/' && pathname != '') home += '/'
1124	}
1125
1126	//----- Return all the components
1127	var page = new Object();
1128	page.domain = domain;
1129	page.pathname = pathname;
1130	page.filename = filename;
1131	page.extension = extension;
1132	page.extention = extension;
1133
1134	page.filenameFull = page.filename;
1135	if (page.extension)
1136		page.filenameFull += '.' + extension;
1137	page.pathfilename = page.filenameFull;
1138	if (page.pathname)
1139		page.pathfilename = page.pathname + '/' + page.pathfilename;
1140
1141	page.query = query;
1142	page.search = query;
1143	page.hash = hash;
1144	page.home = home;
1145
1146	page.sep = ((extension != '') ? '.' : '')
1147	page.href = domain
1148	page.href += pathname
1149	page.href += ((filename != ''&& RZright(page.href,1) != '/') ? '/' : '')
1150	page.href += filename + page.sep + extension + query
1151	if (hash != '') page.href += '#' + hash
1152
1153	return page
1154}
1155/*---------------------------------------------------------------------------
1156----------------------------------------------------------------------------*/
1157function RZbuildurl(fileInfo)
1158{
1159	var location = fileInfo.domain + fileInfo.pathname
1160	if (RZright(location,1) != '/') location += '/'
1161	location += fileInfo.filename + fileInfo.sep + fileInfo.extension
1162	          + fileInfo.query
1163	if (fileInfo.hash != '') location += '#' + fileInfo.hash
1164	return location
1165}
1166/*---------------------------------------------------------------------------
1167Return Browser Version - report page design flaw if unknown
1168
1169Parameters:
1170	None- (no input parameters)
1171
1172Returns: Browser version
1173----------------------------------------------------------------------------*/
1174function RZbrowserversion()
1175{
1176	var version = 0
1177	if (RZ.isnavigator)
1178	{
1179		version = parseFloat( navigator.appVersion )
1180	}else
1181	{
1182		var pos = navigator.appVersion.indexOf("MSIE")
1183		version = parseFloat(navigator.appVersion.substring(pos+4))
1184	}
1185	if (isNaN(version) || version == 0)
1186		RZalert( "Unable to determine Browser version\n"
1187			 + "navigator.appVersion: " + navigator.appVersion )
1188
1189	return version
1190}
1191/*---------------------------------------------------------------------------
1192Resize window; if width or hieght not specified use available size
1193
1194Parameters:
1195	width -		specifies requested window width (text or number)
1196	hieght -	specifies requested window hieght (text or number)
1197	justify -	Optional string; right or left to justify window respectively
1198	win -		Optional window object to specify window if not window/frame
1199				that includes the snippet_helper.js library file.
1200----------------------------------------------------------------------------*/
1201function RZresize(width,height,justify,win)
1202{
1203	 return;
1204	 if (!width) width = screen.availWidth;
1205	 if (!height) height = screen.availHeight;
1206	 if (!justify) justify = 'center'
1207	 if (!win) win = window
1208	 if (win.dialogArguments) return; //DCO 02-04-2014
1209
1210	 //DCO 08-03-2009
1211	 //if (RZ.isnavigator) height -= 125  //TODO: for linkmanager ???
1212
1213	 var x = (screen.availWidth - width) / 2
1214	 var y = (screen.availHeight - height) / 2
1215	 if (justify == 'right')
1216	  x = screen.availWidth - width - 10
1217	 else if (justify == 'left')
1218	  x = 0
1219	 if (x < 0) x = 0
1220	 if (y < 0) y = 0
1221
1222	 win.resizeTo(width,height);
1223     win.moveTo( x,y )
1224
1225}
1226/*-----------------------------------------------------------------------------------
1227Return window and browser screen sizes and offset to locate block of width & height.
1228
1229NOTE: browser width & height returned are limited to screen width/height
1230
1231---------
1232Arguments:
1233---------
1234width		(optional) width of window or layer to open; default is full size
1235height		(optional) height of window or layer to open; default is full size
1236options		list of option=value or option separated by commas from list below:
1237				norounding	returned width/height & offsets rounded to nearest integer
1238				browser		returned width/height & offsets relative to browser window
1239							instead of screen
1240-----------------------------------------------------------------------------------*/
1241function RZscreensizes(width,height,options)
1242{
1243	if (typeof width == 'undefined') width = 0;
1244	if (typeof height == 'undefined') height = 0;
1245
1246	var base, offsetX, offsetY;
1247	var sizes = {
1248		width:width, height:height,
1249		screenWidth:0, screenHeight:0,
1250		browserWidth:0, browserHeight:0,
1251		offsetWidth:0, offsetHeight:0
1252	};
1253
1254	//----- Is offset limited and relative to browser or screen screen size
1255	var base = 'screen';
1256	if (RZcheckoptions(options,'browser'))
1257		base = 'browser';
1258
1259	//----- Window sizes...
1260	sizes.screenWidth=screen.width;
1261	sizes.screenHeight = screen.height;
1262	offsetY = 0;
1263	offsetX = 0;
1264
1265	//----- Browser sizes...
1266	if(!window.innerWidth)	//IE...
1267	{
1268		if (!(document.documentElement.clientWidth == 0))
1269		{					//...strict mode
1270			sizes.browserWidth = document.documentElement.clientWidth;
1271			sizes.browserHeight = document.documentElement.clientHeight;
1272			if (base == 'browser')
1273			{
1274				offsetY = document.documentElement.scrollTop;
1275				offsetX = document.documentElement.scrollLeft;
1276			}
1277		}
1278		else
1279		{					//...quirks mode
1280			sizes.browserWidth = document.body.clientWidth;
1281			sizes.browserHeight = document.body.clientHeight;
1282			if (base == 'browser')
1283			{
1284				offsetY = document.body.scrollTop;
1285				offsetX = document.body.scrollLeft;
1286			}
1287		}
1288	}
1289	else					//WC3...
1290	{
1291		sizes.browserWidth = window.innerWidth;
1292		sizes.browserHeight = window.innerHeight;
1293		if (base == 'browser')
1294		{
1295			offsetX = window.pageXOffset;
1296			offsetY = window.pageYOffset;
1297		}
1298	}
1299
1300	//----- If browser sizes exceed screen sizes, adjust
1301	sizes.browserWidth = Math.min(sizes.browserWidth,sizes.screenWidth);
1302	sizes.browserHeight = Math.min(sizes.browserHeight,sizes.screenHeight);
1303
1304	//----- Adjust height & width to center of browser or screen (depending on base value)
1305	//		If either width or height not specified, set to browser or screen width/height
1306	//		negative width or height uses full size less negative value specified
1307	if (width == 0)
1308		sizes.width = sizes[base+'Width'];
1309	else if (width < 0)
1310		sizes.width = sizes[base+'Width'] + width;
1311
1312	if (height == 0)
1313		sizes.height = sizes[base+'Height'];
1314	else if (height < 0)
1315		sizes.height = sizes[base+'Height'] + height;
1316
1317	//----- Limit width and height to browser or screen width and height
1318	sizes.width = Math.min(sizes.width,sizes[base+'Width']);
1319	sizes.height = Math.min(sizes.height,sizes[base+'Height']);
1320
1321	offsetX = (sizes[base+'Width'] - sizes.width) / 2 + offsetX;
1322	offsetY = (sizes[base+'Height'] - sizes.height) / 2 + offsetY;
1323
1324	//----- round up unless no rounding specified
1325	if (!RZcheckoptions(options,'norounding'))
1326	{
1327		offsetX = parseInt(offsetX + .5);
1328		offsetY = parseInt(offsetY + .5);
1329	}
1330
1331	sizes.offsetWidth = offsetX;
1332	sizes.offsetHeight  = offsetY;
1333
1334	//----- Return object with all sizes
1335	return sizes;
1336}
1337/*---------------------------------------------------------------------------
1338Return true if layer exists and is currently visible.
1339
1340Parameters:
1341----------
1342layerName-	text representing layer name
1343
1344doc-		Optional argument specifing document object
1345			(appropriate when caller in in another frame or window)
1346----------------------------------------------------------------------------*/
1347function RZisvisible(layerName,doc)
1348{
1349	if (typeof doc == 'undefined') doc = document
1350    if (typeof doc == 'undefined') return false;    //firefox cludge
1351	if (typeof(layerName) == 'object')
1352		layerName = layerName.id;
1353	var status = false;
1354
1355	if (doc.layers && doc.layers[layerName])		//ns
1356	{
1357		if(typeof doc.layers[layerName] != 'undefined'
1358		&& doc.layers[layerName].visibility == 'visible') status = true
1359	}
1360	else if (RZ.css)			//ie or firefox (see notes in RZshowlayer)
1361	{
1362		var el = doc.getElementById(layerName)
1363		if (!el && RZ.MSIE) el = doc.all[layerName];
1364		if (el != null)
1365		{
1366			var layerStyle = el.style
1367			if (layerStyle.visibility != ''	&& layerStyle.visibility == 'visible')
1368				status = true
1369			if (layerStyle.display != '' && layerStyle.display != 'none')
1370				status = true
1371		}
1372	}
1373
1374	return status;
1375}
1376/*---------------------------------------------------------------------------
1377Does layer exist?
1378
1379Parameters:
1380----------
1381layerName-	text representing layer name
1382
1383trueFalse-	Not used
1384
1385doc-		Optional argument specifing document object
1386			(appropriate when caller in in another frame or window)
1387----------------------------------------------------------------------------*/
1388function RZhavelayer(layerName,trueFalse,doc)
1389{
1390	if (typeof doc == 'undefined') doc = document
1391	if (typeof(layerName) == 'object')
1392		layerName = layerName.id;
1393	if (doc.layers && doc.layers[layerName])		//ns
1394	{
1395		if(typeof doc.layers[layerName] == 'undefined') return false
1396	}
1397	else if (RZ.css)			//ie or firefox (see notes in RZshowlayer)
1398	{
1399        var el = document.getElementById(layerName)
1400        if (el == null) return false
1401		//if(typeof doc.all[layerName] == 'undefined') return false
1402	}
1403	return true
1404}
1405/*---------------------------------------------------------------------------
1406Show or hide a layer based on browser type.  If the layer visibility property
1407is valid (non-blank), it is used to show or hide layer however it does not
1408work for Firefox.  If the visibility property is blank and the style.display
1409property if not blank, it is used to hide or show layer.
1410
1411This feature was initially added as a simple backward compatible method to use
1412this function in Firefox in legacy utility functions such as the link manager
1413by simply changing the condictionally displayed code to define a display
1414property and leave the visiblity property blank.
1415
1416Parameters:
1417----------
1418layerName-	text representing layer name
1419
1420trueFalse- 	optional argument:
1421			if not passed, toggle layer (i.e. hide if showing or show if hidden)
1422			otherwise: if true show layer, if false hide layer
1423
1424doc-		Optional argument specifing document object
1425			(appropriate when caller in in another frame or window)
1426----------------------------------------------------------------------------*/
1427function RZshowlayer(layerName,trueFalse,doc)
1428{
1429	var el, msg = '';
1430	if (typeof doc == 'undefined') doc = document
1431
1432	//----- Netscape 4 loses layers if page was resized so leave layer visible
1433	if (RZ.isnavigator
1434	&& RZ.isnavigatorLayers == true
1435	&& doc.layers.length == 0) return
1436
1437	if (typeof(layerName) == 'object')
1438		el = layerName;
1439
1440	//----- If invalie layerName of object, set status and return
1441	else if (typeof layerName != 'string')
1442	{
1443		RZalert('Invalid layer name must be text argument');
1444		return;
1445	}
1446 	//----- Get div/span/layer element
1447	else
1448	{
1449		el = doc.getElementById(layerName)
1450		if (!el && RZ.MSIE) el = doc.all[layerName];
1451	}
1452
1453	//----- If trueFalse not specified, toggle setting
1454	if (typeof trueFalse == 'undefined')
1455	{
1456		if ( RZisvisible(layerName,doc) == true)
1457			trueFalse = false
1458		else
1459			trueFalse = true
1460	}
1461
1462	//----- See if layers are found on Netscape
1463	var msg = "Can't Hide Layer because ...\n"
1464	if (trueFalse == true) msg ="Can't Show Layer because ...\n"
1465	if (doc.layers)									//ns
1466	{
1467		if(doc.layers.length == 0)
1468		{
1469			msg += 'No Netscape Layers Defined (may be caused by resizing the window)\n'
1470				 + 'Try refreshing the page and re-entering information'
1471			RZalert(msg)
1472			return
1473		}
1474		RZ.isnavigatorLayers = trueFalse;	//indicate layer existed at one time
1475		if(typeof doc.layers[layerName] == 'undefined')
1476		{
1477			msg += 'Netscape Layer Not Defined: ' + layerName
1478
1479			// list defined layers
1480			msg += '\n\nDOM document.layers properties'
1481			for (i in doc.layers)
1482				msg += '\n      ' + i + '=' + doc.layers[i]
1483			RZalert(msg)
1484			return
1485		}
1486	}
1487	else if (RZ.css)					//ie or firefox (see notes in description)
1488	{
1489		if (el == null)
1490		{
1491			msg += 'Layer Not Defined: ' + layerName
1492			RZalert(msg)
1493			return
1494		}
1495	}
1496
1497	//----- Show or hide layer
1498	if (trueFalse == true)	// show layer
1499	{
1500		if (doc.layers && doc.layers[layerName])			//ns
1501			doc.layers[layerName].visibility = 'visible';
1502
1503		else if (RZ.css)					//ie or firefox (see notes in description)
1504		{
1505			//var displayBlock = el.tagName.toUpperCase() == 'SPAN' ? 'inline' : 'block' ;
1506			var displayBlock = 'inline';	//most tags display=inline
1507			if (el.tagName.toLowerCase() == 'div')
1508				displayBlock = 'block';		//div display=block
1509			if (el.style.visibility != '')
1510			{
1511				el.style.visibility = 'visible';
1512				el.style.zIndex = 100;
1513			}
1514			else if (el.style.display != displayBlock)
1515				el.style.display = displayBlock;
1516		}
1517    }
1518    else 					// hide layer
1519    {
1520		if (doc.layers && doc.layers[layerName])			//ns
1521			doc.layers[layerName].visibility = 'hidden';
1522		else if (RZ.css)				//ie or firefox (see notes in description)
1523		{
1524			if (el.style.visibility != '')
1525				el.style.visibility = 'hidden';
1526			else if (el.style.display != 'none')
1527				el.style.display = 'none';
1528		}
1529	}
1530}
1531/*---------------------------------------------------------------------------
1532Set Cookie value
1533-----------
1534Parameters:
1535-----------
1536key			Key part of the Cookie key=value pair
1537value		Value part of key=value (may have optional qualifier appended)
1538qualifier	(Optional) string specifyin gualifier
1539			e.g. current page url or webspace domain
1540---------
1541Examples:
1542---------
1543	RZsetcookie('RZeditListReturnUrl',location.href);		//no qualifier
1544	RZsetcookie('RZlogin',RZ.webspace+"#"+RZ.page.domain);	//value has qualifier
1545	RZsetcookie('RZuser',RZ.username,RZ.page.domain)		//qualifier 3rd arg
1546----------------------------------------------------------------------------*/
1547function RZsetCookieValue( key, value, qualifier )
1548{ return RZsetcookie( key, value, qualifier ) }
1549function RZsetcookie( key, value, qualifier )
1550{
1551	if (!qualifier) qualifier = '';
1552	if (qualifier)
1553	{
1554		if (qualifier.substr(0,1) != '#')
1555			qualifier = '#' + qualifier;
1556		value += qualifier;
1557	}
1558
1559	var domain = '';
1560	//DO-KS: was causing problems with Netscape when running from a remote host
1561	//if (document.location.host.indexOf('.') >= 0)
1562	//  domain = '; domain=' + document.domain;
1563
1564	document.cookie = key + '=' + value
1565   	                + '; path=/' + domain;
1566
1567	var text = key + "=" + value + domain
1568	RZtrace( 'Set Cookie', text )
1569	return text;
1570}
1571
1572/* Same as RZgetcookie (retained for backward compatibility) */
1573function RZgetCookieValue( key, qualifier )
1574{ return RZgetcookie( key, qualifier ) }
1575/*---------------------------------------------------------------------------
1576Get Cookie value
1577
1578Parameters:
1579----------
1580key-		Key part of the Cookie key=value pair
1581
1582qualifier-	Optional parameter that qualifies the cookie by requiring the
1583			value to end with qualifier string.  Either a blank value is
1584			returned the qualifier string is removed from the returned value.
1585			Examples qualifies are: server domain and/or page url
1586
1587			If qualifer is blank, accept any qualified value after stripping
1588			the cookie qualifier
1589----------------------------------------------------------------------------*/
1590function RZgetcookie( key, qualifier )
1591{
1592
1593	var msg = '';
1594	var value = '';
1595	if (!key)
1596		RZwarn('Key undefined');
1597
1598	else
1599	{
1600		var allcookies = document.cookie + ';'
1601		var pos = allcookies.toLowerCase().indexOf( key.toLowerCase()+';' );
1602		if (pos == -1)	// not empty string value
1603			pos = allcookies.toLowerCase().indexOf( key.toLowerCase()+'=' );
1604		if (pos == -1) 	// if no cookie defined, return blank
1605			value = ""
1606		else // when cookie defined, return value
1607		{
1608			var valStart = pos + key.length + 1;
1609			if (allcookies.substring(valStart-1,valStart) != "=" )
1610				value = ""
1611			else
1612			{
1613				var valEnd = allcookies.indexOf( ";", valStart );
1614				if (valEnd == -1 ) valEnd = allcookies.length - 1
1615				value = allcookies.substring( valStart, valEnd );  //keep value case sensitive
1616			}
1617		}
1618
1619		//----- Build trace message; check for qualifier and remove or set value to blank
1620		msg = key + "=" + value
1621		if (typeof qualifier != 'undefined')
1622		{
1623			msg += '\nQualifier: (' + qualifier + ')'
1624			pos = value.indexOf('#')
1625			if (pos <= 0)
1626				value = ''
1627			else if (qualifier != '' && value.substring(pos+1) != qualifier)
1628				value = ''
1629			else
1630				value = value.substring(0,pos)
1631			msg += '\nQualified Value: (' + value + ')'
1632		}
1633	}
1634
1635	RZtrace("Get Cookie",msg)
1636	return value
1637}
1638/*----------------------------------------------------------------------------
1639Date subclass to supports dashes "-" in constructor for FF & Chrome:
1640	.e.g. new RZdate('12-21-2012')
1641
1642Plus additional properties and methods.
1643The builtin Date() object is not extended to avoid different behavior caused
1644by adding prototypes directly.
1645
1646TODO:
1647	date.formatted.revizeDate --> date.get('revizeDate')
1648----------------------------------------------------------------------------*/
1649function RZdate(year,month,day,hours,minutes,seconds,ms)
1650{
1651	var date = null;
1652	switch (RZdate.arguments.length)
1653	{
1654		case 0:
1655			date = new Date();
1656			break;
1657		case 1:		//milliseconds since midnight 1-1-70 -OR- date string
1658			if (typeof year == 'number')
1659				date = new Date(year)
1660			else
1661			{		//date object or string; replace dashs in date
1662				var dateStr = (year + '')
1663				dateStr = dateStr.replace(/Noon/i,'12:00pm');
1664				dateStr = dateStr.replace(/Midnight/i,'12:00am');
1665				dateStr = dateStr.replace(/(\d)\-(\d)/g,'$1/$2');
1666
1667				dateStr = dateStr.replace(/(\d{1,2}\/\d{1,2}\/)(\d{2})(?!\d)/, '$120$2');
1668				dateStr = dateStr.replace(/(\d)(am|pm)/, '$1 $2');
1669
1670				if (dateStr)
1671					date = new Date(dateStr);
1672				else
1673					date = new Date();
1674			}
1675			break;
1676		case 2:
1677			date = new Date(year,month);
1678			break;
1679		case 3:
1680			date = new Date(year,month,day);
1681			break;
1682		case 4:
1683			date = new Date(year,month,day,hours);
1684			break;
1685		case 5:
1686			date = new Date(year,month,day,hours,minutes);
1687			break;
1688		case 6:
1689			date = new Date(year,month,day,hours,minutes,seconds);
1690			break;
1691		default:
1692			date = new Date(year,month,day,hours,minutes,seconds,ms);
1693			break;
1694	}
1695	//----- If invalid date, return NaN
1696	if (isNaN(date)) return null;
1697
1698	date.isRZdate = true;
1699	date.string = date.toString();	//only used show value in debugger
1700	//date.toString = function() ... may work better
1701
1702	//----- Add additional properties and methods.
1703	//		calendar_app issues
1704	//		1. cloning does not get these properties and methods
1705	//		2. adding reference to homeframe freezes IE7
1706	//		   must explictly reference as homeframe.RZdate(...)
1707	//		3. valid date return true for isNaN beside invalid when
1708	//		   not called from homeframe
1709	for (var prop in RZdate.prototype)
1710		date[prop] = RZdate.prototype[prop];
1711
1712	if (date.getFormatted)			//TODO: change to getFormat()
1713		date.getFormatted();		//set formatted data for constructor date
1714	return date;
1715}
1716/*----------------------------------------------------------*/
1717/*BOOKMARK RZdate static properties (instance not required)*/
1718/*--------------------------------------------------------*/
1719RZdate.baseDate = '01/01/1970';
1720RZdate.monthNames = ["January", "February", "March", "April",
1721				     "May", "June", "July", "August",
1722					 "September", "October", "November", "December"];
1723RZdate.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday",
1724				   "Thursday", "Friday", "Saturday"];
1725
1726RZdate.getMonth = function(monthName)
1727{
1728	for (var i=0; i<RZdate.monthNames; i++)
1729		if (RZdate.monthNames[i] == monthName) return i;
1730	return -1;
1731}
1732
1733/*-------------------------------------------------------------*/
1734/*BOOKMARK RZdate instance properties (backward compatibility)*/
1735/*-----------------------------------------------------------*/
1736RZdate.prototype.monthNames = ["January", "February", "March", "April",
1737							   "May", "June", "July", "August",
1738							   "September", "October", "November", "December"];
1739
1740RZdate.prototype.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday",
1741							  "Thursday", "Friday", "Saturday"];
1742
1743/*------------------------*/
1744/*BOOKMARK RZdate methods*/
1745/*----------------------*/
1746RZdate.prototype.get = function(key)		//return format property
1747{											//TODO: extend to get any property
1748	if (typeof this.formatted[key] == 'undefined')
1749		return key;
1750
1751	this.getFormatted();
1752	return this.formatted[key];
1753}
1754RZdate.prototype.toString = function()		//return string for date
1755{
1756	return new Date(this.getTime()) + '';
1757}
1758RZdate.prototype.getMonthName = function()	//return full month name
1759{
1760	return this.monthNames[this.getMonth()];
1761}
1762RZdate.prototype.getDayName = function()	//return full day name
1763{
1764	return this.dayNames[this.getDay()];
1765}
1766RZdate.prototype.getDaysInMonth = function()
1767{
1768	//                  1  2  3  4  5  6  7  8  9 10 11 12
1769	var daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
1770	var month = this.getMonth();
1771	var days = daysInMonth[month];
1772	if (month==1 && isLeapYear(this.getFullYear()))
1773		days=29;
1774	return (days);
1775
1776	function isLeapYear(Year)
1777	{
1778		if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0))
1779			return true;
1780		else
1781			return false;
1782	}
1783	/* alt from: http://msdn.microsoft.com/en-us/library/aa239571(v=vs.60).aspx
1784	// may not work in non-IE browsers
1785	eomDate = new Date();
1786	eomDate.setMonth(eomDate.getMonth() + 1 );
1787	eomDate.setDate(1);
1788	eomDate.setDate( eomDate.getDate() - 1);
1789	alert("Last day of this month = " + eomDate);
1790	*/
1791}
1792/*----------------------------------------------------------------------------
1793Add/substract number of months to current date.
1794return number of days added or subtracted
1795----------------------------------------------------------------------------*/
1796RZdate.prototype.addMonth = function(number)
1797{	//backward compatibility
1798	return this.addMonths(number)
1799}
1800RZdate.prototype.addMonths = function(number)
1801{
1802	if (typeof number == 'undefined') number = 1;
1803	number = parseInt(number);
1804
1805	var time = this.getTime();
1806	var year = this.getFullYear() + parseInt(number / 12);
1807	var month = (this.getMonth() + number) % 12;
1808	if (number > 0 && month < this.getMonth())
1809		year++;
1810	else if (number < 0 & month > this.getMonth())
1811		year--;
1812	var day = this.getDate();
1813
1814	// advance to next month using day=1
1815	this.setDate(1);
1816	this.setYear(year);
1817	this.setMonth(month);
1818
1819	// adjust date using current day or last day of month
1820	day = Math.min(day,this.getDaysInMonth());
1821	this.setDate(day);
1822	this.getFormatted();
1823
1824	time = this.getTime() - time;
1825	return time / 24 / 60 / 60 / 1000; 	//number of days added
1826}
1827/*----------------------------------------------------------------------------
1828Add/substract number of weeks to current date.
1829return number of minutes added or subtracted
1830----------------------------------------------------------------------------*/
1831RZdate.prototype.addWeeks = function(number)
1832{
1833	if (typeof number == 'undefined') number = 1;
1834	return this.addDays(number*7);
1835}
1836/*----------------------------------------------------------------------------
1837Add/substract number of days to current date.
1838return number of minutes added or subtracted
1839
1840Credit: http://www.w3schools.com/js/js_obj_date.asp
1841They say if adding days goes into another month or year, Date object adjusts.
1842----------------------------------------------------------------------------*/
1843RZdate.prototype.addDays = function(number)
1844{
1845	if (typeof number == 'undefined') number = 1;
1846	number = parseInt(number);
1847
1848	var time = this.getTime();
1849	this.setDate(this.getDate() + number);
1850	this.getFormatted();
1851
1852	time = this.getTime() - time;
1853	return (time / 60 / 1000); 	//number of minutes added
1854}
1855/*----------------------------------------------------------------------------
1856Return new RZdate() object containing only the date portion of this RZdate().
1857----------------------------------------------------------------------------*/
1858RZdate.prototype.getDatePart = function()
1859{
1860	return new RZdate(this.getFullYear(),this.getMonth(),this.getDate());
1861}
1862/*----------------------------------------------------------------------------
1863Return a new Date() object which is GMT representation of time component.
1864
1865Therefore getTime() returns milliseconds since midnight not since GMT 12:00am
1866(e.g. 0 for midnight; 1*60*60*1000 = 3600000 for 1am, etc).
1867
1868However getHours() returns GMT hours not the hour specified when this RZdate
1869object was created. Therefore RZdate() with no time component (i.e. midnight)
1870returns 19 (7pm) from getHours() when local is EST since EST is GMT-5 hours.
1871----------------------------------------------------------------------------*/
1872RZdate.prototype.getTimePart = function()
1873{
1874	var date = new Date(1970,0,1);
1875	date.setUTCHours(this.getHours(),
1876					 this.getMinutes(),
1877					 this.getSeconds(),
1878					 this.getMilliseconds());
1879	return date;
1880}
1881/*----------------------------------------------------------------------------
1882Returns the week number for this date.
1883
1884@param int dowOffset (optional) day week starts on (0 to 6) 1 is Monday
1885@return int ISO 8601 week number
1886
1887Credit: Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com
1888----------------------------------------------------------------------------*/
1889RZdate.prototype.getWeek = function(dowOffset)
1890{
1891	if (isNaN(this)) return null;
1892	dowOffset = typeof(dowOffset) == 'int' ? dowOffset : 0; //default dowOffset to zero
1893
1894	var newYear = new Date(this.getFullYear(),0,1);
1895	var day = newYear.getDay() - dowOffset; //the day of week the year begins on
1896	day = (day >= 0 ? day : day + 7);
1897	var daynum = Math.floor((this.getTime() - newYear.getTime() -
1898				 (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
1899	var weeknum;
1900
1901	//if the year starts before the middle of a week
1902	if(day < 4)
1903	{
1904		weeknum = Math.floor((daynum+day-1)/7) + 1;
1905		if(weeknum > 52)
1906		{
1907			nYear = new Date(this.getFullYear() + 1,0,1);
1908			nday = nYear.getDay() - dowOffset;
1909			nday = nday >= 0 ? nday : nday + 7;
1910			/*if the next year starts before the middle of
1911			  the week, it is week #1 of that year*/
1912			weeknum = nday < 4 ? 1 : 53;
1913		}
1914	}
1915	else
1916		weeknum = Math.floor((daynum+day-1)/7);
1917	return weeknum;
1918}
1919/*---------------------------------------------------------------------------------------------
1920getNthDayInMonth(nth)
1921If nth specified, get date for nth occurance of this.date dayOfWeek -OR-
1922If no parameters, determine occurance of day of week in this.date month
1923
1924----------------------
1925Parameters (optional):
1926----------------------
1927theDayOfWeek 	specifies day of week; 0-6 or day name (at least 3 characters)
1928theNth			specifies desired occurance of theDayOfWeek
1929
1930--------
1931Returns:
1932--------
1933if parameters:	(RZdate) matching theNth occurance of theDayOfWeek in the month
1934otherwise		(String) 1st to 4th or 'last' if nth > 4th)
1935
1936--------
1937Examples:
1938---------
1939this.date=01-01-2012
1940				getNthDayInMonth() 			returns '1st' 01-01-201 is 1nd Sun in Jan 2012
1941				getNthDayInMonth(1) 		returns RZdate('01-01-2012')
1942				getNthDayInMonth(4) 		returns RZdate('01-22-2012')
1943				getNthDayInMonth('last') 	returns RZdate('01-29-2012')
1944this.date=01-09-2012
1945				getNthDayInMonth() 			returns '2nd'; 01-09-201 is 2nd Mon in Jan 2012
1946				getNthDayInMonth(1) 		returns RZdate('01-02-2012')
1947				getNthDayInMonth(4) 		returns RZdate('01-23-2012')
1948				getNthDayInMonth('last') 	returns RZdate('01-23-2012')
1949---------------------------------------------------------------------------------------------*/
1950RZdate.prototype.getNthDayInMonth = function (nth,dayOfWeek)
1951{
1952	var day;
1953	var theDate = RZdate(this);		//work object that can be modified
1954	var daysInMonth = theDate.getDaysInMonth();
1955	var nthCount = 0;
1956	var dateTime = 0;
1957
1958	//----- Compute nth day of current date in month
1959	if (arguments.length == 0)
1960	{
1961		dayOfWeek = theDate.getDay();
1962		for (day=1;day<=daysInMonth;day++)
1963		{
1964	        theDate.setDate(day);
1965			if (theDate.getDay() == dayOfWeek)
1966				nthCount++;
1967			if (theDate.getDatePart()+'' == this.getDatePart()+'')
1968				break;
1969		}
1970		if (nthCount > 4)
1971			nthCount = 'last';
1972		else
1973			nthCount = RZnth(nthCount);
1974		return nthCount;
1975	}
1976
1977	//----- Find date of nth dayOfWeek in month
1978	else
1979	{
1980		if (nth != 'last')
1981			nth = nth.substr(0,1);					//drop th; keep number
1982		for (day=1;day<=daysInMonth;day++)
1983		{
1984			theDate.setDate(day);
1985			if (theDate.getDay() == dayOfWeek)
1986			{
1987				if (nth == 'last')
1988					dateTime = theDate.getTime();
1989				else if (nth == ++nthCount)
1990					return RZdate(theDate);
1991			}
1992		}
1993		return RZdate(dateTime);
1994	}
1995}
1996/*---------------------------------------------------------------------------------------------
1997Return various formatted strings for RZdate() object and save for future reference.
1998---------------------------------------------------------------------------------------------*/
1999RZdate.prototype.getFormatted = function(isForceFormat)
2000{
2001	//----- Initialize return object; formats shown below replaced by subsequent code:
2002	var formatted = {									//all dates are blank if no date component...
2003		briefDate:		'mm-dd-yy',						//2 digits for month, day & year
2004		shortDate:		'mm-dd-yyyy',					//2 digits for month & day; 4 digit year
2005		longDate:	 	'wwww mmmm d, yyyy',			//full day name & month name e.g. Monday January
2006		smartDate:		'mmm d, yyyy',					//3 char day of week (use substr(4) to omit or replace)
2007		revizeDate:		'yyyy-mm-dd',					//4 digit year, 2 digit month and day
2008
2009		month:			'mm',							//2 digit month 01-12
2010		minutes:		'MM',							//2 digit minutes
2011		seconds:		'ss',							//2 digit seconds
2012		hours:			'h',							//1 or 2 digit hour; 12 hr clock
2013		hoursPadded:	'h',							//hours with &nbsp;&nbsp prefix if single digit
2014														//single digit prefixed with ' &nbsp'
2015														//Noon for 12:00:00; Midnight for 00:00:00
2016
2017		hours12:		'hh',							//2 digit hours 12 hour format
2018		hours24:		'hh',							//2 digit hours 24 hour clock
2019		ampm:			'am/pm',						//am or pm
2020
2021		day:			'dd',							//2 digit day 01-31
2022		daySuffix:		'ST',							//st, nd ... th
2023		dayLong:		'dST',							//1-2 digit: 1st, 2nd.. 30th
2024
2025		dayName:     	'WWWW',							//full name of day e.g. Monday
2026		monthName:   	'mmmm',							//full name of month e.g. January
2027
2028		briefTime: 		'[hh:MM am/pm]',				//2 digits for hr; seconds always dropped
2029														//blank if timePart() == 0
2030														//Noon for 12:00:00; 12 hr clock
2031		shortTime: 		'hh:MM[:ss]',					//always 2 digits for hour; seconds dropped if 0
2032														//24 hour clock (hours are 00-23)
2033		longTime: 		'hh:MM:ss am/pm',				//2 digits for hr; seconds always displayed
2034														//Noon for 12:00:00; Midnight for 00:00:00
2035		miniTime:		'hh:MM{:ss] am/pm',				//same as longTime except seconds dropped if 0
2036														//Noon for 12:00:00; Midnight for 00:00:00
2037		ampmTime: 		'hh:MM{:ss] am/pm',				//same as longTime except seconds dropped if 0
2038														//does not use noon or midnight
2039		smartTime:    	' h:MM:ss am/pm',				//blank if no timePart(); single digit padded
2040														//Noon for 12:00:00; seconds dropped if 0
2041														//12 hour clock
2042		timeZone:		'zzzz',							//as shown in new Date().toString()
2043														//varies by browser
2044
2045		briefDateTime: 	'mm-dd-yy [hh:mm am/pm]', 		//time dropped if timePart() = 0
2046														//Noon for 12:00; seconds always dropped
2047		shortDateTime:	'mm-dd-yyyy hh:MM:ss',		    //time always displayed with seconds
2048													    //24 hour clock
2049		longDateTime:  	'wwww mmm d, yyyy hh:MM:ss zzzz', //time dropped if timePart() = 0
2050														//Noon for 12:00:00
2051		smartDateTime: 	' d, yyyy [h:mm:ss am/pm zzzz]', //time dropped if timePart() = 0
2052														//Noon for 12:00:00
2053		revizeDateTime:	'yyyy-mm-dd hh:MM:ss',			//time dropped if timePart() = 0
2054														//hh is 24 hour time; seconds dropped if 0
2055		shortDateBriefTime: '',
2056		formattedTime:  0								//getTime() value used for all formatted
2057	}
2058	// if not forcing formatting and date has not changed since last call, no need to run again
2059	if (!isForceFormat && this.formatted && this.formatted.formattedTime == this.getTime())
2060		return;
2061
2062	formatted.formattedTime == this.getTime();			//remember value last used for formatted
2063
2064	var day = this.getDate();
2065	var month = this.getMonth();
2066	var year = this.getFullYear()
2067	var dayOfWeek = this.getDay();
2068
2069	// day suffix e.g. 1st, 2nd. 3rd, 4th ... 30th
2070	var suffix = ''
2071	if (day == 1 || day == 21 || day == 31)
2072		suffix = 'st';
2073	else if (day == 2 || day == 22)
2074		suffix = 'nd';
2075	else if (day == 3 || day == 23)
2076		suffix = 'rd';
2077	else
2078		suffix = 'th';
2079	formatted.daySuffix = suffix;
2080	formatted.dayLong = day + suffix;
2081
2082	// Full dayName & monthName (use substr(0,3) for short names
2083	formatted.dayName = this.getDayName();
2084	formatted.monthName = this.getMonthName();
2085
2086	//----- Extract time zone from Date.toString() function
2087	//		chrome: Sun Mar 18 2012 23:21:58 GMT-0400 (Eastern Daylight Time)
2088	//		FF:		Sun Mar 18 2012 23:42:25 GMT-0400 (Eastern Daylight Time)
2089	//		IE7-9:  Sun Mar 18 23:21:14 EDT 2012 (may show EST not EDT)
2090	var pattern = new RegExp( '(\\w*' + day + ')(.*)('+year+')' );	//for IE format...
2091	formatted.timeZone = this.toString();								//...move year before timezone
2092	formatted.timeZone = RZtrim(formatted.timeZone.replace(pattern,'$1, $3$2'));
2093	var results = formatted.timeZone.match(/.*\d (.*)$/mi);			//find time zone at end
2094	if (results)
2095		formatted.timeZone = results[1];
2096	else
2097		formatted.timeZone = '';
2098
2099	//----- Dates...
2100	formatted.month = RZright('0'+(month+1),2);
2101	formatted.day = RZright('0'+day,2);
2102
2103	if (month == 0 && day == 1 && year == 1970)		//no date component
2104	{
2105		formatted.briefDate = '';
2106		formatted.shortDate = '';
2107		formatted.longDate = '';
2108		formatted.smartDate = '';
2109		formatted.revizeDate = '';
2110	}
2111	else
2112	{
2113		formatted.briefDate = formatted.month + '-' + formatted.day + '-' + (year+'').substr(2);
2114		formatted.shortDate = formatted.month + '-' + formatted.day + '-' + year;
2115		formatted.longDate = formatted.dayName + ' ' + formatted.monthName + ' '  + day + ', ' + year;
2116		formatted.smartDate = formatted.dayName.substr(0,3) + ' '
2117						    + formatted.monthName.substr(0,3) + ' '  + day + ', ' + year;
2118		formatted.revizeDate = year + '-' +  formatted.month + '-' + formatted.day;
2119	}
2120
2121	//----- Time formats...
2122	var hours = this.getHours();
2123	var minutes = this.getMinutes();
2124	var seconds = this.getSeconds();
2125
2126	var ampm = (hours < 12) ? ' am' : ' pm';
2127	formatted.ampm = ampm.substr(1);
2128	formatted.minutes = RZright('0' + minutes,2);
2129	formatted.seconds = RZright('0' + seconds,2);
2130
2131	formatted.hours24 = RZright('0' + hours,2);
2132	formatted.hours = hours <= 12 ? hours : hours -= 12;
2133	formatted.hours12 = RZright('0'+ (hours==0?'12':hours), 2);
2134	formatted.hoursPadded = (hours.toString().length == 1 ? '&nbsp;&nbsp;' : '') + hours;
2135
2136	formatted.briefTime = ((hours + minutes) > 0)
2137					    ? formatted.hours12 + ':' + formatted.minutes + ampm : '';
2138	formatted.briefTime = formatted.briefTime.replace(/12:00 pm/i,'Noon');
2139
2140	formatted.shortTime = formatted.hours24 + ':' + formatted.minutes
2141					    + (seconds > 0 ? ':' + formatted.seconds : '');
2142
2143	formatted.longTime  = formatted.hours12 + ':' + formatted.minutes + ':' + formatted.seconds + ampm;
2144	formatted.longTime  = formatted.longTime.replace(/12:00:00 am/i,'Midnight');
2145	formatted.longTime  = formatted.longTime.replace(/12:00:00 pm/i,'Noon');
2146
2147	formatted.ampmTime  = formatted.hours12 + ':' + formatted.minutes + ampm;
2148
2149	formatted.miniTime  = formatted.ampmTime.replace(/12:00 am/i,'Midnight');
2150	formatted.miniTime  = formatted.miniTime.replace(/12:00 pm/i,'Noon');
2151
2152	formatted.smartTime = ((hours + minutes + seconds) > 0)
2153					    ? (formatted.hoursPadded + ':' + formatted.minutes + ':' + formatted.seconds) + ampm : '';
2154	formatted.smartTime = formatted.smartTime.replace(/:00 /i,' ');			//drop seconds if zero
2155	formatted.smartTime = formatted.smartTime.replace(/12:00 pm/i,'Noon');
2156
2157	//----- Combine Date and Time
2158	formatted.briefDateTime = formatted.briefDate   + (formatted.briefTime ? ' ' + formatted.briefTime : '');
2159	formatted.shortDateTime = formatted.shortDate   + ' ' + formatted.shortTime;
2160	formatted.longDateTime = formatted.longDate     + ' ' + formatted.longTime;
2161	formatted.smartDateTime = formatted.smartDate   + (formatted.smartTime ? ' ' + RZtrim(formatted.smartTime) : '');
2162	formatted.revizeDateTime = formatted.revizeDate + (formatted.briefTime ? ' ' + formatted.briefTime : '');
2163
2164	// trim leading space in case there was no date or time component
2165	formatted.briefDateTime = RZtrim(formatted.briefDateTime);
2166	formatted.shortDateTime = RZtrim(formatted.shortDateTime);
2167	formatted.longDateTime = RZtrim(formatted.longDateTime);
2168	formatted.smartDateTime = RZtrim(formatted.smartDateTime);
2169	formatted.revizeDateTime = RZtrim(formatted.revizeDateTime);
2170
2171	// Additional date & time combinations
2172	formatted.shortDateBriefTime = RZtrim(formatted.shortDate + ' ' + formatted.briefTime);
2173
2174	this.string = this.toString();	//update value shown in debugger
2175	this.formatted = formatted;
2176	return formatted;
2177}
2178/*---------------------------------------------------------------------------------------------
2179Called to parse a Date string
2180
2181The JavaSript Date.Parse method is used to accept all valid date formats.  Only problem
2182is two digits years (99) are intrepreted as 20th century dates (1999),  We counteract this
2183by adding 100 to the year unless the 4 digit date string exists in the input date string.
2184
2185Parameters:
2186	fieldValue-	String representing a date in any standard format
2187
2188Returns:
2189	returns 	null if invalid date;
2190				blank if no date specified;
2191				formatted date: yyyy-mm-dd hh:mm:ss
2192---------------------------------------------------------------------------------------------*/
2193function RZparseDate(fieldValue)
2194{
2195	RZparseDate.date = null;
2196
2197	if (fieldValue == '') return '';
2198	if (typeof(fieldValue) == 'undefined' || fieldValue == null) return null;
2199
2200	if (fieldValue.constructor == Date)
2201		fieldValue = fieldValue.toString();
2202	if (typeof fieldValue != 'string')
2203		fieldValue = fieldValue + '';
2204
2205	var fieldValueOriginal = fieldValue;
2206	fieldValue = fieldValue.split('-').join('/');	//Chrome, Firefox does not accept -
2207	var dateSeconds = Date.parse(fieldValue);
2208
2209	// may have incorrectly changed dash in: "Mon Jan 09 2012 12:28:37 GMT-0500 (EST)"
2210	// try above legacy conversion first for safe backward compatibility
2211	if(isNaN(dateSeconds) || fieldValue.search('GMT/') != -1)
2212	{							// <digit>-<digit> --> <digit>/<digit>
2213		fieldValue = fieldValueOriginal.replace(/(\d)-(\d)/g,'$1/$2');
2214		dateSeconds = Date.parse(fieldValue);
2215	}
2216
2217	// try time only with today's date
2218	if(isNaN(dateSeconds))
2219	{							// <digit>-<digit> --> <digit>/<digit>
2220		fieldValue = fieldValueOriginal.replace(/(\d)-(\d)/g,'$1/$2');
2221		if (fieldValue.indexOf('/') == -1 && fieldValue.indexOf(':') != -1)
2222		{
2223			fieldValue = RZparseDate(new Date()+'').substr(0,11) + fieldValue;
2224			fieldValue = RZparseDate(fieldValue);
2225			if (RZparseDate.date) dateSeconds = 0;	//valid date/time
2226			fieldValue = RZparseDate.date;
2227			RZparseDate.date = null;				//restore default
2228		}
2229	}
2230
2231	if( isNaN(dateSeconds) ) return null;			//bad date
2232
2233	//----- Treat dates of the form 01 as 2001
2234	var theDate = new Date(fieldValue)
2235	var year = theDate.getYear()					//js 1.1 compatible
2236	if (year < 1000) year += 1900					//broswer quirks
2237	if (year < 2000)
2238	{
2239		//see if the 4 digit year matches a string in the date field
2240		//if not then they we need to add 100 to the year
2241		if (fieldValue.indexOf(year.toString()) == -1)
2242			year += 100
2243	}
2244	var theMonth = theDate.getMonth() + 1
2245	var theDay = theDate.getDate()
2246	fieldValue = year.toString() + '-'
2247			   + RZright('0' + theMonth, 2)
2248			   + '-'
2249			   + RZright('0' + theDay, 2)
2250	var hour = theDate.getHours()
2251	var minutes = theDate.getMinutes()
2252	var seconds = theDate.getSeconds()
2253	fieldValue += ' ' + RZright('0' + hour.toString(), 2)
2254			   +  ':' + RZright('0' + minutes.toString(), 2)
2255			   +  ':' + RZright('0' + seconds.toString(), 2)
2256
2257	//----- Save Date object with correct year and time to milliseconds
2258	RZparseDate.date = new Date(year,theDate.getMonth(),theDay,
2259								hour,minutes,seconds,theDate.getMilliseconds());
2260
2261	//----- return date/time formatted for saveing int Revize db yyyy-mm-dd hh:mm:ss
2262	return fieldValue;
2263}
2264/*---------------------------------------------------------------------------------------------
2265Called to validate Date field
2266
2267Parameters:
2268	fieldname-	field object containing date to validate
2269
2270Returns: true if valid date; otherwise false
2271---------------------------------------------------------------------------------------------*/
2272function RZcheckdate( thisField )
2273{
2274	var fault = false
2275	var dateString = RZparseDate( thisField.value )
2276	if (dateString == null)
2277	{
2278		fault = true
2279		alert( "I'm sorry.  You have not entered a valid Date\n\n"
2280		 + "Examples: 12/12/2011 or 01-01-2012" )
2281		thisField.focus()
2282	}
2283	else
2284	{
2285		var theDate = new Date(dateString)
2286		if (theDate.getFullYear() < 1900)
2287		{
2288			if ( !confirm( 'You have entered a date prior to 1900\n\n'
2289			             + 'Is this correct?' ) )
2290			{
2291				fault = true
2292				thisField.focus()
2293			}
2294		}
2295	}
2296	return !fault		//cancels save if error
2297}
2298/*---------------------------------------------------------------------------
2299Setup or lookup module permits.
2300-----------------------------------------------------------------------------
2301Used by RZaction() and RZlogin to determine if buttons or html should be
2302displayed based on known permissions.
2303
2304If RZpermits() is called with no parameters, the following setup occures:
2305
2306	Get all module permissions determined at login from RZpermits cookie
2307	Permits (crud) are stored in the cookie as: global=crud,links=r
2308
2309	RZ.permits.modules will be loaded with individual module permissions
2310	Following example above:
2311		RZ.permits.modules.global='crud';
2312		RZ.permits.modules.links='r'
2313
2314Currently only the links module permissions are stored at after sucessful
2315login by the control_panel.jsp page (which is only used by the revizelogin
2316template).
2317
2318Parameters:
2319	module-			Name of module to check
2320	requirePermits-	One of more of the following characters: (crud)
2321					c = Create
2322					r = Read
2323					u = Update
2324					d = Delete
2325
2326TODO: Look up all module permissions, store in future control_panel window
2327
2328Returns:
2329
2330If RZpermits() is called with a module and permissions, the specified module
2331object is checked for the requested permissions returning true or false.
2332
2333If there is no object for the specified module, the permissions are not known
2334therefore the function returns true.
2335----------------------------------------------------------------------------*/
2336function RZpermits(module,requiredPermits)
2337{
2338	if (RZ.isauthenticationactive == false)
2339		return true
2340
2341	//----- If setup call...
2342	else if (typeof module == 'undefined')
2343	{
2344		//----- Module permissions
2345		RZ.message = 'none defined';
2346		var permits = RZgetCookieValue('RZpermits')
2347		if (permits != '')
2348		{
2349			// temporarily support both delimeter formats
2350			var permitsArray = permits.indexOf("|") > -1 ? permits.split('|') : permits.split(',')
2351
2352			RZ.message = '';
2353			for (var i=0; i<permitsArray.length; i++)
2354			{
2355				var module_permit = permitsArray[i].split(':')
2356				RZ.permits.modules[module_permit[0]] = module_permit[1]
2357				if (module_permit[1] == '') module_permit[1] = '-none-'
2358				RZmsgAdd(module_permit[0], ' ' + module_permit[1])
2359			}
2360		}
2361		RZtrace('Module Permissions',RZ.message)
2362
2363		//----- Page permissions
2364		RZ.message = ''
2365		RZmsgAdd( 'RZ.page_key       ', ' ' + RZ.page_key )
2366		if (RZ.pagetype == 'template')
2367		{
2368			RZmsgAdd( 'RZ.page_role      ', ' ' + RZ.page_roles )
2369			RZmsgAdd( 'RZ.page_users     ', ' ' + RZ.page_users )
2370		}
2371		else
2372		{
2373			RZmsgAdd( 'RZ.permissions_module  ', ' ' + RZ.permissions_module )
2374			RZmsgAdd( 'RZ.permissions_parent  ', ' ' + RZ.permissions_parent )
2375			RZmsgAdd( 'RZ.permissions_template', ' ' + RZ.permissions_template )
2376		}
2377		RZtrace('Page Permissions',RZ.message)
2378	}
2379
2380	//----- Check permissions...
2381	else
2382	{
2383		//----- Assume full permissions if module not listed in permits
2384		var modulePermits = 'crud';
2385		if (typeof RZ.permits.modules[module] != 'undefined')
2386			modulePermits = RZ.permits.modules[module]
2387		var requiredPermitsOptions = requiredPermits.split('|')
2388
2389		var status = true
2390		for (var j=0; j<requiredPermitsOptions.length; j++)
2391		{
2392			var optionStatus = true
2393			for (var i=0; i<requiredPermitsOptions[j].length; i++)
2394			{
2395				var ch = requiredPermitsOptions[j].substring(i,i+1).toLowerCase()
2396					if (modulePermits.indexOf(ch) == -1)
2397					{
2398						optionStatus = false
2399						break;
2400					}
2401			}
2402			status = optionStatus
2403			if (optionStatus == true) break;
2404		}
2405
2406		RZ.message = ''
2407		RZmsgAdd( 'module', module)
2408		RZmsgAdd( 'module permits', modulePermits)
2409		RZmsgAdd( 'permits required', requiredPermits)
2410		RZmsgAdd( 'status', status)
2411		RZtrace('Permissions Checked', RZ.message)
2412		return status;
2413	}
2414}
2415/*---------------------------------------------------------------------------------------------
2416Determine current page permissions
2417---------------------------------------------------------------------------------------------*/
2418function RZpagepermission()
2419{
2420	RZ.roles = ''
2421	RZ.username = RZgetCookieValue('RZusername',RZ.page.domain)
2422	RZ.hashed_username = RZgetCookieValue('RZhashedusername',RZ.page.domain)
2423	if (RZ.username != '') RZ.roles = RZgetCookieValue('RZroles')
2424
2425	RZ.pagepermission = false;
2426
2427	//----- Get login username and roles
2428	var roles = '|' + RZ.roles + '|'
2429	var username = '|' + RZ.username + '|'
2430	var hashed_username = '|' + RZ.hashed_username + '|'
2431
2432	RZ.browserdev = (roles.indexOf('@browserdev') != -1);
2433
2434	if (RZ.isauthenticationactive == false)
2435		RZ.pagepermission = true;		//all permits if authentication disabled
2436
2437	else if (username == '|')
2438		RZ.pagepermission = false;	//do nothing (not logged in)
2439
2440	else if( roles.indexOf( '|superuser|' ) != -1
2441	||  roles.indexOf( '|administrator|') != -1)
2442		RZ.pagepermission = true;
2443
2444	else if (RZ.page_roles == '' && RZ.page_users == '')
2445		RZ.pagepermission = true;		//no users or roles defined so everyone has access
2446
2447	else
2448	{
2449		if ( ('|'+RZ.page_users+'|').indexOf(username) != -1 || ('|'+RZ.page_users+'|').indexOf(hashed_username) != -1 )
2450			RZ.pagepermission = true;
2451		else
2452		{
2453			var rolesArray = roles.split('|')
2454			for (var i in rolesArray)
2455			{
2456				if ( rolesArray[i] == '' ) continue;
2457				if ( ('|'+RZ.page_roles+'|').indexOf('|'+rolesArray[i]+'|') != -1)
2458				{
2459					RZ.pagepermission = true;
2460					break;
2461				}
2462			}
2463		}
2464	}
2465	return
2466}
2467/*---------------------------------------------------------------------------
2468Calls either addEventListener or attachEvent if defined
2469RZ.browsertype set to "standard", "non-standard" or "unknown"
2470
2471Example calls:
2472	RZeventadd(window, 'focus', function()
2473	{
2474		//do something
2475	});
2476	RZeventadd(form, 'submit', "validate('red,x=2')");
2477
2478	// FF (chrome?), specified function object (e.g. validate) must be defined
2479	// before RZeventAdd called (not required for above calling variations)
2480
2481	// On IE this form passes object as first argument (click event?)
2482	RZeventadd(form, 'submit', validate);
2483----------------------------------------------------------------------------*/
2484function RZeventadd(target, eventType, functionRef, capture)
2485{
2486    if (!capture) capture = false;
2487	if (eventType.substr(0,2) == 'on') eventType = eventType.substr(2);
2488	if (typeof target.addEventListener != "undefined")
2489    {
2490		// e.g. document.addEventListener("error", function, false);
2491        target.addEventListener(eventType, functionRef, capture);
2492        RZ.browsertype = "standards";
2493
2494    }
2495	else if (typeof target.attachEvent != "undefined")
2496	{
2497        target.attachEvent("on" + eventType, functionRef);
2498        RZ.browsertype = "non-standards";
2499    }
2500	else
2501	{
2502        RZ.browsertype = "unknown";
2503    }
2504}
2505/*---------------------------------------------------------------------------
2506Calls either removeEventListener or removeEvent if defined
2507
2508if (window.addEventListener) window.removeEventListener("focus", refresh, false);
2509else if (window.attachEvent) window.detachEvent("onfocus", refresh);   //IE
2510----------------------------------------------------------------------------*/
2511function RZeventremove(target, eventType, functionRef, capture)
2512{
2513    if (!capture) capture = false;
2514
2515	if (typeof target.addEventListener != "undefined")
2516        target.removeEventListener(eventType, functionRef, capture);
2517
2518	else if (typeof target.attachEvent != "undefined")
2519        target.detachEvent("on" + eventType, functionRef);
2520}
2521/*---------------------------------------------------------------------------------------------
2522Enable a new handler (append to current handler if one defined)
2523---------------------------------------------------------------------------------------------*/
2524function RZsetuphandler(handlerType,handlerFunction,isLast)
2525{
2526	//DCO 11-12-2015: MUST use event listeners when called by script before the body tag,
2527	//because body tag events MAY override (think IE) any body/window events defined here.
2528	var is = document.getElementsByTagName('body').length == 0;
2529
2530	//DCO 12-02-2015: if onload and no <body onload="...">, use listener for backward
2531	//compatibilty with webgen/jquery/scripts.js (which overrides window.onload event)
2532	if (!is && handlerType.indexOf('onload') != -1 && !window.onload) is = true;
2533	if (is)
2534	{
2535		var fn = typeof(handlerFunction) == 'function' ? handlerFunction
2536			   : new Function('', handlerFunction.toString());
2537		if (window.addEventListener) window.addEventListener(handlerType.substr(2), fn, false);
2538		else if (window.attachEvent) window.attachEvent(handlerType, fn);   //IE
2539		else return false;	//safety for unexpected
2540		return true;
2541	}
2542
2543	var functionStr = window[handlerType]; //existing handler function if defined
2544	var parameters = ""; //parameters string
2545	var pos = -1; //position of '{'
2546	var pos1 = -1; //position of '('
2547	var pos2 = -1; //position of ')'
2548
2549	if ( functionStr != null )
2550	{
2551		functionStr = functionStr.toString()
2552		pos = functionStr.indexOf( '{' );
2553		pos1 = functionStr.indexOf( '(' );
2554		pos2 = functionStr.indexOf( ')' );
2555	}
2556
2557	//Check if parameters exist.  If they do, then append them to the current
2558	//parameters string.
2559	if ( pos1 >= 0  && pos2 >= 0 )
2560		parameters += functionStr.substring( pos1+1, pos2 );
2561
2562	//Check if the call to Function() exists.  If it does, then append a call to
2563	//new handler to it at the beginning; otherwise, just call new handler.
2564	if ( pos < 0 )
2565		functionStr = handlerFunction + ';'
2566
2567	else if (isLast)	//DCO 10-20-2014
2568		functionStr = functionStr.substring( pos+1, functionStr.length-1 )	//existing function
2569					+ '\n' + handlerFunction + ';'
2570	else
2571		functionStr = handlerFunction + ';'		//appended function call
2572					+ functionStr.substring( pos+1, functionStr.length-1 );	//existing function
2573
2574	//----- Set new handler and make trace entry
2575	window[handlerType] = new Function( parameters, functionStr );
2576
2577	RZtrace("Initialized " + handlerType + " Handler", window[handlerType].toString() )
2578	return true;
2579}
2580/*-----------------------------------------------------------------------------------
2581  Implements button action operations (e.g. forward, save, delete, new, exit)
2582  Either a button or image is displayed on the page if a valid user is
2583  authenticated via the login page. If security is disabled any username is
2584  allowed.
2585
2586  Normally code is generated to display button if authorized however if RZ.action=html
2587  function does not display button only returns html executed by specified button.
2588
2589  TODO:  Document remaining RZ.* variables
2590
2591  Parameters:
2592  action-		String representing type of action button (See Remarks)
2593  Parameters Format:
2594  <table 20c%>
2595  action         Button Types
2596  -------------  -----------------------------------------------
2597  editpage       "Edit this Page" calls -editform.jsp page
2598  editform       (same as above backward compatibility)
2599  editglobal     "Edit Globals" globals-editform.jsp
2600  \
2601  editlist       Edit this List (-editlist.jsp)
2602  exit           Exit Edit List page; return to caller
2603  newitem        Create new list item
2604  new            (same as above backward compatibility)
2605  edititem       Edit an existing list item
2606  edit           (same as above backward compatibility)
2607  delete         Delete an existing list item
2608  deleteitem     (same as above backward compatibility)
2609  \
2610  save           Edit form save button
2611  cancel         Edit form or Edit List cancel button
2612  \
2613  history        Edit form current record history
2614  editversion    Selects record to edit on history
2615  copyversion    Copy record on history as new version
2616  newversion     Create new version of current record
2617  permissions    opens permissions window
2618  </table>
2619
2620  RZ Input Parameters:
2621  RZ.module-      Name of module
2622  RZ.recordid-	  recordid to process
2623  RZ.nexturl-     url of page recieving control from button
2624  RZ.popupwidth-  width of popup window
2625  RZ.popupheight- height of popup window
2626  RZ.popupscroll- indicate if popup window has scroll bars
2627  RZ.img-         if non\-blank html displayed for button
2628  				  (usually an image tag but can be any html)
2629  RZ.caption-     Label of input type=button
2630  				  (image button used if RZ.img not blank)
2631  RZ.tagname-     If non\-blank specified form button name)
2632  RZ.parentkey-   If not blank, specified parent key rather than letting Revize
2633  				  automatically determine.
2634  RZ.action-	  =html, does not display button
2635                  =false TODO
2636                  =true TODO
2637
2638  Returns:  script executed when button clicked; If RZ.action
2639  -----------------------------------------------------------------------------------*/
2640function RZaction(action)
2641{
2642
2643	if (RZ.nexturl == null || RZ.nexturl == 'null' ) RZ.nexturl = ''
2644	if (RZ.popupwidth == null || RZ.popupwidth == 'null') RZ.popupwidth = ''
2645	if (RZ.popupheight == null || RZ.popupheight == 'null') RZ.popupheight = ''
2646	if (RZ.popupscroll == null || RZ.popupscroll == 'null') RZ.popupscroll = ''
2647
2648	var script=''
2649	var html=''
2650	var anchor = ''
2651	var level = ''
2652	var buttonName=''
2653	var requiredModule = RZ.module
2654	var requiredPermits = ''
2655	var options = ''
2656	var recordid = ''
2657	var parentkey = ''
2658	var msg = ''
2659
2660	//----- Create specific JavaScript executed when button clicked
2661	//		(based on type of action requested)
2662	switch ( action.toLowerCase() )
2663	{
2664
2665		case "editlist":
2666		{
2667			requiredPermits = 'c|u|d'
2668			if (RZ.tagname == '') RZ.tagname = 'RZeditlist';
2669
2670			//-----delete below to always use new code-----\\
2671			if (!EZ.isFeature("EZ"))
2672			script = "RZcalleditlist("
2673				   + "'" + RZ.nexturl + "',"
2674				   + "'" + RZ.popupwidth + "',"
2675				   + "'" + RZ.popupheight + "',"
2676				   + "'" + RZ.popupscroll + "', "
2677				   + "'" + RZ.set + "')"
2678			else
2679			//-----delete above to always use new code-----//
2680
2681			// build call of form:	RZeditlist( {nexturl:RZ.nexturl, ..., set:RZ.set});';
2682			script = 'RZeditlist({'
2683				   + EZ.concat([
2684								RZ.nexturl     ? "nexturl: '"    + RZ.nexturl     + "'" : '',
2685								RZ.module      ? "module: '"     + RZ.module      + "'" : '',	//added 12-15-2015
2686								RZ.popupwidth  ? "popupwidth: '" + RZ.popupwidth  + "'" : '',
2687								RZ.popupheight ? "popupheight:'" + RZ.popupheight + "'" : '',
2688								RZ.popupscroll ? "popupscroll:'" + RZ.popupscroll + "'" : '',
2689								RZ.set ? "set:'" + RZ.set.replace(/'/g, "\\'") + "'" : ''
2690								], ',')
2691				   + '})';
2692			break;
2693		}
2694
2695		//----- Common code for all new and edit actions
2696		case "new":
2697		case "newitem":
2698			level = RZ.linklevel;
2699			if (!RZ.linklevel && RZ.module)
2700				level = RZ.nextseq.listid ? RZ.nextseq.listid : 1;
2701
2702		case "edit":
2703		case "edititem":
2704		case "editform":
2705		case "editpage":
2706		case "editglobal":
2707
2708			recordid = RZ.recordid
2709
2710			//----- Format edit form call
2711			//		Note: without the isNaN test, remaining JavaScript not executed
2712			if ( !isNaN(RZ.recordid) || RZ.recordid.toLowerCase() != 'no items in list' )
2713			{
2714				if(action == 'edit' || action == 'edititem')
2715				{
2716					if (RZ.parentkey != '')
2717						parentkey = RZ.parentkey
2718					else
2719						parentkey = RZlevelQualifier(RZ.linkname,RZ.linklevel,RZ.recordid)
2720				}
2721				else if(action == 'new' || action == 'newitem')
2722				{
2723					parentkey = RZ.parentkey;	//non-blank if specified
2724				}
2725
2726
2727				if(action == 'new' || action == 'newitem'
2728				|| action == 'edit' || action == 'edititem')
2729				{
2730					//----- If page permissions warnings are enabled...
2731					if (RZcheckoptions(RZ.permissions_options,"warnings"))
2732					{
2733						// Display icon if module not specified on new or edit item button
2734						if (RZ.module == '' && RZ.template != '*none*')
2735						{
2736							msg = "'" + RZpermissionWarning(action,'') + "'"	//module req msg
2737							html += '<a href="JavaScript:RZpagemessage(' + RZreplace(msg,'\n','--') + ')">'
2738								 +  '  <img src="/revize/images/warning-button.gif" border=0>'
2739								 +  '</a>'
2740						}
2741
2742						// Display hidden icon in case template can not be determineed
2743						else if (RZ.template == '' && RZ.linkname == '')
2744						{
2745							RZ.html = '<span id="RevizeButtonWarning' + RZ.icons.length + '"'
2746									+ ' style="visibility:hidden">'
2747									+ '  <a href="JavaScript:RZiconMessage(\''+ action +'\','
2748									+ RZ.icons.length + ')"'
2749									+ '   ><img src=\"/revize/images/warning-button.gif\"'
2750									+ '   border=0 alt="Click for Details"></a>'
2751									+ '</span>'
2752							//RZ.html = RZ.html.replace(/</g,'&lt;')	//display html
2753							document.write( RZ.html )
2754							RZ.icons[RZ.icons.length] = RZ.module
2755						}
2756					}
2757				}
2758
2759				script = "RZedit( "
2760				       + "'" + RZ.recordid + "', "
2761				       + "'" + RZ.nexturl + "', "
2762				       + "'" + RZ.popupwidth + "',"
2763				       + "'" + RZ.popupheight + "',"
2764				       + "'" + RZ.popupscroll + "', "
2765				       + "'" + RZ.set + "', "
2766				       + "'" + RZ.module + "',"
2767				       + "'" + RZ.field + "',"
2768				       + "'" + RZ.linkname + "',"
2769				       + "'" + action + "',"
2770				       + "'" + RZ.template + "',"
2771				       + "'" + level + "',"
2772				       + "'" + parentkey + "')"
2773			}
2774
2775			// if setting a recordid, ignore the recordid.value
2776			if ( RZ.set.indexOf('_recordid=') >= 0 ) RZ.recordid = ''
2777
2778			//----- Button name dependent on action
2779			if (RZ.tagname == '')
2780			{
2781				switch (action)
2782				{
2783					case "new":
2784					case "newitem":
2785						RZ.tagname = 'RZnewitem';
2786						requiredPermits = 'c'
2787						anchor = 'Revize_' + RZ.module + '[new]'
2788
2789						break;
2790					case "edit":
2791					case "edititem":
2792						RZ.tagname = 'RZedititem' + RZ.recordid;
2793						requiredPermits = 'u'
2794						anchor = 'Revize_' + RZ.module + '[' + RZ.recordid + ']'
2795						break;
2796					case "editform":
2797					case "editpage":
2798						RZ.tagname = 'RZeditpage';
2799						requiredPermits = 'c|u'
2800						break;
2801					case "editglobal":
2802						RZ.tagname = 'RZeditglobal';
2803						requiredPermits = 'c|u'
2804						break;
2805				}
2806			}
2807			break;
2808
2809		case "exit":
2810			if(typeof RZ.nexturl != 'undefined' && RZ.nexturl != '' && RZ.nexturl != 'NEXTURL')
2811				script = "location='" + RZ.nexturl + "'";
2812			else
2813				script = "RZback( 'RZeditListReturnUrl' );"
2814			if (RZ.tagname == '') RZ.tagname = 'RZexit';
2815			break;
2816
2817		case "delete":
2818		case "deleteitem":
2819			if (RZ.recordid.toLowerCase() != 'no items in list')
2820			{
2821				//script = "RZrecordDelete( '" + RZ.recordid +  "', '" + RZ.module + "' );"
2822				script = "RZdelete( '" + RZ.recordid +  "', '" + RZ.module
2823				if (RZ.nexturl != '') script += "', '" + RZ.nexturl
2824				script +=  "' );"
2825			}
2826			if (RZ.tagname == '') RZ.tagname = 'RZdeleteitem';
2827			requiredPermits = 'd'
2828			break;
2829
2830		case "save":
2831			script = "RZsave( document.XMLForm, '" + RZ.nexturl + "' );"
2832			if (RZ.tagname == '') RZ.tagname = 'RevizeSave';
2833			break;
2834
2835		case "save_as_draft":
2836			script = "RZsave_as_draft( '" + RZgetoption(RZ.options,'workflow') + "' );"
2837			if (RZ.tagname == '') RZ.tagname = 'RevizeSaveAsDraft';
2838			break;
2839
2840		case "cancel":
2841			script = "RZeditFormCancel();"
2842			if (RZ.tagname == '') RZ.tagname = 'RevizeCancel';
2843			break;
2844
2845		case "history":
2846			if (RZ.nexturl != '')
2847				options += 'nexturl='+RZ.nexturl
2848			if (RZ.field != '')
2849				options += 'fields='+RZ.field
2850			script = "RZhistory("
2851			       + "'" + RZ.module + "',"
2852			       + "'" + RZ.recordid + "', "
2853			       + "'" + RZ.version + "', "
2854			       + "'" + options + "') "
2855			if (RZ.tagname == '') RZ.tagname = 'RevizeHistory';
2856			break;
2857
2858		case "permissions":
2859			requiredModule = RZ.permissions_module
2860			requiredPermits = 'u'
2861			if (RZ.nexturl != '')
2862				options += 'nexturl='+RZ.nexturl
2863			if (RZ.linkname != '')
2864				options += 'linkname='+RZ.linkname
2865			if (RZ.module != '')
2866				options += 'module='+RZ.module
2867			if (RZ.object != '')
2868				options += 'object='+RZ.object
2869
2870			// if standard permissions buttom, treat as "Admin Panel"
2871			var isAdminPanel = true;
2872			if(RZcheckoptions(RZ.webspacedesc,"noadminpanel"))
2873			{
2874				isAdminPanel = false;
2875			}
2876
2877			if (!options && isAdminPanel
2878			&& (RZ.img.indexOf('src="images/edit/permissions.jpg"') != -1
2879			|| RZ.img.indexOf('src="images/edit/permissions.gif"') != -1))
2880			{
2881				script = "void(0);";
2882				requiredModule = '';
2883				RZ.img = RZ.img.replace(/src="images\/edit\/permissions.jpg"/,'src="/revize/images/edit/admin_panel.jpg"');
2884				RZ.img = RZ.img.replace(/src="images\/edit\/permissions.gif"/,'src="/revize/images/edit/admin_panel.jpg"');
2885				RZ.img = RZ.img.replace(/alt="Permissions"/,'alt="Admin Panel" id="RZadminwinButton" onmouseup="RZadminwin()"');
2886			}
2887			// if permissions active
2888			else if (RZ.permissions_module != '')
2889				script = "RZpermissions("
2890					   + "'" + RZ.set + "',"
2891					   + "'" + options + "') "
2892
2893			if (RZ.tagname == '') RZ.tagname = 'RevizePermissions';
2894			break;
2895
2896		case "copyversion":
2897				options += ',copy'
2898		case "newversion":
2899		case "editversion":
2900			if (RZ.nexturl != '')
2901				options += 'nexturl='+RZ.nexturl
2902			script = "RZeditversion("
2903			       + "'" + RZ.module + "',"
2904			       + "'" + RZ.version + "', "
2905			       + "'" + options + "') "
2906			//TODO: perhaps button should be displayed and message if clicked.
2907			if (RZ.editnextversion == '') script = ''	//new record - no history
2908			if (RZ.tagname == '') RZ.tagname = 'RevizeVersion';
2909			break;
2910
2911		default:
2912			script = "RZalert('Unknown or Invalid Revize Action Request');"
2913	}
2914
2915	//----- Build html containing script (image or button version)
2916	if (script == '')
2917		html = ''
2918	else
2919	{
2920		if (RZ.script != '')
2921		{
2922			//----- Test results of user specified script via conditional operator
2923			//		so RZ.script code can cancel the button by returing false
2924			//
2925			// 			e.g. if (!user script)?donothing:button script;
2926			//
2927			if (RZright(RZ.script,1) != ';') RZ.script += ';'
2928			script = 'RZ.results=' + RZ.script
2929			       + '(!RZ.results && typeof RZ.results != \'undefined\')?void(0):'
2930			       + script;
2931		}
2932
2933		if (RZ.img != "")
2934		{
2935			html += '<a href="javascript:' + script + '">' + RZ.img + '</a>'
2936
2937			// show the help button after the adminpanel button
2938			if (RZ.img.indexOf('/revize/images/edit/admin_panel.jpg') != -1)
2939				html += '&nbsp;<a href="http://cms4.revize.com/revize/supportrevize/revize_faq.php" target="_new">'
2940					  + '<img src="../images/edit/help.jpg" alt="Help" border="0" /></a>';
2941		}
2942		else
2943		{
2944			if (RZ.caption == '') RZ.caption = 'Edit Page'
2945			html += '<input type="button" name="' + RZ.tagname + '" value="' + RZ.caption + '" '
2946				 + 'onClick="' + script + ';">'
2947		}
2948	}
2949
2950	//----- Add <br> and/or anchor tag to html if requested
2951	if (html != '')
2952	{
2953		if (RZ.options.indexOf('<br>') != -1) html += '<br>'
2954		if (anchor != '') anchor = '<a name="' + anchor + '"></a>'
2955		html += anchor
2956	}
2957
2958	//----- write html if logged into this webspace with correct permits
2959	//
2960	//		If RZ.active is blank or false, only write html if logged in with
2961	//		correct permissions for specified module and only return script
2962	//		when html written (default case).
2963	//
2964	//		If RZ.active is true, always write html
2965	//
2966	//		If RZ.active = 'html': return html instead of writting.  If not
2967	//		logged in or do not have permissions return blank for html.
2968
2969	var active = RZ.active;
2970	if (active == 'html')
2971	{
2972		if ( RZlogin('', requiredModule, requiredPermits, action) )
2973			script = html;
2974		else
2975			script = '';
2976	}
2977	//----- If action is blank (i.e. not used)...
2978	else if (active == '')	// RZ.active blank or false (note: blank returns false)
2979	{
2980		// write html if logged into this webspace & permits for module
2981		active = RZlogin( html, requiredModule, requiredPermits, action );
2982		if (!active) script = '';
2983	}
2984	//----- If RZ.action is true, write html without checks
2985	else if ( active == 'true'						// RZ.active is 'true'
2986	|| (typeof active == 'boolean' && active) )		// RZ.active is true
2987	{
2988		document.write(html);
2989	}
2990
2991	RZ.message = ''
2992	RZmsgAdd( "action", action )
2993    RZmsgAdd( "active", active )
2994	RZmsgAdd( "webspace", '\t' + RZ.webspace )
2995    RZmsgAdd( "module  ", '\t' + RZ.module )
2996    RZmsgAdd( "field   ", '\t' + RZ.field )
2997    RZmsgAdd( "linkname", '\t' + RZ.linkname )
2998    RZmsgAdd( "recordid", "\t(" + RZ.recordid + ")" )
2999    RZmsgAdd( "nexturl",  RZ.nexturl )
3000    RZmsgAdd( "popup",    RZ.popupwidth + "," + RZ.popupheight + "," + RZ.popupscroll )
3001    RZmsgAdd( "set",      RZ.set )
3002    RZmsgAdd( "img tag",  RZ.img )
3003    RZmsgAdd( "tagname",  RZ.tagname )
3004    RZmsgAdd( "caption",  RZ.caption )
3005    RZmsgAdd( "options",  options )
3006    RZmsgAdd( "generated html", html )
3007	RZtrace( "Action Button Processed", RZ.message );
3008
3009	//----- clear RZ.* action arguments
3010	RZactionReset();
3011
3012	//if (!active) script = ''
3013	return script;		//return generated script
3014}
3015/*---------------------------------------------------------------------------
3016Append "key: value" to RZ.message if value is not blank
3017Note: empty string same as false AND false matches \t & \t\t
3018----------------------------------------------------------------------------*/
3019function RZmsgAdd(key,val)
3020{
3021	//----- Following line avoids false matching empty string, \t & \t\t
3022	//		(also allow use of substring on true and false values)
3023	return;
3024	value = String(val)
3025
3026	//----- Return if any empty value
3027	if(value==''
3028	|| value==null
3029	|| value=='\t()'					// empty recordid
3030	|| value=='0,0,' || value==',,'		// empty popup
3031	|| value=='\t' || value=='\t\t')
3032		return
3033
3034	//----- Append : to key if value does not begin with a tab
3035	if (value.substring(0,1) != '\t') key += ': '
3036
3037	//----- Append value to message
3038	RZ.message += key + value + '\n'
3039}
3040/*---------------------------------------------------------------------------
3041  (Internal Function) Resets RZ.* variables used as input variables for
3042  serveral functions called using RZ input parameters:
3043  	RZaction, RZlinkmanager, RZdelete
3044
3045  This function is called during page setup and after arguments are used.
3046  This ensures values from one call are not carried forward to the next call.
3047
3048  Parameters:
3049	  None  (no input parameters)
3050
3051  Returns:
3052  No return value but the RZ input objects are set to an empty string
3053  * (see source code for current list of objects)
3054  ---------------------------------------------------------------------------*/
3055function RZactionReset()
3056{
3057	RZ.module=""; RZ.field=""; RZ.recordid=""; RZ.nexturl="";
3058	RZ.popupwidth=0; RZ.popupheight=0; RZ.popupscroll="";
3059	RZ.img=""; RZ.set=""; RZ.caption=""; RZ.tagname="";
3060	RZ.options=""; RZ.active=""; RZ.script="";
3061	RZ.rtefont=""; RZ.rtestyles = "";
3062	RZ.template=""; RZ.object="";
3063	RZ.linkname=""; RZ.linkmodule=""; RZ.linklevel="";
3064	RZ.filelocation=""; RZ.imagelocation="";
3065	RZ.version=""; RZ.nextversion="";
3066	RZ.imagemaxwidth=''; RZ.imagemaxheight=''; RZ.imagemaxbytes='';
3067	RZ.parentkey=''; RZ.windowname='';
3068
3069	// optional link properties not initialized by RZTagSupport
3070	RZ.linkpathname = ''
3071	RZ.linknewsection = ''
3072	RZ.linkdisplaydefault = ''
3073	RZ.linktemplatedefault = ''
3074	RZ.linkfilenamedefault = ''
3075	RZ.linkautocontinue = ''
3076}
3077
3078/*--------------------------------------------------------------------------
3079  Convert url to absolute url using the page location information determined
3080  during page initialization.
3081  Parameters:
3082  url :  url to convert
3083  --------------------------------------------------------------------------*/
3084function RZabsoluteUrl(url)
3085{
3086	if (url != '')
3087	{
3088		if ( !RZisAbsoluteUrl(url) )
3089		{
3090			if(url.substring(0,4) == 'www.')
3091				url = 'http://'+url;
3092			else
3093            {
3094                //DCO 02-22-2007\\
3095                //url = RZ.page.domain + RZ.page.pathname + '/' + url
3096
3097                // domain + page pathname + baseprefix yeilds url to base channel
3098                url = RZ.page.domain + RZ.page.pathname + '/'
3099                	+ (RZ.baseurlprefix ? RZ.baseurlprefix : '')
3100                	+ url;
3101
3102                while (url.indexOf("/../") > 0)
3103                {   //for each ../ remove it along with preceeding folder
3104                    var offsetEnd = url.indexOf("/../");
3105                    var offsetBeg = url.lastIndexOf("/",offsetEnd-1);
3106                    url = RZsubstring(url,0,offsetBeg)
3107                        + RZsubstring(url,offsetEnd+3);
3108                }
3109                //DCO 02-22-2007//
3110            }
3111		}
3112	}
3113	return url
3114}
3115/*---------------------------------------------------------------------------
3116is url absolute reference
3117----------------------------------------------------------------------------*/
3118function RZisAbsoluteUrl(url)
3119{
3120	if(url.substring(0,1) != '/'
3121	&& url.substring(0,7) != 'http://'
3122	&& url.substring(0,8) != 'https://')
3123		return false
3124	else
3125		return true
3126}
3127/*---------------------------------------------------------------------------
3128Determine Edit Page URL
3129----------------------------------------------------------------------------*/
3130function RZgetEditPageUrl( editPageUrl )
3131{
3132	var url = ""
3133	if (editPageUrl == 'EDITLISTURL')
3134		url = RZ.page.filename + '-editlist.jsp'
3135	else if (editPageUrl == 'EDITFORMURL')
3136		url = RZ.page.filename + '-editform.jsp'
3137	else
3138		url = editPageUrl
3139
3140	//----- IE may need baseurlprefix
3141	//DCO 01-23-2014
3142	//if (RZ.MSIE && editPageUrl != '' && !RZisAbsoluteUrl(editPageUrl)
3143
3144	// DJO 06-01-2016 - Can handle Edge with base url method just like IE
3145	if ((RZ.isMSEdge || RZ.MSIE || RZ.isIEstandardsMode)
3146	&& editPageUrl != '' && !RZisAbsoluteUrl(editPageUrl)
3147	&& typeof RZ.baseurlprefix != 'undefined' && RZ.baseurlprefix.length > 0)
3148		url = RZ.baseurlprefix + url;
3149
3150	//----- if url contains a function call, replace with results
3151	//		function call is "non-letter a-z...(...);" semi-colon required
3152	url = url.replace(/([^\w])(\w+\(.*?\));/g,
3153	function (inputStr,nonWord,functionCall,semicolon)
3154	{
3155		return nonWord + eval(functionCall);
3156	});
3157
3158	return url
3159}
3160/*---------------------------------------------------------------------------
3161Save return URL in cookie
3162TODO: store in control panel window
3163----------------------------------------------------------------------------*/
3164function RZsaveReturnUrl( returnUrlKey, url )
3165{
3166	if (arguments.length < 2) url = location.href	//DCO 10-20-2014
3167	//var url = location.href						//		 ''
3168	var hash = location.hash
3169	if (hash != '')
3170		url = url.substring(0,url.length-hash.length)
3171	if (RZ.trace)
3172		url += '#trace'
3173	if (RZ.debug)
3174		url += '#debug'
3175	RZsetCookieValue( returnUrlKey, url )
3176}
3177/*----------------------------------------------------------------------------
3178Call EDIT LIST page
3179----------------------------------------------------------------------------*/
3180/**
3181 *	DCO 03-07-2012: now pass single object argument to RZeditlist()
3182 *					object more flexible & readable
3183 *	Below function with named arguments retained for backward compatibility.
3184 **/
3185function RZcalleditlist(editPageUrl, width, height, scroll, set)
3186{
3187	var args = 		//args element names match RZ.??? names passed to RZaction()
3188	{				//argument names coorespond to legacy argument names
3189		nexturl     : editPageUrl,
3190		popupwidth  : width,
3191		popupheight : height,
3192		popupscroll : scroll,
3193		set         : set
3194	}
3195	return RZeditlist(args);
3196}
3197/**
3198 *	DCO 03-07-2012: new primary function passed single object argument whose
3199 *					element names match RZ.??? names passed to RZaction()
3200 *	Example call:
3201 *		RZeditlist( {nexturl: nexturl, popupwidth: popupwidth, ...} );
3202 **/
3203function RZeditlist (args)
3204{
3205	//----- Internal work variables
3206	var msg = '';
3207
3208	//----- Following variables were previously passed as named arguments
3209	//		Local variables & args element names match RZ.??? names passed to RZaction()
3210	var nexturl     = args.nexturl     ? args.nexturl     : location.href;
3211	var popupwidth  = args.popupwidth  ? args.popupwidth  : '';
3212	var popupheight = args.popupheight ? args.popupheight : '';
3213	var popupscroll = args.popupscroll ? args.popupscroll : '';
3214	var set         = args.set         ? args.set         : '';
3215
3216	//----- New input arguments never passed as named arguments
3217	var windowname = args.windowname ? args.windowname
3218				   : 'ListWindow';	//default
3219
3220	//----- Call Developer defined onlist handler and quit if it returns false
3221	if (typeof window.onlist == 'function')
3222	{
3223		// update args with current values and pass to onedit handler
3224		// returns false to cancel delete, or object with below values:
3225		args.windowname = windowname;
3226		var returnValues = window.onlist(args);
3227		if (typeof returnValues == 'undefined' || returnValues == false)
3228		{
3229			window.status = 'Edit Canceled'
3230			return void(0)
3231		}
3232		else if (typeof(returnValues) == 'object')
3233		{
3234			if (returnValues.set) set = returnValues.set;
3235			if (returnValues.nexturl) nexturl = returnValues.nexturl;
3236			if (returnValues.windowname) windowname = returnValues.windowname;
3237		}
3238	}
3239
3240	//----- Default nexturl if blank and adjust for IE if not absolute
3241	RZ.parameters = RZgetEditPageUrl(nexturl);
3242	RZaddUrlParameter( 'webspace=' + RZ.webspace )
3243	if (args.module && EZ.isFeature("EZ"))
3244	{
3245		RZaddUrlParameter( 'module=' + args.module )			//RZ.editmodule for editlist
3246		if (EZ && EZ.formfields && EZ.formfields.setupDropdown)
3247			set = EZ.formfields.setupDropdown(set, args.module); //check for EZdropdown class
3248	}
3249	RZsetParameter(set)
3250	RZaddUrlParameter( 'permissions_template=' + RZ.pagetemplatename )
3251	RZaddUrlParameter( 'permissions_parent=' + RZ.page_key )
3252	nexturl = RZ.parameters;
3253
3254	RZtrace("Calling Edit List", RZ.message )
3255
3256	RZ.editWindow = RZpopupUrl(windowname, nexturl, popupwidth, popupheight, popupscroll)
3257	if (RZ.editWindow == null)	//no popup properties defined
3258	{
3259		RZsaveReturnUrl( 'RZeditListReturnUrl' )
3260		document.location = nexturl;
3261	}
3262	return void(0)
3263}
3264/*---------------------------------------------------------------------------
3265----------------------------------------------------------------------------*/
3266function RZlistbegin( listid )
3267{
3268	RZ.nextseq.listid = listid + 1;
3269}
3270/*---------------------------------------------------------------------------
3271Called by closing list tag to remember the dependent template used by a link
3272tag inside the list.  See Dreamweaver help for more details.
3273
3274TODO: consider triggering a warning if there is more than one list using the
3275same module which puts the template determination at risk.  Also RZTagSupport
3276might consider multple links and/or templates ambigous.
3277
3278This function is also called with the linkname if a link manager link tag was
3279encountered inside the list.
3280----------------------------------------------------------------------------*/
3281function RZlinktemplate( module, template, listlinkname )
3282{
3283	if (module != '')
3284	{
3285		if (typeof RZ.linktemplates[module] == 'undefined'
3286		||  RZ.linktemplates[module] == '')
3287			RZ.linktemplates[module] = template
3288	}
3289}
3290
3291/*---------------------------------------------------------------------------
3292Multi-level menu / page permissions support:
3293
3294This function NOW called by RZaction to determine parentkey for level > 0.
3295For level 0, blank is returned because parent is determined by other means.
3296The parentkey is stored in RZ.linkpagekey by RZlinkmanager() which is called
3297via the script generated by the rz:link tag.
3298TODO: RZ.linkpagekey should probably be qualified by linkname.
3299
3300This function WAS called by RZlinkmanager() and RZaction() to remember the 1st
3301recordid encountered at each level change for use by edit buttons.
3302
3303This scheme is required to pass information from link tag to edit button
3304processing because the link tag may occur after the button in the html.
3305----------------------------------------------------------------------------*/
3306function RZlevelQualifier(linkname,level,recordid)
3307{
3308	var parentkey = ''
3309
3310	if (isNaN(level)) return '';
3311	level = parseInt(level)
3312
3313	/* deprecated but strategy may be useful in the future
3314	//----- If recordid not a number return
3315	if (isNaN(recordid)) return '';
3316
3317	if (typeof RZ.linklevelmemory == 'undefined')
3318		RZ.linklevelmemory = -1
3319
3320	//----- Clear level qualifier whenever level moves up
3321	if (level < RZ.linklevelmemory)
3322	{
3323		RZ.linklevelmemory = level
3324		RZ.levelrecordid[level] == null
3325	}
3326
3327	//----- Save page_key of prior menu item when level moves down
3328	else if (level > RZ.linklevelmemory)
3329	{
3330		RZ.linklevelmemory = level
3331		RZ.levelrecordid[level] = recordid
3332
3333	}
3334	*/
3335
3336	//----- Get above level pagekey if level > 0
3337	if (level > 0)
3338		parentkey = RZ.linkpagekey[level-1]
3339
3340	return parentkey
3341}
3342/*----------------------------------------------------------------------------
3343Call EDIT FORM page
3344----------------------------------------------------------------------------*/
3345/* Same as RZedit (retained for backward compatibility) */
3346function RZcallEditForm(recordid, editPageUrl, width,height,scroll, set)
3347{
3348	return RZedit(recordid, editPageUrl, width,height,scroll, set);
3349}
3350/* Same as RZedit (retained for backward compatibility) */
3351function RZcalleditform(recordid, editPageUrl, width,height,scroll, set, module, field, linkname)
3352{
3353	return RZedit(recordid, editPageUrl, width,height,scroll, set, module, field, linkname);
3354}
3355/**
3356* 01-20-2014 DCO: moved from setup_editlist_javascript.jsp
3357* Probably only called by NEW and EDIT ITEM buttons created with DW before 02-29-01.
3358**/
3359function RZrecordEdit( recordID, editPageUrl ){
3360  RZcallEditForm ( recordID, editPageUrl )
3361}
3362function RZrecordNew( editPageUrl ){
3363  RZcallEditForm ( 'new', editPageUrl )
3364}
3365/**
3366 *	DCO 03-07-2012: now pass single object argument to RZeditform()
3367 *					way too many arguments; object more flexible & readable
3368 *	Below function with named arguments retained for backward compatibility.
3369 **/
3370function RZedit(recordid, editPageUrl, width, height, scroll, set, module, field, linkname, action, template, level, parentkey)
3371{
3372	var args = 		//args element names match to RZ.??? names passed to RZaction()
3373	{				//argument names coorespond to legacy argument names
3374		recordid    : recordid,
3375		nexturl     : editPageUrl,
3376		popupwidth  : width,
3377		popupheight : height,
3378		popupscroll : scroll,
3379		set         : set,
3380		module      : module,
3381		field       : field,
3382		linkname    : linkname,
3383		action      : action,
3384		template    : template,
3385		level       : level,
3386		parentkey   : parentkey
3387	}
3388	return RZeditform(args);
3389}
3390/**
3391 *	DCO 03-07-2012: new primary function passed single object argument whose
3392 *					element names match RZ.??? names passed to RZaction()
3393 *	Example call:
3394 *		RZeditform( {recordid: nexturl, popupwidth: popupwidth, ...} );
3395 **/
3396function RZeditform(args)
3397{
3398	//----- Internal work variables
3399	var str = '';
3400	var msg = '';
3401
3402	//----- Following variables were previously passed as (optional)named arguments.
3403	//		Local variables & args element names match RZ.??? names passed to RZaction()
3404	var recordid    = args.recordid    ? args.recordid : '';
3405	var nexturl     = args.nexturl     ? args.nexturl : '';
3406	var popupwidth  = args.popupwidth  ? args.popupwidth : ''
3407	var popupheight = args.popupheight ? args.popupheight : ''
3408	var popupscroll = args.popupscroll ? args.popupscroll : ''
3409	var set         = args.set         ? args.set : ''
3410	var module      = args.module      ? args.module : ''
3411	var field       = args.field       ? args.field  : ''
3412	var linkname    = args.linkname    ? args.linkname : ''
3413	var action      = args.action      ? args.action : ''
3414	var template    = args.template    ? args.template : ''
3415	var level       = args.level       ? args.level : ''
3416	var parentkey   = args.parentkey   ? args.parentkey : ''
3417
3418	//----- New input arguments never passed as named arguments
3419	var windowname = args.windowname ? args.windowname
3420				   : (window.name == 'EditWindow' ? 'EditWindowPopup' : 'EditWindow');
3421
3422	var samplearg  = args.samplearg  ? args.samplearg : ''; //default is ''
3423
3424	//----- Processing...
3425	RZtrace( "Edit Form Button Clicked", "Record Id: (" + recordid + ")" );
3426
3427	//----- Call Developer defined onedit handler and quit if it returns false
3428	if (typeof window.onedit == 'function')
3429	{
3430		// update args with current values and pass to onedit handler
3431		// returns false to cancel delete, or object with below values:
3432		args.windowname = windowname;
3433		var returnValues = window.onedit(args);
3434		if (typeof returnValues == 'undefined' || returnValues == false)
3435		{
3436			window.status = 'Edit Canceled'
3437			return void(0)
3438		}
3439		else if (typeof(returnValues) == 'object')
3440		{
3441			if (returnValues.set) set = returnValues.set;
3442			if (returnValues.nexturl) nexturl = returnValues.nexturl;
3443			if (returnValues.windowname) windowname = returnValues.windowname;
3444		}
3445	}
3446
3447	//----- Apply baseurl prefix to nexturl if IE browser
3448	var url = RZgetEditPageUrl(nexturl);
3449	if (linkname == '')
3450	{
3451		RZ.message = ''
3452		var nextseqKey = module + '_' + level;	//level is listid
3453		if (action == 'newitem' && RZ.nextseq.modules[nextseqKey]
3454		&& (','+set).indexOf(','+ module + '.' + RZ.nextseq.modules[nextseqKey].field) == -1)
3455		{
3456			str = module + '.' + RZ.nextseq.modules[nextseqKey].field + '=' + RZ.nextseq.modules[nextseqKey].seq;
3457			if (set) set += ',';
3458			set += str;
3459		}
3460
3461		RZsetEditParameters(module,field,set)
3462
3463		recordidParameter = RZsetEditRecordParameter(recordid)
3464		if (recordidParameter == '*ERROR*') return void(0)
3465
3466		//----- Page Permissions processing (non-link manager)
3467		if (RZ.permissions_module != '')
3468		{
3469			if (action == 'new' || action == 'newitem'
3470			|| action == 'edit' || action == 'edititem')
3471			{
3472				msg = RZpermissionWarning(action,template,module)
3473				if (msg != '')
3474					if (!RZconfirm(msg)) return
3475
3476				if (template == '')
3477					if (typeof RZ.linktemplates[module] != 'undefined')
3478						template = RZ.linktemplates[module];
3479
3480				// When template passed on url, RZsave will include template & parent page_key
3481				// in the save record XML request (template defined by new & edit buttons).
3482				if (template != '' && template != '*none*')
3483					RZaddUrlParameter( 'permissions_template=' + template )
3484			}
3485			else if (action == 'editform' || action == 'editpage' || action == 'editglobal')
3486			{
3487				// edit this page button(s) do not define parents because the edited recordid
3488				// is usually not the dependent record module.  Another issue is parent passed
3489				// below is the current page when links are added and would not be correct for
3490				// this dependent page.
3491				//RZaddUrlParameter( 'permissions_template=' + RZ.pagetemplatename )
3492			}
3493
3494			//----- Always pass parent_key in case the edit form adds links via the RTE.
3495			//		NOTE: Don't add parent if already on url but this is a very specific scenario.
3496			if (RZ.pagetype == 'template' && url.indexOf("permissions_parent=") == -1)
3497				RZaddUrlParameter( 'permissions_parent=' + RZ.page_key )
3498			else	//editlist page
3499				RZaddUrlParameter( 'permissions_parent=' + RZ.permissions_parent )
3500
3501			//----- Pass caller page key to determine workflowname
3502			if (RZ.page_key != '')
3503				RZaddUrlParameter( 'page_key=' + RZ.page_key )
3504		}
3505
3506		if (url.indexOf('?') != -1 && RZ.parameters.substr(0,1) == '?')
3507			RZ.parameters = '&' + RZ.parameters.substring(1);
3508		url += RZ.parameters + recordidParameter
3509		RZtrace('Edit Form url parameters',RZ.message)
3510	}
3511
3512	//----- Check for link manager parameters
3513	else
3514	{
3515		if (typeof RZ.link[linkname] != 'object')
3516			msg = 'Specified Link Name ('+linkname+') Does Not Exist or is Not\n'
3517				+ 'Properly Defined (make sure the ' + linkname + ' link exists).\n'
3518				+ 'The link tag defines required options used by Link Manager\n\n'
3519				+ 'If the list is not displaying a message when empty,\n'
3520				+ '(i.e. noemptylistmessage option set) a copy of the\n'
3521				+ 'link tag must be inside the list header.\n\n'
3522				+ 'If link tag exists make sure its name matches the name specified\n'
3523				+ 'specified on this button.'
3524
3525		if (msg == '' && module == '')
3526			msg = 'Link Name ('+linkname+') associated with this action has\n'
3527				+ 'not specified a module.\n\n'
3528				+ 'Link Manager can not be called without knowing the module\n'
3529				+ '(check associated link and make sure a module is specified).'
3530
3531		//----- If errors display message and return
3532		if (msg != '' )
3533		{
3534			RZalert(msg);
3535			return void(0);
3536		}
3537
3538		//----- Set all link manager properties including window size and url
3539		//		(RZsetLinkManagerProperties calls RZsetEditParameters)
3540		//
3541		RZsetLinkManagerProperties(linkname,module,field,recordid,set,url)
3542		recordidParameter = RZsetEditRecordParameter(recordid)
3543		if (recordidParameter == '*ERROR*') return void(0)
3544
3545		//----- Pass user popup window values to link manager on url
3546		RZ.link[linkname].popupwidth = popupwidth
3547		RZ.link[linkname].popupheight = popupheight
3548		RZ.link[linkname].popupscroll = popupscroll
3549		RZ.link[linkname].nexturl = RZabsoluteUrl( url )
3550
3551		//----- Get link manager popup window properties
3552		popupwidth  = RZ.link[linkname].linkwidth
3553		popupheight = RZ.link[linkname].linkheight
3554		popupscroll = RZ.link[linkname].linkscroll;
3555		url    = RZ.link[linkname].linkurl + recordidParameter
3556			   + (RZ.linkmanagertest ? '#test' : '');
3557
3558		//----- Pass linkparent
3559		var parent = ''
3560		if (level == '')
3561		{
3562			if (typeof RZ.link[linkname].linkparent != 'undefined')
3563				parent = RZ.link[linkname].linkparent
3564			if (parent == '')
3565				parent = RZ.page_key;
3566		}
3567		else	//multi-level processing
3568		{
3569			if (parentkey != '')	//if passed as argument
3570				parent = parentkey;
3571			else if ( isNaN(level) )
3572			{
3573				msg = 'Non-numberic level specified for this button.\n\n'
3574				    + 'Multi-level menu relationships can not be maintained\n'
3575				    + '(check button and specify a numeric level).'
3576				if (!RZconfirm(msg)) return
3577			}
3578			else if (action == 'new' || action == 'newitem')
3579			{
3580				// for existing level, linkparentnew should be defined
3581				if(typeof RZ.linkparentnew[linkname] != 'undefined'
3582				&& typeof RZ.linkparentnew[linkname][level] != 'undefined')
3583					parent = RZ.linkparentnew[linkname][level]
3584
3585				// new level; use last item recordid at prior level for parent
3586				else if (eval(level) != 0)	//TODO: should be min level (not 0)
3587					parent = RZ.linkpagekey[level-1];	//undefined caught below
3588				else
3589					parent = RZ.permissions_parent
3590			}
3591			else if (action == 'edit' || action == 'edititem')
3592			{
3593				if (eval(level) == 0)
3594				{
3595					if(typeof RZ.linkparentnew[linkname] != 'undefined'
3596					&& typeof RZ.linkparentnew[linkname][level] != 'undefined')
3597						parent = RZ.linkparentnew[linkname][level]
3598				}
3599				else	//level > 0
3600					parent = parentkey;		//undefined caught below
3601			}
3602		}		// end of multi-level processing
3603
3604		//----- Must have a parent when page permissions are enabled
3605		if (RZ.permissions_module != ''
3606		&& (typeof parent == 'undefined' || parent == 'undefined' || parent == ''))
3607		{
3608			msg = 'this'
3609			if (action.indexOf('new') == 0) msg = 'new'
3610			msg = 'This button is not configured for the '+msg+' page to properly INHERIT\n'
3611			    + 'page permissions because the parent is unknown'
3612			if (level != '') msg += ' for level ' + level
3613			msg +='.\n\n'
3614			    + 'Permissions may need to be explicitly defined on the page\n'
3615			    + 'associated with this link.'
3616			//if ( !RZconfirm(msg) ) return
3617		}
3618
3619		if (parent != '' && parent != 'undefined')
3620			RZ.link[linkname].linkparent = parent
3621
3622		if (!RZ.link[linkname].linkseq && RZ.nextseq.linknames[linkname])
3623			RZ.link[linkname].linkseq = RZ.nextseq.linknames[linkname].seq;
3624	}
3625
3626	RZtrace("Calling Edit Form", "URL: " + url )
3627
3628	//----- Suppress empty url parameters
3629	if (url.indexOf('/revize/util/linkmanager') == 0)
3630	{
3631		var urlFull = url;
3632		url = url.replace(/\&[^\&]*=(?=\&)/g,'');
3633		if (urlFull != url)
3634			RZtrace("Calling linkmanager (empty parameters deleted)", "URL: " + url )
3635	}
3636
3637	//----- Call popup window if requested else goto Edit Page URL
3638	RZ.editWindow = RZpopupUrl(windowname, url, popupwidth, popupheight, popupscroll)
3639	if (RZ.editWindow == null)	//no popup properties
3640	{
3641		RZsaveReturnUrl( 'RZeditFormReturnUrl' )
3642		var pathfilename = RZisPopupCall() ? RZgetfileinfo(RZabsoluteUrl(url)).pathfilename : '';
3643		RZsetcookie('RZnotPopup', pathfilename, RZ.webspace);
3644		document.location = url
3645	}
3646	//----- If popup call, clear RZeditFormReturnUrl cookie //DCO 10-20-2014
3647	else
3648		RZsaveReturnUrl( 'RZeditFormReturnUrl', '' );
3649
3650	//----- Suspend processing if called as submit
3651	return void(0);
3652}
3653/*---------------------------------------------------------------------------
3654(Internal Function) Display page permission warning
3655Internal: Diagnostics Support
3656----------------------------------------------------------------------------*/
3657function RZlinkWithoutParent(module,recordid,code)
3658{
3659	if (typeof RZ.noparent[module] == 'undefined')
3660		RZ.noparent[module] = new Object();
3661	RZ.noparent[module][recordid] = code
3662
3663	code = "'" + code + "'"
3664	var html = '<a href="javascript:RZpagemessage(' + code + ')">'
3665	         + '<img src="/revize/images/warning-parent.gif" border="0"></a>'
3666	RZlogin(html)
3667}
3668/*---------------------------------------------------------------------------
3669(Internal Function) Display message regarding button configuration issue
3670Internal: Diagnostics Support
3671----------------------------------------------------------------------------*/
3672function RZiconMessage(action,index)
3673{
3674	module = RZ.icons[index]
3675	var msg = RZpermissionWarning(action,'',module)
3676	if (msg != '')
3677		if (!RZconfirm(msg)) return
3678}
3679/*---------------------------------------------------------------------------
3680(Internal Function) Display warning if button not configured correctly
3681Internal: Diagnostics Support
3682----------------------------------------------------------------------------*/
3683function RZpermissionWarning(action,template,module)
3684{
3685	var msg = '';
3686	var buttonName = ''
3687	if (RZsubstring(action,0,3).toLowerCase() == 'new')
3688		buttonName = 'NEW '
3689	else if (RZsubstring(action,0,4).toLowerCase() == 'edit')
3690		buttonName = 'EDIT '
3691
3692	// Get dependent template for page permissions
3693	if (template == '')
3694	{
3695		if (module == '')	//test by clearing RZ.template and RZ.module on button
3696		{
3697			msg = 'The template used to create the new page could not be \n'
3698				+ 'determined because no module was specified on the '
3699				+ buttonName + 'button.'
3700			}
3701
3702		// Get template processed from the list associated with the specified module
3703		else if (typeof RZ.linktemplates[module] != 'undefined')
3704			template = RZ.linktemplates[module];
3705
3706		else				//test by specifing incorrect module on button
3707			msg = 'The template used to create new pages can not be determined\n'
3708				+ 'because there does not appear to be any lists associated with\n'
3709				+ 'with the currently specified module: ' + module + '.'
3710	}
3711	if (msg == '' && template == '')	//test by clearing RZ.template on button
3712		msg = 'The template used to create new pages can not be determined\n'
3713			+ 'because there are no links in the list associated with the\n'
3714			+ 'currently specified module: ' + module + '\n\n'
3715			+ 'The developer may need to specify the template on the ' + buttonName + 'button\n'
3716			+ 'If pages are not created when list items are added, a template of none\n'
3717			+ 'should be specified.'
3718
3719	// template not required for single record edits
3720	if (template == '*none*'
3721	|| action == 'editform' || action == 'editpage' || action == 'editglobal')
3722		msg = ''
3723
3724	// Warn content editor about potential permissions inheritance issues
3725	if (msg != '')
3726	{
3727		if (buttonName == 'NEW ')
3728		{
3729			msg = 'If this NEW button creates a new page, that page will NOT\n'
3730				+ 'inherit permissions for the following reason:\n\n'
3731				+ msg
3732			msg=''
3733		}
3734		else if ( !RZcheckoptions(RZ.permissions_options,"warnings") )
3735			msg = ''	//no warning if migration option not enabled
3736		else
3737			msg = 'The EDIT button is not configured to properly pass page permissions\n'
3738				+ 'to the page created when this item was added to the associated list.\n\n'
3739				+ 'The template must be known to assign a parent to child pages.\n\n'
3740				+ msg
3741	}
3742	return msg
3743}
3744/*---------------------------------------------------------------------------
3745(Internal Function) Sets general edit url parameters used with or w/
3745o link manager.
3746Internal: Update Record Support
3747----------------------------------------------------------------------------*/
3748function RZsetEditParameters(module,field,set)
3749{
3750	RZ.parameters = ''
3751
3752	//----- Append webspace parameter
3753	RZaddUrlParameter( 'webspace=' + RZ.webspace )
3754
3755	/* Was considered for page navigation variables
3756	//----- Template name used to create pageid
3757	if (RZ.pagetemplatename	!= '')
3758		RZaddUrlParameter( 'template=' + RZ.pagetemplatename )
3759	*/
3760
3761	//----- Append module & field
3762	if (module!='')
3763		RZaddUrlParameter( 'module=' + module )	//used by link manager
3764	if (field!='')
3765		RZaddUrlParameter( 'field=' + field )		//future
3766
3767
3768	RZsetParameter(set);	//Append set parameters
3769}
3770/*---------------------------------------------------------------------------
3771(Internal Function) Adds the RZ.set values to the url
3772Called by RZsetEditParameters() & RZcalleditlist()
3773Internal: Update Record Support
3774----------------------------------------------------------------------------*/
3775function RZsetParameter(set)
3776{
3777	RZaddUrlParameter( 'pagetemplateid=' + RZ.pagetemplateid );
3778	RZaddUrlParameter( 'linkedmoduleid=' + RZ.pagemoduleid );
3779	RZaddUrlParameter( 'linkedrecordid=' + RZ.pagerecordid );
3780	//----- Append set parameters
3781	if (set != '')
3782	{
3783		set = set.split('pagerecord._recordid').join( RZ.editrecordid )
3784		RZaddUrlParameter( 'set=' + escape(set) )
3785	}
3786}
3787/*---------------------------------------------------------------------------
3788(Internal Function) Sets recordid parameter used with or w/o link manager.
3789Internal: Update Record Support
3790----------------------------------------------------------------------------*/
3791function RZsetEditRecordParameter(recordid)
3792{
3793	var recordidParameter = '*ERROR*'
3794
3795	if (recordid == 'new')
3796		recordidParameter = '&new'
3797
3798	//----- Calculated value
3799	else if (recordid.length>0 && recordid.substring(recordid.length-1)==';')
3800		recordidParameter = '&recordid=' + eval(recordid)
3801
3802	//----- If rz.fetch returned an error message as text
3803	//		(use alert because it may not be design flaw)
3804	else if (recordid != '' && isNaN(recordid))
3805		alert( 'Revize Button specifies Invalid Record Id: \n' + recordid )
3806
3807	else if (recordid != '')
3808		recordidParameter = '&recordid=' + recordid
3809
3810	else
3811		recordidParameter = ''
3812
3813	return recordidParameter
3814}
3815/*---------------------------------------------------------------------------
3816(Internal Function) Called from above and also from snippet_helper_editform.js
3817before calling RTE.
3818
3819Computed window size just fits 800 X 600 for all options.
3820Create link object if undefined and use default options if undefined.
3821
3822Internal: Link Manager Support
3823----------------------------------------------------------------------------*/
3824function RZsetLinkManagerProperties(linkname,module,field,recordid,set,url)
3825{
3826	//----- Set general edit Url paramters
3827	RZ.message = ''
3828	RZsetEditParameters(module,field,set)
3829
3830	//----- If link object not yet defined, define it
3831	if (typeof RZ.link[linkname] == 'undefined') RZ.link[linkname] = new Object()
3832
3833	//----- Get current options (use default values if undefined)
3834	var options = RZ.link[linkname].options
3835	if (typeof options == 'undefined') options = 'url,template,file'
3836	RZ.link[linkname].options = options
3837
3838	if (typeof RZ.linkoptions != 'undefined' && RZ.linkoptions != '')
3839	RZ.link[linkname].options = RZ.linkoptions
3840
3841	//----- Following properties are used by jsp code and must be passed on url
3842	RZaddUrlParameter( "linkname=" + linkname )
3843	RZsetLinkUrlParameter(linkname,'options')
3844	RZaddUrlParameter( "nexturl=" + RZabsoluteUrl(url) )
3845
3846	//----- Template specfic properties (DW only defines template property)
3847	RZdefaultLinkParameter(linkname,'template')			//blank for all templates
3848	RZdefaultLinkParameter(linkname,'editform')			//template specific editforms
3849	RZdefaultLinkParameter(linkname,'modulelinkfield')	//back link from dependent module
3850
3851	//----- TODO: Following properties are now passed on url (but should NOT)
3852	//		(they are not used by jsp code except to retrieve values for js)
3853	RZdefaultLinkParameter(linkname,'filelocation')		//file manager location (supported by RTE)
3854	RZdefaultLinkParameter(linkname,'fileextension')	//file manager extensions
3855
3856	//----- TODO: Following properties are now passed on url (but probably NOT even used)
3857	RZdefaultLinkParameter(linkname,'imagelocation')	//image manager location
3858	RZdefaultLinkParameter(linkname,'imageextension')	//image manager extensions
3859
3860	//----- Following properties NOT used by jsp code are accessed from the opener window
3861	//		They can be set on RZ.link.<linkname>.<property_below>
3862	RZdefaultLinkOption(linkname,'linkpathname')		//prepended pathname (supported by RTE)
3863	RZdefaultLinkOption(linkname,'linknewsection')		//list of templates that can start new sections
3864
3865	RZdefaultLinkOption(linkname,'linkdisplaydefault')	//default linkdisplay
3866	RZdefaultLinkOption(linkname,'linktemplatedefault')	//default template
3867	RZdefaultLinkOption(linkname,'linkfilenamedefault')	//default path/filename
3868	RZdefaultLinkOption(linkname,'linkautocontinue')	//Auto click Continue button
3869	RZdefaultLinkOption(linkname,'nexturl')				//next editform for all templates
3870	RZdefaultLinkOption(linkname,'set')					//Set passed to dependent module
3871	RZdefaultLinkOption(linkname,'linkparent')			//parent that added link
3872	RZdefaultLinkOption(linkname,'linkmodule')			//list module
3873
3874	//----- Determine link parent (defined by new or edit button - single level menu)
3875	var linkparent = RZ.link[linkname].linkparent
3876	if (linkparent == '')
3877	{
3878		if (RZ.permissions_parent != '')	//this page is surogate parent (e.g. editlist)
3879			linkparent = RZ.permissions_parent
3880		else
3881			linkparent = RZ.page_key
3882	}
3883	RZ.link[linkname].linkparent = linkparent
3884
3885	//----- Convert nexturl to absolute url (some RTE calls have property defined at this time)
3886	var nexturl = RZ.link[linkname].nexturl
3887	if (nexturl != '')
3888		RZ.link[linkname].nexturl = RZabsoluteUrl(nexturl)
3889
3890	//----- Compute link manager window size
3891	var width = 600
3892	var height = 240 		// base height IE or NS (includes target)
3893	var testopt = ',' + options + ','
3894	if (testopt.indexOf(',none,') != -1) height += 25
3895	if (testopt.indexOf(',url,') != -1) height += 40
3896	if (testopt.indexOf(',file,') != -1) height += 45
3897	if (testopt.indexOf(',template,') != -1)
3898	{
3899		height += 220 + 40;		//add 40 for section prompt
3900		if (RZ.isnavigator) height += 25
3901	}
3902
3903	//----- Store computed values in the link object itself
3904	RZ.link[linkname].linkwidth   = width
3905	RZ.link[linkname].linkheight  = height
3906	RZ.link[linkname].linkscroll  = 'yes'
3907
3908	//----- Store link manager url with parameters
3909	RZ.link[linkname].linkurl = '/revize/util/linkmanager_frame.html' + RZ.parameters
3910
3911	//----- Display all link manager properties on trace
3912	RZtrace('Link Manager linkname (' + linkname + ') url parameters',RZ.message)
3913	var msg = ''
3914	for (var i in RZ.link[linkname])
3915		msg += i + '  =  ' + RZ.link[linkname][i] + '\n'
3916	RZtrace('RZsetLinkManagerProperties() linkname (' + linkname + ')',msg)
3917}
3918/*---------------------------------------------------------------------------
3919(Internal Function)Save all link manager information for this link in a new
3920object that is referenced at run time by new and edit buttons.
3921
3922This function is called by the link object to define link properties for use by
3923new and edit buttons.  A separate link object is defined for each linkname so
3924these properties are available when the new or edit button is clicked. The new
3925and edit buttons can then simply supply the linkname to access these properties.
3926
3927See RZTagSupport.java for more information on the link manager calling process.
3928
3929**IMPORTANT**
3930When changing functionality, please update Dreamweaver help file:
3931	RevizePermissionsWorks-Help.htm (contains high level description)
3932
3933Internal: Link Manager / Page Permissions Support
3934----------------------------------------------------------------------------*/
3935function RZlinkmanager( linkname, linkmodule, linkrecordid, linklevel,
3936	                    linkpagekey, linkparent )
3937{
3938	if (typeof linkname == 'undefined') linkname = RZ.linkname
3939	if (typeof linkmodule == 'undefined') linkmodule = ''
3940	if (typeof recordid == 'undefined') recordid = ''
3941	if (typeof linklevel == 'undefined') linklevel = ''
3942	if (typeof linkpagekey == 'undefined') linkpagekey = ''
3943	if (typeof linkparent == 'undefined') linkparent = ''
3944	if (linkparent.indexOf('This is a STANDARD text field:') == 0) linkparent = '';
3945
3946	//----- For multi-level link manager lists...
3947	if (linkmodule != '' && linklevel != '')
3948	{
3949		//----- Save first non-blank linkparent for this level
3950		if (typeof RZ.linkparentnew[linkname] == 'undefined')
3951			RZ.linkparentnew[linkname] = new Object();
3952
3953		if (typeof RZ.linkparentreset[linklevel] == 'undefined')
3954			RZ.linkparentreset[linklevel] = 'reset'
3955
3956		if (typeof RZ.linkparentnew[linkname][linklevel] == 'undefined'
3957		|| RZ.linkparentreset[linklevel] == 'reset')
3958		{
3959			if (linkparent == '') linkparent = RZ.permissions_parent
3960			RZ.linkparentnew[linkname][linklevel] = linkparent
3961			RZ.linkparentreset[linklevel] = ''
3962		}
3963
3964		//----- Indicate new next higher level linkparent can be reset
3965		var nextlevel = RZinteger(linklevel) + 1
3966		RZ.linkparentreset[nextlevel] = 'reset'
3967
3968		//----- Save most recent pagekey (used to get parent for new level button)
3969		RZ.linkpagekey[linklevel] = linkpagekey
3970		if (typeof RZ.linkpagekey[linklevel+1] != 'undefined')
3971			RZ.linkpagekey[linklevel+1] = 'undefined';	//clear lower level value
3972	}
3973
3974	//----- Create link object if not defined to hold module and parent
3975	if (typeof RZ.link[linkname] == 'undefined')
3976	{
3977		RZ.link[linkname] = new Object()
3978		RZ.link[linkname].linkparent = ''
3979		RZ.link[linkname].linkmodule = ''
3980	}
3981
3982	//----- Set linkparent to 1st non-blank parent encountered (used for single level links)
3983	//		When no linkparent is set, the page_key is used when new or edit button clicked.
3984	if (linkparent != '' && RZ.link[linkname].linkparent == '')
3985		RZ.link[linkname].linkparent = linkparent
3986
3987	//----- Save additional link properties
3988	if(RZ.linkname != '')
3989	{
3990
3991		if (RZ.link[linkname].linkmodule == '' && linkmodule != '')
3992			RZ.link[linkname].linkmodule = linkmodule;
3993
3994		RZ.link[RZ.linkname].options = RZ.linkoptions
3995		RZ.link[RZ.linkname].filelocation = RZ.linkfilelocation
3996		RZ.link[RZ.linkname].fileextension = RZ.linkfileextension
3997		RZ.link[RZ.linkname].imagelocation = RZ.linkimagelocation
3998		RZ.link[RZ.linkname].imageextension = RZ.linkimageextension
3999
4000		RZ.link[RZ.linkname].template = RZ.linktemplate
4001		RZ.link[RZ.linkname].editform = RZ.linkeditform
4002		RZ.link[RZ.linkname].modulelinkfield = RZ.linkmodulelinkfield
4003
4004		//----- Properties not passed on url
4005		//		TODO: automatically pick up all options starting with link
4006		RZ.link[RZ.linkname].linkpathname = RZ.linkpathname
4007		RZ.link[RZ.linkname].linknewsection = RZ.linknewsection
4008		RZ.link[RZ.linkname].linkdisplaydefault = RZ.linkdisplaydefault
4009		RZ.link[RZ.linkname].linktemplatedefault = RZ.linktemplatedefault
4010		RZ.link[RZ.linkname].linkfilenamedefault = RZ.linkfilenamedefault
4011		RZ.link[RZ.linkname].linkautocontinue = RZ.linkautocontinue
4012	}
4013
4014	//----- clear RZ.* action arguments
4015	RZactionReset();
4016}
4017/*---------------------------------------------------------------------------
4018(Internal Function) Call RZdefaultLinkOption then add to RZ.parameters
4019Internal: Link Manager Support
4020----------------------------------------------------------------------------*/
4021function RZdefaultLinkParameter(linkname,property)
4022{
4023	RZdefaultLinkOption(linkname,property)
4024	RZsetLinkUrlParameter(linkname,property)
4025}
4026/*---------------------------------------------------------------------------
4027(Internal Function) If property is undefined, set to blank
4028Internal: Link Manager Support
4029----------------------------------------------------------------------------*/
4030function RZdefaultLinkOption(linkname,property)
4031{
4032	if (typeof RZ.link[linkname][property] == 'undefined')
4033		RZ.link[linkname][property] = ''
4034
4035	//RZtrace('RZdefaultLinkOption('+linkname+'):' + property
4036	//       + '<br>-->' +(RZ.link[linkname][property])+ '<--')
4037}
4038/*---------------------------------------------------------------------------
4039(Internal Function) Build link manager url parameters using link properties
4040presumably defined elsewhere on the page if property is defined and not blank.
4041
4042Internal: Link Manager Support
4043----------------------------------------------------------------------------*/
4044function RZsetLinkUrlParameter(linkname,property)
4045{
4046	if (typeof RZ.link[linkname][property] != 'undefined')
4047	{
4048		var value = RZ.link[linkname][property]
4049		if (value != '')
4050			RZaddUrlParameter( 'link' + property + '=' + value )
4051	}
4052}
4053/*---------------------------------------------------------------------------
4054Adds jsp parameter to url
4055* parameter appended RZ.parameters with preceeding ? or & character
4056* parameter appended to RZ.message for output by RZtrace()
4057
4058Parameters:
4059	parameter-	url parameter of the form key = value
4060----------------------------------------------------------------------------*/
4061function RZaddUrlParameter(parameter)
4062{
4063	//----- Build url parameter
4064	if (RZ.parameters.indexOf('?') == -1)
4065		RZ.parameters += '?' + parameter
4066	else
4067		RZ.parameters += '&' + parameter
4068
4069	//----- Build trace message
4070	RZ.message += unescape(parameter) + '\n'
4071}
4072
4073/* Same as: RZback (retained for backward compatibility) */
4074function RZpriorPage(returnUrlKey) { RZback(returnUrlKey) }
4075/*-------------------------------------------------------------------------
4076  Return to calling page (normally called by cancel button)
4077
4078  If popupcall, close window and refresh if not an editform
4079
4080  If returnUrlKey ends with a semicolon, assume it is an expression for url
4081
4082  Otherwise, return to PRIOR PAGE using the following steps
4083  * If URL defined in cookie, use it (returnUrlKey specifies cookie name)
4084  * If not edit list page, use history
4085  * If RZ.page.home is not blank, use it
4086  * Make trace entry and stay on current page
4087
4088  Parameters:
4089  returnUrlKey-	if specified, one of the following:
4090                1) expression containing url of page to get control
4091                2) if expression, must end with semicolon
4092                3) Cookie name containing calling page url
4093  win-			Optional specifies the current window (default is window)
4094  Returns:
4095  There is currently no value returned
4096-------------------------------------------------------------------------*/
4097function RZback(returnUrlKey,win)
4098{
4099	if (typeof win == 'undefined') win = window;
4100	if (!returnUrlKey)
4101		returnUrlKey = (RZ.pagetype == 'editlist' ? 'RZeditListReturnUrl' : 'RZeditFormReturnUrl');
4102
4103	//----- If opener and access to opener
4104	if ( RZisPopupCall(win) )
4105	{
4106		//----- Added for LinkManager RTE interface (but never refresh editform)
4107		if(RZ.parent.opener.RZ != 'undefined'
4108		&& RZ.parent.opener.RZ != null
4109		&& RZ.parent.opener.RZ.pagetype != 'editform')
4110			win.opener.location.reload(true);
4111		win.close()
4112		return;
4113	}
4114
4115	//----- Not a popup call
4116	var returnUrl = ''
4117	if (RZright(returnUrlKey,1) == ';')		//url passed as variable / equation
4118		returnUrl = eval( returnUrlKey )
4119	else									//url read from cookie
4120	{
4121		returnUrl = RZgetCookieValue(returnUrlKey)
4122		if (returnUrl != "")
4123		{	// if cookie defined
4124			RZsetCookieValue(returnUrlKey,"")
4125		}else
4126		{	// when cookie not defined
4127			if (RZ.pagetype == 'editform')
4128			{
4129				returnUrl = ''
4130				history.go(-1); // use history if not edit list
4131			}
4132			else
4133			{
4134				returnUrl = RZ.page.home // use home if edit list
4135			}
4136		}
4137	}
4138
4139	if (returnUrl != null && returnUrl != '')
4140		RZ.parent.location = returnUrl
4141	else
4142		RZtrace('snipper_helper: RZback('+returnUrlKey+')',
4143				'No Prior URL could be determined')
4144}
4145/*--------------------------------------------------------------------------
4146(Internal Function) Determine if this page was called as a popup.
4147
4148Internal: Used by Save & Cancel functions to return to calling window.
4149
4150Returns: true if opener with RZ.pagetype variable defined; otherwise false
4151--------------------------------------------------------------------------*/
4152function RZisPopupCall(win, isStrict)
4153{
4154	if (typeof win == 'undefined') win = window
4155
4156	if (win.parent.opener
4157	&& RZwinaccess(win.parent.opener)
4158	&& typeof win.parent.opener != 'undefined'
4159	&& typeof win.parent.opener != 'undefined'
4160	&& typeof win.parent.opener.RZ != 'undefined'	//opener is a Revize page
4161	&& win.parent.opener.RZ != null
4162	&& typeof RZ.parent.opener.RZ.pagetype != 'undefined'
4163	&& typeof RZ.parent.opener.RZ.editWindow != 'undefined'
4164	&& win.parent.opener.RZ.editWindow == win.parent
4165	&& RZisPopupCallStrict())
4166	{
4167		return true;
4168	}
4169	//----- If opened from workflow task window
4170	//		TODO: probably should always assume popup if opener exists but too risky w/o
4171	//		more analysis and serious regression testing.
4172	else if (win.parent.name == 'Revize_Edit_Record' && typeof win.opener != 'undefined')
4173		return true;
4174
4175	// DCO 10-20-2014:
4176	// Below code can cause js error in RZback() because this is the wrong place to test
4177	// for callback function in RZnextsavereturn; RZsave() should test. Moot point when
4178	// RZ.callback used because RZ.nextsavereturn never contains paraenthesis and RZsave()
4179	// does not rely solely on isPopup() to post save to itself.
4180
4181	//----- If callback function specified after save
4182	else if(RZ.nextsavereturn
4183	&& RZ.nextsavereturn.indexOf('(') > 0 && RZ.nextsavereturn.indexOf(')') > 0)
4184		return true;
4185
4186	else
4187		return false;
4188	//______________________________________________________________________
4189	/**
4190	 *	(Internal function) originally added for email notify
4191	 *
4192	 *	Check if opener and referrer pathnames match -- Prevents editform
4193	 *	from closing popup editlist when editform is not called as popup.
4194	 *
4195	 *	Probably always valid test but as safety, only checks if isStrict
4196	 *	specified and EZ feature active otherwise returns true.
4197	 */
4198	function RZisPopupCallStrict()
4199	{
4200		if (!isStrict || !EZ.isFeature("EZ")) return true;
4201		if (window.dialogArguments) return true;
4202
4203		return RZgetFileInfo(location.href).pathfilename != RZgetcookie('RZnotPopup',RZ.webspace)
4204	}
4205}
4206/*---------------------------------------------------------------------------
4207Following function is called by the DELETE ITEM button
4208Deleted specified recordid after prompting
4209----------------------------------------------------------------------------*/
4210/* Same as RZdelete (retained for backward compatibility) */
4211function RZrecordDelete( recordid, module ) { RZdelete( recordid, module ) }
4212/**
4213 *	DCO 03-07-2012: Can now be called with single object argument whose
4214 *					element names match RZ.??? names passed to RZaction()
4215 *	Example call:
4216 *		RZdelete( {recordid: recordid, module: module, ...} );
4217 *
4218 *	DO NOT add new named arguments; below retained for backward compatibility.
4219 **/
4220
4221/**
4222 * Add Event Listener to delete
4223 */
4224var selectedBtn;
4225document.addEventListener("DOMContentLoaded", function() {
4226	var deleteBtns = document.querySelectorAll('a[href*="javascript:RZdelete"]');
4227	for(var i = 0, len = deleteBtns.length; i < len; i++){
4228		deleteBtns[i].addEventListener('click', function(e){
4229			selectedBtn = e.target.parentNode;
4230		}, false);
4231	}
4232});
4233
4234
4235function RZdelete(recordid, module, nexturl, win)
4236{
4237	//----- Internal work variables
4238	var msg = '';
4239
4240	//----- If first argument is an object, it contains all input arguments as elements.
4241	//		Local variable names & args element names match RZ.??? passed to RZaction()
4242	var args = recordid;	//1st argument
4243
4244	// If first argument not object, create args object containing legacy named arguments
4245	if (typeof(args) != 'object')
4246	{
4247		args = {};
4248		args.recordid = recordid ? recordid : '';
4249		args.module   = module   ? module   : '';
4250		args.nexturl  = nexturl  ? nexturl  : '';
4251		args.win      = win      ? win      : '';
4252	}
4253
4254	//----- Initialize legacy local variables originally passed as named arguments
4255	recordid = args.recordid ? args.recordid : '';
4256	module   = args.module   ? args.module   : '';
4257	win      = args.win      ? args.win      : window;
4258	nexturl  = args.nexturl  ? args.nexturl  : win.location.href;
4259
4260	//----- New input arguments never passed as named arguments
4261	var samplearg = args.samplearg ? args.samplearg : '';	//default '' is in the example
4262
4263	//----- Processing...
4264	RZ.message = "WebSpace: " + RZ.webspace + "\n"
4265			 + "Module: " + module + "\n"
4266			 + "Record Id: (" + recordid + ")\n"
4267			 + "Redirect Url: " + nexturl + "\n"
4268	RZtrace( "Delete Item Clicked", RZ.message );
4269
4270	if (isNaN(recordid))
4271	{
4272		win.alert( 'Invalid Record Id: ' + recordid )
4273		return void(0)
4274	}
4275	else if (recordid=='')
4276	{
4277		win.alert( 'Record Not Specified (Id is Blank)' )
4278		return void(0)
4279	}
4280
4281	var deletemsg='Are you sure you want to delete this link?\n\n'
4282	+'Keep in mind that if this link or page is not being referenced from any other page from your website'
4283	+' then DELETE will physically delete the page record from the database and there would be no way to restore'
4284	+' it if you change your mind. You want to proceed?';
4285	//if (!win.confirm("Ok to Delete This Item?")) return
4286
4287	if(module !== 'links') {
4288		deletemsg = 'Are you sure you want to delete this item?\n\n This action is not reversible.';
4289	}
4290
4291	if(RZ.pagetemplatename === 'document_center'){
4292		var delName = selectedBtn.parentNode.parentNode.querySelector('.docs-toggle');
4293		if(delName != null){
4294			var delChild = delName.firstChild;
4295			var delTexts = [];
4296
4297			while(delChild){
4298				if(delChild.nodeType == 3){
4299					delTexts.push(delChild.data);
4300				}
4301				delChild = delChild.nextSibling;
4302			}
4303
4304			var delText = delTexts.join("");
4305			var delPromp = win.prompt("Are you sure you want to delete this whole category?"
4306			+"\nPlease keep in mind that, if you delete this category, ALL THE DOCUMENTS UNDER THIS CATEGORY WILL BE PERMANENTLY DELEETED AND CAN NOT BE RESTORED BY REVIZE STAFF."
4307			+"\n\nIf you are sure and still want to delete the '"+ delText +"' category, please type in the following in all caps:"
4308			+"\n"+delText.toUpperCase());
4309
4310			if(delPromp !== delText.toUpperCase()){
4311				alert('You entered "'+delPromp+'" while the system expected "'+delText.toUpperCase()+'".\nThe record will NOT be deleted.');
4312				return;
4313			}
4314		} else {
4315			if (!win.confirm(deletemsg)) return
4316		}
4317	} else if(RZ.pagetemplatename === 'agenda_list' || RZ.pagetemplatename === 'agendalist'){
4318		if (!win.confirm(deletemsg)) return
4319	} else {
4320		if (!win.confirm(deletemsg)) return
4321	}
4322
4323	//----- Call Developer defined ondelete handler and quit if it returns false
4324	if (typeof win.ondelete == 'function')
4325	{
4326		// update args with default values and pass to ondelete handler
4327		// returns false to cancel delete, or object with below values;
4328		var returnValues = win.ondelete(args);
4329		if (typeof returnValues == 'undefined' || returnValues == false)
4330		{
4331			win.status = 'Delete Canceled'
4332			return void(0)
4333		}
4334		else if (typeof returnValues == 'object')
4335		{
4336			if (typeof returnValues.nexturl != 'undefined')
4337				nexturl = returnValues.nexturl
4338		}
4339
4340	}
4341
4342	if (EZ.isFeature("EZ"))
4343		RZsetcookie('RZlastedit', (RZ.pagetype + ':delete:' + module + ':' +recordid), RZ.webspace);
4344
4345	// Use the XML translator servlet instead of the old XML form method.
4346	nexturl = RZgetEditPageUrl(nexturl);
4347	var deleteUrl =	"/revize/HTTPTranslatorServlet" +
4348					"?resourcetype=record" +
4349					"&action=delete" +
4350					"&webspace=" + RZ.webspace +
4351					"&softdelete=true" +
4352					"&id=" + recordid +
4353					"&pagetemplateid=" + RZ.pagetemplateid +
4354					"&linkedmoduleid=" + RZ.linkedmoduleid +
4355					"&linkedrecordid=" + RZ.linkedrecordid +
4356					"&modulename=" + module +
4357					"&pagekey=" + RZ.page_key +
4358					"&redirect=" + escape(RZabsoluteUrl(nexturl));
4359	RZtrace( "Delete Item Request", deleteUrl );
4360	RZactionReset();
4361	win.location = deleteUrl;
4362
4363
4364}
4365/*---------------------------------------------------------------------------
4366Bring up page permissions window.
4367
4368The options argument can contain one of the following:
4369	nexturl, linkname, module, object
4370
4371The AdminPanel uses adminpanel option to specify additional url parameters.
4372----------------------------------------------------------------------------*/
4373function RZpermissions(set,options)
4374{
4375	var pos;
4376	if (typeof set == 'object') set = '';	//called from admin panel
4377	if (typeof set == 'undefined') set = ''
4378	if (typeof options == 'undefined') options = ''
4379
4380	var adminpanel = RZgetoption(options, 'adminpanel');
4381	var linkname = RZgetoption(options, 'linkname');
4382	var module = RZgetoption(options, 'module');
4383	var nexturl = RZgetoption(options, 'nexturl');
4384	if (nexturl == '')
4385	{
4386		var fileInfo = RZgetfileinfo('/revize/util/permissions-editform.jsp')
4387		nexturl = RZbuildurl(fileInfo)
4388	}
4389
4390	RZ.message = ''
4391	RZ.parameters = nexturl
4392	RZaddUrlParameter( 'webspace=' + RZ.webspace )
4393	RZaddUrlParameter( 'page_key=' + RZ.page_key )
4394	RZaddUrlParameter( 'parent_key=' + RZ.parent_key  )
4395	if(RZ.workflowmodule != '' && RZ.workflowmodule != undefined)
4396		RZaddUrlParameter('workflowmodule=' + RZ.workflowmodule);
4397	if (adminpanel)
4398		RZaddUrlParameter(adminpanel)
4399
4400	if (set == '')
4401	{
4402		set = RZ.permissions_module + '.page_key=' + RZ.page_key
4403		if (linkname != '')
4404			set += linkname
4405		else if (module != '')
4406			set += module
4407	}
4408	RZaddUrlParameter('set='+escape(set))
4409
4410	RZtrace('Page Permissions Call',RZ.message)
4411	RZ.editWindow = RZpopupUrl( 'EditWindow', RZ.parameters, 600, 500, 'yes')
4412}
4413/*---------------------------------------------------------------------------------------
4414Find all tagName elements with className
4415---------------------------------------------------------------------------------------*/
4416function RZgetTagsByClassName(tagName,className)
4417{
4418	var tags = [];
4419	var elements = document.getElementsByTagName(tagName);
4420	if (elements.length)
4421		for (var i=0;i<elements.length;i++)
4422			if ( (elements[i].className+' ').indexOf(className+' ') != -1)
4423				tags.push(elements[i]);
4424	return tags;
4425}
4426/*---------------------------------------------------*/
4427/*BOOKMARK ----- String minupulation functions -----*/
4428/*-------------------------------------------------*/
4429/*---------------------------------------------------------------------------------------
4430Return number occurances of chars (default char is dash)
4431---------------------------------------------------------------------------------------*/
4432function RZdup(number,char)
4433{
4434	var value = ''
4435	if (!char) char = '-';
4436	for (var i=0;i<number;i++)
4437		value += char;
4438	return value;
4439}
4440/*-----------------------------------------------------------------------------------------------
4441Append th, st, nd or rd to number specified by n.
4442Credit: http://uk.answers.yahoo.com/question/index?qid=20100902055222AAr3Bt6
4443-----------------------------------------------------------------------------------------------*/
4444function RZnth(n)
4445{
4446	n=n+'';
4447	if (!n) return 0;
4448	var l=n.length, r=parseInt(n.substring(l-2,l)), i = n % 10;
4449	var suffix = ((r < 11 || r > 19) && (i < 4)) ? ['th','st','nd','rd'][i] : 'th';
4450	return n + suffix;
4451}
4452/*-----------------------------------------------------------------------------
4453Return "s" if count > 1 otherwise return empty string
4454-----------------------------------------------------------------------------*/
4455function RZs(count)
4456{
4457		if (count.constructor == Array)
4458			count = count.length;
4459		else if (typeof(count) == 'string')
4460			count = count.split(',').length;
4461		else if (isNaN(count))
4462			count = 0;
4463
4464	if (count != 1)
4465			return 's';
4466	else
4467	return '';
4468}
4469/*------------------------------------------------------------------------------
4470Remove any leading and ending blank spaces from string (trim)
4471
4472Parameters:
4473	tmpStr - Input string
4474
4475Returns:
4476	String with leading and trailing spaces removed
4477------------------------------------------------------------------------------*/
4478function RZtrim(tmpStr)
4479{
4480	if (typeof(tmpStr) == 'undefined' || tmpStr == null || tmpStr == '')
4481		return tmpStr;
4482
4483	//----- need to strip \t besides ' '
4484	//while(tmpStr.substring(0,1) == ' ')
4485	while (/^\s/.test(tmpStr))
4486		tmpStr = tmpStr.substring(1, tmpStr.length);
4487
4488	//while(tmpStr.substring(tmpStr.length-1,tmpStr.length) == ' ')
4489	while (/\s$/.test(tmpStr))
4490		tmpStr = tmpStr.substring(0, tmpStr.length - 1);
4491
4492	return tmpStr;
4493}
4494/*------------------------------------------------------------------------------
4495RZreplace(inStr, fromString, toString)
4496
4497Replace all occurances of fromString with toString
4498
4499Created before javascript string.replace was available
4500(retain RZreplaceAll & RZreplacesubstring for backward compatibility)
4501
4502Parameters:
4503	inStr - Input String
4504	fromString - String to replace
4505	toString - Replacement String
4506
4507Returns:
4508	String with replacements
4509------------------------------------------------------------------------------*/
4510function RZreplace( inStr, fromString, toString )
4511{ return RZreplacesubstring( inStr, fromString, toString ) }
4512function RZreplaceAll( inStr, fromString, toString )
4513{ return RZreplacesubstring( inStr, fromString, toString ) }
4514function RZreplacesubstring( inStr, fromString, toString )
4515{
4516	var pos = 0
4517	if (inStr == null
4518	|| typeof inStr.length == 'undefined' //true or false
4519	|| inStr.length == 0) return '';
4520
4521	var fromLen = fromString.length
4522	if (fromLen == 0) return inStr
4523
4524	while (true)
4525	{
4526		pos = inStr.indexOf(fromString,pos)
4527		if (pos == -1) break
4528		inStr = RZsubstring( inStr, 0, pos )
4529		      + toString
4530		      + RZsubstring( inStr, pos + fromLen )
4531		pos += toString.length
4532	}
4533	return inStr
4534}
4535/*------------------------------------------------------------------------------
4536Subsitute for substring method (does not produce javascript errors)
4537
4538A null or empty input string returns empty string
4539
4540Start and end positions outside boundries intrepreted as follows:
4541
4542	if end position not specified or greater than string length,
4543	adjust to input string length
4544
4545	if end position before 1st character,
4546	return empty string
4547
4548	if start position greater than ending position,
4549	return empty string
4550
4551	if start position less than 0,
4552	assume 0
4553
4554Parameters:
4555----------
4556	str-		Input string
4557	startpos-	Starting position
4558	endpos-		Ending position (optional)
4559
4560Returns:
4561	substring as described above.
4562
4563------------------------------------------------------------------------------*/
4564function RZsubstring(str, startpos, endpos)
4565{
4566	if (typeof endpos == 'undefined') endpos = str.length + 1
4567
4568	//----- Validate input string
4569	if (str == null || str.length == 0)	//if null or empty string
4570		return "";						//...return empty string
4571
4572	//----- Validate end position
4573	if (endpos > str.length )			//greater than string length
4574		endpos = str.length;			//...set to length
4575
4576	else if( endpos <= 0 )				//if end position before 1st character
4577		return "";						//...return empty string
4578
4579	//----- Validate start position
4580	if( startpos >= endpos )  			//if start position greater than ending position
4581		return "";						//...return empty string
4582
4583	else if (startpos < 0) 				//if start position less than 0
4584		startpos = 0;					//...assume 0
4585
4586	//----- Return the substring
4587	return str.substring(startpos,endpos);
4588}
4589/*---------------------------------------------------------------------------
4590returns rightmost number of characters specified
4591
4592Parameters:
4593	str - Input String
4594	noChars - number of rightmost characters desired
4595
4596Example:
4597	* right("1234",2) returns "34"
4598    * right("1234",0) returns ""
4599    * right("0",4) returns "0"
4600
4601Returns:
4602	Rightmost substring possible; does not throw exception if string too short
4603----------------------------------------------------------------------------*/
4604function RZright( str, noChars )
4605{
4606	if (!str) return '';
4607	var len = str.length;
4608	if (len == 0) return "";
4609
4610	if (noChars > len) noChars = len;
4611	return str.substring(len-noChars);
4612}
4613/*---------------------------------------------------------------------------------------------
4614Converts number to the nearest integer
46150 is returned if not a valid number unless a defaultValue is supplied
4616
4617Parameters:
4618	number - string or number to be converted to an integer (whole number)
4619	defaultValue - number returned in number parameter is not a valid number
4620
4621Returns:
4622	Nearest whole number of input number; if input number or string is undefined or not
4623	a number, the defaultValue is returned
4624---------------------------------------------------------------------------------------------*/
4625function RZinteger(number,defaultValue)
4626{
4627	if (typeof defaultValue == 'undefined') defaultValue = 0
4628
4629	if (isNaN(number))
4630		return defaultValue
4631
4632	return parseInt( parseFloat(number)+.5 )	//convert number to number then round up
4633}
4634
4635/* Same as RZcheckoptions (retained for backward compatibility) */
4636function RZcheckOptions( pOptions, pChoices )
4637{ return RZcheckoptions( pOptions, pChoices ) }
4638/*---------------------------------------------------------------------------
4639Look for specific option choice(s) in the options string.  Both options and
4640choices use commas to seperate multiple individual options.
4641
4642Parameters:
4643        pOptions - Caller supplied options (e.g. "filter,editsingle,alt")
4644        pChoices - specific option choices to look for (e.g. alt,url,image)
4645
4646Returns:
4647        True if at least one choice is contained in options
4648        False if none of the choice(s) are found
4649
4650Example: RZcheckOptions('cristy,pam,sandy','cristy') returns true
4651----------------------------------------------------------------------------*/
4652function RZcheckoptions( optionsArg, pChoices )
4653{
4654	if (typeof(optionsArg) == 'object' && typeof(optionsArg.length) != 'undefined')
4655		pOptions = optionsArg.join(',');
4656	else
4657		pOptions = optionsArg
4658
4659	if (pOptions == null || pChoices == null
4660	|| typeof pOptions == 'undefined' || typeof  pChoices == 'undefined')
4661		return false;
4662
4663	var str, pos;
4664	var inputSep = pOptions.indexOf('|') != -1 ? '|' : ',';
4665	var inputOpts = inputSep + pOptions + inputSep;
4666	inputOpts = inputOpts.toLowerCase();
4667
4668	var searchSep = pChoices.indexOf('|') != -1 ? '|' : ',';
4669	var searchOpts = pChoices.toLowerCase();
4670
4671	//----- For each desired choice ...
4672	while ( !searchOpts == "" )
4673	{
4674		str = searchOpts;
4675		pos = str.indexOf(searchSep);
4676		if (pos == 0)
4677		{
4678			searchOpts = str.substring(pos+1);	//strip comma
4679			continue;
4680		} else if (pos > 0)
4681		{
4682			searchOpts = str.substring(pos+1);
4683			str = str.substring(0,pos);
4684		} else
4685		{// no commaa
4686			searchOpts = "";
4687		}
4688		// check for this choice
4689		if (inputOpts.indexOf(inputSep + str + inputSep) >= 0) return true;
4690		if (inputOpts.indexOf(inputSep + str + "=") >= 0) return true;
4691	}
4692	return false;
4693}
4694/*---------------------------------------------------------------------------
4695Looks for a key=value in the options string and returns the value portion.
4696(clone of getValue in RZTabSupport)
4697
4698Parameters:
4699	options - String searched for key=value
4700	key - Key to find in options string
4701
4702Returns:
4703	Associated value when key is found, otherwise returns blank string
4704----------------------------------------------------------------------------*/
4705function RZcheckoptionvalue(pOptions,pKey)
4706{ return RZgetoption(pOptions,pKey) }
4707
4708function RZgetKeyValue(pOptions,pKey)
4709{ return RZgetoption(pOptions,pKey) }
4710
4711function RZgetoptionvalue(pOptions,pKey)
4712{ return RZgetoption(pOptions,pKey) }
4713
4714function RZgetoption(pOptions, pKey, defaultValue)
4715{
4716	var pos, str, keyEqual;
4717	if (!pOptions) pOptions = '';
4718	if (typeof defaultValue == 'undefined') defaultValue = '';
4719
4720	//----- Search for key=
4721	keyEqual = pKey + "=";
4722	str = "," + pOptions;
4723	pos = str.toLowerCase().indexOf( keyEqual.toLowerCase() );
4724
4725	if (pos == -1) 	// key not found
4726		str = defaultValue;
4727	else
4728	{
4729		//----- Keep everything after = up to ,
4730		str = pOptions.substring(pos + keyEqual.length - 1);
4731		pos = str.indexOf(",");
4732		if (pos >= 0) str = str.substring( 0, pos );	// value
4733	}
4734	//----- For backward compatibility: only map to true or false
4735	//		if defaultValue specified as boolean type
4736	if (typeof defaultValue == 'boolean')
4737		str = RZistrue(str)
4738	return str;
4739}
4740/*---------------------------------------------------------------------------
4741Return following as false: 'off', 'no', 'false', false, NaN, null, undefined
4742otherwise any other true value as true
4743----------------------------------------------------------------------------*/
4744function RZistrue(str)
4745{
4746	if (str == 0 || str == false
4747	|| str === 'off' || str === 'no' || str === 'false')
4748		str = false;
4749	else
4750		str = true;
4751	return str;
4752}
4753/*---------------------------------------------------------------------------
4754Call Next URL (popup or forward link)
4755----------------------------------------------------------------------------*/
4756function RZcallNextUrl( name,url, width,height,scroll)
4757{
4758	if ( RZpopupUrl(name,url, width,height,scroll) == null )
4759	{
4760		RZtrace("Calling Next URL Form", "URL: " + url )
4761		document.location = url
4762	}
4763}
4764/*---------------------------------------------------------------------------
4765RZeditor(): See RZeditorsetup in snippet_helper_rte.
4766Stub kept here for backward compatibility and warning message.
4767----------------------------------------------------------------------------*/
4768function RZeditor()
4769{
4770	if( RZ.pagetype == 'editform' )
4771		RZeditorsetup()
4772	else
4773		RZalert('Rich Text Editor Must be Opened on Form Page')
4774}
4775/*---------------------------------------------------------------------------
4776Set Link Property value in link object passed to RTE (NOT yet used or tested)
4777Might be useful on edit forms to set link manager properties.
4778----------------------------------------------------------------------------*/
4779function RZsetLinkProperty( linkObj, property )
4780{
4781	if (typeof RZ.link[linkname] != 'object')
4782		if (typeof RZ.link[property] == 'undefined')
4783			linkObj[property] = ''
4784		else
4785			linkObj[property] = RZ[property]
4786}
4787/*---------------------------------------------------------------------------
4788Append key=value to end of set if key not already in set and value not blank.
4789
4790Optional argument options argument
4791	if not an object and true, replace existing key with specified value.
4792	if object then
4793		options.replace contains replaceFlag true to override a prior value
4794		options.update set true if value changed (replaceFlag must be true)
4795
4796Returns true if prior value for key was changed.
4797----------------------------------------------------------------------------*/
4798function RZaddset(key, value, options)
4799{
4800	var replaceFlag = false;
4801	if (typeof options == 'object')
4802		replaceFlag = options.replace;
4803	else if (options)
4804		replaceFlag = options;
4805
4806    // will property be updated (i.e. over-ridden)
4807	var status = false;			//default return status
4808	if (typeof value == 'undefined' || value == '') return status;
4809
4810	var setCheck = ','+ RZ.set;
4811	var start = setCheck.indexOf(','+key);
4812	if (start == -1)
4813	{
4814		if (RZ.set != '') RZ.set += ','
4815		RZ.set += key + '=' + value;
4816	}
4817	else if (replaceFlag)
4818	{
4819		var end = RZ.set.indexOf(',',start);
4820		if (end == -1) end = RZ.set.length;
4821		var oldStr = RZ.set.substring(start,end);
4822		var newStr = key + '=' + value;
4823		if (oldStr != newStr)  status = true;
4824		RZ.set = RZreplace( RZ.set, oldStr , newStr );
4825	}
4826
4827	if (typeof options == 'object')
4828	 	options.update = (options.update || status);
4829
4830	return status;
4831}
4832/*---------------------------------------------------------------------------
4833Set or update RZ property
4834	options.replace contains replaceFlag true to override a prior value
4835	options.update set true if value changed (replaceFlag must be true)
4836----------------------------------------------------------------------------*/
4837function RZupdate(key,value,options)
4838{
4839	if (!options.replace && RZ[key] != '') return;
4840	if (!value == 'undefined' || value == '') return;
4841
4842    // will property be updated (i.e. over-ridden)
4843	if (RZ[key] != '' && RZ[key] != value)
4844		options.update = true;
4845
4846	RZ[key] = value;
4847}
4848/*---------------------------------------------------------------------------
4849Set or update form property (probably won't work for Firefox).
4850	options.replace contains replaceFlag true to override a prior value
4851	options.update set true if value changed (replaceFlag must be true)
4852----------------------------------------------------------------------------*/
4853function RZupdateFormProperty(field,key,value,options)
4854{
4855	if (!options.replace && typeof field[key] != 'undefined') return;
4856    if (!field || typeof value == 'undefined') return;
4857
4858    if (typeof value == 'string' && value == '')
4859    	return;
4860
4861    else if (typeof value == 'object')
4862    {
4863		if (typeof value.length == 'undefined'
4864		|| value.length < 1
4865		|| value[0] == '')
4866    		return;
4867	}
4868
4869    // will property be updated (i.e. over-ridden)
4870    if (typeof field[key] != 'undefined' && field[key] != '' && field[key] != value)
4871		options.update = true;
4872
4873    field[key] = value;
4874}
4875/*-----------------------------------------------------------------------------
4876get innerHTML of el with leading and trailing spaces and &nbsp; removed.
4877return blank if el not valid element or id of valid element or innerHTML is not
4878valid element property.
4879-----------------------------------------------------------------------------*/
4880function RZgetInnerHTML(el)
4881{
4882	if (typeof el == 'string')
4883		el = document.getElementById(el);
4884
4885	var html = '';
4886	if (el && typeof(el.innerHTML) != 'undefined')
4887	{
4888		html = el.innerHTML
4889		html = html.toString();
4890		html = html.replace(/^(<br[^>]*>)*([\s\S]*?)(<br[^>]*>)*$/, '$2');
4891		html = html.replace(/^(\s|&nbsp;)*([\s\S]*?)(\s|&nbsp;)*$/, '$2');
4892	}
4893	return html;
4894}
4895/*-----------------------------------------------------------------------------
4896set innerHTML if el is valid element or id of valid element and innerHTML is
4897valid element property.
4898-----------------------------------------------------------------------------*/
4899function RZsetInnerHTML(id,html,doc)
4900{
4901	var el = id;
4902	if (!doc) doc = document;
4903	if (typeof el == 'string')
4904		el = doc.getElementById(id);
4905
4906	if (el && typeof(el.innerHTML) != 'undefined')
4907	{
4908		el.innerHTML = html.toString().replace(/\n/g,'<br>');
4909		return true;
4910	}
4911	//RZwarn('id=' + id + ' html element NOT found','level=info');
4912	return false;
4913}
4914/*---------------------------------------------------------------------------
4915Open Trace Window and Display Message
4916DCO 10-20-2014: Save trace for admin panel if RZ.trace not enabled
4917----------------------------------------------------------------------------*/
4918function RZtrace(heading,text)
4919{
4920	//console.log({TRACE:heading, message:text})
4921	if (!RZ.trace && !RZtrace.show) return
4922	if (!text) text = ''
4923
4924	text = text.toString();
4925	text = text.split('--').join('\n')
4926
4927	var MSIE = true;
4928	if (navigator.appVersion.indexOf('MSIE') == -1) MSIE = false;
4929
4930	//----- Always open using browser specific options
4931	//		(if already open, it reconnects to existing window)
4932	while (true)
4933	{
4934		if(!MSIE) //Navigator
4935		{
4936			RZ.tracewin = window.open('', 'RevizeTrace',
4937			'width=420,height=580,location=no,menubar=no,resizable=yes,screenX='
4938			+ (screen.availWidth-430)
4939			+ ',screenY=20,directories=no,status=no,scrollbars=yes');
4940		}
4941		else  //IE
4942		{
4943			RZ.tracewin = window.open('', 'RevizeTrace',
4944			'width=420,height=580,location=no,menubar=no,resizable=yes,left='
4945			+ (screen.availWidth-430)
4946			+ ',top=20,directories=no,status=no,scrollbars=yes');
4947		}
4948		//----- Close trace window if no access and open again
4949		if (MSIE && !RZwinaccess(RZ.tracewin))
4950			RZ.tracewin.close()
4951		else
4952			break
4953	}
4954
4955	//----- Convert special characters
4956	text = text.split('<').join('&lt;');
4957	text = text.split('>').join('&gt;');
4958
4959	//----- Display message.
4960	if (heading != '')
4961		RZ.tracewin.document.writeln(
4962			'</pre>',
4963			'<html><title>Trace</title><body>\n',
4964			'<b>',heading,'</b><br>\n',
4965			'<font size="-2" face="Arial">',location.href,'</font>\n',
4966			'<pre>\n',
4967			text)
4968	else if (text != '')
4969		RZ.tracewin.document.writeln( text )
4970	else
4971		RZ.tracewin.document.writeln( '</pre>' )
4972
4973	//----- Give focus, if trace window already open and accessible
4974	if (!MSIE || RZwinaccess(RZ.tracewin)) RZ.tracewin.scrollBy(0,600)
4975}
4976
4977/*---------------------------------------------------------------------------
4978POPUP EDITOR CAN NO LONGER BE CALLED FROM PUBLISHED PAGES
4979
4980***** Editor Support Code *****
4981
4982Open Html Editor in popup window
4983If specified field exists in XMLForm, use that value.
4984Otherwise Revize editor will read and store data from content database.
4985----------------------------------------------------------------------------*/
4986function RZcallEditor( moduleName, fieldName, width, height, options, recordid )
4987{
4988	if (typeof moduleName == 'undefined') moduleName = '';
4989	if (typeof fieldName == 'undefined') fieldName = '';
4990	if (typeof width == 'undefined' || width=='' ) width = '600';
4991	if (typeof height == 'undefined' || height=='') height = '400';
4992	if (typeof options == 'undefined') options = '';
4993	if (typeof recordid == 'undefined') recordid = '';
4994
4995	//----- Make sure field and image elements are supplied
4996	var msg = '';
4997	var useDatabase = false;
4998	if (moduleName == '')
4999		msg = "Module Name Not Specified"
5000	else
5001	{
5002		if (fieldName == '')
5003			msg = "Editable Field Name Not Specified"
5004		else
5005		{
5006		if (typeof document.XMLForm == 'undefined')
5007			useDatabase = true;
5008		else
5009			if (typeof document.XMLForm[fieldName] == 'undefined')
5010			useDatabase = true;
5011		}
5012	}
5013
5014
5015	//----- Report any problems with arguments before using
5016	if (msg != '')
5017	{
5018		RZalert( 'Invalid Revize Editor Request\n\n'
5019			   + 'Function: snippet_helper.js:RZcallEditor()\n\n'
5020			   + 'Problem: ' + msg + '\n' )
5021		return;
5022	}
5023
5024	//----- Make trace entry
5025	RZ.message = '';
5026	RZmsgAdd( "module"  , '\t' + moduleName )
5027	RZmsgAdd( "field"   , '\t' + fieldName )
5028	RZmsgAdd( "width"   , '\t' + width )
5029	RZmsgAdd( "height"  , '\t' + height )
5030	RZmsgAdd( "recordid", '\t' + recordid )
5031	RZmsgAdd( "options" , '\t' + options )
5032	RZtrace( "Revize Editor Request", RZ.message )
5033
5034	//----- Call Editor screen, passing parameters via Url
5035	var url;
5036	var editorDir = '/revize/'
5037
5038	if (!RZ.MSIE || RZ.browserversion < 5.5)
5039	{
5040		editorDir += 'javaeditor'
5041
5042		// Convert any rich edit options to applet editor Url parameters syntax
5043		options = RZ.options.split(';').join('&')
5044		if (options.substring(1,3) == '&&') options = options.substring(1)
5045	}else
5046	{
5047		editorDir += 'htmleditor'
5048		options = RZeditorOptions(options);		//convert to rich edit format
5049		options = 'options=' + escape(options)	//passed as a single parameter
5050	}
5051	url = editorDir + '/editor-editform.jsp?webspace=' + RZ.webspace;
5052	if (useDatabase != '') url += '&module=' + moduleName;
5053	url += '&field=' + fieldName
5054	if (recordid != '') url += '&recordid=' + recordid
5055	url += '&width=' + width + '&height=' + height + '&' + options
5056	RZpopupUrl('revize_editor',url,width,height,'no')
5057}
5058/*---------------------------------------------------------------------------
5059Open Url in Popup Window (return true if popup)
5060
5061Originally used popup window if either width, height or SCROLL was not blank;
5062with advent of RZaction() and use of RZ object arguments, do not assume popup
5063based on scroll value or if both width and height are set to 0.
5064
5065Since scroll is last feature, it can specify other features after the scroll
5066value. For example:
5067	yes,location=yes,menubar=yes,toolbar=yes,directories=yes'
5068
5069If niether width, heigth or scroll are specified assume popup window with no
5070features specified.
5071
5072Returns:
5073	window object of popup window or null if popup window not used
5074----------------------------------------------------------------------------*/
5075function RZpopupUrl(name,url,width,height,scroll)
5076{
5077	var useFeatures = true;
5078	if(typeof width == 'undefined'
5079	&& typeof height == 'undefined'
5080	&& typeof scroll == 'undefined')
5081		useFeatures = false;
5082	else
5083	{
5084		var popup = false;
5085		if (typeof width != 'undefined' && width != '' && width != 0 && width != '0')
5086			popup = true;
5087		if (typeof height != 'undefined' && height != ''	&& height != 0 && height!= '0')
5088			popup = true;
5089		if (!popup) return null;
5090
5091		// DCO 03-26-2014: for IE11+, remove RZ.baseurlprefix
5092		if ((RZ.isIEw3c || RZ.isMSEdge) && RZ.baseurlprefix && url.indexOf(RZ.baseurlprefix) == 0)
5093			url = url.substr(RZ.baseurlprefix.length);
5094	}
5095
5096	RZ.message = "Name: " + name + "\n"
5097		 + "Url:  " + url + "\n"
5098		 + "Width:  " + width + "\n"
5099		 + "Heigth: " + height + "\n"
5100		 + "Scroll: " + scroll + "\n"
5101	RZtrace("Opening Popup Window", RZ.message)
5102
5103	//----- Determine popup properties
5104	if(typeof url == 'undefined') url = ''
5105	if(typeof name == 'undefined') name = 'RevizeWindow'
5106	if(typeof width == 'undefined' || width=='') width = 400
5107	if(typeof height == 'undefined' || height=='') height = 400
5108	if(typeof scroll == 'undefined' || scroll=='') scroll = 'yes'
5109
5110	var menubar = 'no'
5111	var location = 'no'
5112	var toolbar = 'no'
5113	var directories = 'no'
5114	var status = 'yes'
5115	if( RZ.trace || RZ.debug )
5116	{
5117		scroll = 'yes'
5118		menubar = 'yes'
5119		location = 'yes'
5120		toolbar = 'yes'
5121		directories = 'yes'
5122		status = 'yes'
5123		width = parseInt(width) + 15
5124		height = parseInt(height) + 50
5125	}
5126	else if (name == 'admin')
5127	{
5128		menubar = 'yes'
5129		location = 'yes'
5130	}
5131
5132	var features = 'width=' + width + ',height=' + height
5133			   + ',location='+location
5134			   + ',menubar='+menubar
5135			   + ',resizable=yes'
5136			   + ',toolbar=' + toolbar
5137			   + ',directories=' + directories
5138			   + ',status=' + status
5139			   + ',scrollbars=' + scroll	//must be last to allow specify features
5140
5141	var x = (screen.availWidth - width) / 2 - 10
5142	if (RZ.browserdev) x=0;
5143
5144	var y = (screen.availHeight - height) / 2 - 30
5145	if (y < 50) y = 0
5146
5147	if(navigator.appVersion.indexOf('MSIE') == -1 && !RZ.isIEw3c )  // Netscape
5148		features += ',screenX=' + x.toString()
5149				 +  ',screenY=' + y.toString()
5150	else                                            // IE browser
5151		features += ',left=' + x.toString()
5152				 +  ',top=' + y.toString()
5153	if (!useFeatures) features = ''	//do not specify features
5154
5155	/*****
5156	First open the popup window and give it focus in case it was already open.
5157	It is possible that the popup window has been left open by another instance
5158	of the browser.  When this occurs on IE, the popup window will NOT have
5159	access to window.opener property.  To avoid this problem, we wait a second
5160	and then call RZpopupAccess() to close and reopen the popup if the popup
5161	window does not have proper access to this window.  We did not want to
5162	always close and reopen the window because it can be distracting for
5163	content editors.
5164	*****/
5165
5166	//TODO:	This statement gets 1075 error on IE when opening publishing window
5167	//		if popup edit form was left open from another edit (calendar_app)
5168	RZ.popupwin = window.open( url, name, features );
5169
5170	//----- On Netscape, RZ.popupwin sometimes not defined
5171	if (RZ.popupwin == null || typeof RZ.popupwin == 'undefined')
5172		RZ.popupwin = window.open( url, name, features );
5173
5174	//----- Give popup window focus
5175	RZ.timeoutfocus = window.setTimeout('RZfocus(RZ.popupwin)', 500);
5176
5177	//----- Check for access after page loads
5178	var str = 'RZpopupAccess("' + url + '","' + name+ '","' + features + '")'
5179	RZ.timeoutaccess = window.setTimeout(str, 1000)
5180
5181	return RZ.popupwin;
5182}
5183/*---------------------------------------------------------------------------
5184Cancel focus and access timeout events.
5185----------------------------------------------------------------------------*/
5186function RZcancelPopupEvents()
5187{
5188	window.clearTimeout(RZ.timeoutfocus)
5189	window.clearTimeout(RZ.timeoutaccess)
5190}
5191/*---------------------------------------------------------------------------
5192Sets focus in case the specified window was left open from a previous call
5193----------------------------------------------------------------------------*/
5194function RZfocus(win)
5195{
5196    if (RZwinaccess(win))
5197        if (win.name != 'rzrte' && win.name != 'RZpublishing') win.focus();
5198}
5199/*---------------------------------------------------------------------------
5200See above description in RZpopupUrl
5201----------------------------------------------------------------------------*/
5202function RZpopupAccess(url,name,features)
5203{
5204	var str = ''
5205	if (!RZwinaccess(RZ.popupwin))
5206	{
5207		str = 'popup window closed'
5208	}else
5209	{
5210		str = 'opener: '
5211		if (RZwinaccess(RZ.popupwin.opener))
5212		{
5213			if (typeof RZ.popupwin.opener.location == 'undefined')
5214				str += '*no url*'
5215			else
5216				str += RZ.popupwin.opener.location.href
5217		}
5218		else if (typeof RZ.popupwin.opener != 'undefined')
5219			str += 'no access to opener'
5220		else
5221			str += 'opener not defined'
5222	}
5223
5224	var msg = 'name: ' + name + '\n'
5225            + 'url: ' + url + '\n'
5226            + str + '\n'
5227	//alert('Popup Properties\n\n' + msg)
5228	RZtrace( 'Popup Properties', msg)
5229
5230	//----- Quit if popup window has been closed
5231	if (!RZwinaccess(RZ.popupwin)) return
5232
5233	//----- If no access to opener, close window and reopen
5234	if ( !RZwinaccess(RZ.popupwin.opener))
5235	{
5236		RZ.popupwin.close();
5237		RZ.popupwin = window.open( url, name, features );
5238		return
5239	}
5240
5241	/*
5242	//----- If Revize Control Panel... (future)
5243	if ( name == 'revizecontrol' )
5244	{
5245		if (typeof RZ.popupwin.RZ == 'undefined')
5246		{
5247			window.focus()
5248			RZ.popupwin.document.write('<title>Revize Control Panel</title>')
5249		}
5250	}
5251	*/
5252  	RZ.popupwin = null		//indicate popup processing complete
5253}
5254/*---------------------------------------------------------------------------------------------
5255Wait for access to "win" to perform "waitCommand" displaying "waitMsg" while waiting;
5256Only wait "maxSeconds" (default 30); check every "msInterval" (default 1000) milliseconds.
5257---------------------------------------------------------------------------------------------*/
5258function RZwait(win, waitCommand, waitMsg, maxSeconds, msInterval)
5259{
5260	if (typeof waitMsg == 'undefined') waitMsg = 'Waiting for access'
5261	if (typeof maxSeconds == 'undefined') maxSeconds = 30
5262	if (typeof msInterval == 'undefined') msInterval = 1000
5263
5264	RZcancelPopupEvents()	//RZwait overrides automatic popup events
5265
5266	//----- Validate arguments
5267	var msg = ''
5268	if (typeof win != 'string')
5269		msg = '1st Argument is type ' + typeof win;
5270	else if(typeof waitCommand != 'string')
5271		msg = '2nd Argument is type ' + typeof win;
5272
5273	if (msg != '')
5274	{
5275		msg = 'RZwait must be called with string variables\n\n' + msg;
5276		RZalert(msg)
5277		return;
5278	}
5279
5280	//----- Setup call to RZwaitCheck...
5281	var now = new Date()
5282	RZ.waitstart = now.getTime()	//start of wait
5283	RZ.waitaccess = 0
5284
5285	waitCommand = RZreplacesubstring( waitCommand, '"', '\\"' )
5286
5287	RZ.waitcall = 'RZwaitCheck( ' + win
5288	                          + ', "' + waitCommand + '" '
5289	                          + ', "' + waitMsg  + '" '
5290	                          + ', ' + maxSeconds
5291	                          + ', ' + msInterval
5292	                          + ' )'
5293
5294	RZtrace('Setup Wait', RZ.waitcall )
5295	//eval( RZ.waitcall )		//call RZwaitCheck() immediately
5296	setTimeout( RZ.waitcall, msInterval );	//give the url a chance to load
5297}
5298/*---------------------------------------------------------------------------
5299----------------------------------------------------------------------------*/
5300function RZwaitError(message)
5301{
5302	return true
5303}
5304/*---------------------------------------------------------------------------------------------
5305If access to "win" or "maxSeconds" have passed since "RZ.waitstart", perform "waitCommand";
5306otherwise wait another "msInterval" milliseconds.
5307
5308Access means permisison to access window, RZ not null and...
5309either window name is not blank (works for most non-Revize enabled pages)
5310--or-- RZ.loaded is not undefined nor null
5311
5312Notes:
5313It is possible that access to "win" is lost after checking access but prior to actually
5314accessing "win" variables which can cause one of the following JavaScript errors:
5315	RZ is null or not an object
5316	object does not support this property or method
5317
5318Checking the page access before the new url starts to load is believed to be one cause.
5319An alternative onerror handler is set to catch these potential javascript errors.
5320This function stops running after a javascript error but unfortunately when MS studio is
5321installed and IE script debugging is not disabled, the currently defined onerror handler
5322does not run either and therefore can't be used to restore the original onerror handler
5323or schedule RZwaitCheck() to run again.
5324
5325In order to restart RZwaitCheck in all cases is therefore rescheduled before the any
5326javascript error can occur and canceled if no more waiting is required.
5327---------------------------------------------------------------------------------------------*/
5328function RZwaitCheck (win, waitCommand, waitMsg, maxSeconds, msInterval)
5329{
5330	if (window.onerror == RZwaitError)
5331		window.onerror = RZ.waitonerror		//restore original handler
5332
5333	var now = new Date()
5334	var seconds = (now.getTime() - RZ.waitstart).toString() / 1000
5335	waitcallId = setTimeout( RZ.waitcall, msInterval)
5336
5337	var waitMore = ''
5338	if( !RZwinaccess(win) )
5339	{
5340		waitMore = 'no access'
5341		RZ.waitaccess = 0
5342	}
5343	else
5344	{	// see debugger notes this function description for onerror handling
5345		if (window.onerror != RZwaitError)
5346			RZ.waitonerror = window.onerror
5347		window.onerror = RZwaitError
5348
5349		//simulate race error one time as described in debugger notes above
5350		RZ.waitaccess++
5351		//if (RZ.waitaccess <= 1 && RZ.error.force) RZ.waitaccess = 99
5352
5353		// if window reloading, RZ.loaded first set to null
5354		if (typeof win.RZ != 'undefined' && win.RZ != null
5355		&& typeof win.RZ.loaded != 'undefined' && win.RZ.loaded != true)
5356			waitMore = 'refresh pending'
5357
5358		// window name undefined until window loaded (at least on IE)
5359		else if (typeof win.name == 'undefined')
5360			waitMore = 'window loading'
5361
5362		// if window name is not blank, assume window loaded
5363		// (recognizes non-revize enabled pages especially frames)
5364		else if (win.name != '')
5365			waitMore = ''
5366
5367		// RZ.loaded not defined until onload handler complete
5368		else if (typeof win.RZ == 'undefined' || win.RZ == null
5369		|| typeof win.RZ.loaded == 'undefined' || win.RZ.loaded != true)
5370			waitMore = 'onload pending'
5371
5372		window.onerror = RZ.waitonerror		//restore original handler
5373	}
5374
5375	var waitDone = false
5376	if (waitMore != '')
5377	{
5378		var waitedMsg = ' waited ' + parseInt(seconds) + ' seconds'
5379		RZtrace(waitMsg, waitedMsg )
5380		RZ.parent.status = waitMsg + ': ' +  waitedMsg + ' (' + waitMore + ')'
5381		if (seconds > maxSeconds )	//don't wait too long
5382			waitDone = true;		//waited long enough
5383	}
5384	if (waitMore=='' || waitDone)
5385	{
5386		RZ.waitcall = ''			//clear in case scheduled timeout starts
5387		clearTimeout( waitcallId )	//cancel scheduled waitCheck
5388		waitedMsg = 'waited ' + seconds + ' total seconds'
5389		RZtrace('RZwaitCheck(): ' + waitMsg, waitedMsg )
5390		if (!waitDone) RZ.parent.status = ''
5391		eval( waitCommand )
5392	}
5393}
5394
5395/*---------------------------------------------------------------------------
5396Determine if opener properties are still accessible
5397(they will not be if window closed or moved to another url)
5398
5399TODO: check access on NS (unknown)
5400
5401The following is always false on Netscape:
5402
5403if ( typeof RZ.popupwin.opener.document == 'unknown' )
5404----------------------------------------------------------------------------*/
5405function RZwinaccess(win)
5406{
5407	//default to opener for backward compatibility but all calls
5408	//now probably pass an argument.
5409	if (!win) win = RZ.parent.opener
5410
5411	try
5412	{
5413		//TODO: gets interface error (IE?) if calling window is closed
5414		//		(inside try/catch so should not cause issues)
5415
5416		// chrome (and probably FF), throw exception if invalid window
5417		// e.g. parent.opener when it does not exist
5418		if (typeof win == 'undefined' || win == 'undefined') return false
5419
5420		if(win != null
5421		&& typeof win != 'undefined'
5422		&& win.closed != true
5423
5424		// chrome (and probably FF), throw exception if invalid window
5425		// e.g. parent.opener when it does not exist
5426		&& win !='undefined')
5427		{
5428			if (RZ.MSIE && typeof win.document == 'unknown')
5429				return false;
5430			//force error if access denied
5431			else if (!RZ.MSIE && win.location.href == '')
5432				return false;
5433			else
5434				return true;
5435		}
5436	}
5437	catch (ex)
5438	{
5439		return false;
5440	}
5441	return false
5442}
5443
5444/*---------------------------------------------------------------------------
5445Give focus to opener if still accessible.
5446----------------------------------------------------------------------------*/
5447function RZopenerFocus(win)
5448{
5449	if (RZ.refresh)
5450		RZ.refresh = false
5451	else
5452	{
5453      if (typeof win == 'undefined') win = RZ.parent.opener
5454		if (RZwinaccess(win)) win.focus()
5455	}
5456}
5457
5458/*---------------------------------------------------------------------------
5459Display page permission warning defined by code.
5460----------------------------------------------------------------------------*/
5461function RZpagemessage(code,linkname,linkparent,linklevel)
5462{
5463	if (typeof linkname == 'undefined') linkname = ''
5464	if (typeof linkparent == 'undefined') linkparent = ''
5465	if (typeof linklevel == 'undefined') linklevel = ''
5466
5467	var msg = ''
5468	var hash = '';
5469
5470	switch ( code )
5471	{
5472		// button warning
5473		case "":
5474			break;
5475
5476		// page permission icon appearing in upper left corner of page is clicked.
5477		case "noparent":
5478			msg += 'No parent defined for this PAGE'
5479			break;
5480
5481		// link manager
5482		case "nolinkparentfield":
5483			msg += 'No linkparent field defined for this LINK'
5484			break;
5485
5486		// link manager
5487		case "nolinkparent":
5488			msg += 'No parent defined for this LINK'
5489			break;
5490
5491		// button warning
5492		case "nomodule":
5493			msg += 'Revize module not defined on button'
5494			break;
5495
5496		// button warning
5497		case "parent_itself":
5498			msg += 'Page can not be a parent of itself \n(no longer true)'
5499			break;
5500
5501		// unknown warning
5502		default:
5503			msg += 'Page permission incongruency'
5504			code = RZreplace(code,'--','\n')
5505			if (code.length > 25)
5506				msg += ':\n\n' + code
5507			else
5508				msg += ' (reason:' + code + ')'
5509			break;
5510	}
5511
5512	RZ.message = ''
5513	RZ.parameters = ''
5514	if (linkname != '')
5515	{
5516		RZ.message += 'Link Information:\n\n'
5517		RZaddUrlParameter('Link Name: ' + linkname )
5518		RZaddUrlParameter('Link Module: ' + RZ.link[linkname].linkmodule )
5519		RZ.message += '\n'
5520
5521		if (linkparent == '*nofield*')
5522			RZ.message += 'No linkparent field in linkmodule\n'
5523		else if (RZ.link[linkname].linkmodule != '')
5524			RZaddUrlParameter(RZ.link[linkname].linkmodule+'.linkparent: '+ linkparent)
5525		RZaddUrlParameter('First List Item Parent: '+ RZ.link[linkname].linkparent)
5526
5527		if (linklevel != '')
5528		{
5529			RZ.message += '\n'
5530			RZaddUrlParameter('Link Level: '+ linklevel)
5531			if (typeof RZ.linkparentnew[linkname] != 'undefined')
5532				RZaddUrlParameter('Level '+linklevel+' new parent_key: '
5533				                 + RZ.linkparentnew[linkname][linklevel])
5534		}
5535	}
5536	else
5537	{
5538		RZ.message += 'Page Information:\n\n'
5539		var templateType = '(unique)'
5540		if (RZ.pagemodule != '') templateType = '(dependent)'
5541		RZaddUrlParameter('Template: ' + RZ.pagetemplatename + '  ' + templateType )
5542		if (RZ.pagemodule != '')
5543		{
5544			RZaddUrlParameter('Module: '    + RZ.pagemodule )
5545			RZaddUrlParameter('Record Id: ' + RZ.editrecordid )
5546			hash = '#' + RZ.pagemodule + "_" + RZ.editrecordid;
5547		}
5548		RZ.message += '\n'
5549		RZaddUrlParameter('page_key:     '   + RZ.page_key )
5550		RZaddUrlParameter('parent_key:  '   + RZ.parent_key )
5551		RZ.message += '\n'
5552		RZaddUrlParameter('Permitted roles: ' + RZ.page_roles )
5553		RZaddUrlParameter('Permitted users: ' + RZ.page_users )
5554		if (RZ.inherit_key != '')
5555			RZaddUrlParameter('Inherited from: ' + RZ.inherit_key )
5556	}
5557	RZ.message += '\n'
5558	RZaddUrlParameter('permissions_options: ' + RZ.permissions_options )
5559
5560	if (msg != '')
5561	{
5562		msg =  '---------------------------------------------------\n' + msg + '\n'
5563		msg += '---------------------------------------------------\n\n'
5564	}
5565	msg += RZ.message + '\n'
5566	msg += '---------------------------------------------------\n'
5567	msg += 'Click Ok to find pages that link to this page      \n'
5568	msg += '---------------------------------------------------\n'
5569
5570	if (confirm(msg))
5571		location.href = RZ.webspacelinksurl + hash
5572	return void(0)
5573}
5574
5575/*---------------------------------------------------------------------------
5576Display and clear warning from jsp code
5577----------------------------------------------------------------------------*/
5578function RZwarning()
5579{
5580	if (RZ.warning != '')
5581	{
5582		window.status = RZreplaceAll( RZ.warning, '-- --', '; ')
5583		RZtrace( 'Warning from JSP code', RZ.warning )
5584		RZ.warning = ''
5585	}
5586}
5587/*---------------------------------------------------------------------------
5588Display alert or confirm dialog using RZalert (with prepended issue message)
5589Only displayed if RZ.debug is true;
5590
5591By using RZalert, the javascript debugger can be started if in debug mode.
5592
5593Parameters:
5594	message	- Message describing problem encounted with page
5595	isConfirm - Optional If true, confirm dialog is used (default is false)
5596----------------------------------------------------------------------------*/
5597function RZwarn(message,isConfirm) { return RZnote(message,isConfirm) }
5598function RZnote(message,isConfirm)
5599{
5600	var isNote = true
5601	return RZalert(message,isConfirm,isNote)
5602}
5603/*---------------------------------------------------------------------------
5604Display alert using confirm dialog
5605
5606Parameters:
5607	message	- Message describing problem encounted with page
5608----------------------------------------------------------------------------*/
5609function RZconfirm(message)
5610{
5611	return RZalert(message,true)
5612}
5613/*---------------------------------------------------------------------------
5614Add message to trace window (including call stack)
5615
5616Display message in alert with prepended with notation that page has a problem
5617
5618DCO 10-20-2014: Stop using alert() -- RZtrace() saves messages for AdminPanel
5619
5620If RZ.debug is true, a confirm dialog is used with option to start the
5621JavaScript debugger.
5622
5623----------
5624Parameters:
5625----------
5626message	 	Message describing problem encounted with page
5627
5628isConfirm 	(Optional) If true, confirm dialog is used (default is false)
5629				As of 07-22-2012, always prompt for debugger in Debug Mode
5630			09-14-2012: was deprecated probably 07-22; reactivated so can be used as
5631			extended confirm() with option to start debugger in debug mode.
5632			e.g. RZsave() uses as extended confirm() when Revize form wizard deleted.
5633
5634isNote 		(Optional) If true and not RZ.Debug, only display message in status bar
5635			Otherwise use RZalert() to display message.
5636----------------------------------------------------------------------------*/
5637function RZalert(message,isConfirm,isNote)
5638{
5639  	if (typeof isNote == 'undefined') isNote = false;
5640  	if (typeof isConfirm == 'undefined') isConfirm = false;
5641
5642	if (typeof message == 'undefined' || typeof message == 'object')
5643  		message = 'Message is ' + typeof message;
5644
5645  	else if (message == '')
5646  		message = 'No Reason Given';
5647
5648	message = message.split('--').join('\n\n');
5649	if (isConfirm || RZ.debug)
5650	{
5651		if (RZ.debug)
5652		{
5653			var msg = 'DEBUG mode is active; debugger starts if Ok clicked\n\n' + message
5654			message = RZdisplayCaller(msg);
5655		}
5656		if (confirm(message))
5657		{
5658			if (RZ.debug) debugger;
5659			return true;
5660		}
5661	}
5662	else if (isNote)
5663		window.status = message;
5664	else
5665		RZtrace('RZalert',message);	//DCO 10-20-2014
5666		//alert(message);			//		 ''
5667
5668	return '';	//can be used to clear message
5669}
5670/*---------------------------------------------------------------------------
5671Convenience function for determining if administrator logged in
5672----------------------------------------------------------------------------*/
5673function RZisadmin()
5674{
5675	return RZcheckoptions(RZ.roles,'superuser,administrator');
5676}
5677/*---------------------------------------------------------------------------
5678Write html if user is authenticated for current webspace (RZ.webspace).
5679During page initialization RZ.login is set to the RZlogin cookie defined by
5680the login function.
5681TODO: Do not write any html for production channels.
5682
5683Parameters:
5684	html -			html code to be written if logged in and proper permission
5685	module -		Module requiring permissions
5686	permits -		Permissions required on module
5687	action -		Button action
5688----------------------------------------------------------------------------*/
5689function RZlogin( html, module, permits, action )
5690{
5691	// 2nd parameter was webspace way back and there was not a 3rd parameter
5692	// so defaulting permits to blank retains backward compatibility.
5693	if (typeof module == 'undefined') module = '';
5694	if (typeof permits == 'undefined') permits = '';
5695	if (typeof action == 'undefined') action = '';
5696
5697	// backward compatibility
5698	if(typeof RZ.webspace == 'undefined'
5699	&& typeof RZ.webSpaceName != 'undefined')
5700		RZ.webspace = RZ.webSpaceName
5701
5702	// if login webspace does not match page webspace, return false
5703	if(RZ.login != RZ.webspace && RZ.login != '*ALL')
5704		return false
5705
5706	// if pointbasedemo webspace and NOT preview directory, return false
5707	if(RZ.webspace.indexOf('pointbasedemo') >= 0
5708	&& RZ.page.pathname.indexOf('-preview') == -1)
5709		return false;
5710
5711	// if demosite webspace and production directory, return false
5712	if(RZ.webspace.indexOf('demosite') >= 0
5713	&& RZ.page.pathname.indexOf('-prod') != -1)
5714		return false;
5715
5716	// if atwatercounty webspace and production directory, return false
5717	if(RZ.webspace.indexOf('atwatercounty') == 0
5718	&& RZ.page.pathname.indexOf('-prod') != -1)
5719		return false;
5720
5721	// if paradigm webspace and production directory, return false
5722	if(RZ.webspace.indexOf('paradigm') == 0
5723	&& RZ.page.pathname.indexOf('-prod') != -1)
5724		return false;
5725
5726	// show the help button before the permissions button
5727	if(module == 'webspace_page_permissions')
5728		document.write('<a href="http://cms4.revize.com/revize/supportrevize/revize_faq.php" target="_new"><img src="../images/edit/help.jpg" alt="Help" border="0" /></a>');
5729
5730	//----- If called with a module and required permits, check them.
5731	//		If no access, return false and do not write any html.
5732	if ( module != '' && permits != ''
5733	&& RZpermits(module , permits) != true )
5734		return false;
5735
5736
5737	//----- Hide button if no page permissions (TODO: hides what? seq?)
5738	if ( action != 'save' && action != 'cancel' && action != 'history')
5739		if ( !RZ.pagepermission && module != '' ) return false;
5740
5741
5742	if ( typeof html != 'undefined' && html != '')
5743		document.write(html);
5744
5745	return true;
5746}
5747/*---------------------------------------------------------------------------
5748Display rendered width of element
5749----------------------------------------------------------------------------*/
5750function RZrte(id)
5751{
5752	if (!id)
5753	{
5754		id=prompt('Enter element id',RZgetcookie('RZrte'));
5755		if (!id) return;
5756		RZsetcookie('RZrte',id);
5757	}
5758	var msg = '';
5759	var el = document.getElementById(id);
5760	if (!el)
5761		msg = 'id='+id+' not found';
5762	else
5763	{
5764		msg += '\n    font-family=' + currentStyle('font-family') + ';';
5765		msg += '\n    font-size=' + currentStyle('font-size') + ';';
5766		while (el.clientWidth == 0 && el.parentNode)
5767			el = el.parentNode;
5768		var padding = parseInt(currentStyle('padding-left'))
5769		            + parseInt(currentStyle('padding-right'));
5770		msg = '.rte-format {' + msg + '\n}'
5771			+ '\n\nwidth=' + el.clientWidth;
5772		if (padding > 0)
5773			msg += '\n\nwidth=' + (el.clientWidth - padding) + ' (less padding for RTE)';
5774	}
5775	alert(msg);
5776	return;
5777
5778	function currentStyle(style)	//style is css format (e.g. font-size)
5779	{
5780		if (!document.defaultView)
5781		{
5782			style = style.replace(/(-)(\w)/, function (all,dash,word){
5783				return word.toUpperCase();
5784			})
5785			return el.currentStyle[style];
5786		}
5787		else
5788		{
5789			var renderedStyle = document.defaultView.getComputedStyle(el,'');
5790			return renderedStyle.getPropertyValue(style);
5791		}
5792	}
5793}
5794/*---------------------------------------------------------------------------
5795Toggle debug mode with prompt that includes optional notes argument.
5796----------------------------------------------------------------------------*/
5797function RZdebug(notes,win)
5798{
5799	if (typeof win == 'undefined') win = window;
5800
5801	if (typeof notes == 'undefined')
5802		notes = '';
5803	else if (typeof notes == 'object')
5804	{
5805		win = notes;
5806		notes = '';
5807	}
5808
5809	var debugState = !RZ.debug
5810	var msg = 'Set debug ' + debugState + '?'
5811	if (typeof notes != 'undefined')
5812		msg = notes + '\n\n' + msg
5813
5814	//dont need confirm with new adminpanel
5815	if (!notes || win.confirm(msg))
5816	{
5817		RZ.debug = debugState;
5818		RZsetcookie('RZdebug', (RZ.debug ? RZ.webspace : '') ,RZ.page.domain);
5819	}
5820	return void(0)
5821}
5822/*---------------------------------------------------------------------------
5823Prompt to start debugger with optional notes argument.
5824----------------------------------------------------------------------------*/
5825function RZdebugger(notes)
5826{
5827	var msg = 'Start Debugger?'
5828	if (typeof notes != 'undefined')
5829		msg = notes + '\n\n' + msg
5830
5831	if (confirm(msg))
5832	{
5833		//RZ.debug = true;
5834		debugger;
5835	}
5836
5837	return void(0)
5838}
5839/*---------------------------------------------------------------------------
5840Ask to start IE or Netscript Javascript debugger.
5841----------------------------------------------------------------------------*/
5842function RZstartDebugger()
5843{
5844	debugger;
5845	return;
5846}
5847/*---------------------------------------------------------------------------
5848return function name of caller at depth
5849----------------------------------------------------------------------------*/
5850function RZgetcaller(depth)
5851{
5852	if (!depth) depth = 2;	//caller of this func caller
5853	var patternFunction = /function\s*(\w*)\s*\((.*?)\)[^{]*{([\s\S]*)}/
5854	//                                 1         2           3
5855	//								   name      args        body
5856	var funcName = '';
5857	for (var func = RZgetcaller.caller; func != null; func = func.caller)
5858	{
5859		var script = func.toString();
5860		var results = funcName = script.match(patternFunction);
5861		if (!results)
5862			funcName = '*unknown*';
5863		else
5864		{
5865			funcName = results[1];
5866			if (!results[1])
5867				funcName = "anonymous";
5868		}
5869		if (--depth <= 0) return funcName;
5870	}
5871	return '-main-';
5872}
5873/*---------------------------------------------------------------------------------------
5874Display caller stack
5875
5876---------
5877Arguments:
5878---------
5879msg			(Optional) String contain message to display before caller stack
5880options		(Optional) String contains the following seperated by commas
5881			debug		pause in debug mode (used in calendar_app)
5882			debug=???	only pause if RZdebugoption[???] is true
5883			force		pause even if not in debug mode
5884			yes			assume yes rather using comfirm
5885---------------------------------------------------------------------------------------*/
5886RZdisplayCaller.MAX_FUNCTIONS_SHOW_ARGS = 3;
5887RZdisplayCaller.MAX_FUNCTIONS = 15;
5888function RZdisplayCaller(msg,options)
5889{
5890    if (!msg) msg = '';
5891	if (msg) msg += '\n\n';
5892	if (!options) options = '';
5893
5894	var isDebug = RZcheckOptions(options,'debug')
5895	var isDebugForce = RZcheckOptions(options,'force')
5896	if (isDebugForce) isDebug = true;
5897
5898	var e = '';
5899	var funcName = '';
5900	var indentFunc = isDebug ? 0 : 4;
5901	var indentArgs = indentFunc + 4;
5902	var trace = msg;
5903	try											//don't want js error for users
5904	{
5905		if (isDebug)
5906		{
5907			if (!RZ.debug && !isDebugForce)		//RZ.debug can be typeof unknown
5908				return false;
5909			var isDebugYes = RZcheckOptions(options,'yes');
5910			var debugOption = RZgetOption(options,'debug');	//debug=
5911			if (!debugOption || !RZisDebugOption(debugOption)) return false;
5912		}
5913
5914		var i, count = 0;
5915		var patternFunction = /function\s*(\w*)\s*\((.*?)\)[^{]*{([\s\S]*)}/
5916		//                                 1         2           3
5917		//								   name      args        body
5918		for (var func = RZdisplayCaller.caller; func != null; func = func.caller)
5919		{
5920			var script = func.toString();
5921			var results = funcName = script.match(patternFunction);
5922			if (!results)
5923				funcName = '*unknown*';
5924			else
5925			{
5926				funcName = results[1] + '(' + results[2] + ')';
5927				if (!results[1])
5928					funcName = "anonymous" + funcName;
5929			}
5930
5931			// display args for 1st few functions
5932			if (++count <= RZdisplayCaller.MAX_FUNCTIONS_SHOW_ARGS)
5933			{
5934				msg = funcName + '\n';
5935
5936				// display args and current values
5937				var args = results[2];
5938				if (args)
5939				{
5940					args = args.split(',');
5941					for (i=0;i<args.length;i++)
5942					{
5943						var value = 'undefined';
5944						if (i < func.arguments.length) 	//value supplied
5945						{
5946							var indentValue = indentArgs + args[i].length + 1;
5947							value = func.arguments[i] + '';
5948							value = value.replace(/\t/g,'    ');
5949							if (value.length > 20)
5950								value = RZtrim(value.substr(0,20)) + '...';
5951							value = value.replace(/\n/g,'\n' + RZdup(indentValue,' '));
5952						}
5953						msg += RZdup(indentArgs,' ') + args[i] + '='
5954							   + value
5955							   + '\n';
5956					}
5957				}
5958				funcName = msg;
5959			}
5960			// for anonymous, display first non-blank line of function body
5961			if (funcName.indexOf('anonymous(') != -1)
5962			{
5963				results = results[3].match(/\s*(\w+.*)/);
5964				if (results)
5965				{
5966					funcName += RZdup(indentArgs,' ') + '{' + results[1] + '...}\n';
5967				}
5968			}
5969			if (count == 1)
5970			{
5971				if (isDebug)
5972					trace += 'DEBUG MODE pause in: ' + funcName + 'CALLED FROM...\n';
5973				else
5974					trace += 'CALLED FROM...\n' + RZdup(indentFunc,' ') + funcName;
5975			}
5976			else
5977				trace += '    ' + funcName + "";
5978
5979			if (func.caller == func) break;		//NS 4.0 bug workaround
5980			if (count > RZdisplayCaller.MAX_FUNCTIONS) break;	//probably in recursive loop (e.g. calendar setup())
5981		}	// end trace stack
5982
5983		// append main html file
5984		RZdisplayCaller.fn = funcName;
5985		var filepath = location.pathname;
5986		filepath = filepath.replace(/\\/g,'/');
5987		RZdisplayCaller.filename = filepath;
5988		filepath = filepath.substr(filepath.lastIndexOf('/')+1)
5989		trace += '    ' + filepath;
5990
5991		if (isDebug)
5992			return isDebugYes || confirm(trace + '\n\nStart Debugger?');
5993	}
5994	catch (e) {}	//ignore js errors
5995
5996	return trace;
5997}
5998/*---------------------------------------------------------------------------------------
5999Display all object values and expand object children down to OBJECT_DEPTH
6000
6001Can also be used to return display value for other types (i.e. boolean, number or string) OR
6002	*undefined*, *empty*, *null*, *true*, *false*
6003
6004TODO: typeof undefined is not displayed properly
6005	  html elements have el.contructor == Element is true
6006---------------------------------------------------------------------------------------*/
6007function RZdisplayObject(obj,name)
6008{
6009	try
6010	{
6011		return RZdisplayObjectProcess(obj,name);
6012	}
6013	catch (e)
6014	{
6015		RZdisplayObject.display += '\nException Displaying Object:\n' + e.description;
6016		return RZdisplayObject.display;
6017	}
6018}
6019function RZdisplayObjectProcess(obj,name,indent,isArray)
6020{
6021	var i, e, results;
6022
6023	//assume top level starting point, initialize variables
6024	if (typeof(indent) == 'undefined')
6025	{
6026		indent = 0;
6027		RZdisplayObject.objectCount = 0;
6028		RZdisplayObject.quit = false;
6029		RZdisplayObject.lastTypeObject = false;
6030		RZdisplayObject.firstObject = true;
6031		RZdisplayObject.display = '';			//build as processed in case exception
6032	}
6033	//----- Initialize any undefined RZdisplayObject settings
6034	if (!RZdisplayObject.OBJECT_LIMIT)
6035		RZdisplayObject.OBJECT_LIMIT = 100;		//max number of object displayed without prompt
6036	if (!RZdisplayObject.OBJECT_DEPTH)			//TODO:
6037		RZdisplayObject.OBJECT_DEPTH = 5;		//max depth for object display
6038	if (!RZdisplayObject.INDENT_SIZE)
6039		RZdisplayObject.INDENT_SIZE = 4;		//max depth for object display
6040	if (!RZdisplayObject.MAXLINE)
6041		RZdisplayObject.MAXLINE = 500;			//max characters displayed for any value
6042	if (typeof RZdisplayObject.SHOW_PROTOTYPE == 'undefined')
6043		RZdisplayObject.SHOW_PROTOTYPE = false;	//true to display prototype elements
6044	if (typeof RZdisplayObject.SHOW_TYPE == 'undefined')
6045		RZdisplayObject.SHOW_TYPE = true;		//true to display non-object data types
6046	if (!RZdisplayObject.MARKER)
6047		RZdisplayObject.MARKER = '&#8226;';		//used for null, empty, etc
6048	if (!RZdisplayObject.EOL_MARKER)
6049		RZdisplayObject.EOL_MARKER = '&#172;';	//end of non-object value
6050	if (!RZdisplayObject.OBJECT_SPACING)
6051		RZdisplayObject.OBJECT_SPACING = '\n';	//spacing before and after object
6052
6053	//----- Set work variables for this depth
6054	var spaces = RZdup(indent * RZdisplayObject.INDENT_SIZE, "&nbsp;");
6055	var spacesPlus = spaces + RZdup(RZdisplayObject.INDENT_SIZE, "&nbsp;");
6056	var spacesPlusPlus = spacesPlus + RZdup(RZdisplayObject.INDENT_SIZE, "&nbsp;");
6057
6058	var type = '';
6059	var isEmpty = true;
6060	var isObject = true;
6061	var isArrayElement = false;
6062	if (isArray && !isNaN(name))
6063		isArrayElement = true;
6064	var objAdjust = obj;
6065
6066	//----- Determine type
6067	if (obj && obj.constructor == Array)
6068	{
6069		type = 'array';
6070		isArray = true;
6071		//objAdjust = {length: obj.length}
6072		//for (i in obj) {objAdjust[i] = i};
6073	}
6074
6075	else if (obj && obj.constructor == Function)
6076		type = 'function';
6077
6078	//----- Not called with object, display value of obj argument
6079	else if (typeof(obj) != 'object' || (indent==0 && obj === null))
6080		return getValue(obj);
6081
6082	//----- Headings
6083	if (type) type += ' ';
6084	if (indent == 0)	//display for top level
6085	{
6086		if (isObject)
6087		{
6088			if (!name) name = '[' + type + 'object]: ';
6089			RZdisplayObject.display += name + '\n';
6090			indent = 1;
6091		}
6092	}
6093	else
6094	{
6095		RZdisplayObject.display += spaces;
6096		if (isArrayElement)
6097			RZdisplayObject.display += '[' + name + ']: (' + type + 'object)\n';
6098		else
6099			RZdisplayObject.display += '(' + type + 'object): ' + name + '\n';
6100		//RZdisplayObject.display += spaces + '[object' + type + ']: ' + name + '\n';
6101	}
6102
6103	//----- Iterate through the elements in obj; NOTE: when typeof(obj)==function, no iteration takes place
6104	//		Use objAdjust defined above since for (i in obj) does not find array length property
6105	for (i in objAdjust)
6106	{
6107		// process OBJECT within obj (including functions)
6108		if (typeof(obj[i]) == 'object' || typeof(obj[i]) == 'function')		//expand nested object
6109		{
6110			if (overLimit()) continue;
6111			if (typeof(obj[i]) == 'function' && skipPrototype(Function)) continue;
6112
6113			var prefix = '';
6114			if (RZdisplayObject.firstObject && !RZdisplayObject.lastTypeObject)
6115				prefix = RZdisplayObject.OBJECT_SPACING;
6116
6117			// move down another level
6118			RZdisplayObject.display += prefix + spaces + RZdisplayObjectProcess(obj[i],i,indent,isArray);
6119			if (RZdisplayObject.display.substr(RZdisplayObject.display.length-2,1) != '\n')		//don't need newline if returned from nested call
6120				RZdisplayObject.display += RZdisplayObject.OBJECT_SPACING;
6121
6122			RZdisplayObject.firstObject = false;
6123			RZdisplayObject.lastTypeObject = true;
6124			isEmpty = false;
6125		}
6126		// process NON-OBJECT element within obj
6127		else
6128		{
6129			if (skipPrototype()) continue;		// if not displaying prototype variables
6130			if (isArray && isArrayElement) RZdisplayObject.display += spaces;		// extra indentation for array objects
6131
6132			var value = getValue(obj[i]) 		// determine non-object value
6133
6134
6135			value = value.replace(/\n/gm,'\n'+spacesPlusPlus);	//apply indent to all lines
6136			value = RZdisplayObject.display += spacesPlus + i + ': ' + value + '\n';
6137
6138			RZdisplayObject.lastTypeObject = false;
6139			isEmpty = false;
6140		}
6141	}
6142
6143	//----- Done iterating through elements, if nothing displayed, indicate why
6144	if (isEmpty)
6145	{
6146		// extra indentation for array objects
6147		if (isArray) RZdisplayObject.display += spaces;
6148
6149		// special values: null, function, empty
6150		if (obj === null)							//null object
6151			RZdisplayObject.display += spacesPlus + RZdisplayObject.MARKER + 'null' + RZdisplayObject.MARKER + '\n';
6152
6153		else if (obj.constructor == Function)		//function (just show name and paramters)
6154		{
6155			results = obj.toString().match(/function\s*(\w*)\s*\(([^\)]*)\)/);
6156			if (results)
6157				RZdisplayObject.display += spacesPlus + results[0] + '...\n'
6158			else									//name not found (should not get here)
6159				RZdisplayObject.display += spacesPlus  + RZdisplayObject.MARKER+ 'unknown function' + RZdisplayObject.MARKER;
6160			RZdisplayObject.lastTypeObject = false;
6161		}
6162		else if (isEmpty)							//empty object (must test after function test above)
6163			RZdisplayObject.display += spacesPlus + RZdisplayObject.MARKER + 'no elements' + RZdisplayObject.MARKER + '\n';
6164	}
6165	// remove last newline (it gets added by caller)
6166	RZdisplayObject.display = RZdisplayObject.display.substring(0,RZdisplayObject.display.length-1);
6167	//-----------------------------
6168	return RZdisplayObject.display;
6169	//-----------------------------
6170
6171	/*
6172	*	Return true if not displaying any more nested objects.
6173	*/
6174	function overLimit()
6175	{
6176		if (RZdisplayObject.quit || indent >= RZdisplayObject.OBJECT_LIMIT) return true;
6177		if (++RZdisplayObject.objectCount > RZdisplayObject.OBJECT_LIMIT)
6178		{
6179			if ( confirm(RZdisplayObject.OBJECT_LIMIT + ' objects expanded\n'
6180			   + 'Display ' + RZdisplayObject.OBJECT_LIMIT + ' more?'))
6181				RZdisplayObject.objectCount = 0;
6182			else
6183				RZdisplayObject.quit = true;
6184		}
6185		return false;
6186	}
6187	/*
6188	*	Return true if not displaying prototype functions or variables.
6189	*	type (optional: Function if checking for Function constructor
6190	*/
6191	function skipPrototype(type)
6192	{
6193		var status = false;
6194		/* was throwing exceptions (replaced with code below)
6195		if (!RZdisplayObject.SHOW_PROTOTYPE
6196		|| !obj[i].hasOwnProperty(obj))
6197			status = true;
6198		else
6199			status = false;
6200		*/
6201
6202		//js error from RZupdateFieldList trace after RZclearlist(...)
6203		if (!RZdisplayObject.SHOW_PROTOTYPE
6204		&& obj && i && obj[i]
6205		&& obj[i].constructor
6206		&& obj[i].constructor.prototype)
6207		{
6208			if (type && type == Function
6209			&& obj[i].constructor.prototype.constructor == type)
6210				status = true;
6211
6212			//else if (!type && obj[i].constructor.prototype == i)
6213			else if (!type
6214			&& (obj.constructor != Array || isNaN(i))	//added so array[0] displays
6215			&& obj[i].constructor.prototype == i)
6216				status = true;
6217		}
6218		return status;
6219
6220		if (!RZdisplayObject.SHOW_PROTOTYPE
6221		|| !obj[i].hasOwnProperty(obj))
6222			status = true;
6223		else
6224			status = false;
6225	}
6226	/*
6227	*	determine non-object value
6228	*/
6229	function getValue(value)
6230	{
6231		var type = typeof(value);
6232
6233		if (type === 'undefined')
6234			value = RZdisplayObject.MARKER + 'undefined' + RZdisplayObject.MARKER;
6235
6236		else if (value === '')
6237			value = RZdisplayObject.MARKER + 'empty string' + RZdisplayObject.MARKER;
6238
6239		else if (value === null)
6240			value = RZdisplayObject.MARKER + 'null' + RZdisplayObject.MARKER;
6241
6242		else if (value === true)
6243			value = RZdisplayObject.MARKER + 'true' + RZdisplayObject.MARKER;
6244
6245		else if (value === false)
6246			value = RZdisplayObject.MARKER + 'false' + RZdisplayObject.MARKER;
6247
6248		else if (value.length > RZdisplayObject.MAXLINE)
6249			value = value.substr(0,RZdisplayObject.MAXLINE) + '...' + RZdisplayObject.EOL_MARKER;
6250
6251		else
6252			value += RZdisplayObject.EOL_MARKER;
6253
6254		if (RZdisplayObject.SHOW_TYPE && type !== 'undefined'
6255		&& value.indexOf(RZdisplayObject.MARKER + 'empty') != 0
6256		&& value.indexOf(RZdisplayObject.MARKER + 'null') != 0)
6257			value = '(' + type + '): ' + value;
6258
6259		return value;
6260	}
6261}
6262/*-----------------------------------------------------------------------------
6263-----------------------------------------------------------------------------*/
6264function RZdisplayMessage(msg)
6265{
6266	if (!msg) msg = '';
6267	var el = document.getElementById('errorMessage');
6268	if (!el)
6269		el = document.getElementById('message');
6270	if (!el)
6271		el = document.getElementById('msg');
6272
6273	if (el)
6274		el.innerHTML = msg == '' ? '&nbsp;' : msg;
6275	else if (msg)
6276		alert(msg);
6277	if (msg)
6278		return false;
6279	return true;
6280}
6281/*---------------------------------------------------------------------------
6282Load Color Picker.
6283----------------------------------------------------------------------------*/
6284function RZcolorpicker(field)
6285{
6286	RZ.colorfield = field;
6287	while (RZ.colorfield.tagName != 'INPUT')
6288	{
6289		RZ.colorfield = RZ.colorfield.previousSibling
6290		if (RZ.colorfield == null || typeof RZ.colorfield == 'undefined')
6291		{
6292			RZalert('Input field does not preceed Color Picker Icon')
6293			return false;
6294		}
6295	}
6296	features = 'width=320,height=160,scroll=auto,status=no,titlebar=no,resizable=yes';
6297	var x = (screen.availWidth - 320) / 2 - 10;
6298	var y = (screen.availHeight - 160) / 2 - 30;
6299	if (y < 50)
6300		y = 0;
6301
6302	if(navigator.appVersion.indexOf('MSIE') == -1)  // Netscape
6303	{
6304		features += ',screenX=' + x.toString()
6305				 +  ',screenY=' + y.toString();
6306	}
6307	else                                            // IE browser
6308	{
6309		features += ',left=' + x.toString()
6310				 +  ',top=' + y.toString();
6311	}
6312	colorPicker = window.open('/revize/util/snippet_helper_colorpicker.html','',features);
6313	return true;
6314}
6315/*---------------------------------------------------------------------------
6316Spellcheck input or textarea field proceeding specified field.
6317----------------------------------------------------------------------------*/
6318function RZspellcheck(field)
6319{
6320	RZ.spellcheckfield = field;
6321	while (RZ.spellcheckfield.tagName != 'INPUT'
6322	&& RZ.spellcheckfield.tagName != 'TEXTAREA')
6323	{
6324		RZ.spellcheckfield = RZ.spellcheckfield.previousSibling
6325		if (RZ.spellcheckfield == null || typeof RZ.spellcheckfield == 'undefined')
6326		{
6327			RZalert('Input field does not preceed Spell Check Icon')
6328			return false;
6329		}
6330	}
6331
6332	var sURL = "/revize/spellcheck/spellingchecker.html";
6333
6334	features = 'width=490,height=400,scroll=auto,status=yes,resizable=yes,'
6335	         + 'titlebar=yes,menubar=no,location=no,'
6336	         + 'channelmode=0,directories=0,fullscreen=0,center=1'
6337
6338	RZspellcheckwin = window.open(sURL,'_blank',features);
6339	return true;
6340}
6341
6342/*-----------------------------------------------------------------------------
6343Replace webspace template embed keys
6344-----------------------------------------------------------------------------*/
6345RZ.mapsEmbedKey = "AIzaSyC5cMe92Yw3JgHrkvgIyHgdS2lTsH4C95k";
6346document.addEventListener('DOMContentLoaded', function() {
6347	var oldMapsKey = "AIzaSyAOLPINIt8gtJpi00yqu4vHL9Ye6hhKDYI";
6348	var newMapsKey = RZ.mapsEmbedKey;
6349	document.querySelectorAll("iframe").forEach(function(ifr) {
6350		if (ifr.src.indexOf(oldMapsKey) > -1) { ifr.src = ifr.src.replaceAll(oldMapsKey, newMapsKey); }
6351	});
6352});
6353
6354/*-----------------------------------------------------------------------------
6355Indicate script loaded for RZloadjscss()
6356-----------------------------------------------------------------------------*/
6357if (RZ.scriptLoaded)
6358	RZ.scriptLoaded.snippet_helper = true;
6359/************************* End of snippet_helper.js *************************/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.