PageSourceSearch

https://alder-dental.com/sys/weo-lib.js

js alder-dental.com collected 2026-10-07 16:47:17 UTC 248,152 bytes, 6,905 lines download raw bytes

1//WEO JAVASCRIPT SUPPORT ROUTINES
2//============================================================================================
3//Copyright © 2011-2020 WEO MEDIA (TouchPoint Communications LLC). All rights reserved.
4//   UNAUTHORIZED USE IS STRICTLY PROHIBITED
5//   FOR QUESTIONS AND APPROPRIATE LICENSING PLEASE CONTACT WEO MEDIA
6//   www.weomedia.com | [email protected]
7//
8//   Some portions of code (modified and unmodified) have been included from public, 
9//   or open source, sources and have been indicated as appropriate.
10//
11//	***** LIMITATION OF LIABILITY *****
12//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
13//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
14//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
15//  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
16//  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
17//  OR OTHER DEALINGS IN THE SOFTWARE.
18//  ***********************************
19//============================================================================================
20
21var g_AdvEcid = 0;  
22var g_AdvEuid = 0; 
23var g_AdvEsrv = '';
24
25function newWindowClickButtons(aBtnName){
26	var insideBtn;
27	var insideSpan;
28	DebugLog('newWindowClickButtons - looking for buttons named['+ aBtnName +']');
29	var pageBtns = GetDivsByClassList(document,'buttonwrapper');
30	if(pageBtns){
31		for ( const aBtn of pageBtns ) {
32			insideBtn = aBtn.querySelector('a');
33			if(insideBtn){
34				insideSpan = insideBtn.querySelector('span');
35				if(insideSpan){
36					if( aBtnName.indexOf(insideSpan.textContent) == 0 && insideSpan.textContent.indexOf(aBtnName) == 0 ){
37						DebugLog('newWindowClickButtons - a button found - IS A MATCH - jump to URL['+ insideBtn.href +']');
38						goExt(insideBtn.href);
39					}							
40				}
41			}
42		}
43	}
44}
45
46
47//----------------------------------------------------------------------------
48function modifyIframeURL(parentElementID,aParam,aValue)  
49{
50	var theParent = document.getElementById(parentElementID);
51	if(theParent){
52		//DebugLog('modifyIframeURL - found parent element id['+parentElementID +']');
53		var theFrame = theParent.getElementsByTagName('IFRAME')[0];
54		if(theFrame){
55			//DebugLog('modifyIframeURL - found first iframe inside parent['+ theFrame.title +'], src['+ theFrame.src +']');
56			var newURL = updateURLParameter(theFrame.src,aParam,aValue);
57			//DebugLog('modifyIframeURL - revised url['+ newURL +']');
58			theFrame.src = newURL;
59			//DebugLog('modifyIframeURL - new iFrame src['+ theFrame.src +']');
60		}		
61	}
62}
63
64
65
66function updateCNboxes(){
67	var cnList = document.querySelectorAll('div[data-cns]');
68	DebugLog('updateCNboxes - start number of CN items on page ['+ cnList.length +']');
69	if(cnList.length > 0){
70		DebugLog('doUpdateCNboxes - prep for do update CN items');
71		setTimeout('doUpdateCNboxes()',2000);
72	}
73}
74
75function doUpdateCNboxes(){
76	var cnList = document.querySelectorAll('div[data-cns]');
77	var cnStatus = 0;
78	var cnID = '';
79	DebugLog('doUpdateCNboxes - number of CN items on page ['+ cnList.length +']');
80	if(cnList.length > 0){
81		//DebugLog('doUpdateCNboxes - review CN items');
82		var unprocCnt = 0;
83		for ( const aDiv of cnList ) {
84			cnID = aDiv.id;
85			cnStatus = aDiv.getAttribute('data-cns');
86			//DebugLog('doUpdateCNboxes - see div ID ['+ cnID +'] with status['+ cnStatus +']');
87			if( cnStatus == 0 ) {
88				if( isVisible(aDiv) ){
89					DebugLog('doUpdateCNboxes - see div ID ['+ cnID +'] is visible');
90					
91					DebugLog('doUpdateCNboxes - calling doProcessTableCallback');
92					var cnAction = 'process/doProcess-CN.asp?CNT='+ aDiv.getAttribute('data-cnt') +'&CNCID='+aDiv.getAttribute('data-cncid');
93					if(aDiv.getAttribute('data-cnrid')) cnAction = cnAction + '&CNRID='+aDiv.getAttribute('data-cnrid');
94					if(aDiv.getAttribute('data-cnpin')) cnAction = cnAction + '&CNPIN='+aDiv.getAttribute('data-cnpin');
95					if(aDiv.getAttribute('data-alon')) cnAction = cnAction + '&ALON='+aDiv.getAttribute('data-alon');
96					if(aDiv.getAttribute('data-alid')) cnAction = cnAction + '&ALID='+aDiv.getAttribute('data-alid');
97					if(aDiv.getAttribute('data-alfn')) cnAction = cnAction + '&ALFN='+aDiv.getAttribute('data-alfn');
98					cnAction = AddInterfaceLevelToURL(cnAction);
99					DebugLog('doUpdateCNboxes - about to process CN action['+ cnAction +']');
100					doProcessDiv(cnID,cnAction,doProcessCNCallback,12000);
101					aDiv.setAttribute('data-cns',1); 
102				}else{
103					unprocCnt++;
104				}
105			}
106		}
107		if( unprocCnt > 0 ) {
108			DebugLog('doUpdateCNboxes - still ['+ unprocCnt +'] unprocessed CN divs on page');
109			setTimeout('doUpdateCNboxes()',3000);
110		}else{
111			DebugLog('doUpdateCNboxes - no more unprocessed CN divs on page');
112		}
113	}
114}
115
116
117//USE CallbackResult OBJECT TO PARSE RETURN FROM CALLBACKS IN doProcess - HEADER FORMAT IS [OK:rows[~]###[~]total[~]####[~]done[~]1]other stuff here		
118function CallbackResult(aElementID,aReturnContent,aReturnMessage){
119	this.elementID = aElementID;
120	this.status = 'unknown';  //OK, TIMEOUT, AUTHENTICATION, ERROR, or OTHER - look at rawReturn and rawMessage for ERROR and OTHER
121	this.errMsg = '';
122	this.rawReturn = aReturnContent;
123	this.rawMessage = aReturnMessage;
124	this.doneFlag = 0;  //SET TO 1 IF THE HEADER WAS BUILT NORMALLY
125	this.contentStr = '';
126	this.headerArr = null;
127	//USE getHeaderValue TO READ HEADER FIELD VALUES
128	this.getHeader = getHeaderValue;
129	
130	DebugLog('CallbackResult - START - aElementID['+ aElementID +'], aReturnContent['+ aReturnContent +'], aReturnMessage['+ aReturnMessage +']');
131	
132	function getHeaderValue(aHeaderField){
133		if(this.doneFlag > 0){
134			if(this.headerArr){
135				var headValue = getParsedItem(aHeaderField,this.headerArr);
136				return headValue;
137			}else{
138				return '';
139			}
140		}else{
141			return '';
142		}
143	}
144	
145	if(aReturnMessage.includes('Error')){
146		this.status = 'ERROR';
147		this.errMsg = retMessage;
148	}else{
149		// RETMSG FORMAT INCLUDES SOME INFO, PARSE WITH getParsedData AND getParsedItem
150		//[OK:rows[~]###[~]total[~]####[~]done[~]1]<tr>....</tr>
151		if(aReturnContent.substr(0,4).includes('[OK:')){
152			DebugLog('CallbackResult - is OK and we have prefixed data');
153			this.status = 'OK';
154			var dataStr;
155			if(aReturnContent.search(']<') > 0){
156				dataStr = aReturnContent.substring(0,aReturnContent.search(']<'));
157			}else{
158				dataStr = aReturnContent.substring(0,aReturnContent.lastIndexOf(']'));
159			}
160			DebugLog('CallbackResult - raw data string ['+ dataStr + ']');
161			var dataStrLen = dataStr.length;
162			dataStr = dataStr.substring(4,dataStrLen);
163			//DebugLog('CallbackResult - fixed data string ['+ dataStr + ']');
164			
165			this.contentStr = aReturnContent.substring(dataStrLen+1,aReturnContent.length);
166			DebugLog('CallbackResult - contentStr ['+ this.contentStr + ']');
167			this.headerArr = getParsedData(dataStr);
168			
169			this.doneFlag = getParsedItem('done',this.headerArr);
170			DebugLog('CallbackResult - done flag ['+ this.doneFlag +']');	
171			
172		}else{
173
174			DebugLog('CallbackResult - some other response from the system:['+ aReturnContent.slice(0,150) +']');
175			if(aReturnContent.indexOf('Timeout:') >= 0){
176				DebugLog('CallbackResult - response: TIMED OUT');
177				this.status = 'TIMEOUT';
178				this.errMsg = 'The callback timed out.';
179			}else if(aReturnContent.indexOf('[interface process authentication error') >= 0){
180				DebugLog('CallbackResult - response: AUTHENTICATION FAILURE');
181				this.status = 'AUTHENTICATION';
182				this.errMsg = 'The authorization to run the callback failed.';
183			}else if(aReturnMessage.indexOf('Timeout:') >= 0){
184				DebugLog('CallbackResult - response message says: TIMED OUT');
185				this.status = 'TIMEOUT';
186				this.errMsg = 'The callback timed out.';
187			}else{
188				DebugLog('CallbackResult - response: UNHANDLED MESSAGE/CONTENT');
189				this.status = 'OTHER';
190				this.errMsg = 'The callback returned some unhandled result type.';
191			}	
192		}
193	}
194}
195
196
197//----------------------------------------------------------------------------
198function doProcessCNCallback(retID,retContent,retMessage){
199
200	DebugLog('doProcessCNCallback - id['+ retID +'], message['+ retMessage +'], len content['+ retContent.length +']');
201
202	DebugLog('doProcessCNCallback - content['+ retContent +']');
203	
204	var theDiv = document.getElementById(retID);
205	if(theDiv){
206		DebugLog('doProcessCNCallback - found CN item on page');
207		theDiv.setAttribute('data-cns',2); 
208		
209		var cbResult = new CallbackResult(retID,retContent,retMessage);
210		
211		DebugLog('doProcessCNCallback - cbResult - status['+ cbResult.status +']');
212		if(cbResult.status == 'OK'){
213			DebugLog('doProcessCNCallback - cbResult - note count['+ cbResult.getHeader('notecount') +']');
214			DebugLog('doProcessCNCallback - cbResult - action count['+ cbResult.getHeader('actioncount')  +']');
215			if((cbResult.getHeader('notecount') > 0) || (cbResult.getHeader('actioncount') > 0)){	
216				DebugLog('doProcessCNCallback - cbResult - show notes icon');
217				if(cbResult.getHeader('notecount') > 0){
218					if(cbResult.getHeader('actioncount') > 0){
219						theDiv.style.backgroundImage = 'url(images/icon-sm-note-plus.png)';
220					}else{
221						theDiv.style.backgroundImage = 'url(images/icon-sm-note.png)';
222					}
223				}else{
224					theDiv.style.backgroundImage = 'url(images/icon-time.png)';
225				}
226				theDiv.title = 'This item has '+ cbResult.getHeader('notecount') +' associated notes and '+ cbResult.getHeader('actioncount') +' associated actions.';
227				
228				var cnAction = 'process/doProcess-CN.asp?CNT='+ theDiv.getAttribute('data-cnt') +'&CNCID='+theDiv.getAttribute('data-cncid') 
229				if(theDiv.getAttribute('data-cnpin')) cnAction = cnAction +'&CNPIN='+theDiv.getAttribute('data-cnpin');
230				if(theDiv.getAttribute('data-cnrid')) cnAction = cnAction +'&CNRID='+theDiv.getAttribute('data-cnrid');
231				if(theDiv.getAttribute('data-alon')) cnAction = cnAction +'&ALON='+theDiv.getAttribute('data-alon');
232				if(theDiv.getAttribute('data-alid')) cnAction = cnAction +'&ALID='+theDiv.getAttribute('data-alid');
233				if(theDiv.getAttribute('data-alfn')) cnAction = cnAction +'&ALFN='+theDiv.getAttribute('data-alfn');
234				cnAction = cnAction + '&CNVW=1';
235				cnAction = AddInterfaceLevelToURL(cnAction);
236				var theIframeURL = cnAction;
237				var boxContent = '<div data-dlf=1 data-dlfurl="'+ theIframeURL +'" data-dlfmsg="loading notes and actions list..." data-dlfw="400px" data-dlfh="200px" style="display:block;position:relative;width:auto;height:auto;"></div>';		
238
239				var thehbID = 'hb' + (1000000 + Math.floor(Math.random()*8999999)); 
240				var theInside = '<div class="tribox left boxshadow">'+ boxContent +'</div>'
241				var theHbox = '<div id='+ thehbID +' data-hbPos="1" class="hoverinfoRight">'+ theInside +'</div><button data-hoverbubble='+ thehbID +' class="hoverinfobtn" style="background-color:transparent;border:none;">&nbsp;</button>';
242				var theNewHTML = '<div class="hoverboxRight">'+ theHbox +'</div>';
243				theDiv.innerHTML = theNewHTML;
244				
245				//now add our event listeners to this new hoverbubble item
246				var hbList = theDiv.querySelectorAll('button[data-hoverbubble]');
247				hbList.forEach(item => {item.addEventListener('mouseover',hbOver,false); })
248				hbList.forEach(item => {item.addEventListener('mouseout',hbOut,false); })
249				var hbBoxes = theDiv.querySelectorAll('div[data-hbPos]');
250				hbBoxes.forEach(item => {item.addEventListener('mouseover',hbBoxOver,false); })
251				hbBoxes.forEach(item => {item.addEventListener('mouseout',hbBoxOut,false); })
252				
253				dlCheckList(); // also need to check the dlfurl for the iframe
254			}else if((cbResult.getHeader('notecount') == 0) && (cbResult.getHeader('actioncount') == 0)){
255				DebugLog('doProcessCNCallback - cbResult - no notes - just update text');
256				theDiv.style.backgroundImage = 'url(images/icon-check.png)';
257				theDiv.style.opacity = 0.3;
258				theDiv.title = 'This item has no associated notes or actions';
259			}
260		}else{
261			DebugLog('doProcessCNCallback - cbResult - some other status['+ cbResult.status +'] errMsg['+ cbResult.errMsg +']');
262			if(theDiv.cnTryCnt > 10){
263				DebugLog('doProcessCNCallback - cbResult - exceeded TRY COUNT ['+ theDiv.cnTryCnt +'], set red flag');
264				theDiv.style.backgroundImage = 'url(images/redflag.gif)';
265				theDiv.title = 'An error occured while attempting to look for associated notes and actions';
266			}else if(theDiv.cnTryCnt <= 10){
267				theDiv.cnTryCnt = theDiv.cnTryCnt + 1;
268				DebugLog('doProcessCNCallback - cbResult - TRY COUNT ['+ theDiv.cnTryCnt +']');
269				theDiv.setAttribute('data-cns',0); //RESET SO IT WILL TRY AGAIN
270				doUpdateCNboxes();
271			}else{
272				theDiv.cnTryCnt = 1;
273				DebugLog('doProcessCNCallback - cbResult - first TRY COUNT ['+ theDiv.cnTryCnt +']');
274				theDiv.setAttribute('data-cns',0); //RESET SO IT WILL TRY AGAIN
275				doUpdateCNboxes();
276			}
277		}
278	
279	}else{
280		DebugLog('doProcessCNCallback - error - didnt find the CN item on page');
281	}
282}
283
284
285//----------------------------------------------------------------------------
286function isVisible(elem) {
287	if (!(elem instanceof Element)) throw Error('This item is not an element.');
288	const style = getComputedStyle(elem);
289	if (style.display === 'none') return false;
290	if (style.visibility !== 'visible') return false;
291	if (style.opacity < 0.1) return false;
292	if (elem.offsetWidth + elem.offsetHeight + elem.getBoundingClientRect().height +
293			elem.getBoundingClientRect().width === 0) {
294			return false;
295	}
296	const elemCenter   = {
297			x: elem.getBoundingClientRect().left + elem.offsetWidth / 2,
298			y: elem.getBoundingClientRect().top + elem.offsetHeight / 2
299	};
300	if (elemCenter.x < 0) return false;
301	if (elemCenter.x > (document.documentElement.clientWidth || window.innerWidth)) return false;
302	if (elemCenter.y < 0) return false;
303	if (elemCenter.y > (document.documentElement.clientHeight || window.innerHeight)) return false;
304	let pointContainer = document.elementFromPoint(elemCenter.x, elem
304Center.y);
305	do {
306			if (pointContainer === elem) return true;
307			if (!pointContainer) return false;
308	} while (pointContainer = pointContainer.parentNode);
309	return false;
310}
311
312
313//----------------------------------------------------------------------------
314function setDataAttributeByName(elementName,aDataName,aDataValue){
315var ta = document.getElementsByName(elementName)[0];
316	if(ta){
317		ta.setAttribute(aDataName) = aDataValue;
318	}
319}
320
321//----------------------------------------------------------------------------
322function getDataAttributeByName(elementName,aDataName){
323var ta = document.getElementsByName(elementName)[0];
324	if(ta){
325		return ta.gettAttribute(aDataName);
326	}else{
327		return '';
328	}
329}
330//----------------------------------------------------------------------------
331function setDataAttributeById(elementID,aDataName,aDataValue){
332var ta = document.getElementById(elementID);
333	if(ta){
334		ta.setAttribute(aDataName) = aDataValue;
335	}
336}
337
338//----------------------------------------------------------------------------
339function getDataAttributeById(elementID,aDataName){
340var ta = document.getElementById(elementID);
341	if(ta){
342		return ta.gettAttribute(aDataName);
343	}else{
344		return '';
345	}
346}
347
348function initAdv(){
349	var advList = document.querySelectorAll('table[data-ai]');
350	DebugLog('initAdv - number of ai items on page ['+ advList.length +']');
351	if(advList.length > 0){
352		advList.forEach(item => {item.addEventListener('mouseover',advOver,false); })
353		advList.forEach(item => {item.addEventListener('mouseout',advOut,false); })
354		advList.forEach(item => {item.addEventListener('click',advClick,false); })
355		var advDivBoxes = document.querySelectorAll('div[data-ai]');
356		advDivBoxes.forEach(item => {item.addEventListener('mouseover',advOver,false); })
357		advDivBoxes.forEach(item => {item.addEventListener('mouseout',advOut,false); })
358		advDivBoxes.forEach(item => {item.addEventListener('click',advClick,false); })
359	}
360}
361
362
363function advOver(e)
364{ 
365	if(e){
366		var doCP = false;
367		var theElm = e.currentTarget;
368		if(theElm){
369			var advItemID = theElm.getAttribute('data-ai');
370
371			//DebugLog('advOver - advItemID is ['+ advItemID +']');
372			theElm.style.borderStyle = "dashed";
373			theElm.style.borderWidth = "2px";
374			theElm.style.borderColor = "#00EE00";
375			theElm.style.boxSizing = "border-box";
376			//theElm.style.cursor = "pointer";
377			
378			var boxName = 'ntai'+ advItemID;
379			var subBoxName = 'ntais'+ advItemID;
380			var boxNote = '<div id="'+ boxName +'" style="display:inline-block;position:relative;vertical-align:top;"><div id="'+ subBoxName +'" style="display:block;position:absolute;top:0;left:0;cursor:pointer;width:auto;min-width:180px;min-height:18px;border:2px solid #0f0;background-color:#cfc;color:#0a0;font-size:10pt;white-space:pre;padding:4px;line-height:18px;z-index:1000;">article: ai'+ advItemID +' <span style="font-size:8pt">click to edit</span></div></div>';
381			
382			if(theElm.innerHTML.indexOf(boxName) == -1){ 
383				if(theElm.nodeName == 'TABLE'){
384					var theBody = theElm.getElementsByTagName('TBODY')[0];
385					if(theBody){
386						theBody.innerHTML = '<tr><td style="height:0;line-height:0;">' + boxNote + '</td></tr>' + theBody.innerHTML;
387					}
388				}else{
389					theElm.innerHTML = boxNote + theElm.innerHTML;
390				}
391			}else{
392				var boxElm = document.getElementById(boxName);
393				if(boxElm){
394					boxElm.style.display = 'inline-block';
395				}
396			}
397		}
398	}
399}
400
401function advOut(e)
402{  
403	if(e){
404		var theElm = e.currentTarget;
405		if(theElm){
406			var advItemID = theElm.getAttribute('data-ai');
407
408			//DebugLog('advOut - advItemID is ['+ advItemID +']');
409			theElm.style.borderStyle = "solid";
410			theElm.style.borderWidth = "0";
411			theElm.style.borderColor = "";		
412			theElm.style.boxSizing = "content-box";		
413			theElm.style.cursor = "";
414			
415			var boxName = 'ntai'+ advItemID;
416			if(theElm.innerHTML.indexOf(boxName) > -1){ 
417				//DebugLog('advOut - boxname ['+ boxName +'] is there');
418				var boxElm = document.getElementById(boxName);
419				if(boxElm){
420					//DebugLog('advOut - found boxname ['+ boxName +'] element');
421					boxElm.style.display = 'none';
422				}
423			}
424		}
425	}
426}
427
428
429function advClick(e)
430{  
431	if(e){
432		var theElm = e.currentTarget;
433		if(theElm){
434			var advItemID = theElm.getAttribute('data-ai');
435			var subBoxID = 'ntais'+ advItemID;
436			if(isMouseInElement(subBoxID)){
437				//DebugLog('advClick - g_AdvEcid ['+ g_AdvEcid +'], g_AdvEuid ['+ g_AdvEuid +'], advItemID ['+ advItemID +']');
438				//theElm.style.borderStyle = "solid";
439				var chkv = Number(g_AdvEcid) + Number(g_AdvEuid) + Number(advItemID) + 5;
440				var thePage = 'https://'+ g_AdvEsrv +'/sys/action.asp?T=ADVA1&CID='+ g_AdvEcid +'&UID='+ g_AdvEuid +'&AA=5&AP=&AN=&AAX=1&AAU='+chkv+'&ADVAP='+advItemID;
441				//DebugLog('advClick - action thePage ['+ thePage +']');
442				goExt(thePage);					
443			}
444		}
445	}
446}
447
448
449
450
451function initHB(){
452	var hbList = document.querySelectorAll('button[data-hoverbubble]');
453	DebugLog('initHB - number of HB items on page ['+ hbList.length +']');
454	if(hbList.length > 0){
455		hbList.forEach(item => {item.addEventListener('mouseover',hbOver,false); })
456		hbList.forEach(item => {item.addEventListener('mouseout',hbOut,false); })
457		var hbBoxes = document.querySelectorAll('div[data-hbPos]');
458		hbBoxes.forEach(item => {item.addEventListener('mouseover',hbBoxOver,false); })
459		hbBoxes.forEach(item => {item.addEventListener('mouseout',hbBoxOut,false); })
460	}
461
462	setTimeout(dlCheckList,2000);
463}
464
465
466// OPTIONAL PARAMS FOR DYN LOAD FRAMES - data-dlfmsg="loading..." data-dlfw="600px" data-dlfh="400px"
467function dlCheckList()
468{ 
469	var dlList = document.querySelectorAll('div[data-dlf]');
470	//DebugLog('initHB - number of DL items on page ['+ dlList.length +']');
471	if(dlList.length > 0){
472		dlList.forEach(item => {dlCheckOne(item);})
473		setTimeout(dlCheckList,500);
474	}
475}
476
477function dlCheckOne(aDiv)
478{ 
479	var theWidth = '100%';
480	var theHeight = '100%';
481	if(aDiv){
482		if(aDiv.offsetParent === null){
483			//
484		}else{
485			var dfURL = aDiv.getAttribute('data-dlfurl');
486			if(dfURL){
487				if(aDiv.innerHTML.length > 0){
488					// 'THERE IS SOMETHING THERE NOW, SO NO NEED TO DO ANYTHING
489				}else{
490					if(aDiv.getAttribute('data-dlfw')){
491						theWidth = aDiv.getAttribute('data-dlfw');
492					}
493					if(aDiv.getAttribute('data-dlfh')){
494						theHeight = aDiv.getAttribute('data-dlfh');
495					}					
496					if(aDiv.getAttribute('data-dlfpic') == 1){
497						var thePic = '<img src="'+dfURL+'" style="width:'+ theWidth +';height:'+ theHeight +';object-fit:cover;object-position:50% 50%;"">';
498						aDiv.innerHTML = thePic;
499					}else if(aDiv.getAttribute('data-dlfcd') >= 1){
500						var theCall = dfURL + '&PBC='+ aDiv.getAttribute('data-dlfcd'); 
501						var theInnerDivID = 'dlc' + Math.floor(Math.random()*10000);
502						var theInnerDiv = '<div id="'+ theInnerDivID +'"><div>&nbsp;</div></div>';
503						aDiv.innerHTML = theInnerDiv; 
504						MakeSpinnerInElement(theInnerDivID,4,4,12,'#00F',1);
505						doProcessDiv(theInnerDivID,theCall,doProcessOneCallback,10000); //doProcessDiv(aDivID,aProcessURL,aReturnCallback,timeoutMS)
506					}else if(aDiv.getAttribute('data-dlfmsg').length > 0){
507						DebugLog('dyn load frame message content and doing iframe with url['+ dfURL +']');
508						var theInnerDivID = 'dlc' + Math.floor(Math.random()*10000);
509						var theBoxDivID = theInnerDivID + 'box';
510						var theIFrmID = theInnerDivID + 'frame';
511						var theInnerDiv = '<div id="'+ theInnerDivID +'" style="margin-left:auto;margin-right:auto;margin-top:6px;width:78px"><div>&nbsp;</div></div>';
512						aDiv.innerHTML = '<div id="'+ theBoxDivID +'" style="font-weight:normal;font-style:italic;font-color:#999;text-align:center;">'+ aDiv.getAttribute('data-dlfmsg') + theInnerDiv +'</div>';
513						MakeSpinnerInElement(theInnerDivID,4,4,12,'#00F',1);					
514						var theFrame = '<iframe id='+ theIFrmID +' src="'+dfURL+'" style="width:'+ theWidth +';height:'+ theHeight +';" frameBorder="0" marginheight="0px" marginwidth="0px" allowfullscreen></iframe>';
515						aDiv.innerHTML = aDiv.innerHTML + theFrame;
516						setTimeout('checkForIframeFinished("'+	theInnerDivID +'")',200);						
517						
518					}else{
519						DebugLog('doing iframe with url['+ dfURL +']');
520						var theFrame = '<iframe src="'+dfURL+'" style="width:'+ theWidth +';height:'+ theHeight +';overflow:hidden;" frameBorder="0" scrolling="no" marginheight="0px" marginwidth="0px" allowfullscreen></iframe>';
521						aDiv.innerHTML = theFrame;
522					}
523				}
524			}
525		}
526	}
527}
528
529function checkForIframeFinished(baseFrameID){
530	var theframeID = baseFrameID + 'frame';
531	var theBoxID = baseFrameID + 'box';
532	var theIframe = document.getElementById(theframeID);
533	if(theIframe){
534		if(theIframe.isSpinningState == 1){
535			DebugLog('checkForIframeFinished - iframe is currently spinning');
536			var theIframeDoc = theIframe.contentDocument || theIframe.contentWindow.document;
537			
538			// Check if loading is complete
539			if( theIframeDoc.readyState  == 'complete' ){
540				//DebugLog('checkForIframeFinished - iframe complete - iframe height['+ theIframe.clientHeight +'], iframe length['+ theIframeDoc.body.innerHTML.length +']');
541				
542				//if(theIframeDoc.contentWindow){
543				if(theIframeDoc.body.innerHTML.length > 0){
544					//DebugLog('checkForIframeFinished - iframe has content now');
545				//	theIframeDoc.contentWindow.onload = function(){
546						DebugLog('checkForIframeFinished - it is loaded, clear the spinner and loading message');
547						var theInnerBox = document.getElementById(theBoxID);
548						if(theInnerBox){
549							theInnerBox.innerHTML = '';
550							theInnerBox.style.display = 'none';
551						}
552						theIframe.isSpinningState = 2;
553				//	};
554
555				}else{
556					//DebugLog('checkForIframeFinished - set iframe is not complete');
557					setTimeout('checkForIframeFinished("'+ baseFrameID +'")',500);	
558				}
559			}else{ 
560				DebugLog('checkForIframeFinished - set iframe is not complete');
561				setTimeout('checkForIframeFinished("'+ baseFrameID +'")',500);	
562			}
563		}else{
564			if(theIframe.isSpinningState == 2){
565				// done
566				//DebugLog('checkForIframeFinished - set iframe is done loading and spinning finished');
567			}else{
568				theIframe.isSpinningState = 1;
569				//DebugLog('checkForIframeFinished - set iframe is spinning');
570				setTimeout('checkForIframeFinished("'+ baseFrameID +'")',100);	
571			}
572		}
573	}
574}
575
576//----------------------------------------------------------------------------
577function doProcessOneCallback(retID,retContent,retMessage){
578
579	DebugLog('doProcessOneCallback - id['+retID+'], message['+retMessage+'], len content['+retContent.length+']');
580	//DebugLog('doProcessOneCallback - content['+retContent+']');
581
582	var theDiv = document.getElementById(retID);
583	if(theDiv){
584		DebugLog('doProcessOneCallback - found div on page');
585		//[OK:RETURNED CONTENT HERE] OR //[ERR:THE ERROR MESSAGE HERE]
586		if(retContent.substr(0,4).includes('[OK:')){
587			DebugLog('doProcessOneCallback - OK, we have prefixed data');
588			var dataStr;
589			dataStr = retContent.substring(0,retContent.lastIndexOf(']'));
590			var dataStrLen = dataStr.length;
591			dataStr = dataStr.substring(4,dataStrLen);
592			DebugLog('doProcessOneCallback - raw data string [ '+ dataStr +' ]');
593			theDiv.innerHTML = dataStr;
594		}else{
595			DebugLog('doProcessOneCallback - looks like we have error info');
596			theDiv.innerHTML = retContent;
597		}
598	}	
599}
600
601
602
603function hbOver(e)
604{ 
605	if(e){
606		var doCP = false;
607		var theElm = e.currentTarget;
608		if(theElm){
609			var hbItemID = theElm.getAttribute('data-hoverbubble');
610			var thePos = getOffset(theElm);
611			var elmW = theElm.clientWidth;
612			var elmH = theElm.clientHeight;
613			//DebugLog('hbOver - hbID is ['+ hbItemID +'], page left['+ thePos.left +'], page top['+ thePos.top +']');
614			var hBox = document.getElementById(hbItemID);
615			if(hBox){
616				var aPosNum = hBox.getAttribute('data-hbPos');
617				//DebugLog('hbOver - current hBox display is ['+ hBox.style.display +'], hbPos['+ aPosNum +'], elmWidth['+ elmW +'], elmHeight['+ elmH +']');
618				//DebugLog('hbOver - current hBox width['+ hBox.clientWidth +'], height['+ hBox.clientHeight +']');
619				if(hBox.style.display = 'none'){doCP = true;}
620				hBox.style.display = 'block';
621				hBox.hbButton = 1;
622
623				if(doCP){
624					//DebugLog('hbOver - SETTING CHECK POS TIMEOUT');
625					setTimeout(hbCheckPos,1,theElm,1);
626				}
627			}
628		}
629	}
630}
631
632function hbCheckPos(theElm,theRefresh)
633{ 
634	//DebugLog('hbCheckPos - start - theRefresh['+ theRefresh +']');
635
636	if(theElm){
637		var hbItemID = theElm.getAttribute('data-hoverbubble');
638		//var theOffset = getOffset(theElm);
639		var thePos = theElm.getBoundingClientRect();
640		var elmW = theElm.clientWidth;
641		var elmH = theElm.clientHeight;
642		var boxWidth = 0;
643		var boxHeight = 0;
644		//DebugLog('hbCheckPos - hbID is ['+ hbItemID +'], page left['+ thePos.left +'], page top['+ thePos.top +']');
645		var hBox = document.getElementById(hbItemID);
646		if(hBox){
647			var aPosNum = hBox.getAttribute('data-hbPos');
648			//DebugLog('hbCheckPos - current hBox - id['+ hBox.id +'], display is ['+ hBox.style.display +'], hbPos['+ aPosNum +']');
649			//DebugLog('hbCheckPos - current hBox - clientWidth['+ hBox.clientWidth +'], hbWidth['+ hBox.hbWidth +'] - clientHeight['+ hBox.clientHeight +'], hbHeight['+ hBox.hbHeight +']');
650			if(hBox.hbWidth > 0){
651				if(hBox.clientWidth && hBox.clientWidth > hBox.hbWidth){
652					boxWidth = hBox.clientWidth;
653					hBox.hbWidth = boxWidth;
654				}else{
655					boxWidth = hBox.hbWidth;
656				}
657			}else{boxWidth = hBox.clientWidth;hBox.hbWidth = boxWidth;}
658			if(hBox.hbHeight > 0){boxHeight = hBox.hbHeight;}else{boxHeight = hBox.clientHeight;hBox.hbHeight = boxHeight;}
659			//DebugLog('hbCheckPos - using - boxWidth['+ boxWidth +'], boxHeight['+ boxHeight +']');
660			if(hBox.style.display == 'block'){
661				if(aPosNum == 1){
662					//DebugLog('hbCheckPos - doing position Right');
663					//DebugLog('hbCheckPos - using - rect left['+ thePos.left +'], rect top['+ thePos.top +']');
664					//DebugLog('hbCheckPos - using - theOffset left['+ theOffset.left +'], theOffset top['+ theOffset.top +']');
665					hBox.style.left = (thePos.left + elmW) + 'px'; // right of the element
666					hBox.style.top =  ( thePos.top + ((elmH/2) - 26) )  + 'px'; 	
667				}else if(aPosNum == 2){
668					//DebugLog('hbCheckPos - doing position Top');
669					hBox.style.left = ( thePos.left + ((elmW/2) - 45) )  + 'px'; // top of the element
670					hBox.style.top =  ( thePos.top - (boxHeight + 15) )  + 'px'; 				
671				}else if(aPosNum == 3){
672					//DebugLog('hbCheckPos - doing position Bottom');
673					hBox.style.left = ( thePos.left + ((elmW/2) - 45) ) + 'px'; // bottom of the element
674					hBox.style.top =  ( thePos.top + elmH + 15 ) + 'px'; 
675				}else if(aPosNum == 4){
676					//DebugLog('hbCheckPos - doing position Left');
677					hBox.style.left = ( thePos.left - (boxWidth) ) + 'px'; // left of the element
678					hBox.style.top =  ( thePos.top + ((elmH/2) - 26) )  + 'px'; 
679				}
680				
681				setTimeout(hbCheckPos,100,theElm,100);
682			}	
683		}
684	}
685}
686
687function hbOut(e)
688{  
689	if(e){
690		var theElm = e.currentTarget;
691		if(theElm){
692			var hbItemID = theElm.getAttribute('data-hoverbubble');
693			//var thePos = getOffset(theElm);
694			//var elmW = theElm.clientWidth;
695			//var elmH = theElm.clientHeight;
696			//DebugLog('hbOut - hbID is ['+ hbItemID +'], page left['+ thePos.left +'], page top['+ thePos.top +']');
697			var hBox = document.getElementById(hbItemID);
698			if(hBox){
699				//DebugLog('hbOut - hbID is ['+ hbItemID +'] - setting timer');
700				hBox.hbButton = 0;
701				setTimeout('hbCheckForOut("'+hbItemID+'")',200);
702			}
703		}
704	}
705}
706
707function hbCheckForOut(hbItemID)
708{  
709	//DebugLog('hbCheckForOut - start - hbItemID['+ hbItemID +']');
710	if(hbItemID){
711		var hBox = document.getElementById(hbItemID);
712		if(hBox){
713			//DebugLog('hbCheckForOut - current hBox display is ['+ hBox.style.display +'], hbHold['+ hBox.hbHold +'],  hbButton['+ hBox.hbButton +']');
714			if((hBox.hbHold == 1) || (hBox.hbButton == 1)){
715				//DebugLog('hbCheckForOut - keep open');
716				setTimeout('hbCheckForOut("'+hbItemID+'")',200);
717			}else{
718				//DebugLog('hbCheckForOut - hide now');
719				hBox.style.display = 'none';
720			}
721		}
722	}
723}
724
725
726function hbBoxOver(e)
727{ 
728	if(e){
729		var hBox = e.currentTarget;
730		if(hBox){
731			hBox.hbHold = 1;
732		}
733	}
734}
735
736function hbBoxOut(e)
737{  
738	if(e){
739		var hBox = e.currentTarget;
740		if(hBox){
741			hBox.hbHold = 0;
742			hbOut(e);
743		}
744	}
745}
746
747
748
749
750
751
752
753
754function WEOcnLaunch(){
755	DebugLog('WEOcnLaunch - START');
756	setTimeout('CNweo()',3000);
757}
758
759
760function CNweo(){
761	DebugLog('CNweo - TRIGGERED');
762	var chkArr = document.getElementsByClassName('tpCN');
763	var chkElm;
764	var matchVal = false;
765	var dataItem = '';
766	var textItem = '';
767	if(chkArr){
768		//var actionURL = '';
769		for(var i = 0; i < chkArr.length; i++) {
770			chkElm = chkArr[i];
771			if(chkElm){
772				matchVal = false;
773				dataItem = chkElm.getAttribute('data-cn');
774				textItem = chkElm.innerHTML;
775				if(dataItem.match(textItem)){
776					matchVal = true;
777				}else{
778					matchVal = false;
779				}
780				DebugLog('CNweo - check element ['+ i +'] - data['+ dataItem +'], text['+ textItem +'], match['+ matchVal +']');
781				
782				//TODO: IMPLEMENT CALLBACK TO STORE THE RESULTS
783				
784				//actionURL = 'rel:'+ GetPathRelToSys() + 'process/doProcess-FavAction.asp?C='+aClientID+'&UID='+aUserID+'&FT='+aFavType+'&FI='+aFavItemID+'&FA='+actionID;
785				//ProcessAction(actionURL,'','');
786			}
787		}
788	}	
789	DebugLog('CNweo - FINISHED');	
790}
791
792function doProcess(aProcessURL,aReturnCallback,timeoutMS){
793	doProcessAux('',aProcessURL,aReturnCallback,timeoutMS,0,0);
794}
795
796function doProcessDiv(aDivID,aProcessURL,aReturnCallback,timeoutMS){
797	doProcessAux(aDivID,aProcessURL,aReturnCallback,timeoutMS,0,0);
798}
799
800function doProcessDivEx(aDivID,aProcessURL,aReturnCallback,timeoutMS,firstLoad,refresh){
801	doProcessAux(aDivID,aProcessURL,aReturnCallback,timeoutMS,firstLoad,refresh);
802}
803
804var gProcessInterfaceLevel = 0;
805var gProcessSessCheck = 0;
806
807function doProcessAux(aElementID, aProcessURL, aReturnCallback, timeoutMS, firstLoad, refresh) {
808  var httpObj = new XMLHttpRequest();
809	var theURL = ''
810	var countNum = 0;
811	var theCount = '';
812	var theSeconds = '';
813	var isFirstTime = true;
814	var thetimeout = timeoutMS;
815	if(thetimeout == 0){thetimeout = 2000;}
816	
817
818	DebugLog('doProcess - START - id['+aElementID+'], url['+aProcessURL+'], timeout['+timeoutMS+'], firstLoad['+firstLoad+'], refresh['+refresh+']');
819  if(aReturnCallback){
820		httpObj.callback = aReturnCallback;
821	}else{
822		httpObj.callback = defaultdoProcessCallback;
823	}
824	httpObj.firstLoad = firstLoad;
825	httpObj.refresh = refresh;
826	httpObj.startURL = aProcessURL;
827	httpObj.elmID = aElementID;
828	if(aElementID){
829		var theElem = document.getElementById(aElementID);
830		if(theElem){
831			if(theElem.getAttribute('dpCount')){
832				countNum = parseInt(theElem.getAttribute('dpCount')) + 1;
833				theElem.setAttribute('dpCount',countNum);
834				isFirstTime = false;
835			}else{
836				theElem.setAttribute('dpCount',1);
837				countNum = 1;
838			}
839			theCount = '&IC='+countNum;
840			
841			if(theElem.getAttribute('dpStart')){
842				var sTime = parseInt(theElem.getAttribute('dpStart'));
843				var d = new Date();
844				var n = d.getTime(); 
845				var sdiff = parseInt(n/1000) - sTime;
846				theSeconds = '&N='+sdiff;
847			}else{
848				var d = new Date();
849				var n = d.getTime(); 
850				if(n){
851					theElem.setAttribute('dpStart',parseInt(n/1000));
852				}else{
853					theElem.setAttribute('dpStart',0);
854				}
855				theSeconds = '&N=0';
856			}		
857		}
858	}
859	httpObj.theCount = countNum;
860
861	theURL = AddInterfaceLevelToURL(aProcessURL);
862	theURL = theURL + theSeconds + theCount
863	
864	httpObj.ontimeout = doProcessTimeout;
865  httpObj.onload = doProcessSuccess;
866  httpObj.onerror = doProcessError;
867	httpObj.theURL = theURL;
868	httpObj.theTimeout = thetimeout;
869	
870  //httpObj.open("GET", theURL, true);
871	//httpObj.timeout = thetimeout;
872  //httpObj.send(null);	
873	if(isFirstTime){
874		if(firstLoad > 0){
875			DebugLog('doProcessAux - isFirstTime, firstload['+firstLoad+']');
876			//ExecuteProcessGet(httpObj,theURL,thetimeout);
877			//setTimeout('ExecuteProcessGet(httpObj,"'+theURL+'",'+thetimeout+')',firstLoad);
878			setTimeout(ExecuteProcessGet,firstLoad,httpObj,theURL,thetimeout);
879		}else{
880			DebugLog('doProcessAux - isFirstTime, no firstload time');
881			ExecuteProcessGet(httpObj,theURL,thetimeout);			
882		}
883	}else{
884		if(refresh > 0){
885			DebugLog('doProcessAux - next time['+countNum+'], refresh['+refresh+']');
886			//setTimeout(ExecuteProcessGet,refresh,httpObj,theURL,thetimeout);
887			ExecuteProcessGet(httpObj,theURL,thetimeout);			
888
889		}else{
890			DebugLog('doProcessAux - next time['+countNum+'], no refresh time');
891			ExecuteProcessGet(httpObj,theURL,thetimeout);			
892		}
893		
894	}
895	
896}
897
898function ExecuteProcessGet(aHttpObj,theURL,theTimeout){
899	DebugLog('ExecuteProcessGet - url['+theURL+']');
900	aHttpObj.open("GET", theURL, true);
901	aHttpObj.timeout = theTimeout;
902  aHttpObj.send(null);	
903}
904
905function doProcessSuccess(){
906	if (this.readyState === 4) { 
907		if (this.status === 200) {
908			//DebugLog('doProcess: doProcessSuccess - OK - text['+this.responseText+'], statusText['+this.statusText+'], ready['+this.readyState+'], status['+this.status+']');
909			DebugLog('doProcess: doProcessSuccess - OK - statusText['+this.statusText+'], ready['+this.readyState+'], status['+this.status+']');
910			if(this.elmID){
911				this.callback(this.elmID,this.responseText,'',this.aStartTime,this.aCount);
912			}else{
913				this.callback(this.responseText,'');
914			}
915
916			if(this.refresh > 0){
917				DebugLog('doProcessSuccess - count['+this.theCount+'], refresh['+this.refresh+'], starturl['+this.startURL+'], theTimeout['+this.theTimeout+']');
918				//setTimeout(ExecuteProcessGet,this.refresh,this,this.theURL,this.theTimeout);
919				setTimeout(doProcessAux,this.refresh,this.elmID,this.startURL,this.callback,this.theTimeout,this.firstLoad,this.refresh);
920			}
921			
922		} else {
923			DebugLog('doProcess: doProcessSuccess - ERROR - ready['+this.readyState+'], status['+this.status+']');
924			this.onerror();
925		}
926	}
927}
928
929function doProcessError(){
930	DebugLog('doProcess: doProcessError - START');
931	if(this.elmID){
932		this.callback(this.elmID,this.responseText,'Error: '+this.statusText,this.aStartTime,this.aCount);
933	}else{
934		this.callback(this.responseText,'Error: '+this.statusText);
935	}
936}
937
938function doProcessTimeout(){
939	DebugLog('doProcess: doProcessTimeout - START');
940	if(this.elmID){
941		this.callback(this.elmID,this.responseText,'Timeout: '+this.statusText,this.aStartTime,this.aCount);
942	}else{
943		this.callback(this.responseText,'Timeout: '+this.statusText);
944	}
945}
946
947
948function doModuleClick(event){
949	DebugLog('doModuleClick - START');
950	var abutton = getEventTarget(event);
951	if(abutton) DebugLog('doModuleClick - button ID['+abutton.id+']');
952	
953}
954
955//----------------------------------------------------------------------------
956function defaultdoProcessCallback(retID,retContent,retMessage){
957
958	DebugLog('defaultdoProcessCallback - id['+retID+'], message['+retMessage+'], len content['+retContent.length+']');
959	if(retContent.length < 100){
960		DebugLog('defaultdoProcessCallback - content['+retContent+']');
961	}
962}
963
964
965//----------------------------------------------------------------------------
966function doProcessTableGet(tableControlID,tableRecordID){
967
968	DebugLog('doProcessTableGet - tableControlID['+tableControlID+'], tableRecordID['+tableRecordID+']');
969	var theTable = document.getElementById(tableControlID);
970	if(theTable){
971		DebugLog('doProcessTableGet - found table on page');
972		var lastRow = document.getElementById(tableControlID+'dptLR');
973		if(lastRow){
974			lastRow.tableRecordID = tableRecordID; //STORE FOR LATER USE
975			DebugLog('doProcessTableGet - found last row in table');
976			var theTimeoutms = lastRow.getAttribute('data-toms');
977			DebugLog('doProcessTableGet - timeout attribute says['+ theTimeoutms +']');
978			//if(lastRow.firstChild.tempTableText){
979			//	DebugLog('doProcessTableGet - we have saved the loading text, so use it');
980			//	tmpText = lastRow.firstChild.tempTableText //PULL THIS OUT IF WE HAVE IT
981			//	lastRow.firstChild.innerHTML = tmpText;
982			//}			
983			
984			DebugLog('doProcessTableGet - calling doProcessTableCallback');
985			var tableAction = 'process/doProcess-Table.asp?TBID='+tableRecordID;
986			DebugLog('doProcessTableGet - about to process table action['+ tableAction +']');
987			doProcessDiv(tableControlID,tableAction,doProcessTableCallback,theTimeoutms);
988			
989
990		}
991	}
992}
993
994
995//----------------------------------------------------------------------------
996function doProcessTableCancel(tableControlID){
997	DebugLog('doProcessTableCancel - tableControlID['+tableControlID+']');
998	var theTable = document.getElementById(tableControlID);
999	if(theTable){
1000		var lastRow = document.getElementById(tableControlID+'dptLR');
1001		if(lastRow){
1002			DebugLog('doProcessTableCancel - found last row in table, set cancel flag');
1003			lastRow.tableProcessDoCancel = true;
1004		}
1005	}
1006}
1007
1008
1009//----------------------------------------------------------------------------
1010function doProcessTableCallback(retID,retContent,retMessage){
1011
1012	DebugLog('doProcessTableCallback - id['+retID+'], message['+retMessage+'], len content['+retContent.length+']');
1013	//if(retContent.length < 100){
1014		DebugLog('doProcessTableCallback - content['+retContent+']');
1015	//}
1016	
1017	var theTable = document.getElementById(retID);
1018	if(theTable){
1019		DebugLog('doProcessTableCallback - found table on page');
1020		var lastRow = document.getElementById(retID+'dptLR');
1021		if(lastRow){
1022			DebugLog('doProcessTableCallback - found last row in table, add rows');
1023			if(retMessage.includes('Error')){
1024				lastRow.firstChild.innerHTML = '<span style="color:#900">Problem loading rows: <b>'+retMessage+'</b></span><br>'+ retContent;
1025			}else{
1026				// RETMSG FORMAT INCLUDES SOME INFO, PARSE WITH getParsedData AND getParsedItem
1027				//[OK:rows[~]###[~]total[~]####[~]done[~]1]<tr>....</tr>
1028				if(retContent.substr(0,4).includes('[OK:')){
1029					DebugLog('doProcessTableCallback - we have prefixed data');
1030					var dataStr;
1031					if(retContent.search(']<') > 0){
1032						dataStr = retContent.substring(0,retContent.search(']<'));
1033					}else{
1034						dataStr = retContent.substring(0,retContent.lastIndexOf(']'));
1035					}
1036					DebugLog('doProcessTableCallback - raw data string [ '+dataStr+ ' ]');
1037					var dataStrLen = dataStr.length;
1038					dataStr = dataStr.substring(4,dataStrLen);
1039					DebugLog('doProcessTableCallback - fixed data string [ '+dataStr+ ' ]');
1040					var rowsStr = retContent.substring(dataStrLen+1,retContent.length);
1041					DebugLog('doProcessTableCallback - rows string [ '+rowsStr+ ' ]');
1042					var dataArr = getParsedData(dataStr);
1043					var rowsAdded = getParsedItem('rows',dataArr);
1044					DebugLog('doProcessTableCallback - rows added ['+rowsAdded+']');
1045					var totalRows = getParsedItem('total',dataArr);
1046					DebugLog('doProcessTableCallback - total rows ['+totalRows+']');
1047					var doneFlag = getParsedItem('done',dataArr);
1048					DebugLog('doProcessTableCallback - done flag ['+doneFlag+']');
1049					
1050					if(rowsStr.length > 0){
1051						var rowsCount = countRowsInRowsStr(rowsStr);
1052						DebugLog('doProcessTableCallback - direct rowsCount ['+rowsCount+'], reported count['+rowsAdded+']');
1053						var i = 0
1054						var newRow;
1055						var rowContent;
1056						while(i < rowsCount){
1057							i++;
1058							newRow = lastRow.cloneNode(true);
1059							if(newRow){
1060								lastRow.parentNode.insertBefore(newRow,lastRow);
1061								DebugLog('doProcessTableCallback - added new row ['+ i +']');
1062								rowContent = getRowFromRowsStr(rowsStr,i-1);
1063								newRow.outerHTML = rowContent; //PUT THE ROW CONTENT INTO OUR NEW ROW
1064								//newRow.id = lastRow.id + 'newone'+ i;
1065							}
1066							
1067						}
1068						// we might need to re-adjust the header row
1069						DebugLog('doProcessTableCallback - calling SyncTableHeader for table['+ retID +']');
1070						SyncTableHeader(retID);
1071						
1072					}else{
1073						DebugLog('doProcessTableCallback - no rows returned - doneFlag['+ doneFlag +']');
1074					}
1075					DebugLog('doProcessTableCallback - SUMMARY - rows['+rowsAdded+'], total['+totalRows+'], done['+doneFlag+']');
1076					if(doneFlag == 1){
1077						DebugLog('doProcessTableCallback - we are done loading now');
1078						lastRow.firstChild.innerHTML = '<span style=""vertical-align:top;color:#999;"">Finished - total records: '+totalRows+'</span>';
1079					}else{
1080						DebugLog('doProcessTableCallback - need to load more records');
1081						var tmpText;
1082						if(lastRow.firstChild.tempTableText){
1083							DebugLog('doProcessTableCallback - we have saved the loading text, so use it');
1084							tmpText = lastRow.firstChild.tempTableText //PULL THIS OUT IF WE HAVE IT
1085						}else{
1086							DebugLog('doProcessTableCallback - let\'s save the loading text');
1087							tmpText = lastRow.firstChild.innerHTML; 
1088							lastRow.firstChild.tempTableText = tmpText;	//STORE THIS FOR USE LATER						
1089						}
1090						DebugLog('doProcessTableCallback - control['+ retID +'], record['+ lastRow.tableRecordID +']');
1091						
1092						if(doneFlag == 1){
1093							DebugLog('doProcessTableCallback - since we are done, dont show button or reload auto');
1094							var newText = 'Total: '+totalRows
1095							lastRow.firstChild.innerHTML = newText;
1096							
1097						}else{
1098							
1099							var doAutoLoad = lastRow.getAttribute('data-doal');
1100							DebugLog('doProcessTableCallback - doAutoLoad['+doAutoLoad+']');
1101							if(doAutoLoad == '1'){
1102								var autoLoadms = lastRow.getAttribute('data-alms');
1103								DebugLog('doProcessTableCallback - doAutoLoad ms['+autoLoadms+']');
1104								if(lastRow.tableProcessDoCancel){
1105									var newText = 'Finished: '+totalRows+' &nbsp;&nbsp;';
1106									// did a cancel action
1107									newText = newText + ' &nbsp;&nbsp;<span style=""color:#ccc;font-style:italic"">(cancelled)</span>'
1108									lastRow.firstChild.innerHTML = newText;							
1109									
1110								}else{
1111									var newText = 'Loaded: '+totalRows+' &nbsp;&nbsp;';
1112									// add a cancel button
1113									newText = newText + ' <button  style="margin:2px 10px 2px 10px;font-size:9px;" type="button" onclick="javascript:doProcessTableCancel(\''+ retID +'\');return true;">cancel</button>'
1114									newText = newText + ' &nbsp;&nbsp;loading'
1115									tmpText = tmpText.replace('loading',newText);
1116									lastRow.firstChild.innerHTML = tmpText;							
1117									setTimeout('doProcessTableGet("'+ retID +'",'+ lastRow.tableRecordID +')',autoLoadms);
1118								}
1119								
1120							}else{
1121								
1122								DebugLog('doProcessTableCallback - doing manual load button');
1123								var newText = 'Loaded: '+totalRows+' <button  style="margin:2px 10px 2px 10px;font-size:9px;" type="button" onclick="javascript:doProcessTableGet(\''+ retID +'\','+ lastRow.tableRecordID +');return true;">Get More</button>';
1124								//tmpText = tmpText.replace('loading',newText);
1125								lastRow.firstChild.innerHTML = newText;
1126							}
1127						}
1128					}
1129				}else{
1130					DebugLog('doProcessTableCallback - some other response from the system:['+ retContent.slice(0,150) +']');
1131					DebugLog('doProcessTableCallback - some other response from the system');
1132					if(retContent.indexOf('[Timeout:') >= 0){
1133						DebugLog('doProcessTableCallback - response: TIMED OUT');
1134						lastRow.firstChild.innerHTML = '<span style="color:red">Search timed out.</span>';
1135					}else if(retContent.indexOf('[interface process authentication error') >= 0){
1136						DebugLog('doProcessTableCallback - response: AUTHENTICATION FAILURE');
1137						lastRow.firstChild.innerHTML = '<span style="color:red">No longer logged in or session timed out.</span>';
1138					}else{
1139						DebugLog('doProcessTableCallback - response: UNHANDLED MESSAGE/CONTENT');
1140						lastRow.firstChild.innerHTML = '<span style="color:red">Unknown processing response of ['+retMessage+'], content['+ retContent.slice(0,50) +'].</span>';
1141						//lastRow.firstChild.innerHTML = '<span style="color:red">Unknown processing response of ['+ retMessage +']</span>';
1142					}
1143				}
1144				
1145			}
1146			
1147			DebugLog('doProcessTableCallback - about to call doProcessTableDataCallback - controlID['+ retID +'], recID['+ lastRow.tableRecordID +']');
1148			var tableDataAction = 'process/doProcess-TableData.asp?TBID='+lastRow.tableRecordID;
1149			var theDataTimeoutms = 20000;
1150			doProcessDiv(retID,tableDataAction,doProcessTableDataCallback,theDataTimeoutms);		
1151
1152		}
1153		
1154	}	
1155	
1156}
1157
1158
1159
1160//----------------------------------------------------------------------------
1161function doProcessTableDataCallback(retID,retContent,retMessage){
1162
1163	DebugLog('doProcessTableDataCallback - id['+retID+'], message['+retMessage+'], len content['+retContent.length+']');
1164	//if(retContent.length < 100){
1165		DebugLog('doProcessTableDataCallback - content['+retContent+']');
1166	//}
1167	
1168	var theTable = document.getElementById(retID);
1169	if(theTable){
1170		DebugLog('doProcessTableDataCallback - found table on page');
1171		var uDataDiv = document.getElementById(retID+'dptUD');
1172		if(uDataDiv){ 
1173			DebugLog('doProcessTableDataCallback - found userdata render target div, add rendered block...');
1174			if(retMessage.includes('Error')){
1175				uDataDiv.firstChild.innerHTML = '<span style="color:#900">Problem user data rendered block: <b>'+retMessage+'</b></span><br>'+ retContent;
1176			}else{
1177				// RETMSG FORMAT INCLUDES SOME INFO, PARSE WITH getParsedData AND getParsedItem
1178				//[OK:rows[~]###[~]total[~]####[~]done[~]1]SOMEHTMLOUTPUT TO THROW IN THE TARGET DIV
1179				if(retContent.substr(0,4).includes('[OK:')){
1180					DebugLog('doProcessTableDataCallback - we have prefixed data');
1181					var dataStr;
1182					if(retContent.search(']<') > 0){
1183						dataStr = retContent.substring(0,retContent.search(']<'));
1184					}else{
1185						dataStr = retContent.substring(0,retContent.lastIndexOf(']'));
1186					}
1187					DebugLog('doProcessTableDataCallback - raw data string [ '+dataStr+ ' ]');
1188					var dataStrLen = dataStr.length;
1189					dataStr = dataStr.substring(4,dataStrLen);
1190					DebugLog('doProcessTableDataCallback - fixed data string [ '+dataStr+ ' ]');
1191					var renderStr = retContent.substring(dataStrLen+1,retContent.length);
1192					DebugLog('doProcessTableDataCallback - render block string [ '+renderStr+ ' ]');
1193					var dataArr = getParsedData(dataStr);
1194					var rowsAdded = getParsedItem('rows',dataArr);
1195					DebugLog('doProcessTableDataCallback - rows added ['+rowsAdded+']');
1196					var totalRows = getParsedItem('total',dataArr);
1197					DebugLog('doProcessTableDataCallback - total rows ['+totalRows+']');
1198					var doneFlag = getParsedItem('done',dataArr);
1199					DebugLog('doProcessTableDataCallback - done flag ['+doneFlag+']');
1200					
1201					if(renderStr.length > 0){
1202						DebugLog('doProcessTableDataCallback - have render block');
1203						uDataDiv.innerHTML = renderStr; 
1204
1205					}else{
1206						DebugLog('doProcessTableDataCallback - no render block returned - doneFlag['+ doneFlag +']');
1207					}
1208					
1209					DebugLog('doProcessTableDataCallback - SUMMARY - rows['+rowsAdded+'], total['+totalRows+'], done['+doneFlag+']');
1210					if(doneFlag == 1){
1211						DebugLog('doProcessTableDataCallback - we are done loading now');
1212						//uDataDiv.innerHTML = '<span style=""vertical-align:top;color:#999;"">Finished - total records: '+totalRows+'</span>';
1213					}else{
1214						DebugLog('doProcessTableDataCallback - need to load more records');
1215
1216						if(doneFlag == 1){
1217							DebugLog('doProcessTableDataCallback - since we are done, dont show button or reload auto');
1218							var newText = 'Total: '+totalRows
1219							//uDataDiv.firstChild.innerHTML = newText;
1220							
1221						}else{
1222							// MIGHT NOT NEED THIS SECTION
1223							DebugLog('doProcessTableDataCallback - might not need this section now');
1224							//var doAutoLoad = lastRow.getAttribute('data-doal');
1225							//DebugLog('doProcessTableDataCallback - doAutoLoad['+doAutoLoad+']');
1226						}
1227					}
1228					
1229				}else{
1230					DebugLog('doProcessTableDataCallback - some other response from the system');
1231					if(retContent.indexOf('[Timeout:') >= 0){
1232						DebugLog('doProcessTableDataCallback - request for render timed out');
1233						//uDataDiv.firstChild.innerHTML = '<span style="color:red">Search timed out.</span>';
1234					}else{
1235						DebugLog('doProcessTableDataCallback - request for render - other response ['+ retMessage +']');
1236						//uDataDiv.firstChild.innerHTML = '<span style="color:red">Unknown search response of ['+retMessage+'].</span>';
1237					}
1238				}
1239				
1240			}
1241		}
1242	}	
1243	
1244}
1245
1246
1247
1248
1249function countRowsInRowsStr(aStr){
1250	var trs = aStr.indexOf('<tr',0);
1251	var tre = aStr.indexOf('</tr>',0);
1252	var trc = 0;
1253	var trn = -1;
1254	if((trs > -1) && (tre > -1)){
1255		while(trs > -1){
1256			trn = aStr.indexOf('<tr',trs+1); //LOOK FOR NEXT ONE
1257			if((trn > -1) && (trn < tre)){ // LOOKS LIKE A ROW INSIDE A ROW
1258				DebugLog('countRowsInRowsStr - might have a row inside a row here');
1259			}else{
1260				trc++;
1261				trs = aStr.indexOf('<tr',tre+1);
1262				tre = aStr.indexOf('</tr>',tre+1);
1263			}
1264		}
1265	}
1266	return trc;
1267}
1268
1269function getRowFromRowsStr(aStr,aIndex){
1270	var trs = aStr.indexOf('<tr',0);
1271	var tre = aStr.indexOf('</tr>',0);
1272	var trc = 0;
1273	var trn = -1;
1274	var rowContent = '';
1275	DebugLog('getRowFromRowsStr - get row at index ['+aIndex+']');
1276	if((trs > -1) && (tre > -1)){
1277		while(trs > -1){
1278			trn = aStr.indexOf('<tr',trs+1); //LOOK FOR NEXT ONE
1279			if((trn > -1) && (trn < tre)){ // LOOKS LIKE A ROW INSIDE A ROW
1280				DebugLog('getRowFromRowsStr - might have a row inside a row here');
1281			}else{
1282				if(trc == aIndex){
1283					rowContent = aStr.substring(trs,tre+5);
1284					DebugLog('getRowFromRowsStr - raw row content['+rowContent+']');
1285
1286						//trn = rowContent.indexOf('>',0);
1287						//tre = rowContent.length;
1288						//DebugLog('getRowFromRowsStr - trn['+trn+'], tre['+tre+']');
1289						//rowContent = rowContent.substring(trn+1,tre);
1290						//DebugLog('getRowFromRowsStr - fixed row content['+rowContent+']');
1291				}
1292				trc++;
1293				trs = aStr.indexOf('<tr',tre+1);
1294				tre = aStr.indexOf('</tr>',tre+1);
1295			}
1296		}
1297	}
1298	return rowContent;
1299}
1300
1301
1302
1303function getParsedData(aDataStr){
1304//the datastr has the format itemkey[~]itemvalue[~]itemkey[~]itemvalue
1305var items = aDataStr.split('[~]');
1306return items
1307}
1308
1309function getParsedItem(itemName,itemsArray){
1310var itemvalue = '';
1311var itemkey = '';
1312	if(itemsArray){
1313		for(var i = 0; (i < itemsArray.length) && (itemvalue == ''); i = i + 2){
1314			itemkey = itemsArray[i];
1315			if(itemName.match(itemkey)){
1316				itemvalue = itemsArray[i+1];
1317			}
1318		}
1319	}
1320return itemvalue;	
1321}
1322
1323var gcsuN = '';
1324var gcscID = 0;
1325var gcspID = 0;
1326var gcsuID = 0;
1327var gcsiL = 0;
1328
1329function CheckSession(aID,uName,cID,pID,uID,iL){
1330	DebugLog('CheckSession - START - id['+ aID +'], level['+ iL +']');
1331	gcsuN = uName;
1332	gcscID = cID;
1333	gcspID = pID;
1334	gcsuID = uID;
1335	gcsuiL = iL;
1336	gProcessInterfaceLevel = iL; 
1337	gProcessSessCheck = aID;
1338	setTimeout('CheckSessionAux("'+aID+'")',180000);//3MIN REFRESH
1339}
1340
1341function CheckSessionAux(aID){
1342	DebugLog('CheckSessionAux - id['+aID+']');
1343	var checkURL = 'process/doProcess-ChkSess.asp?SI='+aID;
1344	doProcess(checkURL,CheckSessionResult,30000);
1345	setTimeout('CheckSessionAux("'+aID+'")',180000); //3MIN REFRESH
1346}
1347
1348function CheckSessionResult(theText,errorStr){
1349	DebugLog('CheckSessionResult - START - text['+theText+'], errStr['+errorStr+']');
1350	
1351	if (theText.indexOf('authentication error') >= 0){
1352		
1353		var logoutURL = 'dologout.asp?User='+gcsuN+'&ClientID='+gcscID+'&PartnerID='+gcspID+'&UserID='+gcsuID+'&iLvl='+gcsuiL+'&src=indexCheckSession&exp=true';
1354		//DebugLog('CheckSessionResult - need to logout using URL['+logoutURL+']');
1355		window.location.href = logoutURL;
1356		
1357	}else{
1358		DebugLog('CheckSessionResult - still good');
1359	}
1360	
1361}
1362
1363
1364function GetPathRelToSys(){
1365var thebase = '';
1366var theURL = window.location.href;
1367	DebugLog('GetPathRelToSys - cur URL['+theURL+']');
1368	var i = theURL.indexOf('/sys/');
1369	if(i >= 0){
1370		DebugLog('GetPathRelToSys - sys is in path');
1371		var cutURL = theURL.substring(i+5,theURL.length);
1372		DebugLog('GetPathRelToSys - cut URL is ['+cutURL+']');
1373		var moreDirs = countInStr(cutURL,'/');
1374		DebugLog('GetPathRelToSys - count slashes ['+ moreDirs +']');
1375		if(moreDirs >= 1){
1376			for(var j=0;j<moreDirs;j++){
1377				thebase += '../';
1378			}
1379		}else{
1380			
1381		}
1382	}else{
1383		DebugLog('GetPathRelToSys - sys NOT in path');
1384	}
1385	DebugLog('GetPathRelToSys - return base['+thebase+']');
1386return thebase;	
1387}
1388
1389
1390function countInStr(aString,aSubStr) {
1391var retCount = 0;
1392	if(aString){
1393   var tmpStr = aString.split(aSubStr);
1394	 if(tmpStr){
1395		retCount = tmpStr.length - 1;	
1396	 }
1397	}
1398return retCount;
1399}
1400
1401
1402
1403function DoFavClick(aDivClassID,aFavType,aFavItemID,aUserID,aClientID){
1404	//var fav = document.getElementById(aDiv);	
1405	DebugLog('DoFavClick - class id['+aDivClassID+']');
1406	var divArr = document.getElementsByClassName(aDivClassID);
1407	var actionID = '';
1408	if(divArr){
1409		var actionURL = '';
1410		for(var i = 0; i < divArr.length; i++) {
1411			fav = divArr[i];
1412			if(fav){
1413				ToggleClassForElement(fav,'TPfstar','TPfselstar');
1414				if(HasClassName(fav,'TPfselstar')){
1415					RemoveClassForElement(fav,'TPfavhide');
1416					actionID = '1';
1417				}else{
1418					AddClassForElement(fav,'TPfavhide');
1419					actionID = '0'
1420				}
1421				actionURL = 'rel:'+ GetPathRelToSys() + 'process/doProcess-FavAction.asp?C='+aClientID+'&UID='+aUserID+'&FT='+aFavType+'&FI='+aFavItemID+'&FA='+actionID;
1422				ProcessAction(actionURL,'','');
1423			}
1424		}
1425	}
1426}
1427
1428function DoCBClick(aDivClassID,aFavType,aFavItemID,aUserID,aClientID){
1429	//var fav = document.getElementById(aDiv);	
1430	DebugLog('DoFavClick - class id['+aDivClassID+']');
1431	var divArr = document.getElementsByClassName(aDivClassID);
1432	var actionID = '';
1433	if(divArr){
1434		var actionURL = '';
1435		for(var i = 0; i < divArr.length; i++) {
1436			fav = divArr[i];
1437			if(fav){
1438				ToggleClassForElement(fav,'TPcb','TPselcb');
1439				if(HasClassName(fav,'TPselcb')){
1440					RemoveClassForElement(fav,'TPfavhide');
1441					actionID = '1';
1442				}else{
1443					AddClassForElement(fav,'TPfavhide');
1444					actionID = '0'
1445				}
1446				actionURL = 'rel:'+ GetPathRelToSys() + 'process/doProcess-FavAction.asp?C='+aClientID+'&UID='+aUserID+'&FT='+aFavType+'&FI='+aFavItemID+'&FA='+actionID;
1447				ProcessAction(actionURL,'','');
1448			}
1449		}
1450	}
1451}
1452
1453//checkbox click
1454function DoDEcbClick(aDivClassID,aCBtable,aCBfield,aCBrecID,aCBaction,aUserID,aClientID){
1455	//var fav = document.getElementById(aDiv);	
1456	DebugLog('DoDEcbClick - class id['+aDivClassID+']');
1457	var divArr = document.getElementsByClassName(aDivClassID);
1458	var actionID = '';
1459	if(divArr){
1460		var actionURL = '';
1461		for(var i = 0; i < divArr.length; i++) {
1462			fav = divArr[i];
1463			if(fav){
1464				ToggleClassForElement(fav,'TPcb','TPselcb');
1465				if(HasClassName(fav,'TPselcb')){
1466					RemoveClassForElement(fav,'TPcbhide');
1467					actionID = '1';
1468				}else{
1469					AddClassForElement(fav,'TPcbhide');
1470					actionID = '0'
1471				}
1472				actionURL = 'rel:'+ GetPathRelToSys() + 'process/doProcess-CBAction.asp?C='+aClientID+'&UID='+aUserID+'&CBT='+aCBtable+'&CBF='+aCBfield+'&CBR='+aCBrecID+'&CBA='+aCBaction
1473				ProcessAction(actionURL,'','');
1474			}
1475		}
1476	}
1477}
1478
1479
1480function DoDEtextClick(theElement,aTextClass,aEditClass,aUniquePrefix){
1481	var actionID = 0;
1482	DebugLog('DoDEtextClick - text['+aTextClass+'], edit['+aEditClass+']');
1483	if(theElement){
1484		//ToggleClassForElement(theElement,'TPfstar','TPfselstar');
1485		if(HasClassName(theElement,'TPdeHide')){
1486			RemoveClassForElement(theElement,'TPdeHide');
1487			actionID = 1;
1488		}else{
1489			AddClassForElement(theElement,'TPdeHide');
1490			actionID = 0;
1491		}		
1492		DebugLog('DoDEtextClick - action id['+actionID+']');
1493		var edItemID = aUniquePrefix + aEditClass;
1494		var edInputID = 'in'+aUniquePrefix + aEditClass;
1495		
1496		var edElm = document.getElementById(edItemID);
1497		if(edElm){
1498			DebugLog('DoDEtextClick - have edit element id ['+edItemID+']');
1499			if(actionID == 0){
1500				RemoveClassForElement(edElm,'TPdeHide');
1501				DebugLog('DoDEtextClick - removed hide');
1502				var xdiv = document.getElementById('xid');
1503				xdiv.tabIndex = -1;
1504				var chkdiv = document.getElementById('chkid');
1505				chkdiv.tabIndex = -1;
1506				var inputdiv = document.getElementById(edInputID);
1507				inputdiv.focus();
1508				DebugLog('DoDEtextClick - set focus and set controls');
1509			}else{
1510				AddClassForElement(edElm,'TPdeHide');
1511				DebugLog('DoDEtextClick - added hide');
1512			}
1513		}
1514
1515	}
1516}
1517
1518function DoDEcancel(aTextClass,aEditClass,aUniquePrefix){
1519	setTimeout('DoDEcancelEx("'+aTextClass+'","'+aEditClass+'","'+aUniquePrefix+'")',100);
1520}
1521
1522function DoDECheckClick(aTextClass,aEditClass,aUniquePrefix){
1523	g_AvoidCancel = true;
1524	DebugLog('DoDECheckClick - button clicked');
1525}
1526
1527var g_AvoidCancel = false;
1528
1529function DoDEcancelEx(aTextClass,aEditClass,aUniquePrefix){
1530	var actionID = 0;
1531	DebugLog('DoDEcancel - text['+aTextClass+'], edit['+aEditClass+']');
1532	if(g_AvoidCancel){
1533		DebugLog('DoDEcancel - avoiding cancel action');
1534		g_AvoidCancel = false;
1535	}else{
1536		DebugLog('DoDEcancel - DO cancel action');
1537		var textItemID = aUniquePrefix + aTextClass;
1538		var theElement = document.getElementById(textItemID);
1539		if(theElement){
1540			DebugLog('DoDEcancel - remove hide from text version - cur class['+theElement.className+']');			
1541			if(HasClassName(theElement,'TPdeHide')){
1542				RemoveClassForElement(theElement,'TPdeHide');
1543				actionID = 1;
1544			}		
1545			var edItemID = aUniquePrefix + aEditClass;
1546			var edElm = document.getElementById(edItemID);
1547			if(edElm){
1548				DebugLog('DoDEcancel - have edit element id ['+edItemID+']');
1549				if(actionID == 1){
1550					AddClassForElement(edElm,'TPdeHide');
1551					DebugLog('DoDEtextClick - added hide');
1552				}
1553			}
1554
1555		}
1556	}
1557}
1558
1559function DoDEeditClick(theElement,aDivClassID,aTable,aRecID,aField,aType,aUserID,aClientID){
1560	//var fav = document.getElementById(aDiv);	
1561	DebugLog('DoDEClick - class id['+aDivClassID+']');
1562	var divArr = document.getElementsByClassName(aDivClassID);
1563	var actionID = '';
1564	if(divArr){
1565		var actionURL = '';
1566		for(var i = 0; i < divArr.length; i++) {
1567			edititem = divArr[i];
1568			if(edititem){
1569				ToggleClassForElement(edititem,'TPfstar','TPfselstar');
1570				if(HasClassName(edititem,'TPfselstar')){
1571					RemoveClassForElement(edititem,'TPfavhide');
1572					actionID = '1';
1573				}else{
1574					AddClassForElement(edititem,'TPfavhide');
1575					actionID = '0'
1576				}
1577				actionURL = 'rel:'+ GetPathRelToSys() + 'process/doProcess-EditAction.asp?C='+aClientID+'&UID='+aUserID+'&ET='+aTable+'&EI='+aRecID+'&EF='+aField+'&EY='+aType;
1578				ProcessAction(actionURL,'','');
1579			}
1580		}
1581	}
1582}
1583
1584
1585
1586//--- clear out the console ---
1587if (window.console && console.log) {
1588  var adt = new Date();
1589  console.clear; 
1590  console.log('START LOG ['+ adt.toString() +']');
1591}
1592//-----------------------------
1593
1594
1595//----------------------------------------------------------------------------
1596function DoJSDebugInfo(){
1597  DebugLog('START - JS Debug Information Dump');
1598  DebugLog('JS Debug State value ['+ g_JSDebugState + ']');
1599  DebugLog('Current ViewPort Width: '+ ViewPortWidth());
1600  DebugLog('Current ViewPort Height: '+ ViewPortHeight());
1601  AddToDebugDiv('(JS output) Current Viewport Width: '+ViewPortWidth());
1602  AddToDebugDiv('(JS output) Current Viewport Height: '+ViewPortHeight());
1603	AddToDebugDiv('(JS output) Device Pixel Ratio: '+window.devicePixelRatio);
1604	if(typeof window.innerWidth != 'undefined'){
1605		AddToDebugDiv('(JS output) Window Width: '+window.innerWidth);
1606		AddToDebugDiv('(JS output) Window Height: '+window.innerHeight);
1607	}
1608	if(typeof screen.width != 'undefined'){
1609		AddToDebugDiv('(JS output) Screen Width: '+screen.width);
1610		AddToDebugDiv('(JS output) Screen Height: '+screen.height);
1611	}
1612	AddToDebugDiv('- - -');
1613
1614  DebugLog('END - JS Debug Information Dump');
1615
1616}
1617
1618
1619
1620//----------------------------------------------------------------------------
1621function AddToDebugDiv(aMsg){
1622var dd = document.getElementById("JSDebugDiv");
1623  if (dd) {
1624    dd.innerHTML = dd.innerHTML + aMsg + '<br>';
1625  }
1626} 
1627
1628
1629var g_DLstarted = 0;
1630var g_DLstartTime = 0;
1631
1632//----------------------------------------------------------------------------
1633function DebugLog(aMsg){
1634	if(!g_DLstarted){g_DLstartTime = window.performance.now();g_DLstarted=1;}
1635  if (window.console && console.log) {
1636		var endTime = window.performance.now();
1637		var diffTime = myTrunc(endTime - g_DLstartTime);
1638		var newMsg = '['+ diffTime +'] '+ aMsg
1639		console.log(newMsg); 
1640	}
1641} 
1642
1643function myTrunc(aNum,decimalPlaces){
1644  var numStr = aNum.toString();
1645  var places = decimalPlaces ? decimalPlaces : 0;
1646  var apos = numStr.indexOf('.') != -1 ? numStr.indexOf('.') + places + 1 : numStr.length;
1647  return parseFloat(aNum.toString().substring(0, apos));
1648};
1649
1650
1651var g_JSDebugState = 0;
1652var g_SysPage = 'index.asp';
1653
1654//----------------------------------------------------------------------------
1655function InDebugState(){
1656var aval = false;
1657
1658  if (g_JSDebugState == 1) {
1659    aval = true
1660  }
1661  return aval;
1662} 
1663
1664// Returns a function, that, as long as it continues to be invoked, will not
1665// be triggered. The function will be called after it stops being called for
1666// N milliseconds. If `immediate` is passed, trigger the function on the
1667// leading edge, instead of the trailing.
1668
1669//EXAMPLE:
1670//  var myEfficientFn = debounce(function() {
1671//	  // All the taxing stuff you do
1672//  }, 250);
1673//  window.addEventListener('resize', myEfficientFn);
1674
1675
1676function hoverBox(element,aWidth,aHTMLText){
1677var theText = decodeURIparam(aHTMLText);
1678	DebugLog('hoverBox - START - width['+aWidth+'], text['+theText+']');
1679	var theBox = document.getElementById('tpHoverBox');
1680	if(!theBox){
1681		DebugLog('hoverBox - building tpHoverBox');
1682		var theAdd = '<style type="text/css">#tpHoverBox{font-size:9pt;padding:10px;opacity:0.1; transition:opacity 0.5s} #tpHoverBox:hover{opacity:1.0;}</style>';
1683		theAdd += '<div id="tpHoverBox" style="display:block;position:absolute;visibility:hidden;width:'+aWidth+';height:auto;z-index:1000;background-color:#fff;border:1px solid #000;border-radius:20px;">&nbsp;</div>'
1684		document.body.innerHTML += theAdd
1685		theBox = document.getElementById('tpHoverBox');
1686	}
1687	if(theBox){
1688		DebugLog('hoverBox - now have tpHoverBox');
1689		theBox.innerHTML = theText;
1690		var curTop = parseInt(this.style.top);
1691		var curLeft = parseInt(this.style.top);
1692		theBox.style.top = curTop+'px';
1693		theBox.style.left = curLeft+'px';
1694		ShowDiv('tpHoverBox');
1695		DebugLog('hoverBox - now shown at top['+theBox.style.top+'], left['+theBox.style.left+']');
1696	}else{
1697		DebugLog('hoverBox - ERROR: could  not create and find tpHoverBox element');
1698	}
1699}
1700
1701//----------------------------------------------------------------------------
1702function debounce(func, wait, immediate) {
1703	var timeout;
1704	return function() {
1705		var context = this, args = arguments;
1706		var later = function() {
1707			timeout = null;
1708			if (!immediate) func.apply(context, args);
1709		};
1710		var callNow = immediate && !timeout;
1711		clearTimeout(timeout);
1712		timeout = setTimeout(later, wait);
1713		if (callNow) func.apply(context, args);
1714	};
1715};
1716
1717
1718//----------------------------------------------------------------------------
1719function AdjustInputTextForDomain(anID,aAttribute,aPlaceholder,aDefaultText,aDomain,aNewText){
1720var theEle = document.getElementById(anID);	
1721	
1722	//DebugLog('AdjustTextForDomain - start');
1723	if(theEle){
1724		if(aAttribute == 'innerHTML'){
1725			DebugLog('AdjustTextForDomain - have element ['+anID+'], updating innerHTML');
1726			var theHTML = theEle.innerHTML;
1727			if(theHTML){
1728				//DebugLog('AdjustTextForDomain - have attribute ['+theAttr+']');
1729				//DebugLog('AdjustTextForDomain - cur url is ['+window.location.href+']');
1730				if(window.location.href.indexOf(aDomain) > -1){
1731					//DebugLog('AdjustTextForDomain - found a match for the domain check ['+aDomain+']');
1732					theHTML = theHTML.replace(aPlaceholder,aNewText);
1733					//DebugLog('AdjustTextForDomain - updated to new attribute ['+theAttr+']');
1734					theEle.innerHTML = theHTML;			
1735				}else{
1736					//DebugLog('AdjustTextForDomain - domain match failed for ['+aDomain+'], using defaults');
1737					theHTML = theHTML.replace(aPlaceholder,aDefaultText);
1738					//DebugLog('AdjustTextForDomain - updated to default attribute ['+theAttr+']');
1739					theEle.innerHTML = theHTML;	
1740				}
1741			}			
1742		}else{
1743			DebugLog('AdjustTextForDomain - have element ['+anID+'], updating attribute['+aAttribute+']');
1744			var theAttr = theEle.getAttribute(aAttribute);
1745			if(theAttr){
1746				//DebugLog('AdjustTextForDomain - have attribute ['+theAttr+']');
1747				//DebugLog('AdjustTextForDomain - cur url is ['+window.location.href+']');
1748				if(window.location.href.indexOf(aDomain) > -1){
1749					//DebugLog('AdjustTextForDomain - found a match for the domain check ['+aDomain+']');
1750					theAttr = theAttr.replace(aPlaceholder,aNewText);
1751					//DebugLog('AdjustTextForDomain - updated to new attribute ['+theAttr+']');
1752					theEle.setAttribute(aAttribute,theAttr);				
1753				}else{
1754					//DebugLog('AdjustTextForDomain - domain match failed for ['+aDomain+'], using defaults');
1755					theAttr = theAttr.replace(aPlaceholder,aDefaultText);
1756					//DebugLog('AdjustTextForDomain - updated to default attribute ['+theAttr+']');
1757					theEle.setAttribute(aAttribute,theAttr);
1758				}
1759			}
1760		}
1761	}
1762}
1763
1764
1765//----------------------------------------------------------------------------
1766function PageRescroll(aPosition){
1767var preVal;
1768var postVal;
1769var didIt = false;
1770  if(aPosition >= 0){
1771    DebugLog('PageRescroll - to pos['+aPosition+']');
1772    preVal = document.documentElement.scrollTop;
1773    DebugLog('PageRescroll - element current['+document.documentElement.scrollTop+']');
1774    document.documentElement.scrollTop = aPosition;
1775    postVal = document.documentElement.scrollTop;
1776    DebugLog('PageRescroll - element after['+document.documentElement.scrollTop+']');
1777    if((preVal == postVal)&&(postVal = aPosition)){
1778      didIt = true;
1779    }
1780    if(didIt == false)
1781    {
1782      DebugLog('PageRescroll - body current['+document.body.scrollTop+']');
1783      document.body.scrollTop = aPosition;
1784      DebugLog('PageRescroll - body after['+document.body.scrollTop+']');
1785    }
1786  }else{
1787    DebugLog('PageRescroll - invalid position['+aPosition+']');
1788  }
1789}
1790
1791//----------------------------------------------------------------------------
1792function PageScrollUp(aPixels){
1793  if(aPixels){
1794    DebugLog('PageScrollUp - scroll up by['+aPixels+']');
1795    var newpos = GetScrollTop(); 
1796    DebugLog('PageScrollUp - current['+newpos+']');
1797    newpos = newpos - aPixels;
1798    DebugLog('PageScrollUp - new['+newpos+']');
1799    PageRescroll(newpos);
1800  }
1801}
1802
1803//----------------------------------------------------------------------------
1804function PageScrollDown(aPixels){
1805  if(aPixels){
1806    DebugLog('PageScrollDown - scroll down by['+aPixels+']');
1807    var newpos = GetScrollTop(); 
1808    DebugLog('PageScrollDown - current['+newpos+']');
1809    newpos = newpos + aPixels;
1810    DebugLog('PageScrollDown - new['+newpos+']');
1811    PageRescroll(newpos);
1812    DebugLog('PageScrollDown - final pos['+GetScrollTop()+']');
1813  }
1814}
1815
1816//----------------------------------------------------------------------------
1817function scrollDown(anID){
1818var theElement = document.getElementById(anID);
1819  if(theElement){
1820    DebugLog('scrollDown - scroll down to bottom of ['+anID+'], cur scrolltop['+theElement.scrollTop+'], scrollheight['+theElement.scrollHeight+'], clientHeight['+theElement.clientHeight+']');
1821		var lastoverflow = theElement.style.overflowY;
1822		
1823		var newscrolltop = theElement.scrollHeight - theElement.clientHeight;
1824		if(newscrolltop < 0){
1825			newscrolltop = 0;
1826		}
1827		DebugLog('scrollDown - newscrolltop ['+newscrolltop+'], lastoverflow['+lastoverflow+']');
1828    //document.getElementById(anID).scrollTop = newscrolltop;
1829		//theElement.style.overflowY = 'hidden';
1830		//theElement.style.overflowY = lastoverflow;
1831		//document.getElementById(anID).style.overflowY = 'hidden';
1832		//document.getElementById(anID).style.overflowY = 'scroll';
1833    //document.getElementById(anID).scrollTop = newscrolltop;
1834		DebugLog('scrollDown - new scrolltop['+document.getElementById(anID).scrollTop+']');
1835		document.getElementById('CHL').scrollTop = 91;
1836		DebugLog('scrollDown - CHL scrolltop['+document.getElementById('CHL').scrollTop+']');
1837  }
1838}
1839
1840//----------------------------------------------------------------------------
1841function WaitAndScrollDown(anID,aWaitTime){
1842  DebugLog('WaitAndScrollDown - ['+anID+'], waitTime['+aWaitTime+']');
1843  setTimeout('scrollDown("'+anID+'")',aWaitTime);
1844}
1845
1846
1847//----------------------------------------------------------------------------
1848function WaitAndScrollToElement(aElement,aWaitTime){
1849  DebugLog('WaitAndScrollToElement - ['+aElement+'], waitTime['+aWaitTime+']');
1850  setTimeout('ScrollToElement("'+aElement+'")',aWaitTime);
1851}
1852
1853//----------------------------------------------------------------------------
1854function ScrollToElement(aElement){
1855var theElement = document.getElementById(aElement);
1856  
1857  if(theElement){
1858    var thePos = getOffset(theElement).top;
1859    DebugLog('ScrollToElement - ['+aElement+'], offset['+thePos+']');
1860    PageRescroll(thePos);
1861  }else{
1862    DebugLog('ScrollToElement - item not found - element ['+aElement+']');
1863  }
1864}
1865
1866//----------------------------------------------------------------------------
1867function ScrollToChild(aElement,aChildElement){
1868var theElement = document.getElementById(aElement);
1869  DebugLog('ScrollToChild - START - parent['+aElement+'], child['+aChildElement+']');
1870  if(theElement){
1871		var theChild = document.getElementById(aChildElement);
1872		if(theChild){
1873    var thePos = theChild.offsetTop;
1874    DebugLog('ScrollToChild - parent['+aElement+'], child['+aChildElement+'] child offset['+thePos+']');
1875    theElement.scrollTop = thePos;
1876		}else{
1877			DebugLog('ScrollToChild - item not found - child element ['+aChildElement+']');
1878		}
1879  }else{
1880    DebugLog('ScrollToChild - item not found - parent element ['+aElement+']');
1881  }
1882}
1883
1884
1885//----------------------------------------------------------------------------
1886function textareaTrimmer(taName, maxLength){
1887var ta = document.getElementsByName(taName)[0];
1888
1889    if (ta.value.length > maxLength)
1890    {
1891        ta.value = ta.value.substring(0, maxLength);
1892    }
1893}
1894
1895//----------------------------------------------------------------------------
1896function playMedia(itemID){
1897var item = document.getElementByID(itemID);
1898
1899    if(item)
1900    {
1901        item.play();
1902    }
1903}
1904
1905
1906//----------------------------------------------------------------------------
1907function getDateTime() {
1908  var now     = new Date(); 
1909  var year    = now.getFullYear();
1910  var month   = now.getMonth()+1; 
1911  var day     = now.getDate();
1912  var hour    = now.getHours();
1913  var minute  = now.getMinutes();
1914  var second  = now.getSeconds(); 
1915  if(month.toString().length == 1) {
1916      var month = '0'+month;
1917  }
1918  if(day.toString().length == 1) {
1919      var day = '0'+day;
1920  }   
1921  if(hour.toString().length == 1) {
1922      var hour = '0'+hour;
1923  }
1924  if(minute.toString().length == 1) {
1925      var minute = '0'+minute;
1926  }
1927  if(second.toString().length == 1) {
1928      var second = '0'+second;
1929  }   
1930  var dateTime = year+'/'+month+'/'+day+' '+hour+':'+minute+':'+second;   
1931  return dateTime;
1932}
1933
1934//----------------------------------------------------------------------------
1935function DateDiff(aDT1,aDT2){
1936  var date1 = new Date(aDT1);
1937  var date2 = new Date(aDT2); 
1938  //DebugLog('DateDiff - dt1['+aDT1+'], dt2['+aDT2+']');
1939  //DebugLog('DateDiff - date1['+date1+'], date2['+date2+']');
1940  
1941  if (date2 < date1) {
1942    date2.setDate(date2.getDate() + 1);
1943  }
1944  var diff = date2 - date1;
1945  return diff;
1946}
1947
1948
1949
1950//----------------------------------------------------------------------------
1951function clickButton(e, buttonid){ 
1952      var bt = document.getElementById(buttonid); 
1953      if (typeof bt == 'object'){ 
1954            if(navigator.appName.indexOf("Netscape")>(-1)){ 
1955                  if (e.keyCode == 13){ 
1956                        bt.click(); 
1957                        return false; 
1958                  } 
1959            } 
1960            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
1961                  if (event.keyCode == 13){ 
1962                        bt.click(); 
1963                        return false; 
1964                  } 
1965            } 
1966      } 
1967} 
1968
1969//----------------------------------------------------------------------------
1970function GetScrollTop(){
1971var st;
1972  st = 0;
1973	if(window.pageYOffset){
1974		st = window.pageYOffset;
1975	}else{
1976		if(document.body.scrollTop == 0){
1977			st = document.documentElement.scrollTop;
1978		}else{
1979			st = document.body.scrollTop;
1980		}
1981	}
1982return st;
1983}
1984
1985//----------------------------------------------------------------------------
1986function GetScrollLeft(){
1987var sl;
1988  sl = 0;
1989  if(document.body.scrollTop == 0){
1990    sl = document.documentElement.scrollLeft;
1991  }else{
1992    sl = document.body.scrollLeft;
1993  }
1994
1995return sl;
1996}
1997
1998
1999//----------------------------------------------------------------------------
2000function doReloadPage()
2001{
2002	var thePage = window.location.href;
2003	DebugLog('doReloadPage - the page URL['+thePage+']');
2004	//doBP(thePage);
2005	doWS(thePage);
2006}
2007
2008//----------------------------------------------------------------------------
2009function doReloadPageNoSpin()
2010{
2011	var thePage = window.location.href;
2012	DebugLog('doReloadPageNoSpin - the page URL['+thePage+']');
2013	//doBP(thePage);
2014	GoToPage(thePage);
2015}
2016
2017
2018//----------------------------------------------------------------------------
2019function prpAllfrmSBD(){
2020	DebugLog('start prpAllfrmSBD');
2021	var frmsList = document.getElementsByTagName('form');
2022	if(frmsList){for(var i=0;i<frmsList.length;i++){prpfrmSBD(frmsList[i].name);}}
2023}
2024
2025
2026//----------------------------------------------------------------------------
2027function prpfrmSBD(aFormName){
2028	DebugLog('start prpfrmSBD for FormName['+ aFormName +']');
2029	if(aFormName != ''){
2030		document.getElementsByName(aFormName)[0].addEventListener('submit', function(e){
2031			var frm = e.target;
2032			if(frm.frmdidSubmit){e.preventDefault();   
2033			}else{
2034				//e.preventDefault();
2035				var btnVal = document.activeElement.getAttribute('value');
2036				frm.frmdidSubmit = true;
2037				var btns = frm.querySelectorAll('input[type=submit]'); var bgc; var intxt = ''; var txts = '0.7';
2038				for(var i = 0;i < btns.length; ++i){
2039					if(btnVal == btns[i].value){DebugLog('CLICKED ONE');bgc='#cfc';intxt='processing...';txts='0.6em;font-weight:normal;';if(btns[i].clientWidth < 50){intxt='...';txts='1.0em;font-weight:bold';} }else{bgc='#eee';intxt='';txts='0.7em;font-weight:normal;'; }
2040					var whV = 'display:inline-block;position:relative;vertical-align:top;overflow:hidden;border:1px solid rgba(0,0,0,0.1);border-radius:6px;color:#999;padding:0;text-align:center;background-color:'+ bgc +';width:' + btns[i].clientWidth + 'px;height:' + btns[i].clientHeight + 'px;';
2041					var clV = '';
2042					if(btns[i].className != ''){clV = 'class="' + btns[i].className +'" '};
2043					var theID = 'fsbid' + Math.floor(Math.random()*10000);
2044					var theDiv = '<div id="'+ theID +'"><div>&nbsp;</div></div>';
2045					if(intxt == ''){theDiv='&nbsp;';}else{
2046						var ipbox = document.getElementById('PageWaitDiv');
2047						if(ipbox){killDynDivLoads();}
2048					}
2049					btns[i].insertAdjacentHTML('afterend', '<div '+ clV +'style="'+ whV +'">'+ theDiv +'</div>');
2050					//btns[i].insertAdjacentHTML('afterend', '<div '+ clV +'style="'+ whV +'"><span style="display:inline-block;position:relative;top:40%;transform:translateY(-50%);margin-left:auto;margin-right:auto;font-size:'+ txts +';">'+ intxt +'</span></div>');
2051					btns[i].style.display = 'none'; 
2052					MakeSpinnerInElement(theID,1,4,32,'#4a4',1);	
2053				}
2054			}
2055		});
2056	}
2057}
2058
2059
2060
2061//----------------------------------------------------------------------------
2062function submitForm(aFormName,msToWait)
2063{
2064	DebugLog('submitForm - formName['+ aFormName +'], wait time ['+ msToWait +']');
2065	if(msToWait > 0){
2066		DebugLog('submitForm - about to wait ['+msToWait+'ms]');
2067		setTimeout('submitForm("'+aFormName+'",0)',msToWait);
2068	}else{
2069		DebugLog('submitForm - submitting form.');
2070		document.forms[aFormName].submit();
2071	}
2072}
2073
2074
2075//----------------------------------------------------------------------------
2076function addHiddenToForm(aFormName,aName,aValue)
2077{
2078	DebugLog('addHiddenToForm - formName['+ aFormName +'], name['+ aName +'] value['+ aValue +']');
2079	var theForm = document.getElementsByName(aFormName)[0];
2080	if(theForm){
2081		var theInput = document.createElement("input");
2082		theInput.setAttribute("type","hidden");
2083		theInput.setAttribute("name",aName);
2084		theInput.setAttribute("value",aValue);
2085		theForm.appendChild(theInput);
2086		DebugLog('addHiddenToForm - added hidden field to the form');
2087	}else{
2088		DebugLog('addHiddenToForm - form not found');
2089	}
2090}
2091
2092
2093
2094//----------------------------------------------------------------------------
2095function waitAndReloadPageRunFunc(msToWait,additionalJStoRun)
2096{
2097	DebugLog('waitAndReloadPageRunFunc - wait time ['+ msToWait +'], codeToRun['+ additionalJStoRun +']');
2098	var thefunccall = 'doRunCodeStr("'+additionalJStoRun+'");doReloadPage();';
2099	setTimeout(thefunccall,msToWait);
2100}
2101
2102//----------------------------------------------------------------------------
2103function doRunCodeStr(additionalJStoRun)
2104{
2105	DebugLog('doRunCodeStr - codeToRun['+ additionalJStoRun +']');
2106	if(additionalJStoRun){
2107		// the js may have encoded single quotes it in that we need to decode
2108		var newjs = ConvertJSQ(additionalJStoRun);
2109		DebugLog('doRunCodeStr2 - newjs['+ newjs +']');
2110		var retval = eval(newjs);
2111		DebugLog('doRunCodeStr - result['+ retval +']');
2112	}
2113}
2114
2115//----------------------------------------------------------------------------
2116function ConvertJSQ(aText)
2117{
2118	var jsmatchstr = '[jsq]';
2119	jsmatchstr = jsmatchstr.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
2120	newtext = aText;
2121	newtext = newtext.replace(new RegExp(jsmatchstr,'gi'),'\'');	
2122	return newtext;
2123}
2124
2125//----------------------------------------------------------------------------
2126function waitAndReloadPage(msToWait)
2127{
2128	setTimeout('doReloadPage()',msToWait);
2129}
2130
2131//----------------------------------------------------------------------------
2132function waitAndReloadPageNoSpin(msToWait)
2133{
2134	setTimeout('doReloadPageNoSpin()',msToWait);
2135}
2136
2137//----------------------------------------------------------------------------
2138function doBP(thePage)  // adds the current window position into the URL to reposition the page
2139{
2140  var newURL = updateURLParameter(thePage, 'bpos', GetScrollTop()); //updateURLParameter(url, param, paramVal)
2141  //window.location.href = thePage + '&bpos=' + GetScrollTop();
2142  window.location.href = newURL;
2143}
2144
2145//----------------------------------------------------------------------------
2146function doWS(thePage)  // activates the wait screen if needed during the load, adds the page body position too
2147{
2148	ShowWaitNow();
2149  var newURL = updateURLParameter(thePage, 'bpos', GetScrollTop()); //updateURLParameter(url, param, paramVal)
2150  GoToPage(newURL);
2151}
2152
2153//----------------------------------------------------------------------------
2154function goWS(thePage)  // activates the wait screen if needed during the load
2155{
2156  ShowWaitNow();
2157  GoToPage(thePage);
2158}
2159
2160//----------------------------------------------------------------------------
2161function goExt(thePage)  // LOAD A PAGE IN A NEW WINDOW
2162{
2163	if(location.hostname === 'localhost'){
2164		if(thePage.indexOf('//') == -1){
2165			thePage = '//localhost/weo1.com'+ thePage;
2166		}
2167	}
2168  window.open(thePage,'_blank');
2169}
2170
2171//----------------------------------------------------------------------------
2172function ShowWait() {
2173var thebox = document.getElementById('PageWaitDiv');
2174  if (thebox) {
2175    if ( thebox.style.display == 'none') {
2176      setTimeout("DoActivateWait()", 500);
2177    }
2178  }
2179}
2180
2181//----------------------------------------------------------------------------
2182function ShowWaitNow() {
2183var thebox = document.getElementById('PageWaitDiv');
2184  if (thebox) {
2185    if ( thebox.style.display == 'none') {
2186      setTimeout('DoActivateWait()',1);
2187			killDynDivLoads();
2188    }
2189  }
2190}
2191
2192
2193//----------------------------------------------------------------------------
2194function DoActivateWait() {
2195var thebox = document.getElementById('PageWaitDiv');
2196  if (thebox) {
2197    if ( thebox.style.display == 'none') {
2198     thebox.style.display = 'inline';
2199     SetupSpinner();
2200     SetWaitSize();
2201     DoRefreshSize();
2202    }
2203  }
2204}
2205
2206//----------------------------------------------------------------------------
2207function DoRefreshSize(){
2208var thebox = document.getElementById('PageWaitDiv');
2209  if (thebox) {
2210    if ( thebox.style.display != 'none') {
2211      SetWaitSize();
2212      setTimeout("DoRefreshSize()",100);
2213    }
2214  }
2215}
2216
2217//----------------------------------------------------------------------------
2218function GoToPage(theURL) {
2219  setTimeout('GoToPageAux("'+theURL+'")', 10);
2220}
2221
2222//----------------------------------------------------------------------------
2223function GoToPageAux(theURL) {
2224	if(location.hostname === 'localhost'){
2225		if(theURL.indexOf('//') == -1){
2226			theURL = '//localhost/weo1.com'+ theURL;
2227		}
2228	}
2229  window.location.href = theURL;
2230}
2231
2232var g_SpinnerColor = '#555';
2233var g_SpinnerLineLen = 8;
2234
2235//----------------------------------------------------------------------------
2236function SetupSpinner(){
2237var opts = {
2238  lines: 24, // The number of lines to draw
2239  length: g_SpinnerLineLen, // The length of each line
2240  width: 1, // The line thickness
2241  radius: 8, // The radius of the inner circle
2242  corners: 1, // Corner roundness (0..1)
2243  rotate: 0, // The rotation offset
2244  color: g_SpinnerColor, // #rgb or #rrggbb
2245  speed: 0.5, // Rounds per second
2246  trail: 30, // Afterglow percentage
2247  shadow: false, // Whether to render a shadow
2248  hwaccel: false, // Whether to use hardware acceleration
2249  className: 'spinner', // The CSS class to assign to the spinner
2250  zIndex: 2e9, // The z-index (defaults to 2000000000)
2251  top: 'auto', // Top position relative to parent in px
2252  left: 'auto' // Left position relative to parent in px
2253  };
2254
2255
2256  var target = document.getElementById('InSpin');
2257  var spinner = new Spinner(opts).spin(target);
2258
2259}
2260
2261//----------------------------------------------------------------------------
2262function MakeSpinnerInElement(anID,aSpinLineLen,aSpinInnerRadius,aSpinLines,aSpinLineColor,aSpinsPerSec){
2263var opts = {
2264  lines: aSpinLines, // The number of lines to draw
2265  length: aSpinLineLen, // The length of each line - like 8
2266  width: 1, // The line thickness
2267  radius: aSpinInnerRadius, // The radius of the inner circle
2268  corners: 1, // Corner roundness (0..1)
2269  rotate: 0, // The rotation offset
2270  color: aSpinLineColor, // #rgb or #rrggbb - like #555
2271  speed: aSpinsPerSec, // Rounds per second - like 0.5
2272  trail: 30, // Afterglow percentage
2273  shadow: false, // Whether to render a shadow
2274  hwaccel: false, // Whether to use hardware acceleration
2275  className: 'spinner', // The CSS class to assign to the spinner
2276  zIndex: 2e9, // The z-index (defaults to 2000000000)
2277  top: 'auto', // Top position relative to parent in px
2278  left: 'auto' // Left position relative to parent in px
2279  };
2280
2281
2282  var target = document.getElementById(anID);
2283	if(target){
2284		var spinner = new Spinner(opts).spin(target);
2285	}
2286
2287}
2288
2289//----------------------------------------------------------------------------
2290function SetWaitSize()
2291{
2292  var randomnumber = 10000 + Math.floor(Math.random()*10000);
2293  var thebox = document.getElementById('PageWaitDiv');
2294
2295  //document.getElementById('PageWaitImage').style.display = ''; 
2296  //document.getElementById('PageWaitImage').src = 'images/loaderb64.gif';
2297  //thebox.innerHTML = thebox.innerHTML;
2298  //alert('SetWaitSize - here - top: '+pageTop());
2299  document.getElementById('PageWaitDiv').style.top = pageTop() + 'px';
2300  document.getElementById('PageWaitDiv').style.left = pageLeft() + 'px';
2301  document.getElementById('PageWaitDiv').style.height = pageHeight() + 'px';
2302  document.getElementById('PageWaitDiv').style.width = pageWidth() + 'px';
2303 
2304  var tempLength = pageHeight();
2305  var tempInnerLength = 300;
2306  var tempPadding = 0;
2307  if ( tempLength > tempInnerLength)
2308  {
2309    tempPadding = (tempLength - tempInnerLength ) / 2;
2310    
2311  }
2312  else
2313  {
2314    tempPadding = 0;
2315  }
2316
2317  document.getElementById("PageWaitTable").style.marginTop = tempPadding +  "px";
2318  //document.getElementById("SearchOverlay").style.height = pageHeight() + "px";
2319  //document.getElementById("SearchOverlay").style.width = pageWidth() + "px";
2320  /*
2321  try
2322  {
2323    document.getElementById("EditOverlay").style.paddingLeft = tempPadding + "px";      
2324    document.getElementById("EditOverlay").style.height = pageHeight() + "px";
2325    document.getElementById("EditOverlay").style.width = pageWidth() + "px";
2326  }
2327  catch(err)
2328  {
2329    // item does not exist
2330  }
2331  */
2332  //alert('Got Here - width: '+pageWidth()+', height: '+pageHeight()+', top: '+pageTop()+', left: '+pageLeft());
2333}
2334
2335
2336//----------------------------------------------------------------------------
2337function GetDivList(matchID){
2338var divs = document.getElementsByTagName("div");
2339var divArr = [];
2340  for (var i = 0; i < divs.length; i++) {
2341    if(divs[i].id.indexOf(matchID) == 0)
2342      divArr.push(divs[i]);
2343  }
2344return divArr;
2345}
2346
2347
2348//----------------------------------------------------------------------------
2349function doBARaction(aBaseTableID,actionNum){
2350	doBARactionEx(aBaseTableID,actionNum,'');
2351}
2352
2353//----------------------------------------------------------------------------
2354function doBARactionEx(aBaseTableID,actionNum,cleanParamsList){
2355	DebugLog('doBARaction - START - baseTableID['+ aBaseTableID +'], actionNum['+ actionNum +'], cleanParamsList['+ cleanParamsList +']');
2356	//GET THE VALUES
2357	var theTbl = document.getElementById(aBaseTableID);
2358	var vArrStr = '';
2359	var iName = '';
2360	var iVal = '';
2361	var nameLen = aBaseTableID.length + 3;
2362	if(theTbl){
2363		var barSDid = aBaseTableID + 'barSD';
2364		var theBarSD = document.getElementById(barSDid);
2365		if(theBarSD){
2366			DebugLog('doBARaction - have barSD');
2367			var barCBs = getBARcontrols(aBaseTableID);
2368			//BUILD PARAMS FOR THE ACTION AND ITEM LIST
2369			for (var i = 0; i < barCBs.length; i++){
2370				if(barCBs[i].checked){
2371					DebugLog('doBARaction - ['+ barCBs[i].id +'] is checked');
2372					iName = barCBs[i].id.slice(nameLen);
2373					iVal = barCBs[i].value;
2374					if(iName != 'SD'){
2375						DebugLog('doBARaction - ['+ barCBs[i].id +'] name is['+ iName +'], value is['+ iVal +']');
2376						if(vArrStr) vArrStr += ',';
2377						vArrStr += iName +','+ iVal;
2378						DebugLog('doBARaction - param str is ['+ vArrStr +']');
2379					}
2380				}
2381			}
2382		}
2383	}	
2384		
2385	//GET THE CURRENT URL
2386	var theURL = window.location.href;
2387	
2388	//DebugLog('doBARaction - clean params list['+ cleanParamsList +'] from starting URL['+ theURL +']');
2389	if(cleanParamsList){
2390		var theParamsArr = cleanParamsList.split(",");
2391		for(var p = 0; p < theParamsArr.length; p++) {
2392			//DebugLog('doBARaction - doing clean index['+ p +'], param['+ theParamsArr[p] +']');
2393			theURL = updateURLParameter(theURL,theParamsArr[p],''); //CLEAR THE PARAM
2394			//DebugLog('doBARaction - doing clean param['+ theParamsArr[p] +'] - updated URL ['+ theURL +']');
2395		}
2396	}
2397	//DebugLog('doBARaction - after clean params - new URL ['+ theURL +']');
2398	
2399	//DebugLog('doBARaction - adding TBAA - actionNum ['+ actionNum +']');
2400	theURL = updateURLParameter(theURL,'TBAA',actionNum);
2401	//DebugLog('doBARaction - after TBAA - updated URL ['+ theURL +']');
2402	
2403	//DebugLog('doBARaction - adding TBAIDS - vArrStr ['+ vArrStr +']');
2404	theURL = updateURLParameter(theURL,'TBAIDS',vArrStr);
2405	//DebugLog('doBARaction - after TBAIDS - updated URL ['+ theURL +']');
2406
2407	theURL = AddInterfaceLevelToURL(theURL);
2408	theURL = AddClientIDToURL(theURL);
2409	
2410	DebugLog('doBARaction - final URL ['+ theURL +']');
2411	GoToPage(theURL);
2412}
2413
2414//----------------------------------------------------------------------------
2415function doBARclick(aBaseTableID){
2416	DebugLog('doBARclick - START - baseTableID['+ aBaseTableID +']');
2417	var theTbl = document.getElementById(aBaseTableID);
2418	if(theTbl){
2419		var barSDid = aBaseTableID + 'barSD';
2420		var theBarSD = document.getElementById(barSDid);
2421		if(theBarSD){
2422			DebugLog('doBARclick - have barSD');
2423			var barCBs = getBARcontrols(aBaseTableID);
2424			var doCheckIt = theBarSD.checked;
2425			DebugLog('doBARclick - top barSD is checked ['+ doCheckIt +']');
2426			for (var i = 0; i < barCBs.length; i++){
2427				if(barCBs[i].checked && !doCheckIt){
2428					DebugLog('doBARclick - unchecking it ['+ barCBs[i].id +']');
2429					barCBs[i].checked = false;
2430				}else if(!barCBs[i].checked && doCheckIt){
2431					DebugLog('doBARclick - checking it ['+ barCBs[i].id +']');
2432					barCBs[i].checked = true;
2433				}
2434			}
2435		}
2436	}
2437}
2438
2439
2440//----------------------------------------------------------------------------
2441function getBARcontrols(aBaseTableID){
2442	DebugLog('GetBARcontrols - START - baseTableID['+ aBaseTableID +']');
2443	var controlsArr = [];
2444	var theTbl = document.getElementById(aBaseTableID);
2445	if(theTbl){
2446		var barInputs = theTbl.getElementsByTagName('input');
2447		var matchID = aBaseTableID + 'bar';
2448		for (var i = 0; i < barInputs.length; i++) {
2449			if(barInputs[i].id.indexOf(matchID) == 0){
2450				DebugLog('getBARcontrols - adding ['+ barInputs[i].id +']');
2451				controlsArr.push(barInputs[i]);
2452			}
2453		}
2454	}
2455return controlsArr;
2456}
2457
2458
2459
2460//----------------------------------------------------------------------------
2461function fixCurrentURL(newURL){
2462	DebugLog('fixCurrentURL - START - newURL['+ newURL +']');
2463	window.history.replaceState({}, document.title, "/" + newURL);
2464}
2465
2466
2467//----------------------------------------------------------------------------
2468function GetDivsByClassList(anElement,aClassName){
2469	if(anElement){
2470		var divs = anElement.getElementsByTagName("div");
2471	}else{
2472		var divs = document.getElementsByTagName("div");
2473	}
2474	
2475	var divArr = [];
2476	for (var i = 0; i < divs.length; i++) {
2477		if(HasClassName(divs[i],aClassName))
2478			divArr.push(divs[i]);
2479	}
2480return divArr;
2481}
2482
2483
2484//----------------------------------------------------------------------------
2485function GetDivListByAttrib(anAttribName){
2486var divs = document.getElementsByTagName("div");
2487var divArr = [];
2488  for (var i = 0; i < divs.length; i++) {
2489    if(divs[i].getAttribute(anAttribName))
2490      divArr.push(divs[i]);
2491  }
2492return divArr;
2493}
2494
2495//----------------------------------------------------------------------------
2496function GetChildDivListByAttrib(anElement,anAttribName){
2497	if(anElement){
2498		var divs = anElement.getElementsByTagName("div");
2499	}else{
2500		var divs = document.getElementsByTagName("div");
2501		
2502	}
2503	var divArr = [];
2504  for (var i = 0; i < divs.length; i++) {
2505    if(divs[i].getAttribute(anAttribName))
2506      divArr.push(divs[i]);
2507  }
2508return divArr;
2509}
2510
2511//----------------------------------------------------------------------------
2512function FindAllModules(){
2513var divArr = GetDivListByAttrib('data-im-f');	
2514var modURL = '';
2515var theDiv;
2516var attribs;
2517var thesecs = 0;
2518var thecount = 0;
2519var firstload = 0;
2520var refresh = 0;
2521	DebugLog('FindAllModules - START');
2522  if(divArr){
2523    for(var i = 0; i < divArr.length; i++) {
2524      DebugLog('FindAllModules - div['+ (i+1) +'], the id['+ divArr[i].id +']');
2525			theDiv = divArr[i];
2526			attribs = 'F=' + theDiv.getAttribute('data-im-f');
2527			if(theDiv.getAttribute('data-im-u')) attribs = attribs + '&U='+theDiv.getAttribute('data-im-u');
2528			if(theDiv.getAttribute('data-im-c')) attribs = attribs + '&C='+theDiv.getAttribute('data-im-c');
2529			if (theDiv.getAttribute('data-im-d')) attribs = attribs + '&D=' + theDiv.getAttribute('data-im-d');
2530			if (theDiv.getAttribute('data-im-cd')) attribs = attribs + '&cd=' + theDiv.getAttribute('data-im-cd');
2531			if(theDiv.getAttribute('data-im-fl')) firstload = parseInt(theDiv.getAttribute('data-im-fl'));
2532			if(theDiv.getAttribute('data-im-rf')) refresh = parseInt(theDiv.getAttribute('data-im-rf'));
2533			// IC= iteration count - theCount
2534			modURL =  GetPathRelToSys() + 'process/doProcess-LoadModule.asp?' + attribs;
2535			doProcessDivEx(theDiv.id,modURL,IModuleDone,10000,firstload,refresh);
2536    }
2537  }	
2538}
2539
2540//----------------------------------------------------------------------------
2541function IModuleDone(retID,retContent,retMessage){
2542
2543	DebugLog('IModuleDone - START');
2544	var thediv;
2545	if(retID){
2546		thediv = document.getElementById(retID);
2547	}
2548	DebugLog('IModuleDone - id['+retID+']');
2549	DebugLog('IModuleDone - message['+retMessage+']');
2550	DebugLog('IModuleDone - len content['+retContent.length+']');
2551	
2552	if(thediv){
2553		DebugLog('IModuleDone - accessing div id['+thediv.id+']');
2554		thediv.innerHTML = retContent;
2555	}else{
2556		DebugLog('IModuleDone - could not find div id['+retID+']');
2557	}
2558
2559	
2560}
2561
2562//THESE FUNCTIONS ARE USED IN CONJUNCTION WITH THE class-tpTable OBJECT ALLOWING
2563//FOR THE SEPARATE HEADER ROW FROM THE SCROLLABLE DATA ROWS - WE NEED JS TO
2564//ALIGN THE COLUMN WIDTHS AFTER THE DATA GRID HAS BEEN SETUP
2565//----------------------------------------------------------------------------
2566function SyncTableHeader(aTable){
2567	DebugLog('SyncTableHeader - set timer for syncing table headers for table ['+ aTable +']');
2568  setTimeout('SyncTableHeaderWait("'+ aTable +'")',500);
2569}
2570
2571//----------------------------------------------------------------------------
2572function SyncTableHeaderWait(aTable){
2573var tbl = document.getElementById(aTable);
2574  if(tbl){
2575		DebugLog('SyncTableHeaderWait - syncing table headers cols ['+ aTable +']');
2576    SyncTableHeaderCols(aTable);
2577  }else{
2578    setTimeout('SyncTableHeaderWait("'+ aTable +'")',250);
2579  }
2580}
2581
2582
2583//----------------------------------------------------------------------------
2584function GetChildElementByID(anElement,aID){
2585	if(anElement){
2586	DebugLog('GetChildElementByID - parent element ['+anElement+'], child ID to find['+ aID +']');
2587	//var c = document.body.children;
2588	//var i;
2589	//for (i = 0; i < c.length; i++) {
2590	//	c[i].style.backgroundColor = "red";
2591	//}
2592	}else{
2593		DebugLog('GetChildElementByID - parent element NOT FOUND for child id['+ aID +']');
2594	}
2595}
2596
2597
2598//----------------------------------------------------------------------------
2599function SyncTableHeaderCols(aTable){
2600DebugLog('SyncTableHeaderCols: '+aTable);
2601var tbl = document.getElementById(aTable);
2602var headName = '';
2603var firstName = '';
2604var headRow;
2605var headCell;
2606var firstCell;
2607var i;
2608var maxcol;
2609var cellwidth;
2610var startcolindex = 0;
2611  // Header Table: aTable + "HEADTABLE"
2612  // header row of table: aTable + HEADER  , num of cols set in this obj as attribute: TblColCount
2613  // header cells of table: aTable + HRCOL#
2614
2615
2616  if(tbl){
2617    headName = aTable+'HEADER';
2618    headRow = document.getElementById(headName);
2619    if(headRow){
2620      DebugLog('SyncTableHeaderCols - got header row object ['+headName+']');
2621      maxcol = headRow.getAttribute('tblcolcount');
2622      DebugLog('SyncTableHeaderCols - max col ['+ maxcol +'], row width['+ headRow.clientWidth +']');
2623 
2624			var endDiff = 0;
2625			firstName = aTable+'FRCOL' + startcolindex;
2626			firstCell = document.getElementById(firstName);
2627			if(firstCell){
2628				var firstRowElement = firstCell.parentElement;
2629				endDiff = headRow.clientWidth - firstRowElement.clientWidth
2630				DebugLog('SyncTableHeaderCols - first row(zero) width['+ firstRowElement.clientWidth +'], difference with header row['+ endDiff +']');
2631			}else{
2632				startcolindex = 1;	
2633				firstName = aTable+'FRCOL' + startcolindex;
2634				firstCell = document.getElementById(firstName);	
2635				if(firstCell){
2636					var firstRowElement = firstCell.parentElement;
2637					endDiff = headRow.clientWidth - firstRowElement.clientWidth
2638					DebugLog('SyncTableHeaderCols - first row(1) width['+ firstRowElement.clientWidth +'], difference with header row['+ endDiff +']');
2639				}				
2640			}
2641			
2642			for(i=startcolindex;i<=maxcol;i++){
2643        headName = aTable+'HRCOL'+i;
2644        headCell = document.getElementById(headName);
2645        firstName = aTable+'FRCOL'+i;
2646        firstCell = document.getElementById(firstName);
2647        if(firstCell){
2648          cellwidth = firstCell.clientWidth;
2649          DebugLog('SyncTableHeaderCols - first row cell ['+firstName+'] = '+ cellwidth);
2650          if(headCell){
2651						if(i == maxcol){cellwidth = cellwidth + endDiff;}
2652            headCell.style.width = cellwidth+'px';
2653            DebugLog('SyncTableHeaderCols - header row cell ['+headName+'] is now: '+ headCell.style.width);
2654          }
2655          
2656        }else{
2657          DebugLog('SyncTableHeaderCols - first row cell not found for ['+firstName+']');
2658        }
2659      
2660      }
2661      
2662      
2663    }else{
2664      DebugLog('SyncTableHeaderCols - header row object not found ['+headName+']');
2665    }
2666  
2667  }else{
2668    DebugLog('SyncTableHeaderCols - table object not found ['+aTable+']');
2669  }
2670
2671}
2672
2673
2674//----------------------------------------------------------------------------
2675function encodeURIparam(aValue){
2676	var retval = aValue;
2677	retval = retval.replace(/&/g,'%26');
2678	retval = retval.replace(/\//g,'%2F');
2679	retval = retval.replace('=','%3D');
2680	retval = retval.replace(':','%3A');
2681	retval = retval.replace('?','%3F');	
2682	retval = retval.replace('-','%2D');	
2683	retval = retval.replace('[','%5B');	
2684	retval = retval.replace(']','%5D');	
2685	retval = retval.replace('.','%2E');	
2686	retval = retval.replace('@','%64');	
2687	retval = retval.replace('+','%43');	
2688	retval = retval.replace('$','%36');	
2689	retval = retval.replace(',','%44');	
2690	retval = retval.replace('.','%2E');		
2691
2692	retval = retval.replace(';','%3B');	
2693	retval = retval.replace('#','%23');	
2694	retval = retval.replace('"','%22');	
2695	retval = retval.replace('\'','%27');		
2696	retval = retval.replace(' ','%20');
2697	return retval;
2698}
2699
2700
2701//----------------------------------------------------------------------------
2702function decodeURIparam(aValue){
2703	var retval = aValue;
2704	retval = retval.replace('%26','&');
2705	retval = retval.replace('%2F','/');
2706	retval = retval.replace('%3D','=');
2707	retval = retval.replace('%3A',':');
2708	retval = retval.replace('%3F','?');	
2709	retval = retval.replace('%2D','-');	
2710	retval = retval.replace('%5B','[');	
2711	retval = retval.replace('%5D',']');	
2712	retval = retval.replace('%2E','.');	
2713	retval = retval.replace('%64','@');	
2714	retval = retval.replace('%43','+');	
2715	retval = retval.replace('%36','$');	
2716	retval = retval.replace('%44',',');	
2717	retval = retval.replace('%2E','.');		
2718	
2719	retval = retval.replace('%3B',';');	
2720	retval = retval.replace('%23','#');	
2721	retval = retval.replace('%22','"');	
2722	retval = retval.replace('%27','\'');
2723	retval = retval.replace('%20',' ');		
2724	return retval;
2725}
2726
2727
2728//----------------------------------------------------------------------------
2729function DoRunAsync(aDivID,aPID,aCID,aCodeFilePath,addlParams){
2730	
2731	DebugLog('DoRunAsync - START - code['+aCodeFilePath+']');
2732	var codepath = encodeURIparam(aCodeFilePath);
2733	var params = encodeURIparam(addlParams);
2734	var curURL = encodeURIparam(window.location.href);
2735	DebugLog('current url: '+window.location.href);
2736	
2737	//var execPath = 'http://www.weo1.com/sys/process/doProcess-RunCode.asp?C='+aCID+'&P='+aPID+'&CP='+codepath+'&AP='+params;
2738	//var execPath = '/sys/process/doProcess-RunCode.asp?C='+aCID+'&P='+aPID+'&CP='+codepath+'&AP='+params;
2739	//var execPath = 'rel:/sys/process/doProcess-RunCode.asp?C='+aCID+'&P='+aPID+'&CP='+codepath+'&AP='+params;
2740	var execPath = 'rel:/sys/process/doProcess-RunCode.asp?C='+aCID+'&P='+aPID+'&CP='+codepath+'&AP='+params+'&CU='+curURL;
2741	//ProcessAction(execPath,aMsgDiv,aDivID);
2742	
2743	SetupDynDivExtraParam(aDivID,'execPath',execPath); //ADD THIS PARAM TO THE DYN DIV SO WE CAN USE IT
2744	//SetupDynDiv(theDiv,actionCallback,finishCallback,waitTimeToLoad,altLoadText,altFailedText) 
2745	SetupDynDiv(aDivID,RunAsyncGet,RunAsyncFinish,0,'','Could not load code: '+aCodeFilePath); //DON'T SET A REFRESH TIMER
2746	DynDivRefreshAuto(aDivID); //RUN THE FIRST REFRESH RIGHT NOW
2747	
2748	DebugLog('DoRunAsync - FINISH');
2749}
2750
2751//----------------------------------------------------------------------------
2752function RunAsyncGet(aDivID,theURL){
2753  var retURL = GetDynDivExtraParam(aDivID,'execPath');
2754	DebugLog('RunAsyncGet - for ['+aDivID+'], retURL['+retURL+']');
2755return retURL;
2756}
2757
2758//----------------------------------------------------------------------------
2759function RunAsyncFinish(aDivID){
2760  DebugLog('RunAsyncFinish - for ['+aDivID+']');
2761return true;	
2762}
2763
2764
2765
2766
2767var ProcessActionNameCounter = 0;
2768
2769//----------------------------------------------------------------------------
2770function ProcessAction(doProcessURL,resultMsgDiv,refreshDivID){
2771	ProcessActionNameCounter = ProcessActionNameCounter + 1;	
2772	var msgDiv;
2773	var msgDivName;
2774	if(resultMsgDiv){
2775		msgDiv = document.getElementById(resultMsgDiv);
2776		msgDivName = resultMsgDiv;
2777	}else{
2778		msgDivName = 'PrAcM'+ProcessActionNameCounter;
2779		DebugLog('ProcessAction - building and adding message div['+msgDivName+']');
2780		var tmpMsgDivHTML = '<div id="'+msgDivName+'" style="display:block;position:fixed;top:1px;left:1px;width:auto;height:auto;border:1px solid blue;padding:10px;visibility:hidden;"></div>';
2781		document.body.innerHTML += tmpMsgDivHTML; //ADD IT TO THE PAGE
2782		msgDiv = document.getElementById(msgDivName);
2783	}
2784	
2785	var tmpDivName = 'PrAc'+ProcessActionNameCounter;
2786	var tmpDivHTML = '<div id="'+tmpDivName+'" style="visibility:hidden;"></div>'; // WE MAKE A LITTLE TEMP DIV TO BE OUR DATA STRUCTURE
2787	//var tmpDivHTML = '<div id="'+tmpDivName+'" style="display:inline-block;position:relative;width:100px;height:10px;border:1px solid red;">hello</div>'; // WE MAKE A LITTLE TEMP DIV TO BE OUR DATA STRUCTURE
2788	var tmpDiv;
2789
2790  if(msgDiv){
2791    DebugLog('ProcessAction - url['+doProcessURL+'], result div['+resultMsgDiv+']');
2792    msgDiv.innerHTML = tmpDivHTML; //PUT OUR LITTLE DIV INSIDE THE MESSAGE DIV FOR NOW
2793    tmpDiv = document.getElementById(tmpDivName); //NOW GET THE DIV SO WE CAN PUT SOME STUFF IN THERE
2794    if(tmpDiv){
2795      tmpDiv.PAURL = doProcessURL; //PUT THE ACTION URL IN TO THE NEW DIV
2796      tmpDiv.PAPDV = resultMsgDiv; //STORE THE PARENT MSG DIV TOO
2797      tmpDiv.PARFD = refreshDivID; //STORE THE REFRESH DIV TOO
2798      
2799      SetupDynDiv(tmpDivName,ProcessActionGet,ProcessActionFinish,1,'',''); //SETUP THE DYNDIV IN THE TEMP DIV SO WE CAN GO GET THE VALUES 
2800    
2801    }else{
2802      DebugLog('ProcessAction - tmpDiv['+tmpDivName+'] could not be setup');
2803    }
2804    
2805  
2806  }else{
2807    DebugLog('Could not locate the message div ['+resultMsgDiv+']');
2808  }
2809
2810}
2811
2812//----------------------------------------------------------------------------
2813function ProcessActionGet(theDiv){
2814var retURL = '';
2815var dynDiv = document.getElementById(theDiv);
2816  if(dynDiv){
2817    retURL = dynDiv.PAURL;
2818    DebugLog('ProcessActionGet for ['+theDiv+'] - action URL is ['+retURL+'].');
2819  }else{
2820    DebugLog('ProcessActionGet for ['+theDiv+'] - could not get the internal div.');
2821  }
2822  
2823return retURL;
2824}
2825
2826
2827//----------------------------------------------------------------------------
2828function ProcessActionFinish(theDiv){
2829var dynDiv = document.getElementById(theDiv);
2830var msgDiv;
2831var aRefreshDivID;
2832
2833  if(dynDiv){
2834    DebugLog('ProcessActionFinish for ['+theDiv+'] - ok.');
2835    if(dynDiv.PAPDV){
2836      msgDiv = document.getElementById(dynDiv.PAPDV);
2837      if(msgDiv){
2838        DebugLog('ProcessActionFinish for ['+theDiv+'] - got parent mesage div ['+dynDiv.PAPDV+'].');
2839        if(hasDynDivLoaded(theDiv)){
2840          DebugLog('ProcessActionFinish for ['+theDiv+'] - dyndiv has loaded.');
2841          if(dynDiv.innerHTML){
2842            DebugLog('ProcessActionFinish for ['+theDiv+'] - dyn div has some innerHTML.');
2843            msgDiv.innerHTML = dynDiv.innerHTML;
2844            
2845            aRefreshDivID = dynDiv.PARFD; //WE MAY OR MAY NOT HAVE A DIV TO REFRESH AT THE END
2846            if(aRefreshDivID){
2847              DebugLog('ProcessActionFinish for ['+theDiv+'] - dyn div has a refreshDiv['+ aRefreshDivID +']');
2848              DynDivRefresh(aRefreshDivID);
2849              
2850            }else{
2851              DebugLog('ProcessActionFinish for ['+theDiv+'] - dyn div has no refreshDiv.');
2852            }
2853            
2854          }else{
2855            DebugLog('ProcessActionFinish for ['+theDiv+'] - dyn div has no innerHTML.');
2856          }
2857        }else{
2858          DebugLog('ProcessActionFinish for ['+theDiv+'] - dyn div have not loaded.');
2859        }
2860      }else{
2861        DebugLog('ProcessActionFinish for ['+theDiv+'] - could not get parent message div.');
2862      }
2863    }else{
2864      DebugLog('ProcessActionFinish for ['+theDiv+'] - parent message div was not set.');
2865    }
2866  }else{
2867    DebugLog('ProcessActionFinish for ['+theDiv+'] - could not get the internal div.');
2868  }
2869}
2870
2871
2872
2873var SetupDynDivRetryCount = 0;
2874
2875
2876//----------------------------------------------------------------------------
2877function SetupDynDivExtraParam(aDivID,paramName,paramValue){
2878	var theDivBox = document.getElementById(aDivID);
2879  if(theDivBox != null){
2880		var newAttrName = 'xmlhttp'+paramName;
2881		theDivBox.setAttribute(newAttrName,paramValue);
2882		DebugLog('SetupDynDivExtraParam - for ['+aDivID+'], new attribute['+newAttrName+'], value['+paramValue+']');
2883	}	
2884}
2885
2886//----------------------------------------------------------------------------
2887function GetDynDivExtraParam(aDivID,paramName){
2888	var retVal = '';
2889	var theDivBox = document.getElementById(aDivID);
2890  if(theDivBox != null){
2891		var newAttrName = 'xmlhttp'+paramName;
2892		retVal = theDivBox.getAttribute(newAttrName);
2893		DebugLog('GetDynDivExtraParam - for ['+aDivID+'], new attribute['+newAttrName+'], return value['+retVal+']');
2894	}		
2895	return retVal;
2896}
2897
2898
2899function killDynDivLoads(){
2900	
2901	DebugLog('killDynDivLoads - - - - - - - - - - - - - - -');
2902	var dynListLen = g_DynDivs.length
2903	var theDiv;
2904	
2905	for(var i = 0; i < dynListLen; i++){
2906		theDiv = g_DynDivs[i];
2907		if(theDiv){
2908			DebugLog('killDynDivLoads: i('+i+'), div name: '+theDiv.id+', inProcess: '+theDiv.getAttribute('xmlhttpInProcess'));
2909			theDiv.setAttribute('xmlhttpKillRequest',true);
2910			theDiv.xmlhttpObj.abort; 
2911		}
2912	}
2913	
2914}
2915
2916
2917
2918var g_DynDivs = []; // array of dyn divs
2919
2920//----------------------------------------------------------------------------
2921// the dyn div will pull content dynamically
2922function SetupDynDiv(theDiv,actionCallback,finishCallback,waitTimeToLoad,altLoadText,altFailedText) {
2923var theDivBox = document.getElementById(theDiv); 
2924var fullActionCallback = actionCallback;
2925var doKillIt = false;
2926
2927  DebugLog('SetupDynDiv: START - div['+theDiv+']');
2928  
2929  if(theDivBox != null){
2930    //WE LOAD THE HTTP OBJ INTO THE DIV OBJ ITSELF
2931    theDivBox.xmlhttpObj = GetXmlHttpObject(); //SETUP FOR THE POSTBACK PROCESSING
2932    theDivBox.xmlhttpCallback = fullActionCallback; //THE ACTION CALLBACK WHEN THE DIV GOES TO GET INFO
2933    theDivBox.xmlhttpFinishCallback = finishCallback; //THE FINISH CALLBACK WHEN THE DIV CONTENT IS LOADED
2934    theDivBox.setAttribute('xmlhttpInitialWait',waitTimeToLoad); //HOW LONG TO WAIT TO INITIALLY REFRESH THIS DYN DIV
2935    theDivBox.setAttribute('xmlhttpInitialLoad',false);
2936    theDivBox.setAttribute('xmlhttpLoadCount',0);
2937    theDivBox.setAttribute('xmlhttpInProcess',false);
2938		theDivBox.setAttribute('xmlhttpKillRequest',false);
2939    DebugLog('SetupDynDiv - div['+theDiv+'] - xmlhttpInitialLoad['+theDivBox.getAttribute('xmlhttpInitialLoad')+']');
2940		
2941		g_DynDivs.push(theDivBox); //ADD THE DIV TO OUR REFERENCE LIST
2942		
2943    //STORE THE APPROPRIATE FAIL TEXT INTO THE DIV OBJ
2944    if(altFailedText != null){
2945      if(altFailedText != ''){
2946        theDivBox.setAttribute('xmlhttpFailText',altFailedText); 
2947      }
2948      else{
2949        theDivBox.setAttribute('xmlhttpFailText','<i>load failed</i>'); 
2950      }
2951    }
2952    else{
2953      theDivBox.setAttribute('xmlhttpFailText','<i>load failed</i>'); 
2954    }
2955
2956    if(altLoadText != null){
2957      if(altLoadText != ''){
2958        theDivBox.setAttribute('xmlhttpLoadText',altLoadText); 
2959      }
2960      else{
2961        theDivBox.setAttribute('xmlhttpLoadText','<i>loading...</i>'); 
2962      }
2963    }
2964    else{
2965      theDivBox.setAttribute('xmlhttpLoadText','<i>loading...</i>'); 
2966    }
2967    
2968    //------ SET THE CALLBACK FUNCTION FOR THE DIV HTTP OBJECT
2969      theDivBox.xmlhttpObj.onreadystatechange=function()
2970      {
2971        //DebugLog('xmlhttpObj Callback: current readyState is: '+theDivBox.xmlhttpObj.readyState);
2972        if (theDivBox.xmlhttpObj.readyState==4 && theDivBox.xmlhttpObj.status==200)
2973        {
2974          //DebugLog('xmlhttpObj Callback: object is now ready: '+theDiv);
2975          theDivBox.setAttribute('xmlhttpInProcess','false'); //MARK IT AS NO LONGER IN PROCESS, A FLAG JUST FOR US
2976          HideDivWait(theDiv); //IF WE ARE SHOWING THE SPINNER, THEN TURN IT OFF
2977          
2978          //IF WE HAVE NO RESPONSE, THEN SHOW OUR PROVIDED OR DEFAULT FAILED MESSAGE
2979          if(theDivBox.xmlhttpObj.responseText == ''){
2980						//DebugLog('xmlhttpObj Callback: we have no response, lets fail now');
2981            theDivBox.innerHTML = theDivBox.getAttribute('xmlhttpFailText');
2982          }
2983          else {
2984            //HEY, WE GOT A RESPONSE, SO POP THAT INTO THE DIV
2985						//DebugLog('xmlhttpObj Callback: we got a response, use it - state['+theDivBox.xmlhttpObj.readyState+'], status['+theDivBox.xmlhttpObj.status+']');
2986						theDivBox.innerHTML = theDivBox.xmlhttpObj.responseText; 
2987          }
2988          
2989          //IF WE HAVE A CALLBACK TO DO AFTER WE'RE DONE, THEN DO IT
2990          if(theDivBox.xmlhttpFinishCallback != null){
2991						//DebugLog('xmlhttpObj Callback: have a callback routine, so jump to that');
2992            theDivBox.xmlhttpFinishCallback(theDiv);
2993          }
2994        }
2995        else{
2996          if(theDivBox.xmlhttpObj){
2997						//DebugLog('xmlhttpObj have it');
2998            if(theDivBox.xmlhttpObj.readyState){
2999							//DebugLog('xmlhttpObj have ready state');
3000              if(theDivBox.xmlhttpObj.readyState > 1){
3001                //DebugLog('xmlhttpObj Callback: readyState is: '+theDivBox.xmlhttpObj.readyState.toString());
3002              }
3003              else{
3004                //DebugLog('xmlhttpObj Callback: readyState is < 2');
3005              }
3006            }
3007            else{
3008              //DebugLog('xmlhttpObj Callback: readyState not valid');
3009            }
3010          }
3011          else{
3012            //DebugLog('xmlhttpObj Callback: xmlhttpObj not valid');
3013          }
3014        }
3015      }
3016    //---------
3017    
3018    //NOW SETUP THE INITIAL REFRESH IF REQUESTED
3019    if((waitTimeToLoad != '') &&(waitTimeToLoad != 0)){
3020      initRefreshCall = 'DynDivRefreshAuto("'+theDiv+'")'; //CALL THE AUTO REFRESH ROUTINE
3021      DebugLog('SetupDynDiv: setting up timeout for auto-refresh: '+waitTimeToLoad);
3022      setTimeout(initRefreshCall,waitTimeToLoad);
3023    }
3024    else{
3025      //DO NOTHING, WE WILL WAIT FOR A MANUAL CALL TO DYNDIVREFRESH
3026      DebugLog('SetupDynDiv: not setting up timeout refresh');
3027    }
3028  }
3029  else{
3030    
3031		
3032		//DebugLog('SetupDynDiv: ['+theDiv+'] xmlhttpKillRequest value is ['+theDivBox.getAttribute('xmlhttpKillRequest')+']');
3033		//if(theDivBox.getAttribute('xmlhttpKillRequest') == 'true'){
3034		//	doKillIt = true;
3035		//	DebugLog('SetupDynDiv: ['+theDiv+'] - setting doKillIt');
3036		//}
3037		
3038		if(!doKillIt){
3039			var bailout = false;
3040			SetupDynDivRetryCount = SetupDynDivRetryCount + 1;
3041			if(SetupDynDivRetryCount < 100){
3042				if(SetupDynDivRetryCount > 3){
3043					var parentDivName = theDiv.replace('Content','');
3044					var parentDiv = document.getElementById(parentDivName); 
3045					if(!parentDiv){
3046						DebugLog('SetupDynDiv: the parent div is not present, so bail out ['+ parentDivName+']');
3047						bailout = true;
3048					}
3049				}
3050				
3051				if(!bailout){
3052					DebugLog('SetupDynDiv: is still null, try again: '+ SetupDynDivRetryCount);
3053					//SetupDynDiv(theDiv,actionCallback,finishCallback,waitTimeToLoad,altLoadText,altFailedText)
3054					var thefunccall = 'SetupDynDiv("'+ theDiv +'",'+ fullActionCallback +','+ finishCallback +','+ waitTimeToLoad +',"'+ altLoadText +'","'+ altFailedText +'")';
3055					var newwaittime = 100 * SetupDynDivRetryCount;
3056					setTimeout(thefunccall,newwaittime); //TRY AGAIN 
3057				}
3058			}else{
3059				DebugLog('SetupDynDiv: is still null, all retries have failed');
3060			}
3061		}else{
3062			DebugLog('SetupDynDiv: skipping because doKillIt is set');
3063		}
3064  }
3065}  
3066
3067
3068//----------------------------------------------------------------------------
3069// RETURNS TRUE IF AT LEAST ONE REFRESH HAS BEEN DONE
3070function hasDynDivLoaded(theDiv) {
3071var theDivBox = document.getElementById(theDiv);
3072 
3073  if(theDivBox != null){
3074    if(theDivBox.getAttribute('xmlhttpInitialLoad') != null){
3075      return theDivBox.getAttribute('xmlhttpInitialLoad');
3076    }
3077    else{
3078      return false;
3079    }
3080  }
3081  else{
3082    return false;
3083  }
3084}
3085
3086
3087//----------------------------------------------------------------------------
3088// RETURNS TRUE IF AT LEAST ONE REFRESH HAS BEEN DONE
3089function getDynDivLoadCount(theDiv) {
3090var theDivBox = document.getElementById(theDiv);
3091 
3092  if(theDivBox != null){
3093    if(theDivBox.getAttribute('xmlhttpInitialLoad') != null){
3094      return theDivBox.getAttribute('xmlhttpInitialLoad');
3095    }
3096    else{
3097      return 0;
3098    }
3099  }
3100  else{
3101    return 0;
3102  }
3103}
3104
3105//----------------------------------------------------------------------------
3106// RETURNS TRUE IF THE DYN DIV IS ACTIVELY GETTING THE CONTENT
3107function isDynDivInProcess(theDiv) {
3108var theDivBox = document.getElementById(theDiv);
3109 
3110  if(theDivBox != null){
3111    return theDivBox.getAttribute('xmlhttpInProcess');
3112  }
3113  else{
3114    return false;
3115  }
3116}
3117
3118
3119var g_WaitForDynDivRefresh = false;
3120var g_WaitForDynDivTimerSet = false
3121
3122function PrepDynRefresh(theDiv){
3123	DebugLog('PrepDynRefresh - START for ['+theDiv+']');
3124	g_WaitForDynDivRefresh = true;
3125	if(!g_WaitForDynDivTimerSet){
3126		CheckDynRefresh(theDiv);
3127	}
3128
3129}
3130
3131function CheckDynRefresh(theDiv){
3132	if(g_WaitForDynDivRefresh){
3133		g_WaitForDynDivRefresh = false;
3134		g_WaitForDynDivTimerSet = true;
3135		setTimeout('CheckDynRefresh("'+theDiv+'")',500);
3136	}else{
3137		g_WaitForDynDivTimerSet = false;
3138		DebugLog('CheckDynRefresh - OK refresh the div ['+theDiv+']');
3139		DynDivRefresh(theDiv);
3140	}
3141}
3142
3143//----------------------------------------------------------------------------
3144// THIS ROUTINE IS CALLED BY THE AUTO INITIAL LOAD TIMER, WILL ONLY LOAD THE CONTENT
3145// IF IT HASN'T BEEN LOADED AND ISN'T LOADING RIGHT NOW
3146function DynDivRefreshAuto(theDiv) {
3147var theDivBox = document.getElementById(theDiv); 
3148DebugLog('DynDivRefreshAuto: starting for DIV: '+theDiv);
3149  if(theDivBox != null){
3150    //IF WE HAVEN'T ALREADY DONE ONE LOAD AND WE AREN'T LOADING IT RIGHT NOW
3151		DebugLog('DynDivRefreshAuto: ['+theDiv+'] xmlhttpInitialLoad['+theDivBox.getAttribute('xmlhttpInitialLoad')+'], xmlhttpInProcess['+theDivBox.getAttribute('xmlhttpInProcess')+']');
3152
3153    if((theDivBox.getAttribute('xmlhttpInitialLoad') == 'false') && (theDivBox.getAttribute('xmlhttpInProcess') == 'false')){ 
3154      DebugLog('DynDivRefreshAuto: do the DynDivRefresh for: '+theDiv);
3155      DynDivRefresh(theDiv); 
3156    }else{
3157      DebugLog('DynDivRefreshAuto: cant auto-refresh div, it is in load or is in process');
3158    }
3159  }  
3160}
3161
3162var DynDivRefreshRetryCount = 0;
3163
3164//----------------------------------------------------------------------------
3165// CALL THIS ROUTINE TO GO GET THE DYNAMIC CONTENT FOR THE DYN DIV
3166// MUST HAVE PREVIOUSLY CALLED SetupDynDiv TO PREPARE THE DYN DIV
3167function DynDivRefresh(theDiv) {
3168var theDivBox = document.getElementById(theDiv); 
3169var loadURL;
3170var i;
3171var retryTime;
3172var doTryAgain;
3173var doKillIt = false;
3174
3175  doTryAgain = true;
3176  
3177  //alert('DynDivRefresh start: '+theDiv);
3178  DebugLog('DynDivRefresh: STARTING for div['+theDiv+']');
3179  if(theDivBox != null){
3180    DebugLog('DynDivRefresh: ['+theDiv+'] got the div element');
3181    DebugLog('DynDivRefresh: ['+theDiv+'] xmlhttpInProcess value is ['+theDivBox.getAttribute('xmlhttpInProcess')+']');
3182		
3183		DebugLog('DynDivRefresh: ['+theDiv+'] xmlhttpKillRequest value is ['+theDivBox.getAttribute('xmlhttpKillRequest')+']');
3184		if(theDivBox.getAttribute('xmlhttpKillRequest') == 'true'){
3185			doKillIt = true;
3186			DebugLog('DynDivRefresh: ['+theDiv+'] KILLTEST - setting doKillIt');
3187		}
3188		
3189    if((theDivBox.getAttribute('xmlhttpInProcess') == 'false') && (!doKillIt)){ //IF WE AREN'T ALREADY PROCESSING
3190      DebugLog('DynDivRefresh: ['+theDiv+'] xmlhttpInProcess is not set, so get started');
3191      theDivBox.setAttribute('xmlhttpInProcess','true');
3192      theDivBox.setAttribute('xmlhttpInitialLoad','true');
3193      theDivBox.setAttribute('xmlhttpLoadCount',theDivBox.xmlhttpLoadCount + 1);
3194      
3195			theSpinMessage = '';
3196			if(theDivBox.getAttribute('xmlhttpLoadText') == null){
3197				theSpinMessage = 'loading error';
3198			}else{
3199				theSpinMessage = theDivBox.getAttribute('xmlhttpLoadText');
3200			}
3201      theDivBox.innerHTML = '<div style="font-family:arial,sanserif;font-size:10px;padding:4px;color:#999;text-align:center;margin:auto;">'+ theSpinMessage +'</div>'; 
3202      DebugLog('DynDivRefresh: ['+theDiv+'] go ahead and show the loading spinner');
3203			ShowDivWait(theDiv);
3204
3205      if(theDivBox.xmlhttpCallback != null){ 
3206        DebugLog('DynDivRefresh: ['+theDiv+'] have a xmlhttpCallback - so get the URL');
3207        loadURL = theDivBox.xmlhttpCallback(theDiv); //GO GET THE URL TO HIT
3208        if (loadURL) {
3209          i = loadURL.indexOf('ERROR:'); //IF THE RETURN MESSAGE STARTS WITH "ERROR:" THEN IT IS A NON-URL RETURN MESSAGE
3210          if(i >= 0){
3211            DebugLog('DynDivRefresh: ['+theDiv+'] have an error ['+loadURL+']');
3212            loadURL = loadURL.replace('ERROR:','');
3213            theDivBox.innerHTML = loadURL;  //JUST DISPLAY THE RETURN VALUE MINUS THE LEADING ERROR: TEXT
3214            HideDivWait(theDiv); //HIDE THE SPINNER BECAUSE WE'RE DONE
3215            theDivBox.setAttribute('xmlhttpInProcess','false'); //MAKE THE DIV AS NOT IN PROCESS
3216            doTryAgain = false;
3217          }
3218          else{
3219            //OK, IT IS A URL NOT A FAIL MESSAGE
3220            var fullLoadURL;
3221            if(loadURL.indexOf('http') == 0){
3222              DebugLog('DynDivRefresh: ['+theDiv+'] full URL to get ['+loadURL+']');
3223              fullLoadURL = loadURL;
3224						}else if(loadURL.indexOf('rel:') == 0){
3225							DebugLog('DynDivRefresh: ['+theDiv+'] relative URL to get ['+loadURL+']');
3226							fullLoadURL = loadURL.substr(4); //TRIM OFF THE REL: PORTION
3227            }else{
3228							
3229							var ppos = loadURL.indexOf('process/');
3230							DebugLog('DynDivRefresh: position of process/ in path ['+ppos+']');
3231							if(ppos == 0){
3232								DebugLog('DynDivRefresh: has it, so leave it');
3233								fullLoadURL = loadURL;
3234							}else{
3235								DebugLog('DynDivRefresh: does not have it, so add it');
3236								fullLoadURL = 'process/'+ loadURL;
3237							}
3238              DebugLog('DynDivRefresh: ['+theDiv+'] local sys URL to get ['+fullLoadURL+']');
3239            }
3240						
3241						fullLoadURL = AddInterfaceLevelToURL(fullLoadURL);
3242						
3243            DebugLog('DynDivRefresh: ['+theDiv+'] doing send ['+fullLoadURL+']');
3244            
3245            theDivBox.xmlhttpObj.open('GET',fullLoadURL,true);
3246            theDivBox.xmlhttpObj.send();
3247            doTryAgain = false;
3248          }
3249        } else {
3250         //THIS IS AN ERROR CONDITION
3251         DebugLog('DynDivRefresh: ['+theDiv+'] failed to get the loadURL value from the div xmlcallback routine.');
3252        }
3253      }
3254      else{
3255        DebugLog('DynDivRefresh: ['+theDiv+'] No action xmlhttpCallback setup for dyn div ['+theDiv+']');
3256      }
3257    }
3258    else{
3259			if(doKillIt){
3260				DebugLog('DynDivRefresh: ['+theDiv+'] we are supposed to kill this request');
3261				doTryAgain = false;
3262			}else{
3263				DebugLog('DynDivRefresh: ['+theDiv+'] xmlhttpInProcess is still in process');
3264				doTryAgain = true;
3265			}
3266    }
3267  }
3268  else{ 
3269    DebugLog('DynDivRefresh: ['+theDiv+'] theDivBox is not valid yet.');    
3270    doTryAgain = true;
3271  }
3272  
3273  if(doTryAgain && (!doKillIt)){
3274    DebugLog('DynDivRefresh: ['+theDiv+'] doTryAgain.');    
3275
3276    //IF THE DIV ISN'T THERE THEN WAIT FOR IT AND TRY AGAIN
3277    if(DynDivRefreshRetryCount < 17){
3278      DynDivRefreshRetryCount = DynDivRefreshRetryCount + 1;
3279      retryTime = (DynDivRefreshRetryCount * 300) + 300;
3280      if(theDivBox != null){
3281        theDivBox.setAttribute('xmlhttpInProcess','false');  //TELL THE OBJ THAT WE THINK IT SHOULD BE DONE
3282      }
3283      DebugLog('DynDivRefresh - ['+theDiv+'] retry: '+DynDivRefreshRetryCount+', retry delay: '+retryTime);
3284      setTimeout("DynDivRefresh('"+ theDiv+ "')",retryTime); //KICK OFF A NEW REFRESH AFTER THE WAIT TIME
3285      
3286    }else{
3287      //alert('DynDivRefresh - unable to reload '+theDiv+', the item is still unavailable. [ '+DynDivRefreshRetryCount+']');
3288      DebugLog('DynDivRefresh: ['+theDiv+'] - unable to reload, the item is still unavailable. [ '+DynDivRefreshRetryCount+']');
3289      //alert('Sorry.  Unable to update the dynamic information.  Please refresh the page and try again.');
3290    }
3291  }
3292}
3293
3294 
3295function AddInterfaceLevelToURL(aURL){
3296var retURL = aURL;
3297	if(retURL.length > 0){
3298		
3299		//if(retURL.indexOf('?') >= 0)
3300		//{ 
3301		//	retURL = retURL + '&rz=' + Math.random(); // NEED TO ADD THIS TO PREVENT CACHING OF THIS IN THE BROWSER
3302		//}else{
3303		//	retURL = retURL + '?rz=' + Math.random(); // NEED TO ADD THIS TO PREVENT CACHING OF THIS IN THE BROWSER
3304		//}			
3305		
3306		retURL = updateURLParameter(retURL,'rz',Math.random());
3307		
3308		if(retURL.indexOf('&i=') >= 0){
3309			DebugLog('AddInterfaceLevelToURL - i param already present');	
3310		}else{
3311			if(gProcessInterfaceLevel){
3312				retURL = retURL + '&i=' + gProcessInterfaceLevel;
3313			}else{
3314				retURL = retURL + '&i=0';
3315			}
3316			if(gProcessSessCheck){
3317				retURL = retURL + '&sk=' + gProcessSessCheck;
3318			}else{
3319				retURL = retURL + '&sk=0';
3320			}	
3321		}
3322	}
3323	DebugLog('AddInterfaceLevelToURL - ret URL['+ retURL +']');
3324return retURL;
3325}
3326
3327
3328function AddClientIDToURL(aURL){
3329var retURL = aURL;
3330	if(retURL.length > 0){
3331		
3332		if((retURL.indexOf('&c=') >= 0) || (retURL.indexOf('&C=') >= 0)){
3333			DebugLog('AddClientIDToURL - c param already present');	
3334		}else{
3335			if(gcscID > 0){
3336				retURL = retURL + '&c=' + gcscID;
3337			}else{
3338				retURL = retURL + '&c=0';
3339			}	
3340		}
3341	}
3342	DebugLog('AddClientIDToURL - ret URL['+ retURL +']');
3343return retURL;
3344}
3345
3346
3347//----------------------------------------------------------------------------
3348function ShowDivWait(theDiv){
3349var opts = {
3350  lines: 12, // The number of lines to draw
3351  length: 4, // The length of each line
3352  width: 1, // The line thickness
3353  radius: 3, // The radius of the inner circle
3354  corners: 1, // Corner roundness (0..1)
3355  rotate: 0, // The rotation offset
3356  color: '#555', // #rgb or #rrggbb
3357  speed: 0.5, // Rounds per second
3358  trail: 30, // Afterglow percentage
3359  shadow: false, // Whether to render a shadow
3360  hwaccel: false, // Whether to use hardware acceleration
3361  className: 'spinner', // The CSS class to assign to the spinner
3362  zIndex: 2e9, // The z-index (defaults to 2000000000)
3363  top: 'auto', // Top position relative to parent in px
3364  left: 'auto' // Left position relative to parent in px
3365};
3366var divbox = document.getElementById(theDiv);
3367if(divbox != null){
3368  var thespinnername = theDiv+'Spinner';
3369  var thespinnerblock = '<div id="'+thespinnername+'" style="position:relative;margin:auto;margin-top:1px;width:20px;height:20px;"></div>';
3370  divbox.innerHTML = divbox.innerHTML + thespinnerblock; //ADD THE SPINNER DIV TO THE DIV
3371  var target = document.getElementById(thespinnername); //NOW GET THE OBJ FROM THE DOM
3372  if(target != null){
3373    var spinner = new Spinner(opts).spin(target);
3374  }
3375  else{
3376    //alert('spinner: '+thespinnername+' was not found.');
3377  }
3378}
3379
3380}
3381
3382
3383//----------------------------------------------------------------------------
3384function HideDivWait(theDiv){
3385
3386var target = document.getElementById(theDiv+'Spinner');
3387
3388  if(target != null){
3389    target.style.visibility = 'hidden';
3390    target.style.display = 'none';
3391  
3392  }
3393
3394}
3395
3396//----------------------------------------------------------------------------
3397function go(theURL) {
3398  setTimeout(function(){ window.location.href = theURL; }, 100);
3399}
3400
3401
3402 //window.location.href = "mailto:[email protected]?subject=Subject&body=message%20goes%20here";
3403//----------------------------------------------------------------------------
3404function mailTo(theEmail,theSubject,theBody) {
3405var theurl;
3406DebugLog('mailto function');
3407  theurl = 'mailto:'+theEmail+'?subject='+theSubject+'&body='+theBody;
3408  window.location.href = theurl;
3409}
3410
3411//----------------------------------------------------------------------------
3412function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
3413
3414//----------------------------------------------------------------------------
3415function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
3416
3417//----------------------------------------------------------------------------
3418function ViewPortWidth(){
3419var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
3420return w;
3421}
3422//----------------------------------------------------------------------------
3423function ViewPortHeight(){
3424var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0
3424);
3425return h;
3426}
3427
3428//----------------------------------------------------------------------------
3429function pageTop() {
3430  if(typeof pageYOffset!= 'undefined'){
3431      //most browsers
3432      return pageYOffset;
3433  }
3434  else{
3435      var B= document.body; //IE 'quirks'
3436      var D= document.documentElement; //IE with doctype
3437      D= (D.clientHeight)? D: B;
3438      return D.scrollTop;
3439  }
3440
3441}
3442
3443//----------------------------------------------------------------------------
3444function pageLeft() {
3445  if(typeof pageXOffset!= 'undefined'){
3446      //most browsers
3447      return pageXOffset;
3448  }
3449  else{
3450      var B= document.body; //IE 'quirks'
3451      var D= document.documentElement; //IE with doctype
3452      D= (D.clientWidth)? D: B;
3453      return D.scrollLeft;
3454  }
3455}
3456
3457
3458
3459//----------------------------------------------------------------------------
3460function GetWaitDiv() {
3461var thediv;
3462
3463  thediv = '<div  style="display:inline;position:absolute;z-index:100;left:0px;top:0px;background-color:#ccf;width:100%;height:100%;background:url(images/loaderb64.gif) no-repeat center center;"></div>';
3464
3465return thediv;
3466}
3467
3468
3469
3470//----------------------------------------------------------------------------
3471function doSetInheritCSS(inputItem,inheritItem,parentItem) {
3472var thefrom = document.getElementById(inheritItem);
3473var theto = document.getElementById(inputItem);
3474var theparent = document.getElementById(parentItem);
3475  DebugLog('doSetInheritCSS - inherit:'+inheritItem+' to input:'+ inputItem);
3476  if(thefrom && theto){
3477    DebugLog('doSetInheritCSS - copy value is ['+thefrom.innerHTML+']');
3478    theto.value = thefrom.innerHTML;
3479    if(theparent){
3480      theparent.style.visibility = 'hidden';
3481    }
3482  }
3483}
3484
3485//----------------------------------------------------------------------------
3486function doClearCSSInput(inputItem,inheritItem,parentItem) {
3487var thefrom = document.getElementById(inheritItem);
3488var theto = document.getElementById(inputItem);
3489var theparent = document.getElementById(parentItem);
3490  DebugLog('doClearCSS - input:'+ inputItem);
3491  if(thefrom && theto){
3492    DebugLog('doClearCSS - doing clear');
3493    theto.value = '';
3494    if(theparent){
3495      theparent.style.visibility = '';
3496    }
3497  }
3498}
3499
3500
3501
3502//----------------------------------------------------------------------------
3503function CopyValueFromTo(fromItem,toItem) {
3504var thefrom = document.getElementById(fromItem);
3505var theto = document.getElementById(toItem);
3506  DebugLog('CopyValueToFrom - '+fromItem+' to '+ toItem);
3507  if(thefrom && theto){
3508    DebugLog('CopyValueToFrom - copy value is ['+thefrom.value+']');
3509    theto.value = thefrom.value;
3510  }
3511}
3512
3513//----------------------------------------------------------------------------
3514function SetInputValue(anInputID,aValue) {
3515var theinput = document.getElementById(anInputID);
3516  DebugLog('SetInputValue - input['+anInputID+'] to value['+ aValue+']');
3517  if(theinput){
3518    theinput.value = aValue;
3519  }
3520}
3521
3522//----------------------------------------------------------------------------
3523function AllowNumberOnlyKeyPress(e) { 
3524	// Only allow numbers or the period character - use with OnKeyPress event - onkeypress="return AllowNumberOnlyKeyPress(event)"
3525	var theCode = (e.which) ? e.which : e.keyCode; 
3526	if((theCode >= 48 && theCode <= 57) || (theCode == 46)){
3527		return true; 
3528	}else{
3529		return false; 
3530	}
3531} 
3532
3533//----------------------------------------------------------------------------
3534function CopyValueFromToByName(fromItemName,toItemName) {
3535var thefrom = document.getElementsByName(fromItemName)[0];
3536var theto = document.getElementsByName(toItemName)[0];
3537  DebugLog('CopyValueFromToByName - '+fromItemName+' to '+ toItemName);
3538  if(thefrom && theto){
3539    DebugLog('CopyValueFromToByName - copy value is ['+thefrom.value+']');
3540    theto.value = thefrom.value;
3541  }
3542}
3543
3544//----------------------------------------------------------------------------
3545function CopyValueFromToTextArea(fromItemID,toTextAreaID) {
3546var thefrom = document.getElementById(fromItemID);
3547var theto = document.getElementById(toTextAreaID);
3548  DebugLog('CopyValueFromToTextArea - from control['+fromItemID+'] to textarea['+ toTextAreaID+']');
3549  if(thefrom && theto){
3550    DebugLog('CopyValueFromToTextArea - copy value is ['+thefrom.value+']');
3551    theto.innerHTML = thefrom.value;
3552  }
3553}
3554
3555//----------------------------------------------------------------------------
3556function CheckAndWrapValue(editField,prefix,postfix) {
3557var theitem = document.getElementById(editField);
3558  DebugLog('CheckAndWrapValue - '+editField+', pre['+ prefix +'], posst['+ postfix +']');
3559  if(theitem){
3560    var orgVal;
3561    var newVal;
3562    orgVal = theitem.value;
3563    if(orgVal){
3564      if(orgVal.indexOf(prefix) == 0){ //PREFIX IS ALREADY THERE
3565        DebugLog('CheckAndWrapValue - prefix already there');
3566      }else{ //PREFIX IS NOT THERE
3567        newVal = prefix + orgVal + postfix;
3568        theitem.value = newVal;
3569      } 
3570    
3571    }else{
3572      DebugLog('CheckAndWrapValue - no value');
3573    }
3574    
3575  }
3576}
3577
3578
3579//----------------------------------------------------------------------------
3580function SetInnerHTML(anID,theHTML) {
3581var theItem = document.getElementById(anID);
3582  DebugLog('SetInnerHTML - '+anID);
3583  if(theItem){
3584    theItem.innerHTML = theHTML;
3585  }
3586}
3587
3588//----------------------------------------------------------------------------
3589function CopyInnerHTML(fromID,toID) {
3590var theFrom = document.getElementById(fromID);
3591var theTo = document.getElementById(toID);
3592  DebugLog('CopyInnerHTML - from['+ fromID +'] to['+ toID +']');
3593  if(theFrom){
3594		if(theTo){
3595			theTo.innerHTML = theFrom.innerHTML;
3596		}else{
3597			DebugLog('CopyInnerHTML - failed to find the target item['+toID+']');
3598		}
3599  }else{
3600		DebugLog('CopyInnerHTML - failed to find the source item['+fromID+']');
3601	}
3602}
3603
3604//----------------------------------------------------------------------------
3605function CopyInnerHTMLAndShow(fromID,toID) {
3606var theFrom = document.getElementById(fromID);
3607var theTo = document.getElementById(toID);
3608  DebugLog('CopyInnerHTMLAndShow - from['+ fromID +'] to['+ toID +']');
3609  if(theFrom){
3610		if(theTo){
3611			theTo.innerHTML = theFrom.innerHTML;
3612			theTo.visibility = '';
3613		}else{
3614			DebugLog('CopyInnerHTMLAndShow - failed to find the target item['+toID+']');
3615		}
3616  }else{
3617		DebugLog('CopyInnerHTMLAndShow - failed to find the source item['+fromID+']');
3618	}
3619}
3620
3621
3622
3623//----------------------------------------------------------------------------
3624function startRotateChildDivs(parentDivID,theDelay,showClassName,hideClassName){
3625var divContainer = document.getElementById(parentDivID);
3626	if(parentDivID){
3627		setTimeout("doRotateChildDivs('"+parentDivID+"',"+theDelay+",'"+showClassName+"','"+hideClassName+"');",theDelay);
3628	}else{
3629		setTimeout("startRotateChildDivs('"+parentDivID+"',"+theDelay+",'"+showClassName+"','"+hideClassName+"');",1000);		
3630	}
3631}
3632
3633//----------------------------------------------------------------------------
3634function doRotateChildDivs(parentDivID,theDelay,showClassName,hideClassName){
3635var divContainer = document.getElementById(parentDivID);
3636	if(parentDivID){
3637		//DebugLog('doRotateChildDivs - START');
3638		RotateChildDivs(parentDivID,showClassName,hideClassName);
3639		setTimeout("doRotateChildDivs('"+parentDivID+"',"+theDelay+",'"+showClassName+"','"+hideClassName+"');",theDelay);
3640	}	
3641}
3642
3643
3644
3645//----------------------------------------------------------------------------
3646function RotateChildDivs(parentDivID,showClassName,hideClassName){
3647var divContainer = document.getElementById(parentDivID);
3648var thecName;
3649var theShowDiv = -1;
3650var theCurCount = 0;
3651var theMaxCount = 0;
3652var theNextDiv = 0;
3653
3654	if(divContainer){
3655		//DebugLog('RotateChildDivs - START');
3656		var divArr = divContainer.getElementsByTagName("div");
3657		var divArr = GetChildDivListByAttrib(divContainer,"data-artlist-num");
3658		if(divArr){
3659			for(var i = 0; i < divArr.length; i++) {
3660				theCurCount = divArr[i].getAttribute('data-artlist-num');
3661				if(theCurCount > theMaxCount){ theMaxCount = theCurCount; }
3662				if(HasClassName(divArr[i],showClassName)){theShowDiv = i;}
3663			}
3664			if(theShowDiv >= 0){
3665				theNextDiv = theShowDiv + 1;
3666			}else{
3667				theNextDiv = 0;
3668			}
3669			if(theNextDiv >= divArr.length){theNextDiv = 0;}
3670			//DebugLog('RotateChildDivs - curShow['+theShowDiv+'], newShow['+theNextDiv+']');
3671			for(var i = 0; i < divArr.length; i++) {
3672				//DebugLog('RotateChildDivs - i['+i+'], class['+divArr[i].className+']');
3673				if(i == theShowDiv){
3674					//DebugLog('RotateChildDivs - hiding the show at i['+i+']'); 
3675					SwapClassForElement(divArr[i],showClassName,hideClassName);
3676				}else if(i == theNextDiv){
3677					//DebugLog('RotateChildDivs - showing the next hide at i['+i+'], show['+showClassName+'], hide['+hideClassName+']'); 
3678					SwapClassForElement(divArr[i],hideClassName,showClassName);
3679				}
3680			}
3681		}
3682	}
3683}
3684
3685
3686
3687//----------------------------------------------------------------------------
3688function DivSelect(matchDivs,aSelectID){
3689var divArr = GetDivList(matchDivs);
3690var theSelName;
3691
3692  if(divArr){
3693    theSelName = matchDivs + aSelectID;
3694    //alert('DivSelect - the selected div ['+theSelName+']');
3695    for(var i = 0; i < divArr.length; i++) {
3696      if(divArr[i].id.match(theSelName)){
3697        //alert('DivSelect - location div ['+divArr[i].id+'] - showing div');
3698        divArr[i].style.visibility = '';
3699      }else{
3700        //alert('DivSelect - location div ['+divArr[i].id+'] - hidding div');
3701        divArr[i].style.visibility = 'hidden';
3702      }
3703    }
3704  }
3705}
3706
3707
3708
3709//----------------------------------------------------------------------------
3710function DivSelectClass(matchDivs,aSelectID,selectClassName){
3711var divArr = GetDivList(matchDivs);
3712var theSelName;
3713
3714  if(divArr){
3715    theSelName = matchDivs + aSelectID;
3716    //alert('DivSelect - the selected div ['+theSelName+']');
3717    for(var i = 0; i < divArr.length; i++) {
3718      if(divArr[i].id.match(theSelName)){
3719        //alert('DivSelect - location div ['+divArr[i].id+'] - adding class');
3720        AddClass(theSelName,selectClassName);
3721      }else{
3722        //alert('DivSelect - location div ['+divArr[i].id+'] - removing class');
3723        RemoveClass(divArr[i].id,selectClassName);
3724      }
3725    }
3726  }
3727}
3728
3729//----------------------------------------------------------------------------
3730function DivSelectClassSwap(matchDivs,aSelectID,selectClassName,nonSelectClassName){
3731var divArr = GetDivList(matchDivs);
3732var theSelName;
3733
3734  if(divArr){
3735    theSelName = matchDivs + aSelectID;
3736    for(var i = 0; i < divArr.length; i++) {
3737      if(divArr[i].id.match(theSelName)){
3738        SwapClass(theSelName,nonSelectClassName,selectClassName);
3739      }else{
3740        SwapClass(divArr[i].id,selectClassName,nonSelectClassName);
3741      }
3742    }
3743  }
3744}
3745
3746//----------------------------------------------------------------------------
3747function AllDivClassSwap(curClassName,newClassName){
3748var divArr = document.getElementsByTagName("div");
3749  if(divArr){
3750    for(var i = 0; i < divArr.length; i++) {
3751      SwapClassForElement(divArr[i],curClassName,newClassName);
3752    }
3753  }
3754}
3755
3756//----------------------------------------------------------------------------
3757function FirstDivClassSwap(curClassName,newClassName){
3758var divArr = document.getElementsByTagName("div");
3759var thecName;
3760  if(divArr){
3761		var didOne = false;
3762    for(var i = 0; i < divArr.length; i++) {
3763      didOne = SwapClassForElement(divArr[i],curClassName,newClassName);
3764			if(didOne){
3765				//DebugLog('FirstDivClassSwap - did it - ['+curClassName+'] and ['+newClassName+']');
3766				i = divArr.length;
3767			}else{
3768				thecName = divArr[i].className;
3769				if(HasClassName(divArr[i],newClassName)){
3770					//DebugLog('FirstDivClassSwap - found newclass there, we are done');
3771					i = divArr.length;					
3772				}
3773			}
3774    }
3775  }
3776}
3777
3778//----------------------------------------------------------------------------
3779function FirstElementClassSwap(aTagName,curClassName,newClassName){
3780var divArr = document.getElementsByTagName(aTagName);
3781var thecName;
3782  if(divArr){
3783		var didOne = false;
3784    for(var i = 0; i < divArr.length; i++) {
3785      didOne = SwapClassForElement(divArr[i],curClassName,newClassName);
3786			if(didOne){
3787				//DebugLog('FirstElementClassSwap - did it - ['+curClassName+'] and ['+newClassName+']');
3788				i = divArr.length;
3789			}else{
3790				thecName = divArr[i].className;
3791				if(HasClassName(divArr[i],newClassName)){
3792					//DebugLog('FirstElementClassSwap - found newclass there, we are done');
3793					i = divArr.length;					
3794				}
3795			}
3796    }
3797  }
3798}
3799//----------------------------------------------------------------------------
3800function GetDivTopByID(aDivID,aPercentOfHeight){
3801var aEle = document.getElementById(aDivID);
3802var aheight = 0;
3803var aoffset = 0;
3804var thePos = 0;
3805	if(aEle){
3806		aoffset = getOffset(aEle).top;
3807		DebugLog('GetDivTopByID - have element,offset is['+aoffset+']');
3808		aheight = aEle.clientHeight;
3809		DebugLog('GetDivTopByID - have element, height is['+aheight+']');
3810		if(aPercentOfHeight > 0){
3811			thePos = aoffset + (aheight * aPercentOfHeight);
3812		}else{
3813			if(aPercentOfHeight == 0){
3814				thePos = aoffset;
3815			}
3816		}
3817	}
3818	DebugLog('GetDivTopByID - return position is ['+thePos+']');
3819	return thePos;
3820}
3821
3822
3823//----------------------------------------------------------------------------
3824function GetDivTopByClass(aClassName,aPercentOfHeight){
3825var aEle = GetFirstDivByClass(aClassName);
3826var aheight = 0;
3827var aoffset = 0;
3828var thePos = 0;
3829	if(aEle){
3830		aoffset = getOffset(aEle).top;
3831		//DebugLog('GetDivTopByClass - have element,offset is['+aoffset+']');
3832		aheight = aEle.clientHeight;
3833		//DebugLog('GetDivTopByClass - have element, height is['+aheight+']');
3834		if(aPercentOfHeight > 0){
3835			thePos = aoffset + (aheight * aPercentOfHeight);
3836		}else{
3837			if(aPercentOfHeight == 0){
3838				thePos = aoffset;
3839			}
3840		}
3841	}
3842	//DebugLog('GetDivTopByClass - return position is ['+thePos+']');
3843	return thePos;
3844}
3845
3846//----------------------------------------------------------------------------
3847function GetElementTopByClass(aTagName,aClassName,aPercentOfHeight){
3848var aEle = GetFirstElementByClass(aTagName,aClassName);
3849var aheight = 0;
3850var aoffset = 0;
3851var thePos = 0;
3852	if(aEle){
3853		aoffset = getOffset(aEle).top;
3854		//DebugLog('GetElementTopByClass - have element,offset is['+aoffset+']');
3855		aheight = aEle.clientHeight;
3856		//DebugLog('GetElementTopByClass - have element, height is['+aheight+']');
3857		if(aPercentOfHeight > 0){
3858			thePos = aoffset + (aheight * aPercentOfHeight);
3859		}else{
3860			if(aPercentOfHeight == 0){
3861				thePos = aoffset;
3862			}
3863		}
3864	}
3865	//DebugLog('GetElementTopByClass - return position is ['+thePos+']');
3866	return thePos;
3867}
3868
3869//----------------------------------------------------------------------------
3870function GetFirstDivByClass(aClassName){
3871var divArr = document.getElementsByTagName("div");
3872var thecName;
3873var anElement;
3874var retval;
3875  if(divArr){
3876		var didOne = false;
3877    for(var i = 0; i < divArr.length; i++) {
3878			anElement = divArr[i];
3879			if(anElement){
3880				thecName = anElement.className;
3881				//DebugLog('GetFirstDivByClass - for['+anElement.id+'], class['+thecName+']');
3882				if(HasClassName(anElement,aClassName)){
3883					//DebugLog('GetFirstDivByClass - got div by class');
3884					retval = divArr[i];
3885					i = divArr.length;
3886				}
3887			}
3888    }
3889  }
3890	return retval;
3891}
3892
3893//----------------------------------------------------------------------------
3894function GetElementTopByClass(aTagName,aClassName,aPercentOfHeight){
3895var aEle = GetFirstElementByClass(aTagName,aClassName);
3896var aheight = 0;
3897var aoffset = 0;
3898var thePos = 0;
3899	if(aEle){
3900		aoffset = getOffset(aEle).top;
3901		//DebugLog('GetFirstElementByClass - have element,offset is['+aoffset+']');
3902		aheight = aEle.clientHeight;
3903		//DebugLog('GetFirstElementByClass - have element, height is['+aheight+']');
3904		if(aPercentOfHeight > 0){
3905			thePos = aoffset + (aheight * aPercentOfHeight);
3906		}else{
3907			if(aPercentOfHeight == 0){
3908				thePos = aoffset;
3909			}
3910		}
3911	}
3912	//DebugLog('GetFirstElementByClass - return position is ['+thePos+']');
3913	return thePos;
3914}
3915
3916
3917//----------------------------------------------------------------------------
3918function GetFirstElementByClass(aTagName,aClassName){
3919var divArr = document.getElementsByTagName(aTagName);
3920var thecName;
3921var anElement;
3922var retval;
3923  if(divArr){
3924		var didOne = false;
3925    for(var i = 0; i < divArr.length; i++) {
3926			anElement = divArr[i];
3927			if(anElement){
3928				thecName = anElement.className;
3929				//DebugLog('GetFirstElementByClass - for['+anElement.id+'], class['+thecName+']');
3930				if(HasClassName(anElement,aClassName)){
3931					//DebugLog('GetFirstElementByClass - got div by class');
3932					retval = divArr[i];
3933					i = divArr.length;
3934				}
3935			}
3936    }
3937  }
3938	return retval;
3939}
3940
3941
3942//----------------------------------------------------------------------------
3943function AddClass(anID,classNameToAdd){
3944var adiv = document.getElementById(anID);	
3945AddClassForElement(adiv,classNameToAdd);
3946}
3947
3948//----------------------------------------------------------------------------
3949function AddClassForElement(adiv,classNameToAdd){
3950var thecName;
3951
3952  if(adiv){
3953    thecName = adiv.className;
3954		DebugLog('AddClassForElement - add class['+classNameToAdd+'], cur class['+thecName+']');
3955    if(!HasClassName(adiv,classNameToAdd)){
3956			DebugLog('AddClassForElement - doesnt already have class');
3957      if(thecName == ''){
3958				thecName = classNameToAdd;
3959			}else{
3960				thecName = thecName + ' ' + classNameToAdd;
3961			}
3962			
3963      adiv.className = thecName;
3964			DebugLog('AddClassForElement - final class['+thecName+']');
3965    }
3966  }
3967}
3968
3969//----------------------------------------------------------------------------
3970function RemoveClass(anID,classNameToRemove){
3971var adiv = document.getElementById(anID);
3972RemoveClassForElement(adiv,classNameToRemove);
3973}
3974
3975//----------------------------------------------------------------------------
3976function RemoveClassForElement(adiv,classNameToRemove){
3977var thecName;
3978
3979  if(adiv){
3980    thecName = adiv.className;
3981		DebugLog('RemoveClassForElement - remove class['+classNameToRemove+'], cur class['+thecName+']');
3982    if(HasClassName(adiv,classNameToRemove)){
3983      if(adiv.className){
3984				ReplaceClassName(adiv,classNameToRemove,'');
3985        //alert('thecName after class['+ adiv.className +']');
3986      }
3987    }
3988  }
3989}
3990
3991
3992//----------------------------------------------------------------------------
3993function SwapClass(anID,oldClassName,newClassName){
3994var adiv = document.getElementById(anID);
3995var thecName;
3996
3997  if(adiv){
3998    thecName = adiv.className;
3999		DebugLog('SwapClass - for['+anID+'], class['+thecName+']');
4000    if(HasClassName(adiv,oldClassName)){
4001			DebugLog('SwapClass - found class');
4002      if(adiv.className){
4003        DebugLog('SwapClass - thecName for['+anID+'] is ['+thecName+'], removing['+classNameToRemove+']');
4004				ReplaceClassName(adiv,oldClassName,newClassName);
4005        DebugLog('SwapClass - thecName after class['+ adiv.className +']');
4006      }
4007    }
4008  }
4009}
4010
4011//----------------------------------------------------------------------------
4012function ToggleClass(anID,oldClassName,newClassName){
4013var adiv = document.getElementById(anID);
4014ToggleClassForElement(adiv,oldClassName,newClassName);
4015}
4016
4017//----------------------------------------------------------------------------
4018function HasClassName(aElement,aClassName){
4019var retVal = false;
4020	if(aElement){
4021		var clName = aElement.className;
4022		if(clName){
4023			clName = clName + ' ';
4024			var testName = aClassName + ' ';
4025			if(clName.indexOf(testName) >= 0){
4026				retVal = true
4027			}
4028		}
4029	}
4030return retVal;
4031}
4032
4033//----------------------------------------------------------------------------
4034function ReplaceClassName(aElement,oldClassName,newClassName){
4035var retVal = false;
4036	if(aElement){
4037		var clName = aElement.className;
4038		if(clName){
4039			clName = clName + ' ';
4040			var oldName = oldClassName + ' ';
4041			var newName = '';
4042			if(newClassName){
4043				newName = newClassName + ' ';
4044			}
4045			var newcName = clName.replace(oldName,newName);
4046			var lastchar = newcName.slice(-1);
4047			if(lastchar == ' '){
4048				newcName = newcName.slice(0,-1);
4049			}
4050			DebugLog('ReplaceClassName - new class['+newcName+']');
4051			aElement.className = newcName;
4052		}
4053	}
4054return retVal;
4055}
4056
4057//----------------------------------------------------------------------------
4058function ToggleClassForElement(adiv,oldClassName,newClassName){
4059var thecName;
4060
4061  if(adiv){
4062    thecName = adiv.className;
4063		DebugLog('ToggleClass - for['+adiv.id+'], class['+thecName+']');
4064    if(HasClassName(adiv,oldClassName)){
4065			DebugLog('ToggleClass - found old class');
4066      if(adiv.className){
4067				ReplaceClassName(adiv,oldClassName,newClassName);
4068        DebugLog('ToggleClass - thecName after class['+ adiv.className +']');
4069      }
4070    }else{
4071			if(HasClassName(adiv,newClassName)){
4072				DebugLog('ToggleClass - found new class');
4073				if(adiv.className){
4074					ReplaceClassName(adiv,newClassName,oldClassName);
4075					DebugLog('ToggleClass - thecName after class['+ adiv.className +']');
4076				}
4077    	}		
4078		}
4079  }
4080}
4081
4082//----------------------------------------------------------------------------
4083function SwapClassForElement(anElement,oldClassName,newClassName){
4084var thecName;
4085var retval = false;
4086
4087  if(anElement){
4088    thecName = anElement.className;
4089		//DebugLog('SwapClassForElement - for['+anElement.id+'], class['+thecName+']');
4090    if(thecName.indexOf(oldClassName) >= 0){
4091			//DebugLog('SwapClassForElement - found class');
4092
4093        //DebugLog('SwapClassForElement - thecName for['+anElement.id+'] is ['+thecName+'], removing['+oldClassName+'], switch to['+newClassName+']');
4094        thecName = anElement.className.replace(oldClassName,newClassName);
4095        anElement.className = thecName;
4096        //DebugLog('SwapClassForElement - thecName after swap['+ anElement.className +']');
4097				retval = true;
4098    }
4099  }
4100return retval;
4101}
4102
4103//----------------------------------------------------------------------------
4104function HideShowDivs(aDivNameList) {
4105//Prefix name with + for show, 
4106var theArr = aDivNameList.split(",");
4107var i;
4108var theID;
4109var firstChar;
4110
4111  DebugLog('HideShowDivs - the div list ['+ aDivNameList +']');
4112  if(theArr) {
4113    for(i=0; i < theArr.length; i++){
4114      theID = theArr[i];
4115      if(theID.length > 0){
4116        firstChar = theID.charAt(0); //first char might be a + or a - or nothing special
4117        DebugLog('HideShowDivs - i['+i+'], val['+theID+'], firstchar['+firstChar+']');
4118        
4119        if(firstChar == '+'){
4120          theID = theID.substring(1);
4121          DebugLog('HideShowDivs - i['+i+'], showdiv['+theID+']');
4122          ShowDiv(theID);
4123        }else if(firstChar == '-'){
4124          theID = theID.substring(1);
4125          DebugLog('HideShowDivs - i['+i+'], hidediv['+theID+']');
4126          HideDiv(theID);
4127        }else{
4128          DebugLog('HideShowDivs - i['+i+'], togglediv['+theID+']');
4129          ToggleDiv(theID);
4130        }
4131      }
4132    }
4133    
4134  }else{
4135    DebugLog('HideShowDivs - the div list array was null.');
4136  }
4137}
4138
4139//----------------------------------------------------------------------------
4140function ShowDiv(aDivName) {
4141var thebox = document.getElementById(aDivName);
4142DebugLog('ShowDiv - looking for div ['+ aDivName +']');
4143  if(thebox) {
4144			DebugLog('ShowDiv - the div ['+ aDivName +'] visibility['+thebox.style.visibility+']');
4145    //if ( thebox.style.visibility == 'hidden') {
4146      thebox.style.visibility = 'visible';
4147			DebugLog('ShowDiv - the div ['+ aDivName +'] was shown.');
4148    //}
4149  }else{
4150  DebugLog('ShowDiv - the div ['+ aDivName +'] was not found.');
4151  }
4152}
4153
4154//----------------------------------------------------------------------------
4155function ShowDivForSeconds(aDivName,numSeconds) {
4156var thebox = document.getElementById(aDivName);
4157
4158  if(thebox) {
4159    //if ( thebox.style.visibility == 'hidden') {
4160      thebox.style.visibility = 'visible';
4161      var msecs = numSeconds * 1000;
4162      setTimeout("HideDiv('"+aDivName+"');",msecs);
4163    //}
4164  }else{
4165  DebugLog('ShowDivForSeconds - the div ['+ aDivName +'] was not found.');
4166  }
4167}
4168
4169
4170//----------------------------------------------------------------------------
4171function HideDiv(aDivName) {
4172var thebox = document.getElementById(aDivName);
4173
4174  if(thebox) {
4175    //if ( thebox.style.visibility == '') {
4176      thebox.style.visibility = 'hidden';
4177			DebugLog('HideDiv - the div ['+ aDivName +'] was hidden.');
4178    //}
4179  }else{
4180  DebugLog('HideDiv - the div ['+ aDivName +'] was not found.');
4181  }
4182}
4183
4184
4185//----------------------------------------------------------------------------
4186function HideParentDiv(aDivName) {
4187var thebox = document.getElementById(aDivName);
4188	DebugLog('HideParentDiv - the div name ['+aDivName+'].');
4189  if(thebox) {
4190		var theparent = thebox.parentNode;
4191		if(theparent){
4192			//if ( theparent.style.visibility == '') {
4193				theparent.style.visibility = 'hidden';
4194			//}
4195		}else{
4196			DebugLog('HideParentDiv - the parent div was not found.');
4197			
4198		}
4199  }else{
4200		DebugLog('HideParentDiv - the self div was not found.');
4201  }
4202}
4203
4204
4205//----------------------------------------------------------------------------
4206function checkValueThenHideDiv(aEditControl,aDivName) {
4207var thebox = document.getElementById(aDivName);
4208var theEdit = document.getElementById(aEditControl);
4209  if(thebox) {
4210		//DebugLog('checkValueThenHideDiv - div to hide['+aDivName+']');
4211    if(theEdit){
4212			//DebugLog('checkValueThenHideDiv - have input control['+aEditControl+']');
4213      if(theEdit.value != ''){
4214				//DebugLog('checkValueThenHideDiv - input has value, hide div - cur state['+thebox.style.visibility+']');
4215        if ( (thebox.style.visibility == '')||(thebox.style.visibility == 'visible') ) {
4216          thebox.style.visibility = 'hidden';
4217        }
4218      }
4219    }else{
4220			//DebugLog('checkValueThenHideDiv - no input control found, hide the div');
4221      if ( (thebox.style.visibility == '')||(thebox.style.visibility == 'visible') ) {
4222        thebox.style.visibility = 'hidden';
4223      }
4224    }
4225  }else{
4226  DebugLog('HideDiv - the div ['+ aDivName +'] was not found.');
4227  }
4228}
4229
4230//----------------------------------------------------------------------------
4231function ToggleDiv(aDivName) {
4232var thebox = document.getElementById(aDivName);
4233
4234  if(thebox) {
4235    if ( (thebox.style.visibility == '')||(thebox.style.visibility == 'visible') ) {
4236      thebox.style.visibility = 'hidden';
4237    }
4238    else {
4239      thebox.style.visibility = 'visible';
4240    }
4241  }else{
4242  DebugLog('ToggleDiv - the div ['+ aDivName +'] was not found.');
4243  }
4244}
4245
4246
4247
4248//----------------------------------------------------------------------------
4249function FindParentDivAttributeValue(aDivRef,aAttribute,aMinValue){
4250	var retValue = -1;
4251	if(aDivRef){
4252		var aDivName = aDivRef.name;
4253		DebugLog('FindParentDivAttributeValue - the name ['+ aDivRef.name +'], id ['+ aDivRef.id +'], aAttribute['+ aAttribute +'], aMinValue['+ aMinValue +']');
4254		
4255		var theparent = thebox.parentNode;
4256		if(theparent){
4257			if(theparent.tagName == 'div'){
4258				var attribVal = theparent.getAttribute(aAttribute);
4259				if(attribVal){
4260					if(attribVal >= aMinValue){
4261						retValue = attribVal;
4262						return retValue;
4263					}else{
4264						DebugLog('FindParentDivAttributeValue - parent is div and attribute is set['+ attribVal +'], but not above threshold, go up one level.');
4265						retValue = FindParentDivAttributeValue(theparent,aAttribute,aMinValue);
4266						return retValue;					
4267					}
4268				}else{
4269					DebugLog('FindParentDivAttributeValue - parent is div, but attribute is not set, go up one level.');
4270					retValue = FindParentDivAttributeValue(theparent,aAttribute,aMinValue);
4271					return retValue;					
4272				}
4273			}else{
4274				DebugLog('FindParentDivAttributeValue - parent is not a div, go up one level.');
4275				retValue = FindParentDivAttributeValue(theparent,aAttribute,aMinValue);
4276				return retValue;
4277			}
4278		}else{
4279			DebugLog('FindParentDivAttributeValue - no parent node.');
4280			return -1;
4281		}
4282	}else{
4283		DebugLog('FindParentDivAttributeValue - invalid div ref.');
4284		return -1;
4285	}
4286}
4287
4288
4289
4290//----------------------------------------------------------------------------
4291function getOffset( el ) {
4292    var _x = 0;
4293    var _y = 0;
4294    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
4295        _x += el.offsetLeft - el.scrollLeft;
4296        _y += el.offsetTop - el.scrollTop;
4297        el = el.offsetParent;
4298    }
4299    return { top: _y, left: _x };
4300}
4301
4302
4303//----------------------------------------------------------------------------
4304function getPageOffset( el ) {
4305    var _x = 0;
4306    var _y = 0;
4307    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
4308        _x += el.offsetLeft;
4309        _y += el.offsetTop;
4310        el = el.offsetParent;
4311    }
4312    return { top: _y, left: _x };
4313}
4314
4315//----------------------------------------------------------------------------
4316function EnableItem(aItemID) {
4317var theitem = document.getElementById(aItemID);
4318  if(theitem){
4319    if( theitem.disabled == true){
4320      theitem.disabled = false;
4321    }
4322  }
4323}
4324
4325//----------------------------------------------------------------------------
4326function DisableItem(aItemID) {
4327var theitem = document.getElementById(aItemID);
4328  DebugLog('DisableItem - '+aItemID+' - start');
4329  if(theitem){
4330    DebugLog('DisableItem - '+aItemID+', disabled: '+theitem.disabled);
4331    if( theitem.disabled == false){
4332      theitem.disabled = true;
4333    }
4334  }
4335}
4336
4337//----------------------------------------------------------------------------
4338function MakeItemReadable(aItemID) {
4339var theitem = document.getElementById(aItemID);
4340  if(theitem){
4341    if( theitem.readonly == true){
4342      theitem.readonly = false;
4343    }
4344  }
4345}
4346
4347//----------------------------------------------------------------------------
4348function MakeItemReadOnly(aItemID) {
4349var theitem = document.getElementById(aItemID);
4350  DebugLog('MakeItemReadOnly - '+aItemID+' - start');
4351  if(theitem){
4352    DebugLog('MakeItemReadOnly - '+aItemID+', readonly: '+theitem.readonly);
4353    if( theitem.readonly == false){
4354      theitem.readonly = true;
4355    }
4356  }
4357}
4358
4359
4360
4361
4362//----------------------------------------------------------------------------
4363function StartToggle(aImgName,aFile1,aFile2,aDelay) {
4364var theimg = document.getElementById(aImgName);
4365
4366  //alert('here');
4367  if (theimg != null) {
4368    if ((aDelay > 0) && (theimg.togglestarted != 1)) {
4369      setTimeout("ToggleImage('"+aImgName+"','"+aFile1+"','"+aFile2+"',"+aDelay+");",aDelay);
4370    }
4371  }
4372}
4373
4374//----------------------------------------------------------------------------
4375//DONT CALL THIS ONE DIRECTLY, CALL StartToggle ABOVE
4376function ToggleImage(aImgName,aFile1,aFile2,aDelay) {
4377var theimg = document.getElementById(aImgName);
4378
4379  //alert('here');
4380  if (theimg != null) {
4381    if ( (theimg.toggleimage == null) || (theimg.toggleimage == 1) ) {
4382      theimg.src = aFile2;
4383      theimg.toggleimage = 0;
4384      theimg.togglestarted = 1;
4385    }
4386    else {
4387      theimg.src = aFile1;
4388      theimg.toggleimage = 1;
4389      theimg.togglestarted = 1;
4390    }
4391    if (aDelay > 0) {
4392      setTimeout("ToggleImage('"+aImgName+"','"+aFile1+"','"+aFile2+"',"+aDelay+");",aDelay);
4393	    return true;
4394	  }
4395	}
4396}
4397
4398//----------------------------------------------------------------------------
4399function ScrollDivRight(aDivID) {
4400var thediv = document.getElementById(aDivID);
4401
4402  if (thediv) {
4403    if (thediv.scrollLeftMax) {
4404      thediv.scrollLeft = thediv.scrollLeftMax;
4405    }else{
4406      thediv.scrollLeft = 100000;
4407    }
4408  }
4409}
4410
4411
4412
4413//----------------------------------------------------------------------------
4414function getOffset( el ) {
4415    var _x = 0;
4416    var _y = 0;
4417    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
4418        _x += el.offsetLeft - el.scrollLeft;
4419        _y += el.offsetTop - el.scrollTop;
4420        el = el.offsetParent;
4421    }
4422    return { top: _y, left: _x };
4423}
4424
4425
4426
4427//----------------------------------------------------------------------------
4428function changeBgImage (image, id) {
4429	var element = document.getElementById(id);
4430	element.style.backgroundImage = "url("+image+")";
4431}
4432
4433
4434
4435//----------------------------------------------------------------------------
4436function changeBgColor (theColor, id) {
4437	var element = document.getElementById(id);
4438	element.style.backgroundColor = theColor;
4439}
4440
4441
4442
4443//----------------------------------------------------------------------------
4444function copyToClipboardFromElement(aItemID,anAttribute) {
4445	var theitem = document.getElementById(aItemID);
4446	var theText =  '';
4447	if(theitem){
4448		if(anAttribute == 'innerHTML'){
4449			DebugLog('copyToClipboardFromElement - getting innerHTML');
4450			theText = theitem.innerHTML;
4451		}else{
4452			DebugLog('copyToClipboardFromElement - getting attribute['+anAttribute+']');
4453			theText = theitem.getAttribute(anAttribute);
4454		}
4455		theText = theText.replaceAll('&gt;','>');
4456		theText = theText.replaceAll('&lt;','<');
4457		theText = theText.replaceAll('&amp;','&');
4458		DebugLog('copyToClipboardFromElement - the item['+aItemID+'] attribute['+anAttribute+'], theText['+theText+']');
4459		copyToClipboard(theText);
4460	}else{
4461		DebugLog('copyToClipboardFromElement - the item['+aItemID+'] was not found.');
4462	}
4463}
4464
4465//----------------------------------------------------------------------------
4466function copyControlToClipboard(theControlID) {
4467  var theControl = document.getElementById(theControlID);
4468	if(theControl){
4469		theControl.focus();
4470		theControl.select();
4471		try {
4472			var successful = document.execCommand('copy');
4473			var aMsg = successful ? 'successful' : 'unsuccessful';
4474			DebugLog('copyControlToClipboard - Copying text to clipboard result: ' + aMsg);
4475		} catch (err) {
4476			DebugLog('copyControlToClipboard - Failed to copy to clipboard');
4477		}
4478	}else{
4479		DebugLog('copyControlToClipboard - control ['+theControlID+'] not found');
4480	}
4481}
4482
4483//----------------------------------------------------------------------------
4484function copyToClipboard(theText) {
4485  var textArea;
4486	DebugLog('copyToClipboard - START - theText['+theText+']');
4487	textArea = document.createElement('textArea');
4488  textArea.style.position = 'fixed';
4489  textArea.style.top = 0;
4490  textArea.style.left = 0;
4491  textArea.style.width = '2em';
4492  textArea.style.height = '2em';
4493  textArea.style.padding = 0;
4494  textArea.style.border = 'none';
4495  textArea.style.outline = 'none';
4496  textArea.style.boxShadow = 'none';
4497  textArea.style.background = 'transparent';
4498  textArea.value = theText;
4499  document.body.appendChild(textArea);	
4500	textArea.focus();
4501  textArea.select();
4502
4503  try {
4504    var successful = document.execCommand('copy');
4505    var aMsg = successful ? 'successful' : 'unsuccessful';
4506    DebugLog('copyToClipboard - Copying text to clipboard result: ' + aMsg);
4507  } catch (err) {
4508    DebugLog('copyToClipboard - Failed to copy to clipboard');
4509  }
4510}
4511
4512
4513var clipboardHelper;
4514//----------------------------------------------------------------------------
4515function OLDcopyToClipboard (text) {
4516  if (window.clipboardData) // Internet Explorer
4517  {  
4518    window.clipboardData.setData("Text", text);
4519  }
4520  else
4521  {  
4522    unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
4523    clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);  
4524    clipboardHelper.copyString(text);
4525  }
4526}
4527
4528//----------------------------------------------------------------------------
4529function setFocus(theControlID) {
4530var theControl = document.getElementById(theControlID);
4531  if(theControl){
4532    theControl.focus();
4533		DebugLog('setFocus - set focus on control ['+theControlID+']');
4534  }else{
4535		DebugLog('setFocus - Control not found: ['+theControlID+']');
4536  }
4537}
4538
4539
4540//----------------------------------------------------------------------------
4541function insertTextIntoControl (theControlID,theText) {
4542var theControl = document.getElementById(theControlID);
4543var thePos;
4544  if(theControl){
4545    DebugLog('insertTextIntoControl - Control: '+theControlID);
4546    theControl.focus();
4547    insertAtCursor(theControl, theText);
4548  }else{
4549  DebugLog('insertTextIntoControl - Control not found: '+theControlID);
4550  }
4551}
4552
4553
4554//----------------------------------------------------------------------------
4555//http://jsfiddle.net/Znarkus/Z99mK/
4556function insertAtCursor(myField, myValue) {
4557    //IE support
4558    if (document.selection) {
4559        myField.focus();
4560        sel = document.selection.createRange();
4561        sel.text = myValue;
4562    }
4563    //MOZILLA and others
4564    else if (myField.selectionStart || myField.selectionStart == '0') {
4565        var startPos = myField.selectionStart;
4566        var endPos = myField.selectionEnd;
4567        myField.value = myField.value.substring(0, startPos)
4568            + myValue
4569            + myField.value.substring(endPos, myField.value.length);
4570        myField.selectionStart = startPos + myValue.length;
4571        myField.selectionEnd = startPos + myValue.length;
4572    } else {
4573        myField.value += myValue;
4574    }
4575}
4576
4577
4578//----------------------------------------------------------------------------
4579function selectTextInControl(theControlID) {
4580var theControl = document.getElementById(theControlID);
4581var thePos;
4582  if(theControl){
4583    DebugLog('selectTextInControl - Control['+theControlID+'], length['+theControl.value.length+']');
4584    theControl.focus();
4585    theControl.selectionStart = 0;
4586		theControl.selectionEnd = theControl.value.length;
4587  }else{
4588  DebugLog('selectTextInControl - Control not found: '+theControlID);
4589  }
4590}
4591
4592
4593//----------------------------------------------------------------------------
4594//http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea/2735606#2735606
4595function getCaret(el) { 
4596  if (el.selectionStart) { 
4597    return el.selectionStart; 
4598  } else if (document.selection) { 
4599    el.focus(); 
4600
4601    var r = document.selection.createRange(); 
4602    if (r == null) { 
4603      return 0; 
4604    } 
4605
4606    var re = el.createTextRange(), 
4607        rc = re.duplicate(); 
4608    re.moveToBookmark(r.getBookmark()); 
4609    rc.setEndPoint('EndToStart', re); 
4610
4611    return rc.text.length; 
4612  }  
4613  return 0; 
4614}
4615
4616
4617//----------------------------------------------------------------------------
4618function stopBubbles(e) {
4619
4620  e = e || window.event;
4621  if(e){
4622    e.cancelBubble = true;
4623    if (e.stopPropagation) e.stopPropagation();
4624  }
4625  return false;
4626}
4627
4628
4629//----------------------------------------------------------------------------
4630function getEventTarget(e) {
4631  e = e || window.event;
4632	var targ = e.target || e.srcElement;
4633  if (targ.nodeType == 3) targ = targ.parentNode; // defeat Safari bug
4634  return targ;
4635}
4636
4637//----------------------------------------------------------------------------
4638function PrepCloseMenu(aClickName,aMenuName,aDelay) {
4639var theMenu = document.getElementById(aClickName);
4640	if(theMenu){
4641		if(theMenu.getAttribute('ADcloseTimerSet') == 'true'){
4642			theMenu.setAttribute('ADcloseTimerSet','false');
4643		}else{
4644			theMenu.setAttribute('ADcloseTimerSet','true');
4645			 setTimeout('DoCloseMenu("'+aClickName+'","'+aMenuName+'",'+aDelay+')',aDelay);
4646		}
4647	}
4648
4649}
4650
4651//----------------------------------------------------------------------------
4652function PrepCloseMenuEx(aClickName,aMenuName,aDelay,aCallbackFunc) {
4653var theMenu = document.getElementById(aClickName);
4654	if(theMenu){
4655		if(theMenu.getAttribute('ADcloseTimerSet') == 'true'){
4656			theMenu.setAttribute('ADcloseTimerSet','false');
4657		}else{
4658			theMenu.setAttribute('ADcloseTimerSet','true');
4659			setTimeout('DoCloseMenuEx("'+aClickName+'","'+aMenuName+'",'+aDelay+','+aCallbackFunc+')',aDelay);	
4660		}
4661	}
4662  
4663}
4664
4665//----------------------------------------------------------------------------
4666function DoCloseMenu(aClickName,aMenuName,aDelay) {
4667	DoCloseMenuEx(aClickName,aMenuName,aDelay,null); 
4668}
4669//----------------------------------------------------------------------------
4670function DoCloseMenuEx(aClickName,aMenuName,aDelay,aCallbackFunc) {
4671	DebugLog('DoCloseMenuEx - START - click['+aClickName+'], menu['+aMenuName+']');
4672
4673	if(isMouseInAbsElement(aClickName)){
4674		//DebugLog('DoCloseMenuEx - over click area');
4675		setTimeout('DoCloseMenuEx("'+aClickName+'","'+aMenuName+'",'+aDelay+','+aCallbackFunc+')',aDelay);	
4676		
4677	}else if(isMouseInAbsElement(aMenuName+'Child')){
4678		//DebugLog('DoCloseMenuEx - over menu area');
4679		setTimeout('DoCloseMenuEx("'+aClickName+'","'+aMenuName+'",'+aDelay+','+aCallbackFunc+')',aDelay);		
4680	
4681	}else if(isMouseInAbsElement(aMenuName+'Content')){
4682		//DebugLog('DoCloseMenuEx - over menu area');
4683		setTimeout('DoCloseMenuEx("'+aClickName+'","'+aMenuName+'",'+aDelay+','+aCallbackFunc+')',aDelay);		
4684		
4685	}else{
4686		//DebugLog('DoCloseMenuEx - checking for popup dialog next');
4687		var keepGoing = true;
4688		var thedlg = document.getElementById('PopUpDlg');
4689		if(thedlg){
4690			//DebugLog('DoCloseMenuEx - found popup dialog box on page');
4691			if(thedlg.style.display == 'none'){
4692				//DebugLog('DoCloseMenuEx - popup dialog is closed');
4693			}else{
4694				//DebugLog('DoCloseMenuEx - POPUP DIALOG IS STILL OPEN, KEEP WAITING');
4695				keepGoing = false;
4696				setTimeout('DoCloseMenuEx("'+aClickName+'","'+aMenuName+'",'+aDelay+','+aCallbackFunc+')',aDelay);	
4697			}
4698		}else{
4699			//DebugLog('DoCloseMenuEx - no popup dialog found!');
4700		}
4701		
4702		if(keepGoing){
4703			//DebugLog('DoCloseMenuEx - click['+aClickName+'], menu['+aMenuName+'] - closing now');
4704			var theMenu = document.getElementById(aClickName);
4705			if(theMenu){
4706				theMenu.setAttribute('ADcloseTimerSet','false');
4707			}		
4708			//DebugLog('DoCloseMenuEx - closing menu now');
4709			AnimateDivClose(aMenuName);
4710			if(aCallbackFunc){
4711				DebugLog('DoCloseMenuEx - click['+aClickName+'], menu['+aMenuName+'] - have callback, calling it now');
4712				aCallbackFunc();
4713			}
4714		}
4715	}
4716}
4717
4718
4719
4720//----------------------------------------------------------------------------
4721function AnimateDivUpDown(aDivName,aWidth,closedHeight,openHeight) {
4722	DebugLog('AnimateDivUpDown - for ['+aDivName+']');
4723  return AnimateDivUpDownEx(aDivName,aWidth,closedHeight,openHeight,150);
4724}
4725
4726//----------------------------------------------------------------------------
4727function AnimateDivOpen(aDivName) {
4728var thebox = document.getElementById(aDivName);
4729  if(thebox){
4730    DebugLog('AnimateDivOpen - box['+aDivName+']');
4731    thebox.setAttribute('ADopen','false'); //TELL THE BOX IT IS CLOSED SO THAT IT WILL OPEN
4732  }
4733  return AnimateDivUpDownEx(aDivName,-1,-1,-1,-1);
4734}
4735
4736//----------------------------------------------------------------------------
4737function AnimateDivClose(aDivName) {
4738var thebox = document.getElementById(aDivName);
4739
4740  if(thebox){
4741		DebugLog('AnimateDivClose - for ['+aDivName+']');
4742    thebox.setAttribute('ADopen','true'); //TELL THE BOX IT IS OPEN SO IT WILL CLOSE
4743  }
4744  return AnimateDivUpDownEx(aDivName,-1,-1,-1,-1);
4745}
4746
4747//----------------------------------------------------------------------------
4748function AnimateDivSetOpen(aDivName,aWidth,closedHeight,openHeight,aniSpeed) {
4749var thebox = document.getElementById(aDivName);
4750  if(thebox){
4751    DebugLog('AnimateDivSetOpen - doing open for ['+aDivName+']');
4752    thebox.setAttribute('ADopen','false'); //TELL THE BOX IT IS CLOSED SO THAT IT WILL OPEN
4753  }
4754	SetAnimateDiv(aDivName,aWidth,closedHeight,openHeight,aniSpeed); 
4755  return AnimateDivUpDownEx(aDivName,aWidth,closedHeight,openHeight,aniSpeed);
4756}
4757
4758//----------------------------------------------------------------------------
4759function AnimateDivSetClose(aDivName,aWidth,closedHeight,openHeight,aniSpeed) {
4760var thebox = document.getElementById(aDivName);
4761
4762  if(thebox){
4763		DebugLog('AnimateDivSetClose - doing close for ['+aDivName+']');
4764    thebox.setAttribute('ADopen','true'); //TELL THE BOX IT IS OPEN SO THAT IT WILL CLOSE
4765  }
4766	SetAnimateDiv(aDivName,aWidth,closedHeight,openHeight,aniSpeed); 
4767  return AnimateDivUpDownEx(aDivName,aWidth,closedHeight,openHeight,aniSpeed);
4768}
4769
4770//----------------------------------------------------------------------------
4771function PrepAnimateDiv(aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) {
4772  PrepAnimateDivAux(0,aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) 
4773}  
4774
4775//----------------------------------------------------------------------------
4776function PrepAnimateDivAux(aCount,aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) {
4777var thebox = document.getElementById(aDivName);
4778
4779  if(thebox){
4780    DebugLog('PrepAnimateDivAux - found box ['+aDivName+']');
4781    SetAnimateDiv(aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) 
4782    
4783  }else{
4784    newCount = aCount + 1;
4785    if(newCount > 100){
4786      DebugLog('PrepAnimateDivAux - failed after 100 attempts to find ['+aDivName+']');
4787    }else{
4788      setTimeout("PrepAnimateDivAux("+newCount+",'"+aDivName+"',"+aWidth+","+aClosedHeight+","+aOpenHeight+","+aAniSpeed+")",50);
4789    }
4790  }
4791}  
4792
4793//----------------------------------------------------------------------------
4794function SetAnimateDiv(aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) {
4795var thebox = document.getElementById(aDivName);
4796
4797  if(thebox){
4798    DebugLog('SetAnimateDiv - found box ['+aDivName+']');
4799    thebox.setAttribute('ADwidth',aWidth);
4800    thebox.setAttribute('ADclosedHeight',aClosedHeight);
4801    thebox.setAttribute('ADopenHeight',aOpenHeight);
4802    thebox.setAttribute('ADaniSpeed',aAniSpeed);
4803    DebugLog('SetAnimateDiv - made box settings - width['+aWidth+'], closedHeight['+aClosedHeight+'], openHeight['+aOpenHeight+'], aniSpeed['+aAniSpeed+']');
4804
4805   }
4806}  
4807
4808
4809//----------------------------------------------------------------------------
4810function SetAnimateDivSelectClass(aDivName,aSelectedClassName){
4811var thebox = document.getElementById(aDivName);
4812
4813  if(thebox){
4814    DebugLog('SetAnimateDivSelectClass - found div ['+aDivName+'], setting class to add['+aSelectedClassName+']');
4815    thebox.setAttribute('ADselClass',aSelectedClassName);
4816   }else{
4817		 DebugLog('SetAnimateDivSelectClass - didnt find the div ['+aDivName+']');
4818	 }
4819	
4820}
4821
4822var g_ADrecursion = false;
4823
4824//----------------------------------------------------------------------------
4825function AnimateDivUpDownEx(aDivName,aWidth,aClosedHeight,aOpenHeight,aAniSpeed) {
4826var thebox = document.getElementById(aDivName);
4827var thechild = document.getElementById(aDivName+'Child');
4828var thehold = document.getElementById(aDivName+'hold');
4829var theWidth;
4830var theArrowName;
4831var theArrow;
4832var newsrc;
4833var newopenheight;
4834var newopenwidth;
4835var retVal;
4836var closedHeight;
4837var openHeight;
4838var aniSpeed;
4839var clickDivName = aDivName + 'Click';
4840var curTop = 0;
4841var curLeft = 0;
4842var calcChildHeight = 0;
4843
4844  retVal = 0;
4845  if(thebox){
4846		curTop = parseInt(thebox.style.top);
4847		curLeft = parseInt(thebox.style.left);
4848		
4849     DebugLog('AnimateDivUpDownEx - START - found div ['+aDivName+'], anispeed['+aAniSpeed+']');
4850    if(aAniSpeed == -1){
4851			DebugLog('AnimateDivUpDownEx - anispeed set to -1 get values from the DIV settings');
4852      theWidth = thebox.getAttribute('ADwidth');
4853      closedHeight = thebox.getAttribute('ADclosedHeight');
4854      openHeight = thebox.getAttribute('ADopenHeight');
4855      aniSpeed = thebox.getAttribute('ADaniSpeed');
4856      DebugLog('AnimateDivUpDownEx - ['+aDivName+'] have DIV settings - width['+theWidth+'], closedHeight['+closedHeight+'], openHeight['+openHeight+'], aniSpeed['+aniSpeed+']');
4857      
4858    }else{
4859       DebugLog('AnimateDivUpDownEx - ['+aDivName+'] use parameters - width['+aWidth+'], closedHeight['+aClosedHeight+'], openHeight['+aOpenHeight+'], aniSpeed['+aAniSpeed+']');
4860      if(aWidth == -1){
4861				if(thebox.width){
4862					theWidth = thebox.width;
4863				}else{
4864					theWidth = 0;
4865				}
4866        
4867      }
4868      else{
4869        theWidth = aWidth;
4870      }
4871			//store the settings
4872			if(typeof theWidth !== 'undefined'){thebox.setAttribute('ADwidth',theWidth)}
4873			if(typeof aClosedHeight !== 'undefined'){thebox.setAttribute('ADclosedHeight',aClosedHeight)}
4874			if(typeof aOpenHeight !== 'undefined'){thebox.setAttribute('ADopenHeight',aOpenHeight)}
4875			if(typeof aAniSpeed !== 'undefined'){thebox.setAttribute('ADaniSpeed',aAniSpeed)}
4876
4877      DebugLog('AnimateDivUpDownEx - ['+aDivName+'] updated DIV settings - width['+thebox.getAttribute('ADwidth')+'], closedHeight['+thebox.getAttribute('ADclosedHeight')+'], openHeight['+thebox.getAttribute('ADopenHeight')+'], aniSpeed['+thebox.getAttribute('ADaniSpeed')+']');
4878      
4879      closedHeight = aClosedHeight;
4880      openHeight = aOpenHeight;
4881      aniSpeed = aAniSpeed;
4882    }
4883
4884    if(theWidth == 0){
4885			if(thehold){
4886				newopenwidth = thehold.clientWidth + 4;
4887				DebugLog('AnimateDivUpDownEx - auto width setting - theHold new width is ['+ new
4887openwidth +']');
4888			}else{
4889				if(thechild){
4890					if(thechild.clientWidth <= 4){
4891						if(thechild.getAttribute('ADcalcWidth')){
4892							newopenwidth = thechild.getAttribute('ADcalcWidth');
4893							DebugLog('AnimateDivUpDownEx - auto width setting - theChild (calc stored) new width is ['+ newopenwidth +']');
4894						}else{
4895							thebox.style.visibility = 'visible';
4896							thebox.style.opacity = 0.001;
4897							thebox.style.width = 'auto';
4898							thebox.style.height = 'auto';
4899							thebox.style.whiteSpace = 'pre';
4900							newopenwidth = thechild.clientWidth;
4901							calcChildHeight = thechild.clientHeight;
4902							DebugLog('AnimateDivUpDownEx - auto width setting - recalc theChild - new width is ['+ newopenwidth +']');
4903							//thebox.style.visibility = 'hidden';
4904							thebox.style.width = newopenwidth +'px';  //DEFAULT DIV TO WIDTH OF CHILD
4905							thebox.style.height = '0px';	
4906							thebox.style.opacity = 1;		
4907							thechild.setAttribute('ADcalcWidth',newopenwidth);					
4908							thechild.setAttribute('ADcalcHeight',calcChildHeight);
4909						}
4910					}else{
4911						newopenwidth = thechild.clientWidth + 4;
4912						DebugLog('AnimateDivUpDownEx - auto width setting - theChild new width is ['+ newopenwidth +']');
4913					}
4914				}else{
4915					newopenwidth = thebox.clientWidth + 4;
4916					DebugLog('AnimateDivUpDownEx - auto width setting - theBox new width is ['+ newopenwidth +']');
4917				}				
4918			}
4919
4920    }else{
4921      //newopenwidth = thebox.width;
4922      newopenwidth = theWidth;
4923			DebugLog('AnimateDivUpDownEx - auto width setting - ELSE new width is ['+ newopenwidth +']');
4924    }      
4925
4926
4927    theArrowName = aDivName + 'Arrow';
4928    theArrow = document.getElementById(theArrowName);
4929		 DebugLog('AnimateDivUpDownEx - box status - open flag['+thebox.getAttribute('ADopen')+']');
4930     if(thebox.getAttribute('ADopen') == '' || thebox.getAttribute('ADopen') == null || thebox.getAttribute('ADopen') == 'false')
4931     {
4932        if(openHeight == 0){
4933					if(thehold){
4934						//newopenheight = thehold.clientHeight + 4;
4935						newopenheight = thehold.scrollHeight + 4;
4936						DebugLog('AnimateDivUpDownEx - auto height setting - theHold new height is ['+ newopenheight +']');
4937					}else{
4938						if(thechild){
4939							if(calcChildHeight){
4940								newopenheight = calcChildHeight;
4941								DebugLog('AnimateDivUpDownEx - auto height setting - calc theChild - new height is ['+ newopenheight +']');
4942							}else{
4943								if(thechild.getAttribute('ADcalcHeight')){
4944									newopenheight = thechild.getAttribute('ADcalcHeight');
4945									DebugLog('AnimateDivUpDownEx - auto height setting - theChild (calc stored) new height is ['+ newopenheight +']');
4946								
4947								}else{
4948									newopenheight = thechild.clientHeight + 4;
4949									DebugLog('AnimateDivUpDownEx - auto height setting - theChild new height is ['+ newopenheight +']');
4950								}
4951							}
4952						}else{
4953							newopenheight = thebox.clientHeight + 4;
4954							DebugLog('AnimateDivUpDownEx - auto height setting - theBox new height is ['+ newopenheight +']');
4955						}						
4956					}
4957
4958        }else{
4959          newopenheight = openHeight;
4960					DebugLog('AnimateDivUpDownEx - auto height setting - ELSE new height is ['+ newopenheight +']');
4961        }
4962        DebugLog('AnimateDivUpDownEx - box is CLOSED, going to open - newopenwidth['+ newopenwidth +'], newopenheight['+ newopenheight +'], aniSpeed['+ aniSpeed +']'); 
4963        
4964				//LOOK FOR AN PROCESS OTHER DIVS OF THE SAME GROUP PREFIX__RESTOFNAMEHERE - BUT ONLY IF WE AREN'T ALREADY DOING THIS SECTION
4965        var dubUS = aDivName.indexOf('__');
4966				if((dubUS >= 0) && (g_ADrecursion == false)){
4967					DebugLog('AnimateDivUpDownEx - found double underscore in div name['+aDivName+'] at pos ['+ dubUS +']');
4968					var divprefix = aDivName.slice(0,dubUS + 2);
4969					 DebugLog('AnimateDivUpDownEx - div group prefix is['+divprefix+']');
4970					//document.querySelector('[id^="gatewayContainerstacks"]')
4971					//document.querySelectorAll('[id^="gatewayContainerstacks"]')
4972					var groupDivList = document.querySelectorAll('[id^="'+divprefix+'"]');
4973					if(groupDivList){
4974						DebugLog('Found matching divs');
4975						for(var i = 0;i < groupDivList.length; ++i){
4976							DebugLog('Here is one of the divs ['+ groupDivList[i].id +']');
4977							if(aDivName.valueOf() == groupDivList[i].id.valueOf()){
4978								DebugLog('this is the one we just clicked on - dont do anything');
4979							}else{
4980								var thecurdiv = document.getElementById(groupDivList[i].id);
4981								
4982								if(thecurdiv){
4983									var thedivname = thecurdiv.id;
4984									var childpos = thedivname.indexOf('Child',thedivname.length - 5);
4985									if(childpos >= 0){
4986										DebugLog('this is a child div we want to look at');
4987										var theparentname = thedivname.slice(0,thedivname.length - 5);
4988										DebugLog('this is the parent of the child['+ theparentname +']');
4989										var theparent = document.getElementById(theparentname);
4990										if(theparent){
4991											if(theparent.getAttribute('ADopen') == 'true'){
4992												DebugLog('the div['+ thedivname +'] is open, so CLOSE IT NOW');
4993												g_ADrecursion = true;
4994												AnimateDivUpDownEx(theparentname,0,0,0,aAniSpeed);
4995												g_ADrecursion = false;
4996												DebugLog('the div['+ thedivname +'] finshed doing the close.');
4997											}
4998										}
4999									}
5000								}
5001							}
5002						}
5003					}else{
5004						DebugLog('Didnt find any matching divs');
5005					}
5006				}
5007				 
5008				
5009				if(openHeight != 0){
5010					DebugLog('AnimateDivUpDownEx - openHeight is set, add overflow auto as callback');
5011					animate(aDivName, curLeft, curTop, newopenwidth, newopenheight, aniSpeed, PostOpenAddAuto);
5012					//thebox.style.overflowY = 'auto';
5013				}else{
5014					DebugLog('AnimateDivUpDownEx - animate call - newWidth['+ newopenwidth +'], newHeight['+ newopenheight +'], speed['+ aniSpeed +']');
5015					animate(aDivName, curLeft, curTop, newopenwidth, newopenheight, aniSpeed, PostOpenAddAuto);
5016				}
5017				thebox.setAttribute('ADopen','true');
5018				
5019				
5020				var cntDivName = aDivName + 'Content';
5021				var cntDiv = document.getElementById(cntDivName);
5022				if(cntDiv){
5023					//DebugLog('found Content div inside Dyn div named ['+ cntDivName +'] and we are opening'); 
5024					if(cntDiv.style.overflowY != 'auto'){
5025						cntDiv.style.overflowY = 'auto';
5026					}
5027				}
5028				
5029				
5030				//CHECK FOR AND ADD THE SELECTED CLASS IF ONE IS SET FOR THIS DIV
5031				if(thebox.getAttribute('ADselClass')){
5032					DebugLog('we need to apply the selected class['+ thebox.getAttribute('ADselClass') +'] to the div');
5033					AddClass(clickDivName,thebox.getAttribute('ADselClass'));
5034				}
5035				
5036        //headerElement.innerHTML = 'vvv';
5037        //thebox.innerHTML = 'opened - width: '+theWidth+', height: '+openHeight
5038        if(theArrow != null){
5039          DebugLog('arrow src = '+theArrow.src);
5040          if(theArrow.src.indexOf('down-arrow') > -1){
5041            theArrow.src = theArrow.src.replace('down-arrow','up-arrow');
5042          }else{
5043            theArrow.src = theArrow.src.replace('down','up');
5044          }
5045        }
5046        retVal = 1;
5047     }
5048     else
5049     {
5050
5051        DebugLog('AnimateDivUpDownEx - box is OPEN, going to close it - newopenwidth['+newopenwidth+'], closedHeight['+closedHeight+'], aniSpeed['+aniSpeed+']'); 
5052
5053				if(openHeight != 0){
5054					 DebugLog('AnimateDivUpDownEx - openHeight is set, remove overflow auto');
5055					thebox.style.overflowY = 'hidden';
5056				}
5057				
5058        animate(aDivName, curLeft, curTop, newopenwidth, closedHeight, aniSpeed, null);
5059        thebox.setAttribute('ADopen','false');
5060
5061				
5062				var cntDivName = aDivName + 'Content';
5063				var cntDiv = document.getElementById(cntDivName);
5064				if(cntDiv){
5065					//DebugLog('found Content div inside Dyn div named ['+ cntDivName +'] and we are closing'); 
5066					if(cntDiv.style.overflowY == 'auto'){
5067						cntDiv.style.overflowY = 'hidden';
5068					}
5069				}
5070				
5071				
5072				//CHECK FOR AND REMOVE THE SELECTED CLASS IF ONE IS SET FOR THIS DIV
5073				if(thebox.getAttribute('ADselClass')){
5074					 DebugLog('we need to remove the selected class['+ thebox.getAttribute('ADselClass') +'] for the div');
5075					RemoveClass(clickDivName,thebox.getAttribute('ADselClass'));
5076				}
5077				
5078        if(theArrow != null){
5079          //alert('arrow src = '+theArrow.src);
5080          if(theArrow.src.indexOf('down-arrow') > -1){
5081            theArrow.src = theArrow.src.replace('up-arrow','down-arrow');
5082          }else{
5083            theArrow.src = theArrow.src.replace('up','down');
5084          }
5085        }
5086        //headerElement.innerHTML = '^^^';
5087        //thebox.innerHTML = 'closed - width: '+theWidth+', height: '+closedHeight
5088        retVal = 2;
5089     }
5090   }else{
5091     DebugLog('AnimateDivUpDownEx - the box['+aDivName+'] was not found.');
5092   }
5093	 
5094	 DebugLog('AnimateDivUpDownEx - END');
5095   return retVal;
5096}
5097
5098//----------------------------------------------------------------------------
5099function PostOpenAddAuto(aElementID){
5100	DebugLog('PostOpenAddAuto - for element['+aElementID+']');
5101	var thebox = document.getElementById(aElementID);
5102	if(thebox){
5103		var firstChild = thebox.getElementsByTagName('div')[0];
5104		if(firstChild){
5105			if(firstChild.style.overflowY == 'auto'){
5106				//WE DON'T NEED TO APPLY IT IF IT IS ALREADY IN THE CHILD DIV
5107			}else{
5108				//2018-11-9 MSH - removed this condition based on wrk289452577, but might have side effects
5109				//if(thebox.adopenheight && theboxadopenheight > 0){
5110					//thebox.style.overflowY = 'auto';
5111					//DebugLog('PostOpenAddAuto - adding (first child no auto) overflowY = auto');
5112				//}else{
5113					//THIS DOESN'T LOOOK LIKE A BOX WE HAVE TO ADJUST
5114				//}
5115			}
5116		}else{
5117			thebox.style.overflowY = 'auto';
5118			DebugLog('PostOpenAddAuto - adding (no first child) overflowY = auto');
5119		}
5120		
5121		
5122	}
5123}
5124
5125
5126//----------------------------------------------------------------------------
5127function AnimateDiv(aDivName,closedWidth,openWidth,closedHeight,openHeight) {
5128  return AnimateDivEx(aDivName,closedWidth,openWidth,closedHeight,openHeight,150);
5129}
5130
5131//----------------------------------------------------------------------------
5132function AnimateDivEx(aDivName,closedWidth,openWidth,closedHeight,openHeight,aniSpeed) {
5133var thebox = document.getElementById(aDivName);
5134var thechild = document.getElementById(aDivName+'Child');
5135var theWidth;
5136var theArrowName;
5137var theArrow;
5138var newsrc;
5139var newopenheight;
5140var newopenwidth;
5141var retVal;
5142var curLeft = 0;
5143var curTop = 0;
5144
5145  retVal = 0;
5146
5147	if(thebox){
5148		curTop = parseInt(thebox.style.top);
5149		curLeft = parseInt(thebox.style.left);
5150	}
5151
5152  theArrowName = aDivName + 'Arrow';
5153  theArrow = document.getElementById(theArrowName);
5154
5155   if(thebox.getAttribute('ADopen') == '' || thebox.getAttribute('ADopen') == null || thebox.getAttribute('ADopen') == 'false')
5156   {
5157      if(openHeight == 0){
5158        if(thechild){
5159          newopenheight = thechild.clientHeight + 4;
5160        }else{
5161          newopenheight = thebox.clientHeight + 4;
5162        }
5163      }else{
5164        newopenheight = openHeight;
5165      }
5166      
5167      if(openWidth == 0){
5168        if(thechild){
5169          newopenwidth = thechild.clientWidth + 4;
5170        }else{
5171          newopenwidth = thebox.clientWidth + 4;
5172        }
5173      }else{
5174        newopenwidth = openWidth;
5175      }
5176      
5177      
5178      animate(aDivName, curLeft, curTop, newopenwidth, newopenheight, aniSpeed, null);
5179      thebox.setAttribute('ADopen','true');
5180
5181      //headerElement.innerHTML = 'vvv';
5182      //thebox.innerHTML = 'opened - width: '+theWidth+', height: '+openHeight
5183      if(theArrow != null){
5184        //DebugLog('arrow src = '+theArrow.src);
5185        if(theArrow.src){
5186          if(theArrow.src.indexOf('down-arrow') > -1){
5187            theArrow.src = theArrow.src.replace('down-arrow','up-arrow');
5188          }else{
5189            theArrow.src = theArrow.src.replace('down','up');
5190          }
5191        }
5192      }
5193      retVal = 1;
5194   }
5195   else
5196   {
5197
5198      animate(aDivName, curLeft, curTop, closedWidth, closedHeight, aniSpeed, null);
5199      thebox.setAttribute('ADopen','false');
5200
5201      if(theArrow != null){
5202        //alert('arrow src = '+theArrow.src);
5203        if(theArrow.src){
5204          if(theArrow.src.indexOf('down-arrow') > -1){
5205            theArrow.src = theArrow.src.replace('up-arrow','down-arrow');
5206          }else{
5207            theArrow.src = theArrow.src.replace('up','down');
5208          }
5209        }
5210      }
5211      //headerElement.innerHTML = '^^^';
5212      //thebox.innerHTML = 'closed - width: '+theWidth+', height: '+closedHeight
5213      retVal = 2;
5214   }
5215   return retVal;
5216}
5217
5218//----------------------------------------------------------------------------
5219function IsAnimateDivOpen(aDivName){
5220var thebox = document.getElementById(aDivName);
5221
5222  if(thebox.getAttribute('ADopen') == '' || thebox.getAttribute('ADopen') == null || thebox.getAttribute('ADopen') == 'false') {
5223    return false;
5224  }
5225  else {
5226    return true;
5227  }
5228  
5229}
5230
5231
5232//----------------------------------------------------------------------------
5233function animate(elementID, newLeft, newTop, newWidth, newHeight, time, callback)
5234{
5235	DebugLog('animate - start - newLeft['+newLeft+'], newTop['+newTop+'], newWidth['+newWidth+'], newHeight['+newHeight+']');
5236  var el = document.getElementById(elementID);
5237  if(el == null)
5238    return;
5239 
5240  var cLeft = parseInt(el.style.left);
5241  var cTop = parseInt(el.style.top);
5242  var cWidth = parseInt(el.style.width);
5243	if(isNaN(cWidth)){
5244		DebugLog('animate - setting to zero');
5245		cWidth = 0;
5246	}
5247	
5248  var cHeight = parseInt(el.style.height);
5249 
5250  var totalFrames = 1;
5251  if(time > 2000){
5252		totalFrames = time/50;
5253	}else if(time > 1000){
5254		totalFrames = time/50;
5255	}else if(time > 500){
5256		totalFrames = time/50;
5257	}else if(time > 200){
5258		totalFrames = time/50;
5259	}else if(time > 0){
5260		totalFrames = time/50;
5261	}
5262    	
5263  el.aniFrameTotal = totalFrames; //SAVE THE TOTAL FRAME COUNT IN THE DIV OBJ
5264  el.aniFrameCount = 0; //ALSO KEEP TRACK OF THE FRAMES RENDERED IN THE DIV OBJ TOO
5265
5266  var fLeft = newLeft - cLeft;
5267  if(fLeft != 0)
5268    fLeft /= totalFrames;
5269 
5270  var fTop = newTop - cTop;
5271  if(fTop != 0)
5272    fTop /= totalFrames;
5273 
5274	DebugLog('animate - before fWidth calc - newwidth['+newWidth+'], cWidth['+cWidth+']'); 
5275  var fWidth = newWidth - cWidth;
5276	DebugLog('animate - after fWidth calc - fWidth['+fWidth+']');
5277  if(fWidth != 0)
5278    fWidth /= totalFrames;
5279	DebugLog('animate - after fWidth frames calc - fWidth['+fWidth+']');
5280	
5281  var fHeight = newHeight - cHeight;
5282  if(fHeight != 0)
5283    fHeight /= totalFrames;
5284   
5285	DebugLog('animate - before doFrame - left['+fLeft+'], top['+fTop+'], width['+fWidth+'], height['+fHeight+']');
5286  doFrame(elementID, cLeft, newLeft, fLeft,
5287      cTop, newTop, fTop, cWidth, newWidth, fWidth,
5288      cHeight, newHeight, fHeight, callback);
5289}
5290
5291//----------------------------------------------------------------------------
5292function doFrame(eID, cLeft, nLeft, fLeft,
5293      cTop, nTop, fTop, cWidth, nWidth, fWidth,
5294      cHeight, nHeight, fHeight, callback)
5295{
5296   var el = document.getElementById(eID);
5297   if(el == null)
5298     return;
5299
5300  el.aniFrameCount = el.aniFrameCount + 1;
5301
5302  cLeft = moveSingleVal(cLeft, nLeft, fLeft);
5303  cTop = moveSingleVal(cTop, nTop, fTop);
5304  cWidth = moveSingleVal(cWidth, nWidth, fWidth);
5305  cHeight = moveSingleVal(cHeight, nHeight, fHeight);
5306
5307	DebugLog('doFrame - cur width['+el.style.width+'], new width['+ Math.round(cWidth) + 'px' +']');
5308  el.style.left = Math.round(cLeft) + 'px';
5309  el.style.top = Math.round(cTop) + 'px';
5310  el.style.width = Math.round(cWidth) + 'px';
5311  el.style.height = Math.round(cHeight) + 'px';
5312 
5313  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
5314    && cWidth == nWidth)
5315  {
5316    el.aniFrameCount = 0;
5317    if(callback != null)
5318      callback(eID); 
5319    return; //WE ARE DONE, SO BAIL OUT NOW
5320  }
5321  else{ 
5322    //CHECK FOR THE FRAME COUNT LIMITATION
5323    if(  el.aniFrameCount > (el.aniFrameTotal + 1)){
5324      //alert('max: '+el.aniFrameTotal+', count: '+el.aniFrameCount);
5325      el.aniFrameCount = 0;
5326      if(callback != null)
5327        callback(eID);
5328      return;
5329    }
5330    else{
5331      //WE NEED TO KEEP RENDERING FRAMES, GET READY TO DO THE NEXT FRAME
5332      setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','
5333        +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','
5334        +cHeight+','+nHeight+','+fHeight+','+callback+')', 50);
5335    }
5336  }
5337}
5338
5339//----------------------------------------------------------------------------
5340function moveSingleVal(currentVal, finalVal, frameAmt)
5341{
5342  if(frameAmt == 0 || currentVal == finalVal)
5343    return finalVal;
5344 
5345  currentVal += frameAmt;
5346  if((frameAmt> 0 && currentVal>= finalVal)
5347    || (frameAmt <0 && currentVal <= finalVal))
5348  {
5349    return finalVal;
5350  }
5351  return currentVal;
5352}
5353
5354
5355//----------------------------------------------------------------------------
5356function GetOpacity(aElement){
5357var theOp = null;
5358
5359  if(aElement){
5360    if(aElement.style.opacity){
5361      theOp = aElement.style.opacity;
5362    }else{
5363      if(aElement.style.filter){
5364        theOp = aElement.style.filter; //alpha(opacity=90)
5365      }else{
5366        theOp = 1.0;
5367      }
5368    }
5369  }
5370return theOp;
5371} 
5372
5373
5374//----------------------------------------------------------------------------
5375function SetOpacity(aElement,anOpacity){
5376  if(aElement){
5377    if(aElement.style.opacity){
5378      if(anOpacity <= 0){
5379        DebugLog('SetOpacity - given['+anOpacity+'], force to zero');
5380        aElement.style.opacity = 0.0;
5381        //setTimeout("SetZeroOpacityAgain('"+ aElement.id +"')",2000);
5382      }else if(anOpacity >= 1){
5383        DebugLog('SetOpacity - given['+anOpacity+'], force to 1.0');
5384        aElement.style.opacity = 1.0;      
5385      }else{
5386        DebugLog('SetOpacity - given['+anOpacity+'] set as given');
5387        aElement.style.opacity = anOpacity;
5388      }
5389    }else{
5390      if(aElement.style.filter){
5391        if(anOpacity <= 0){
5392          aElement.style.filter = 'alpha(opacity=0)'; //alpha(opacity=90)
5393        }else if(anOpacity >= 1){
5394          aElement.style.filter = 'alpha(opacity=100)'; //alpha(opacity=90)
5395        }else{
5396          aElement.style.filter = 'alpha(opacity='+ (anOpacity*100) +')'; //alpha(opacity=90)
5397        }
5398      }else{
5399        aElement.style.opacity = anOpacity;
5400      }
5401    }
5402  }
5403}
5404
5405
5406//----------------------------------------------------------------------------
5407function SetZeroOpacityAgain(aElementID){
5408var aElement = document.getElementById(aElementID);
5409  DebugLog('SetZeroOpacityAgain - divName['+aElementID+']');
5410  if(aElement){
5411    if(aElement.style.opacity){
5412      DebugLog('SetZeroOpacityAgain - setting it to zero in a callback');
5413      aElement.style.opacity = -1.0;
5414    }
5415  }
5416}
5417
5418
5419
5420//----------------------------------------------------------------------------
5421function SetSweep(aElement,aDirection,aDecSweep,aTargetSize){
5422var newVal = 0;
5423
5424  if(aElement){
5425    switch(aDirection){
5426      case 1: //LEFT TO RIGHT
5427        newVal = Math.round( aTargetSize * (1-aDecSweep) );
5428        if(newVal < 0) newVal = 0;
5429        
5430        DebugLog('SetSweep(L 2 R): cur width = '+aElement.clientWidth+', scale to pct['+aDecSweep+']');
5431        DebugLog('SetSweep(L 2 R): new width = '+newVal);
5432        aElement.style.width = newVal+'px';
5433        break;
5434        
5435      case 2: //RIGHT TO LEFT
5436        newVal =Math.round( aTargetSize * aDecSweep );
5437        if(newVal < 0) newVal = 0;
5438        
5439        DebugLog('SetSweep(R 2 L): cur width = '+aElement.clientWidth+', scale to pct['+aDecSweep+']');
5440        DebugLog('SetSweep(R 2 L): new width = '+newVal);
5441        aElement.style.width = newVal+'px';
5442        break;
5443
5444      case 3: //TOP TO BOTTOM
5445        newVal =Math.round( aTargetSize * aDecSweep );
5446        if(newVal < 0) newVal = 0;
5447        
5448        DebugLog('SetSweep(T 2 B): cur height = '+aElement.clientHeight+', scale to pct['+aDecSweep+']');
5449        DebugLog('SetSweep(T 2 B): new height = '+newVal);
5450        aElement.style.height = newVal+'px';
5451        break;
5452
5453    
5454    }
5455  }
5456}
5457
5458//----------------------------------------------------------------------------
5459function HoverDivLoad(aDivName) {
5460var thebox = document.getElementById(aDivName);
5461var theOp = null;
5462
5463  DebugLog('HoverDivLoad - START - div['+aDivName+']');
5464  if(thebox){
5465    //theOp = GetOpacity(thebox);
5466    //DebugLog('HoverDivLoad - thebox opacity = '+theOp);
5467
5468    var parentdiv = thebox.parentNode;
5469    if(parentdiv){
5470      //DebugLog('parentdiv - id['+parentdiv.id+']');
5471      //DebugLog('parentdiv - background color['+parentdiv.style.backgroundColor+']');
5472      if(thebox.style.backgroundImage == ''){
5473        //DebugLog('thebox - no background image');
5474        if(thebox.style.backgroundColor == ''){
5475          //DebugLog('thebox - no background color, set to parent backgroundColor');
5476          thebox.style.backgroundColor = parentdiv.style.backgroundColor;
5477        }
5478      }
5479    }
5480  }
5481}
5482
5483
5484//----------------------------------------------------------------------------
5485function HoverDivFade(aDivName,orgWidth,orgHeight,fadeTime,aniMode) {
5486var thebox = document.getElementById(aDivName);
5487var theOp = null;
5488  //DebugLog('HOVERDIV');
5489  DebugLog('HoverDivFade - START - div['+aDivName+']');
5490  
5491  theOp = GetOpacity(thebox);
5492  //DebugLog('HoverDivFade - thebox opacity = '+theOp);
5493  //element.style.filter = 'alpha(opacity=90)'; // USE IE FALLBACK
5494  /*
5495  var parentdiv = thebox.parentNode;
5496  if(parentdiv){
5497    DebugLog('parentdiv - id['+parentdiv.id+']');
5498    DebugLog('parentdiv - background color['+parentdiv.style.backgroundColor+']');
5499    if(thebox.style.backgroundImage == ''){
5500      DebugLog('thebox - no background image');
5501      if(thebox.style.backgroundColor == ''){
5502        DebugLog('thebox - no background color, set to parent backgroundColor');
5503        thebox.style.backgroundColor = parentdiv.style.backgroundColor;
5504      }
5505    }
5506  }
5507  */
5508  
5509  thebox.fadeAniMode = aniMode;
5510  thebox.orgClientWidth = orgWidth;
5511  thebox.orgClientHeight = orgHeight;
5512  DebugLog('HoverDivFade - orgWidth ['+orgWidth+'], orgHeight ['+orgHeight+']');
5513  
5514  if(thebox.fadecomplete){
5515    DebugLog('HoverDivFade - already faded, skip restart');
5516    thebox.FadeReleaseTimer = setTimeout( 'doReleaseFade("'+aDivName+'",'+fadeTime+')', 200);
5517  }else{
5518    DebugLog('HoverDivFade - go ahead');
5519    if((thebox.fadestart == null) || (thebox.fadestart == false) || (thebox.faderelease == true) ){
5520      thebox.faderelease = false;
5521      //DebugLog('HoverDivFade - start fade - fadeBG: '+fadeBGcolor+' fadeBorder: '+fadeBorderColor);
5522      KillThenAnimateDivFade(aDivName,fadeTime);
5523    }else{
5524      //DebugLog('HoverDivFade - fadestart is: '+thebox.fadestart+', faderelease is: '+thebox.faderelease);
5525    }
5526    
5527    if(thebox.FadeReleaseTimer){
5528      //DebugLog('HoverDivFade - clearTimeout');
5529      clearTimeout(thebox.FadeReleaseTimer);
5530    }
5531
5532    if(theOp == 0){
5533      //DO SOMETHING HERE
5534    }
5535    thebox.FadeReleaseTimer = setTimeout( 'doReleaseFade("'+aDivName+'",'+fadeTime+')', 200);
5536  }
5537}
5538
5539
5540//----------------------------------------------------------------------------
5541function HoverDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime) {
5542var thebox = document.getElementById(aDivName);
5543var orgBGcolor = getResolvedColor(thebox.style.backgroundColor);
5544//DebugLog('getstyle = '+getStyle(thebox,'borderColor'));
5545//var orgBorderColor = getResolvedColor(getStyle(thebox,'borderColor'));
5546var orgBorderColor = getResolvedColor(thebox.style.borderColor);
5547  fadeBGcolor = getResolvedColor(fadeBGcolor);
5548  fadeBorderColor = getResolvedColor(fadeBorderColor);
5549  //DebugLog('HOVERDIV');
5550  
5551  DebugLog('style.opacity = '+thebox.style.opacity);
5552  //element.style.filter = 'alpha(opacity=90)'; // USE IE FALLBACK
5553  
5554  
5555  if((thebox.fadestart == null) || (thebox.fadestart == false) || (thebox.faderelease == true) ){
5556    if(thebox.orgBGcolor){
5557      orgBGcolor = getResolvedColor(thebox.orgBGcolor);
5558      orgBorderColor = getResolvedColor(thebox.orgBorderColor);
5559    }else{
5560      DebugLog('setting the original background colors for this div - bg['+orgBGcolor+'], border['+orgBorderColor+']');
5561      thebox.orgBGcolor = orgBGcolor;
5562      thebox.orgBorderColor = orgBorderColor;
5563    }
5564    thebox.faderelease = false;
5565    //DebugLog('HoverDivFade - start fade - fadeBG: '+fadeBGcolor+' fadeBorder: '+fadeBorderColor);
5566    KillThenAnimateDivFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime);
5567  }else{
5568    //DebugLog('HoverDivFade - fadestart is: '+thebox.fadestart+', faderelease is: '+thebox.faderelease);
5569  }
5570  
5571  if(thebox.FadeReleaseTimer){
5572    //DebugLog('HoverDivFade - clearTimeout');
5573    clearTimeout(thebox.FadeReleaseTimer);
5574  }
5575
5576  if(thebox.orgBGcolor){
5577    orgBGcolor = getResolvedColor(thebox.orgBGcolor);
5578    orgBorderColor = getResolvedColor(thebox.orgBorderColor);
5579  }
5580  thebox.FadeReleaseTimer = setTimeout( 'doReleaseColorFade("'+aDivName+'","'+orgBGcolor+'","'+orgBorderColor+'",'+fadeTime+')', 100);
5581}
5582
5583//----------------------------------------------------------------------------
5584function doReleaseFade(aDivName,fadeTime) {
5585var thebox = document.getElementById(aDivName);
5586var backDivName = aDivName + 'Bk';
5587var FinDivName = aDivName + 'In';
5588var BinDivName = aDivName + 'BkIn';
5589var BaseDivName = aDivName.substring(0, aDivName.length - 2)
5590
5591  DebugLog('doReleaseFade - START - checking div name['+aDivName+']');
5592  if(isMouseInElement(BaseDivName)) DebugLog('in DIV ['+BaseDivName+']');
5593  if(isMouseInElement(aDivName)) DebugLog('in DIV ['+aDivName+']');
5594  if(isMouseInElement(backDivName)) DebugLog('in DIV ['+backDivName+']');
5595  if(isMouseInElement(FinDivName)) DebugLog('in DIV ['+FinDivName+']');
5596  if(isMouseInElement(BinDivName)) DebugLog('in DIV ['+BinDivName+']');
5597  
5598  if(isMouseInElement(BaseDivName) || isMouseInElement(aDivName) || isMouseInElement(backDivName) || isMouseInElement(FinDivName) || isMouseInElement(BinDivName)){
5599    DebugLog('doReleaseFade - is hovering');
5600    thebox.FadeReleaseTimer = setTimeout( 'doReleaseFade("'+aDivName+'",'+fadeTime+')', 200);
5601
5602  }else{
5603    DebugLog('doReleaseFade - no longer hovering, reverse fade');
5604    if(thebox.FadeReleaseTimer){
5605      //DebugLog('doReleaseFade - clearTimeout');
5606      clearTimeout(thebox.FadeReleaseTimer);
5607    }
5608    //thebox.fadestart = false;
5609    //thebox.fadenew = false;
5610    thebox.faderelease = true;
5611    
5612    //WE ARE RELASING THE FADE SO ANIMATE BACK TO ORIGINAL COLORS
5613    KillThenAnimateDivFade(aDivName,fadeTime);
5614  }
5615  DebugLog('doReleastFade - FINISH');
5616}
5617
5618//----------------------------------------------------------------------------
5619function doReleaseColorFade(aDivName,orgBGcolor,orgBorderColor,fadeTime) {
5620var thebox = document.getElementById(aDivName);
5621var theBGcolor = getResolvedColor(orgBGcolor);
5622var theBorderColor = getResolvedColor(orgBorderColor);
5623
5624  //DebugLog('doReleaseFade - orgBG: '+theBGcolor+' orgBorder: '+theBorderColor);
5625  if(isMouseInElement(aDivName)){
5626    //DebugLog('doReleaseFade - is hovering');
5627    thebox.FadeReleaseTimer = setTimeout( 'doReleaseColorFade("'+aDivName+'","'+orgBGcolor+'","'+orgBorderColor+'",'+fadeTime+')', 100);
5628
5629  }else{
5630    //DebugLog('doReleaseFade - no longer hovering, reverse fade');
5631    if(thebox.FadeReleaseTimer){
5632      //DebugLog('doReleaseFade - clearTimeout');
5633      clearTimeout(thebox.FadeReleaseTimer);
5634    }
5635    //thebox.fadestart = false;
5636    //thebox.fadenew = false;
5637    thebox.faderelease = true;
5638    
5639    //WE ARE RELASING THE FADE SO ANIMATE BACK TO ORIGINAL COLORS
5640    KillThenAnimateDivColorFade(aDivName,theBGcolor,theBorderColor,fadeTime);
5641  }
5642  
5643}
5644
5645
5646//----------------------------------------------------------------------------
5647function KillThenAnimateDivFade(aDivName,fadeTime) {
5648var thebox = document.getElementById(aDivName);
5649
5650  if(thebox.fadestart){
5651    DebugLog('KillThenAnimateDivFade - a fade is running, mark the kill flag and check it');
5652    thebox.killFade = true;
5653    setTimeout( 'CheckThenAnimateDivFade("'+aDivName+'",'+fadeTime+')', 50);
5654  }else{
5655    DebugLog('KillThenAnimateDivFade - no fade running, start animation now');
5656    AnimateDivFade(aDivName,fadeTime);
5657  }
5658}
5659
5660//----------------------------------------------------------------------------
5661function KillThenAnimateDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime) {
5662var thebox = document.getElementById(aDivName);
5663
5664  if(thebox.fadestart){
5665    //DebugLog('KillThenAnimateDivFade - a fade is running, mark the kill flag and check it');
5666    thebox.killFade = true;
5667    setTimeout( 'CheckThenAnimateDivColorFade("'+aDivName+'","'+fadeBGcolor+'","'+fadeBorderColor+'",'+fadeTime+')', 50);
5668  }else{
5669    //DebugLog('KillThenAnimateDivFade - no fade running, start animation now');
5670    AnimateDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime);
5671  }
5672}
5673
5674//----------------------------------------------------------------------------
5675function CheckThenAnimateDivFade(aDivName,fadeTime) {
5676var thebox = document.getElementById(aDivName);
5677
5678  if(thebox.killFade == false){
5679    //DebugLog('CheckThenAnimateDivFade - start animation now');
5680    AnimateDivFade(aDivName,fadeTime);
5681  }else{
5682    //DebugLog('CheckThenAnimateDivFade - still waiting for kill to be set');
5683    setTimeout( 'CheckThenAnimateDivFade("'+aDivName+'",'+fadeTime+')', 50);
5684  }
5685}
5686
5687//----------------------------------------------------------------------------
5688function CheckThenAnimateDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime) {
5689var thebox = document.getElementById(aDivName);
5690
5691  if(thebox.killFade == false){
5692    //DebugLog('CheckThenAnimateDivFade - start animation now');
5693    AnimateDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime);
5694  }else{
5695    //DebugLog('CheckThenAnimateDivFade - still waiting for kill to be set');
5696
5697    setTimeout( 'CheckThenAnimateDivColorFade("'+aDivName+'","'+fadeBGcolor+'","'+fadeBorderColor+'",'+fadeTime+')', 50);
5698  }
5699}
5700
5701//----------------------------------------------------------------------------
5702function AnimateDivFade(aDivName,fadeTime) {
5703var thebox = document.getElementById(aDivName);
5704var theWidth;
5705var theArrowName;
5706var theArrow;
5707var newsrc;
5708
5709
5710  DebugLog('AnimateDivFade - START - time['+fadeTime+']');
5711  var useFadeTime = 250;
5712  if(fadeTime > 0)
5713    useFadeTime = fadeTime;
5714
5715    thebox.fadenew = false;
5716    thebox.fadestart = true;
5717    thebox.fadecomplete = false;   
5718    
5719    if(thebox.killFade == null || thebox.killFade == false){
5720      DebugLog('killFade: not true');
5721      if(thebox.faderelease){
5722        animateFade(aDivName, useFadeTime, FinishFadeRelease);
5723      }else{
5724        animateFade(aDivName, useFadeTime, null);
5725      }
5726    }
5727}
5728
5729//----------------------------------------------------------------------------
5730function AnimateDivColorFade(aDivName,fadeBGcolor,fadeBorderColor,fadeTime) {
5731var thebox = document.getElementById(aDivName);
5732var theWidth;
5733var theArrowName;
5734var theArrow;
5735var newsrc;
5736var orgBGColor; 
5737var orgBorderColor;
5738var colortest;
5739
5740  //NOTE: REQUIRES FULL HEX COLOR #FF00FF, CAN'T TAKE #F0F SHORTHAND
5741  fadeBGcolor = getResolvedColor(fadeBGcolor);
5742  fadeBorderColor = getResolvedColor(fadeBorderColor);
5743
5744  orgBGcolor = getResolvedColor(thebox.style.backgroundColor);
5745  orgBorderColor = getResolvedColor(thebox.style.borderColor);
5746
5747  //DebugLog('AnimateDivFade - BG: '+orgBGcolor+' to: '+fadeBGcolor+',  Border: '+orgBorderColor+' to: '+fadeBorderColor);
5748  var useFadeTime = 250;
5749  if(fadeTime > 0)
5750    useFadeTime = fadeTime;
5751
5752    thebox.fadenew = false;
5753    thebox.fadestart = true;
5754    if(thebox.killFade == null || thebox.killFade == false){
5755      //DebugLog('fadenew: '+fadenew+', fadestart: '+fadestart+', faderelease: '+faderelease+', killFade: not true');
5756      if(thebox.faderelease){
5757        animateColorFade(aDivName, orgBGcolor, fadeBGcolor, orgBorderColor, fadeBorderColor, useFadeTime, FinishFadeRelease);
5758      }else{
5759        animateColorFade(aDivName, orgBGcolor, fadeBGcolor, orgBorderColor, fadeBorderColor, useFadeTime, null);
5760      }
5761    }
5762}
5763
5764//----------------------------------------------------------------------------
5765function FinishFadeRelease(aDivName){
5766var thebox = document.getElementById(aDivName);
5767//DebugLog('FinishFadeRelease');
5768  thebox.faderelease = false;
5769  thebox.fadestart = false;
5770}
5771
5772//----------------------------------------------------------------------------
5773function IsDivFaded(aDivName){
5774var thebox = document.getElementById(aDivName);
5775
5776  if((thebox.fadenew == null) || (thebox.fadenew == false))
5777  {
5778    return false;
5779  }
5780  else {
5781    return true;
5782  } 
5783}
5784
5785//----------------------------------------------------------------------------
5786function animateFade(elementID, time, callback)
5787{
5788  var el = document.getElementById(elementID);
5789  if(el == null)
5790    return;
5791  el.killFade = false;
5792
5793  var totalFrames = 1;
5794  if(time > 0)
5795    totalFrames = time/50;
5796
5797  el.aniFrameTotal = totalFrames; //SAVE THE TOTAL FRAME COUNT IN THE DIV OBJ
5798  el.aniFrameCount = 0; //ALSO KEEP TRACK OF THE FRAMES RENDERED IN THE DIV OBJ TOO
5799  
5800  doFadeFrame(elementID, callback);
5801}
5802
5803
5804//----------------------------------------------------------------------------
5805function animateColorFade(elementID, orgBGcolor, newBGcolor, orgBorderColor, newBorderColor, time, callback)
5806{
5807  var el = document.getElementById(elementID);
5808  if(el == null)
5809    return;
5810  el.killFade = false;
5811  //DebugLog('start animate: '+GetTicks());
5812  var oBG = orgBGcolor;
5813  var oBrd = orgBorderColor;
5814  var nBG = newBGcolor;
5815  var nBrd = newBorderColor;
5816
5817  var totalFrames = 1;
5818  if(time > 0)
5819    totalFrames = time/20;
5820
5821  el.aniFrameTotal = totalFrames; //SAVE THE TOTAL FRAME COUNT IN THE DIV OBJ
5822  el.aniFrameCount = 0; //ALSO KEEP TRACK OF THE FRAMES RENDERED IN THE DIV OBJ TOO
5823
5824  var fBG = totalFrames;
5825  var fBrd = totalFrames;
5826   
5827  doFadeColorFrame(elementID, oBG, nBG, fBG, oBrd, nBrd, fBrd, callback);
5828}
5829
5830//----------------------------------------------------------------------------
5831function doFadeFrame(eID, callback)
5832{
5833  var el = document.getElementById(eID);
5834  var theOp = null;
5835  var newVal = null;
5836  if(el == null)
5837    return;
5838  if(el.killFade){
5839    el.killFade = false;
5840    el.fadestart = false;
5841    el.fadenew = false
5842    el.fadecomplete = false;
5843    DebugLog('abort doFadeFrame due to killFade flag');
5844    return;
5845  }
5846  el.aniFrameCount = el.aniFrameCount + 1;
5847  DebugLog('doFadeFrame - framecount['+el.aniFrameCount+']');
5848
5849  //theOp = GetOpacity(el); //CURRENT OPACITY
5850  //orgClientWidth
5851  //orgClientHeight
5852  
5853  if(el.faderelease){
5854    switch(el.fadeAniMode){
5855      case 1:
5856        DebugLog('doFadeFrame(release) - ['+el.aniFrameCount+']/['+el.aniFrameTotal+'] = ['+ el.aniFrameCount/el.aniFrameTotal +']');
5857        newVal = (el.aniFrameCount / el.aniFrameTotal);
5858        break;
5859
5860      case 2:
5861        DebugLog('doFadeFrame(sweep1-release)');
5862        newVal = 1 - (el.aniFrameCount / el.aniFrameTotal);
5863        break;
5864
5865      case 3:
5866        DebugLog('doFadeFrame(sweep2-release)');
5867        newVal = 1 - (el.aniFrameCount / el.aniFrameTotal);
5868        break;
5869
5870      default:
5871        DebugLog('doFadeFrame(release) - ['+el.aniFrameCount+']/['+el.aniFrameTotal+'] = ['+ el.aniFrameCount/el.aniFrameTotal +']');
5872        newVal = (el.aniFrameCount / el.aniFrameTotal);
5873        break;
5874        
5875    }
5876  }else{
5877    switch(el.fadeAniMode){
5878      case 1:
5879        DebugLog('doFadeFrame(fade) - ['+el.aniFrameCount+']/['+el.aniFrameTotal+'] = ['+ el.aniFrameCount/el.aniFrameTotal +']');
5880        newVal = 1 - (el.aniFrameCount / el.aniFrameTotal);
5881        break;
5882
5883      case 2:
5884        DebugLog('doFadeFrame(sweep L2R)');
5885        newVal = (el.aniFrameCount / el.aniFrameTotal);
5886        break;
5887        
5888      case 3:
5889        DebugLog('doFadeFrame(sweep T2B)');
5890        newVal = (el.aniFrameCount / el.aniFrameTotal);
5891        break;
5892        
5893      default:
5894        DebugLog('doFadeFrame(fade) - ['+el.aniFrameCount+']/['+el.aniFrameTotal+'] = ['+ el.aniFrameCount/el.aniFrameTotal +']');
5895        newVal = 1 - (el.aniFrameCount / el.aniFrameTotal);
5896        break;
5897    }
5898  }
5899  
5900  //NOW APPLY THE UPDATE
5901  switch(el.fadeAniMode){
5902    case 1:
5903      DebugLog('doFadeFrame - newOpacity['+newVal+']');
5904      SetOpacity(el,newVal);
5905      break;
5906
5907    case 2:
5908      DebugLog('doFadeFrame - newSweep(L2R)['+newVal+'], orgWidth['+el.orgClientWidth+']');
5909      SetSweep(el,1,newVal,el.orgClientWidth); //DIRECTION 1 IS LEFT TO RIGHT
5910      break;
5911
5912    case 3:
5913      DebugLog('doFadeFrame - newSweep(T2B)['+newVal+'], orgHeight['+el.orgClientHeight+']');
5914      SetSweep(el,3,newVal,el.orgClientHeight); //DIRECTION 3 IS TOP TO BOTTOM
5915      break;
5916
5917
5918    default:
5919      DebugLog('doFadeFrame - newOp['+newVal+']');
5920      SetOpacity(el,newVal);
5921      break;
5922    
5923  }
5924  
5925  DebugLog('doFadeFrame - newVal is ['+newVal+']');
5926  if(newVal <= 0)
5927  {
5928    el.aniFrameCount = 0;
5929    el.fadenew = true;  //DONE WITH THE FADE
5930    el.fadestart = false; //ANIMATION COMPLETE
5931    if(el.faderelease){
5932      el.fadecomplete = false;
5933    }else{
5934      el.fadecomplete = true;
5935    }
5936    DebugLog('Fade complete 1');
5937    if(callback != null)
5938      callback(eID); 
5939    //DebugLog('end animate 1: '+GetTicks());
5940    return; //WE ARE DONE, SO BAIL OUT NOW
5941  }
5942  else{ 
5943    DebugLog('doFadeFrame - check frame limiation count - count['+el.aniFrameCount+'], frame total['+el.aniFrameTotal+']');
5944    //CHECK FOR THE FRAME COUNT LIMITATION
5945    if(  el.aniFrameCount >= (el.aniFrameTotal)){
5946      DebugLog('doFadeFrame - frame limiation triggered');
5947      //alert('max: '+el.aniFrameTotal+', count: '+el.aniFrameCount);
5948      el.aniFrameCount = 0;
5949      el.fadenew = true;  //DONE WITH THE FADE
5950      el.fadestart = false; //ANIMATION COMPLETE
5951      if(el.faderelease){
5952        el.fadecomplete = false;
5953      }else{
5954        el.fadecomplete = true;
5955      }
5956      DebugLog('Fade complete 2');
5957      if(callback != null)
5958        callback(eID);
5959      return;
5960    }
5961    else{
5962      //WE NEED TO KEEP RENDERING FRAMES, GET READY TO DO THE NEXT FRAME
5963      setTimeout( 'doFadeFrame("'+eID+'",'+callback+')', 20);
5964    }
5965  }
5966}
5967
5968
5969//----------------------------------------------------------------------------
5970function doFadeColorFrame(eID, oBG, nBG, fBG, oBrd, nBrd, fBrd, callback)
5971{
5972  var el = document.getElementById(eID);
5973  if(el == null)
5974    return;
5975  if(el.killFade){
5976    el.killFade = false;
5977    el.fadestart = false;
5978    el.fadenew = false
5979    //DebugLog('abort doFadeFrame due to killFade flag');
5980    return;
5981  }
5982  el.aniFrameCount = el.aniFrameCount + 1;
5983  //DebugLog('doFadeFrame - oBG: '+oBG+' nBG: '+nBG+' fBG: '+fBG);
5984  //DebugLog('doFadeFrame - oBrd: '+oBrd+' nBrd: '+nBrd+' fBrd: '+fBrd);
5985  if(oBG != '')
5986    oBG = fadeColorVal(oBG, nBG, fBG);
5987  if(oBrd != '')
5988    oBrd = fadeColorVal(oBrd, nBrd, fBrd);
5989
5990  el.style.backgroundColor = oBG;
5991  el.style.borderColor = oBrd;
5992 
5993  if(oBG == nBG && oBrd == nBrd)
5994  {
5995    el.aniFrameCount = 0;
5996    el.fadenew = true;  //DONE WITH THE FADE
5997    el.fadestart = false; //ANIMATION COMPLETE
5998    //DebugLog('Fade complete 1');
5999    if(callback != null)
6000      callback(eID); 
6001    //DebugLog('end animate 1: '+GetTicks());
6002    return; //WE ARE DONE, SO BAIL OUT NOW
6003  }
6004  else{ 
6005    //CHECK FOR THE FRAME COUNT LIMITATION
6006    if(  el.aniFrameCount > (el.aniFrameTotal + 1)){
6007      //alert('max: '+el.aniFrameTotal+', count: '+el.aniFrameCount);
6008      el.aniFrameCount = 0;
6009      el.fadenew = true;  //DONE WITH THE FADE
6010      el.fadestart = false; //ANIMATION COMPLETE
6011      //DebugLog('Fade complete 2');
6012      if(callback != null)
6013        callback(eID);
6014      return;
6015    }
6016    else{
6017      //REDUCE THE NUMBER OF FRAMES EACH TIME
6018      fBG = fBG - 1;
6019      if(fBG <= 0) 
6020        fBG = 0;
6021      fBrd = fBrd - 1;
6022      if(fBrd <= 0)
6023        fBrd = 0;
6024      //WE NEED TO KEEP RENDERING FRAMES, GET READY TO DO THE NEXT FRAME
6025      setTimeout( 'doFadeColorFrame("'+eID+'","'+oBG+'","'+nBG+'",'+fBG+',"'+oBrd+'","'+nBrd+'",'+fBrd+','+callback+')', 20);
6026    }
6027  }
6028}
6029
6030
6031//----------------------------------------------------------------------------
6032function fadeColorVal(currentVal, finalVal, incrementCnt)
6033{
6034  if(incrementCnt <= 0 || currentVal == finalVal)
6035    return finalVal;
6036    
6037  //GET THE CURRENT HEX COLOR IN TO RGB DEC VALUES  
6038  //DebugLog('fadeColorVal - currentVal: '+currentVal);
6039  var cValRGB = hex2rgb(currentVal)
6040  var rval = cValRGB.red;
6041  var gval = cValRGB.green;
6042  var bval = cValRGB.blue;
6043
6044  //GET THE FINAL HEX COLOR IN TO RGB DEC VALUES  
6045  //DebugLog('fadeColorVal - finalVal: '+finalVal);
6046  var fValRGB = hex2rgb(finalVal)
6047  var frval = fValRGB.red;
6048  var fgval = fValRGB.green;
6049  var fbval = fValRGB.blue;
6050
6051  //DebugLog('fadeColorVal - incrementCnt: '+incrementCnt);
6052
6053
6054  //INCREMENT FROM CURRENT TO FINAL BY ONE STEP OF THE INCREMENT CNT
6055  var newr = rval;
6056  if(rval != frval)
6057    newr = Math.round(rval + ((frval - rval) / incrementCnt));
6058
6059  var newg = gval;
6060  if(gval != fgval)
6061    newg = Math.round(gval + ((fgval - gval) / incrementCnt));
6062
6063  var newb = bval;
6064  if(bval != fbval)
6065    newb = Math.round(bval + ((fbval - bval) / incrementCnt));
6066 
6067  //NOW BUILD THE OUTPUT HEX COLOR
6068  var newVal = '#';
6069  //DebugLog('r val: '+newr+' hex: '+newr.toString(16));
6070  //DebugLog('g val: '+newg+' hex: '+newg.toString(16));
6071  //DebugLog('b val: '+newb+' hex: '+newb.toString(16));
6072  var tmpr = newr.toString(16);
6073  var tmpg = newg.toString(16);
6074  var tmpb = newb.toString(16);
6075  if(tmpr.length == 1)
6076    tmpr = '0' + tmpr;
6077  if(tmpg.length == 1)
6078    tmpg = '0' + tmpg;
6079  if(tmpb.length == 1)
6080    tmpb = '0' + tmpb;
6081  
6082  newVal = newVal + tmpr + tmpg + tmpb;
6083
6084  //DebugLog('newval: '+newVal);
6085  return newVal;
6086}
6087
6088
6089//----------------------------------------------------------------------------
6090function hex2rgb(hex) {
6091// SAMPLE CALL
6092//var hex = "#fA0";
6093//var rgb = hex2rgb(hex);
6094//document.write("<pre>"+hex+" \u2192 rgb("+rgb.red+","+rgb.green+","+rgb.blue+")</pre>");
6095  
6096  //DebugLog('start hex['+hex+']');
6097  //DebugLog('start hex0['+hex.substr(0,1)+']');
6098
6099  if (hex.substr(0,1)=='#'){ 
6100    hex = hex.substr(1);
6101    //DebugLog('hex#['+hex+']');
6102  }
6103  
6104  if (hex.length == 1) {
6105    hex = '00000'+hex;
6106  }else if (hex.length == 2) {
6107    hex = '0000'+hex;
6108  }else if (hex.length == 4) {
6109    hex = '00'+hex;
6110  }else if (hex.length == 5) {
6111    hex = '0'+hex;
6112  }else if (hex.length == 3) {
6113    var temp = hex; 
6114    hex = '';
6115    var tmpregex = new RegExp('^([a-f0-9])([a-f0-9])([a-f0-9])$','i');
6116    //temp = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp);
6117    var temp = tmpregex.exec(temp);
6118    //DebugLog('temp str['+temp+']');
6119    temp = temp.slice(1);
6120    //DebugLog('temp slice['+temp+']');
6121    for (var i=0;i<3;i++) hex+=temp[i]+temp[i];
6122  }
6123  //DebugLog('hex str['+hex+']');
6124  var tregex = new RegExp('^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$','i');
6125  //var triplets = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex);
6126  var triplets = tregex.exec(hex);
6127  //DebugLog('triplets str['+triplets+']');
6128  triplets = triplets.slice(1);
6129  //DebugLog('triplets slice['+triplets+']');
6130  return {
6131    red: parseInt(triplets[0],16),
6132    green: parseInt(triplets[1],16),
6133    blue: parseInt(triplets[2],16)
6134  }
6135}
6136
6137
6138//----------------------------------------------------------------------------
6139function getResolvedColor(aColor){
6140var newcolor = aColor;
6141var colortest;
6142var hex;
6143  //DebugLog('getResolvedColor - start['+aColor+']');
6144  if(newcolor == ''){
6145    //DebugLog('is blank color str');
6146    newcolor = '#FFFFFF';
6147  }
6148
6149  if (newcolor.substr(0,1) == '#'){
6150    //DebugLog('has leading #');
6151    hex = newcolor.substr(1);
6152    if (hex.length == 1) {
6153      hex = '00000'+hex;
6154    }else if (hex.length == 2) {
6155      hex = '0000'+hex;
6156    }else if (hex.length == 4) {
6157      hex = '00'+hex;
6158    }else if (hex.length == 5) {
6159      hex = '0'+hex;
6160    }
6161    newcolor = '#'+hex;
6162  }else{
6163    //DebugLog('does not have leading #');
6164  }
6165
6166  colortest = colorNameToHex(newcolor);
6167
6168  if(colortest != false && colortest != 'undefined' ){
6169    //DebugLog('assign to colortest value ['+colortest+']');
6170    newcolor = colortest;
6171  }else{
6172    //DebugLog('assign to newcolor value ['+newcolor+']');
6173    newcolor = colorToHex(newcolor);
6174  }
6175  
6176  //DebugLog('getResolvedColor - finish['+newcolor+']');
6177
6178return newcolor;
6179}
6180
6181
6182//----------------------------------------------------------------------------
6183function colorToHex(aColor) {
6184  //DebugLog('colorToHex - color['+aColor+']');
6185  if (aColor.substr(0, 1) == '#') {
6186      return aColor;
6187  }
6188  //var cthRegEx = new RegExp('(.*?)rgb\((\d+), (\d+), (\d+)\)'); //WASN'T RETURNING WHAT I NEEDED CONSISTENTLY
6189  var cthRegEx = /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/; //THIS ONE WORKS BETTER BUT RED IS IN DIGITS[1], NOT DIGITS[2]
6190  cthRegEx.lastIndex = 0;
6191  var aDigits = cthRegEx.exec(aColor);
6192  
6193  //DebugLog('red: '+aDigits[1]);
6194  //DebugLog('green: '+aDigits[2]);
6195  //DebugLog('blue: '+aDigits[3]);
6196
6197  //var red = parseInt(aDigits[2]);
6198  //var green = parseInt(aDigits[3]);
6199  //var blue = parseInt(aDigits[4]);
6200  var red = parseInt(aDigits[1]);
6201  var green = parseInt(aDigits[2]);
6202  var blue = parseInt(aDigits[3]);
6203  
6204  var aRGB = blue | (green << 8) | (red << 16);
6205  //return aDigits[1] + '#' + aRGB.toString(16);
6206  return '#' + aRGB.toString(16);
6207};
6208
6209
6210//----------------------------------------------------------------------------
6211function colorNameToHex(acolor)
6212{
6213    var thecolors = {"aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff",
6214    "beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887",
6215    "cadetblue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflowerblue":"#6495ed","cornsilk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff",
6216    "darkblue":"#00008b","darkcyan":"#008b8b","darkgoldenrod":"#b8860b","darkgray":"#a9a9a9","darkgreen":"#006400","darkkhaki":"#bdb76b","darkmagenta":"#8b008b","darkolivegreen":"#556b2f",
6217    "darkorange":"#ff8c00","darkorchid":"#9932cc","darkred":"#8b0000","darksalmon":"#e9967a","darkseagreen":"#8fbc8f","darkslateblue":"#483d8b","darkslategray":"#2f4f4f","darkturquoise":"#00ced1",
6218    "darkviolet":"#9400d3","deeppink":"#ff1493","deepskyblue":"#00bfff","dimgray":"#696969","dodgerblue":"#1e90ff",
6219    "firebrick":"#b22222","floralwhite":"#fffaf0","forestgreen":"#228b22","fuchsia":"#ff00ff",
6220    "gainsboro":"#dcdcdc","ghostwhite":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","green":"#008000","greenyellow":"#adff2f",
6221    "honeydew":"#f0fff0","hotpink":"#ff69b4",
6222    "indianred ":"#cd5c5c","indigo ":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c",
6223    "lavender":"#e6e6fa","lavenderblush":"#fff0f5","lawngreen":"#7cfc00","lemonchiffon":"#fffacd","lightblue":"#add8e6","lightcoral":"#f08080","lightcyan":"#e0ffff","lightgoldenrodyellow":"#fafad2",
6224    "lightgrey":"#d3d3d3","lightgreen":"#90ee90","lightpink":"#ffb6c1","lightsalmon":"#ffa07a","lightseagreen":"#20b2aa","lightskyblue":"#87cefa","lightslategray":"#778899","lightsteelblue":"#b0c4de",
6225    "lightyellow":"#ffffe0","lime":"#00ff00","limegreen":"#32cd32","linen":"#faf0e6",
6226    "magenta":"#ff00ff","maroon":"#800000","mediumaquamarine":"#66cdaa","mediumblue":"#0000cd","mediumorchid":"#ba55d3","mediumpurple":"#9370d8","mediumseagreen":"#3cb371","mediumslateblue":"#7b68ee",
6227    "mediumspringgreen":"#00fa9a","mediumturquoise":"#48d1cc","mediumvioletred":"#c71585","midnightblue":"#191970","mintcream":"#f5fffa","mistyrose":"#ffe4e1","moccasin":"#ffe4b5",
6228    "navajowhite":"#ffdead","navy":"#000080",
6229    "oldlace":"#fdf5e6","olive":"#808000","olivedrab":"#6b8e23","orange":"#ffa500","orangered":"#ff4500","orchid":"#da70d6",
6230    "palegoldenrod":"#eee8aa","palegreen":"#98fb98","paleturquoise":"#afeeee","palevioletred":"#d87093","papayawhip":"#ffefd5","peachpuff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powderblue":"#b0e0e6","purple":"#800080",
6231    "red":"#ff0000","rosybrown":"#bc8f8f","royalblue":"#4169e1",
6232    "saddlebrown":"#8b4513","salmon":"#fa8072","sandybrown":"#f4a460","seagreen":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","skyblue":"#87ceeb","slateblue":"#6a5acd","slategray":"#708090","snow":"#fffafa","springgreen":"#00ff7f","steelblue":"#4682b4",
6233    "tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise"
6233:"#40e0d0",
6234    "violet":"#ee82ee",
6235    "wheat":"#f5deb3","white":"#ffffff","whitesmoke":"#f5f5f5",
6236    "yellow":"#ffff00","yellowgreen":"#9acd32"};
6237
6238    if (typeof thecolors[acolor.toLowerCase()] != 'undefined')
6239    	return thecolors[acolor.toLowerCase()];
6240
6241    return false;
6242}
6243
6244
6245//----------------------------------------------------------------------------
6246function getStyle(elem, name) {
6247  if (document.defaultView && document.defaultView.getComputedStyle) {
6248    name = name.replace(/([A-Z])/g, "-$1");
6249    name = name.toLowerCase();
6250    s = document.defaultView.getComputedStyle(elem, "");
6251    return s && s.getPropertyValue(name);
6252  } else if (elem.currentStyle) {
6253    if (/backgroundcolor/i.test(name)) {
6254      return (function (el) { // get a rgb based color on IE
6255        var oRG=document.body.createTextRange();
6256        oRG.moveToElementText(el);
6257        var iClr=oRG.queryCommandValue("BackColor");
6258          return "rgb("+(iClr & 0xFF)+","+((iClr & 0xFF00)>>8)+","+
6259                      ((iClr & 0xFF0000)>>16)+")";
6260      })(elem);
6261    }
6262
6263    return elem.currentStyle[name];
6264  } else if (elem.style[name]) {
6265    return elem.style[name];
6266  } else  {
6267    return null;
6268  }
6269}
6270
6271
6272//----------------------------------------------------------------------------
6273//----------------------------------------------------------------------------
6274//----------------------------------------------------------------------------
6275//----------------------------------------------------------------------------
6276// info on mouse move, drag and drop, etc
6277// http://www.webreference.com/programming/javascript/mk/column2/index.html
6278var mousePos;
6279var absMousePos;
6280document.onmousemove = mouseMove; 
6281
6282//----------------------------------------------------------------------------
6283function mouseMove(ev){ 
6284  ev           = ev || window.event; 
6285  mousePos = mouseCoords(ev); 
6286  absMousePos = absMouseCoords(ev); 
6287	//DebugLog('mouseMove - cur pos ['+mousePos.x+','+mousePos.y+'], abs ['+ev.clientX+','+ev.clientY+']');
6288}     
6289
6290//----------------------------------------------------------------------------
6291function mouseCoords(ev){
6292	// from http://www.webreference.com/programming/javascript/mk/column2/
6293	if(ev.pageX || ev.pageY){
6294		return {x:ev.pageX, y:ev.pageY};
6295	}
6296	return {
6297		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
6298		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
6299	};
6300}
6301
6302//----------------------------------------------------------------------------
6303function absMouseCoords(ev){
6304	if(ev.clientX || ev.clientY){
6305		return {x:ev.clientX, y:ev.clientY};
6306	}
6307	return {x:ev.clientX, y:ev.clientY};
6308}
6309
6310//----------------------------------------------------------------------------
6311function isMouseInElement(anItemID){
6312var thebox = document.getElementById(anItemID);
6313var isInBox = false;
6314var rectOffset;
6315
6316  if(thebox){
6317    rectOffset = getPageOffset(thebox);
6318    var BRx = rectOffset.left + thebox.clientWidth; 
6319    var BRy = rectOffset.top + thebox.clientHeight; 
6320    isInBox = isPointInRectangle(mousePos.x,mousePos.y,rectOffset.left,rectOffset.top,BRx,BRy);
6321    //DebugLog('isMouseInElement: item['+anItemID+'] - isIN['+isInBox+'] - mouse('+mousePos.x+','+mousePos.y+') - x: '+rectOffset.left+' to '+BRx+',  y: '+rectOffset.top+' to '+BRy);
6322  }
6323  
6324  return isInBox;
6325}
6326
6327//----------------------------------------------------------------------------
6328function isMouseInAbsElement(anItemID){
6329var thebox = document.getElementById(anItemID);
6330var isInBox = false;
6331var rectOffset;
6332
6333  if(thebox){
6334    rectOffset = getPageOffset(thebox);
6335    //var BRx = rectOffset.left + thebox.clientWidth; 
6336    //var BRy = rectOffset.top + thebox.clientHeight; 
6337    var BRx = rectOffset.left + thebox.offsetWidth; 
6338    var BRy = rectOffset.top + thebox.offsetHeight; 
6339    isInBox = isPointInRectangle(absMousePos.x,absMousePos.y,rectOffset.left,rectOffset.top,BRx,BRy);
6340    //DebugLog('isMouseInAbsElement: item['+anItemID+'] - isIN['+isInBox+'] - mouse('+absMousePos.x+','+absMousePos.y+') - x: '+rectOffset.left+' to '+BRx+',  y: '+rectOffset.top+' to '+BRy);
6341  }
6342  return isInBox;
6343}
6344
6345
6346//----------------------------------------------------------------------------
6347function isPointInRectangle(theX,theY,rectTLx,rectTLy,rectBRx,rectBRy){
6348var isIn = false;
6349  if(theX >= rectTLx  &&  theX <= rectBRx){
6350    if(theY >= rectTLy  &&  theY <= rectBRy){
6351      isIn = true;
6352    }
6353  }
6354return isIn;
6355}
6356
6357
6358//----------------------------------------------------------------------------
6359function enableDragable(aDivID){
6360	var theDiv = document.getElementById(aDivID);	
6361	DebugLog('enableDragable - div name['+aDivID+']');
6362	if(theDiv){
6363		dragElement(theDiv);
6364	}
6365}
6366
6367//----------------------------------------------------------------------------
6368function dragElement(aElement) {
6369  var pos1 = 0;
6370	var pos2 = 0;
6371	var pos3 = 0
6372	var pos4 = 0;
6373	DebugLog('['+aElement.id+'] dragElement - start');
6374  if (document.getElementById(aElement.id + "header")) {
6375    document.getElementById(aElement.id + "header").onmousedown = dragStart;
6376  } else { 
6377    aElement.onmousedown = dragStart;
6378  }
6379	//----------------------------
6380  function dragStart(e) {
6381		// start
6382    e = e || window.event;
6383    e.preventDefault();
6384    pos3 = e.clientX;
6385    pos4 = e.clientY;
6386		aElement.didStartDrag = true;
6387    document.onmouseup = dragDone;
6388    document.onmousemove = dragMove;
6389  }
6390	//----------------------------
6391  function dragDone() {
6392    // finish
6393    document.onmouseup = null;
6394    document.onmousemove = null;
6395  }
6396	//----------------------------
6397  function dragMove(e) {
6398		// move
6399    e = e || window.event;
6400    e.preventDefault();
6401    pos1 = pos3 - e.clientX;
6402    pos2 = pos4 - e.clientY;
6403    pos3 = e.clientX;
6404    pos4 = e.clientY;
6405    aElement.style.top = (aElement.offsetTop - pos2) + "px";
6406    aElement.style.left = (aElement.offsetLeft - pos1) + "px";
6407  }
6408
6409}
6410
6411
6412//----------------------------------------------------------------------------
6413//var xmlhttp = GetXmlHttpObject(); //SETUP FOR THE POSTBACK PROCESSING
6414//
6415//xmlhttp.onreadystatechange=function()
6416//{
6417//  if (xmlhttp.readyState==4 && xmlhttp.status==200)
6418//  {
6419//    //UPDATE ANSWER
6420//    document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 
6421//  }
6422//}
6423// USAGE:
6424//  xmlhttp.open('GET','doProcess.asp?ACT=1&UI='+aUI+'&QN='+aQuestionNum+'&OV='+aValueNum+'&CT='+rstr,true);
6425//  xmlhttp.send();
6426
6427function GetXmlHttpObject() {
6428  var xmlHttp = null;
6429  try {
6430      // IE7+, Firefox, Opera 8.0+, Safari
6431      DebugLog("before XMLHttpRequest create");
6432      xmlHttp = new XMLHttpRequest();
6433      //xmlHttp = new ServerXMLHttpRequest();
6434      
6435      //response.Expires = 0
6436      //response.ExpiresAbsolute = Now() - 1
6437      //response.addHeader "pragma","no-cache"
6438      //response.addHeader "cache-control","private"
6439      //Response.CacheControl = "no-cache"
6440      DebugLog("after XMLHttpRequest create");
6441      //if(xmlHttp){
6442      //  DebugLog("inside XMLHttpRequest test ");
6443        //xmlHttp.setRequestHeader("Expires", 0);
6444        //xmlHttp.setRequestHeader "pragma", "no-cache";
6445        //xmlHttp.setRequestHeader "cache-control", "private";
6446        //xmlHttp.setRequestHeader "CacheControl", "no-cache";
6447      //  DebugLog("after XMLHttpRequest headers set ");
6448      //}
6449  }
6450  catch (e) {
6451      // Internet Explorer
6452      try {
6453          DebugLog("before ActiveXObject(Msxml2.XMLHTTP) create");
6454          //xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
6455          xmlHttp = new ActiveXObject("Msxml2.ServerXMLHTTP");
6456          DebugLog("after ActiveXObject(Msxml2.XMLHTTP) create");
6457          //if(xmlHttp){
6458            //xmlHttp.setRequestHeader "Expires", "0";
6459            //xmlHttp.setRequestHeader "pragma", "no-cache";
6460            //xmlHttp.setRequestHeader "cache-control", "private";
6461            //xmlHttp.setRequestHeader "CacheControl", "no-cache";
6462          //}
6463      }
6464      catch (e) {
6465          DebugLog("before ActiveXObject(Microsoft.XMLHTTP) create");
6466          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
6467          DebugLog("after ActiveXObject(Microsoft.XMLHTTP) create");
6468      }
6469  }
6470
6471
6472  return xmlHttp;
6473}
6474
6475
6476
6477//----------------------------------------------------------------------------
6478function ClearIFrame(iFrameID) {
6479
6480  gCleariFrameID = iFrameID
6481  ClearIFrameAux(); //USE THIS HELPER FUNCTION FOR THE TIMEOUT
6482
6483}
6484
6485
6486
6487//----------------------------------------------------------------------------
6488function ClearIFrameAux() {
6489var theiframe = document.getElementById(gCleariFrameID); //USE THE GLOBAL TO ID THE IFRAME IN THE SETTIMEOUT CALLBACK
6490
6491  if( theiframe.document ) {
6492    if( theiframe.document.body ) {
6493      theiframe.document.body.innerHTML = ''; //Chrome, IE
6494    }
6495    else {
6496      setTimeout('ClearIFrame("'+ iFrameID +'")',100);
6497    }
6498  }
6499  else {
6500    if( theiframe.contentDocument.body ){
6501      theiframe.contentDocument.body.innerHTML = ''; //FireFox
6502    }
6503    else {
6504      setTimeout('ClearIFrame("'+ iFrameID +'")',100);
6505    }
6506  }
6507
6508}
6509
6510
6511
6512
6513//-----------------------------------------------------------------------------------------------------------
6514//fgnass.github.com/spin.js#v1.2.5  :  http://fgnass.github.com/spin.js/
6515(function(window, document, undefined) {
6516
6517/**
6518 * Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de]
6519 * Licensed under the MIT license
6520 */
6521
6522  var prefixes = ['webkit', 'Moz', 'ms', 'O']; /* Vendor prefixes */
6523  var animations = {}; /* Animation rules keyed by their name */
6524  var useCssAnimations;
6525
6526  /**
6527   * Utility function to create elements. If no tag name is given,
6528   * a DIV is created. Optionally properties can be passed.
6529   */
6530  function createEl(tag, prop) {
6531    var el = document.createElement(tag || 'div');
6532    var n;
6533
6534    for(n in prop) {
6535      el[n] = prop[n];
6536    }
6537    return el;
6538  }
6539
6540  /**
6541   * Appends children and returns the parent.
6542   */
6543  function ins(parent /* child1, child2, ...*/) {
6544    for (var i=1, n=arguments.length; i<n; i++) {
6545      parent.appendChild(arguments[i]);
6546    }
6547    return parent;
6548  }
6549
6550  /**
6551   * Insert a new stylesheet to hold the @keyframe or VML rules.
6552   */
6553  var sheet = function() {
6554    var el = createEl('style');
6555    ins(document.getElementsByTagName('head')[0], el);
6556    return el.sheet || el.styleSheet;
6557  }();
6558
6559  /**
6560   * Creates an opacity keyframe animation rule and returns its name.
6561   * Since most mobile Webkits have timing issues with animation-delay,
6562   * we create separate rules for each line/segment.
6563   */
6564  function addAnimation(alpha, trail, i, lines) {
6565    var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-');
6566    var start = 0.01 + i/lines*100;
6567    var z = Math.max(1-(1-alpha)/trail*(100-start) , alpha);
6568    var prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase();
6569    var pre = prefix && '-'+prefix+'-' || '';
6570
6571    if (!animations[name]) {
6572      sheet.insertRule(
6573        '@' + pre + 'keyframes ' + name + '{' +
6574        '0%{opacity:'+z+'}' +
6575        start + '%{opacity:'+ alpha + '}' +
6576        (start+0.01) + '%{opacity:1}' +
6577        (start+trail)%100 + '%{opacity:'+ alpha + '}' +
6578        '100%{opacity:'+ z + '}' +
6579        '}', 0);
6580      animations[name] = 1;
6581    }
6582    return name;
6583  }
6584
6585  /**
vendor: 4,406 bytes, lines 6586-6730
6586   * Tries various vendor prefixes and returns the first supported property.
6587   **/
6588  function vendor(el, prop) {
6589    var s = el.style;
6590    var pp;
6591    var i;
6592
6593    if(s[prop] !== undefined) return prop;
6594    prop = prop.charAt(0).toUpperCase() + prop.slice(1);
6595    for(i=0; i<prefixes.length; i++) {
6596      pp = prefixes[i]+prop;
6597      if(s[pp] !== undefined) return pp;
6598    }
6599  }
6600
6601  /**
6602   * Sets multiple style properties at once.
6603   */
6604  function css(el, prop) {
6605    for (var n in prop) {
6606      el.style[vendor(el, n)||n] = prop[n];
6607    }
6608    return el;
6609  }
6610
6611  /**
6612   * Fills in default values.
6613   */
6614  function merge(obj) {
6615    for (var i=1; i < arguments.length; i++) {
6616      var def = arguments[i];
6617      for (var n in def) {
6618        if (obj[n] === undefined) obj[n] = def[n];
6619      }
6620    }
6621    return obj;
6622  }
6623
6624  /**
6625   * Returns the absolute page-offset of the given element.
6626   */
6627  function pos(el) {
6628    var o = {x:el.offsetLeft, y:el.offsetTop};
6629    while((el = el.offsetParent)) {
6630      o.x+=el.offsetLeft;
6631      o.y+=el.offsetTop;
6632    }
6633    return o;
6634  }
6635
6636  var defaults = {
6637    lines: 12,            // The number of lines to draw
6638    length: 7,            // The length of each line
6639    width: 5,             // The line thickness
6640    radius: 10,           // The radius of the inner circle
6641    rotate: 0,            // rotation offset
6642    color: '#000',        // #rgb or #rrggbb
6643    speed: 1,             // Rounds per second
6644    trail: 100,           // Afterglow percentage
6645    opacity: 1/4,         // Opacity of the lines
6646    fps: 20,              // Frames per second when using setTimeout()
6647    zIndex: 2e9,          // Use a high z-index by default
6648    className: 'spinner', // CSS class to assign to the element
6649    top: 'auto',          // center vertically
6650    left: 'auto'          // center horizontally
6651  };
6652
6653  /** The constructor */
6654  var Spinner = function Spinner(o) {
6655    if (!this.spin) return new Spinner(o);
6656    this.opts = merge(o || {}, Spinner.defaults, defaults);
6657  };
6658
6659  Spinner.defaults = {};
6660  merge(Spinner.prototype, {
6661    spin: function(target) {
6662      this.stop();
6663      var self = this;
6664      var o = self.opts;
6665      var el = self.el = css(createEl(0, {className: o.className}), {position: 'relative', zIndex: o.zIndex});
6666      var mid = o.radius+o.length+o.width;
6667      var ep; // element position
6668      var tp; // target position
6669
6670      if (target) {
6671        target.insertBefore(el, target.firstChild||null);
6672        tp = pos(target);
6673        ep = pos(el);
6674        css(el, {
6675          left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : o.left+mid) + 'px',
6676          top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : o.top+mid)  + 'px'
6677        });
6678      }
6679
6680      el.setAttribute('aria-role', 'progressbar');
6681      self.lines(el, self.opts);
6682
6683      if (!useCssAnimations) {
6684        // No CSS animation support, use setTimeout() instead
6685        var i = 0;
6686        var fps = o.fps;
6687        var f = fps/o.speed;
6688        var ostep = (1-o.opacity)/(f*o.trail / 100);
6689        var astep = f/o.lines;
6690
6691        !function anim() {
6692          i++;
6693          for (var s=o.lines; s; s--) {
6694            var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity);
6695            self.opacity(el, o.lines-s, alpha, o);
6696          }
6697          self.timeout = self.el && setTimeout(anim, ~~(1000/fps));
6698        }();
6699      }
6700      return self;
6701    },
6702    stop: function() {
6703      var el = this.el;
6704      if (el) {
6705        clearTimeout(this.timeout);
6706        if (el.parentNode) el.parentNode.removeChild(el);
6707        this.el = undefined;
6708      }
6709      return this;
6710    },
6711    lines: function(el, o) {
6712      var i = 0;
6713      var seg;
6714
6715      function fill(color, shadow) {
6716        return css(createEl(), {
6717          position: 'absolute',
6718          width: (o.length+o.width) + 'px',
6719          height: o.width + 'px',
6720          background: color,
6721          boxShadow: shadow,
6722          transformOrigin: 'left',
6723          transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
6724          borderRadius: (o.width>>1) + 'px'
6725        });
6726      }
6727      for (; i < o.lines; i++) {
6728        seg = css(createEl(), {
6729          position: 'absolute',
6730          top: 1+~(o.width/2) + 'px',
6731          transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
6732          opacity: o.opacity,
6733          animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
6734        });
6735        if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}));
6736        ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')));
6737      }
6738      return el;
6739    },
6740    opacity: function(el, i, val) {
6741      if (i < el.childNodes.length) el.childNodes[i].style.opacity = val;
6742    }
6743  });
6744
6745  /////////////////////////////////////////////////////////////////////////
6746  // VML rendering for IE
6747  /////////////////////////////////////////////////////////////////////////
6748
6749  /**
6750   * Check and init VML support
6751   */
6752  !function() {
6753
6754    function vml(tag, attr) {
6755      return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr);
6756    }
6757
6758    var s = css(createEl('group'), {behavior: 'url(#default#VML)'});
6759
6760    if (!vendor(s, 'transform') && s.adj) {
6761
6762      // VML support detected. Insert CSS rule ...
6763      sheet.addRule('.spin-vml', 'behavior:url(#default#VML)');
6764
6765      Spinner.prototype.lines = function(el, o) {
6766        var r = o.length+o.width;
6767        var s = 2*r;
6768
6769        function grp() {
6770          return css(vml('group', {coordsize: s +' '+s, coordorigin: -r +' '+-r}), {width: s, height: s});
6771        }
6772
6773        var margin = -(o.width+o.length)*2+'px';
6774        var g = css(grp(), {position: 'absolute', top: margin, left: margin});
6775
6776        var i;
6777
6778        function seg(i, dx, filter) {
6779          ins(g,
6780            ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
6781              ins(css(vml('roundrect', {arcsize: 1}), {
6782                  width: r,
6783                  height: o.width,
6784                  left: o.radius,
6785                  top: -o.width>>1,
6786                  filter: filter
6787                }),
6788                vml('fill', {color: o.color, opacity: o.opacity}),
6789                vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
6790              )
6791            )
6792          );
6793        }
6794
6795        if (o.shadow) {
6796          for (i = 1; i <= o.lines; i++) {
6797            seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)');
6798          }
6799        }
6800        for (i = 1; i <= o.lines; i++) seg(i);
6801        return ins(el, g);
6802      };
6803      Spinner.prototype.opacity = function(el, i, val, o) {
6804        var c = el.firstChild;
6805        o = o.shadow && o.lines || 0;
6806        if (c && i+o < c.childNodes.length) {
6807          c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild;
6808          if (c) c.opacity = val;
6809        }
6810      };
6811    }
6812    else {
6813      useCssAnimations = vendor(s, 'animation');
6814    }
6815  }();
6816
6817  window.Spinner = Spinner;
6818
6819})(window, document);
6820
6821
6822//-----------------------------------------------------------------------------------------------------------
6823function getCurrentURLParameter(param)
6824{
6825return getURLParameter(window.location.href, param);
6826}
6827
6828//-----------------------------------------------------------------------------------------------------------
6829function getURLParameter(url, param)
6830{
6831	var newAdditionalURL = "";
6832	var tempArray = url.split("?");
6833	var baseURL = tempArray[0];
6834	var additionalURL = tempArray[1];
6835	var temp = "";
6836	var paramValue = "";
6837	
6838	if (additionalURL) 
6839	{
6840		tempArray = additionalURL.split("&");
6841		for (i=0; i<tempArray.length; i++)
6842		{
6843			if(tempArray[i].split('=')[0] == param)
6844			{
6845				paramValue = tempArray[i].split('=')[1];
6846			}
6847		}        
6848	}
6849	else
6850	{
6851		paramValue = "";
6852	}
6853	DebugLog('getURLParameter - param['+param+'], value['+paramValue+'], url['+url+']');
6854  return paramValue
6855}
6856
6857//-----------------------------------------------------------------------------------------------------------
6858function updateURLParameter(url, param, paramVal)
6859{
6860    var TheAnchor = null;
6861    var newAdditionalURL = "";
6862    var tempArray = url.split("?");
6863    var baseURL = tempArray[0];
6864    var additionalURL = tempArray[1];
6865    var temp = "";
6866
6867    if (additionalURL) 
6868    {
6869        var tmpAnchor = additionalURL.split("#");
6870        var TheParams = tmpAnchor[0];
6871            TheAnchor = tmpAnchor[1];
6872        if(TheAnchor)
6873            additionalURL = TheParams;
6874
6875        tempArray = additionalURL.split("&");
6876
6877        for (i=0; i<tempArray.length; i++)
6878        {
6879            if(tempArray[i].split('=')[0] != param)
6880            {
6881                newAdditionalURL += temp + tempArray[i];
6882                temp = "&";
6883            }
6884        }        
6885    }
6886    else
6887    {
6888        var tmpAnchor = baseURL.split("#");
6889        var TheParams = tmpAnchor[0];
6890            TheAnchor  = tmpAnchor[1];
6891
6892        if(TheParams)
6893            baseURL = TheParams;
6894    }
6895
6896    if(TheAnchor)
6897        paramVal += "#" + TheAnchor;
6898		
6899		if(!(paramVal === '')){
6900			var rows_txt = temp + "" + param + "=" + paramVal;
6901		}else{
6902			var rows_txt = "";
6903		}
6904    return baseURL + "?" + newAdditionalURL + rows_txt;
6905}

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.