	
	// check for NS 7+, IE 5+ or Firefox
	var minIEversion = 5;
	var minNSversion = 5;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows		
	var IEcheck = Number(navigator.appVersion.charAt(navigator.appVersion.indexOf("MSIE")+5)) >= minIEversion;				
	var NScheck = parseInt(navigator.appVersion) >= minNSversion  && navigator.userAgent.indexOf("Netscape") != -1;
	var FFcheck = navigator.userAgent.indexOf("Firefox") != -1;
	var OPcheck = navigator.userAgent.indexOf("Opera") != -1;
	var SAFcheck = navigator.userAgent.indexOf("Safari") != -1;

	function repopulate (popSourceString) {
		var originalCustomListForm = document.forms[1];
		if(!originalCustomListForm)originalCustomListForm = document.forms[0];
		if(typeof(originalCustomListForm.sourceCheckBox) == 'object'){
			var numBoxes = (originalCustomListForm.sourceCheckBox.length) ? originalCustomListForm.sourceCheckBox.length : 1;
			for(var i = 0; numBoxes > i; i++){				
				if(numBoxes == 1){
					if(popSourceString.search(originalCustomListForm.sourceCheckBox.value) != -1){
						originalCustomListForm.sourceCheckBox.checked = true;
					}
				}else{				
					if(popSourceString.search(originalCustomListForm.sourceCheckBox[i].value) != -1){
						originalCustomListForm.sourceCheckBox[i].checked = true;
					}
				}								
			}
		}
	}
	
	//**************************************************************************
	
	function disenableInput(input, check1, check2){	
		input.className = "searchForm";
		input.disabled = false;
		if(check1 == check2){
			input.disabled = true;
			input.className = "disabled";
			if(input.type == "text"){input.value = ''};
		}
	}

	//**************************************************************************		
	
	function changeVal(input,val,f,fsubmit){			
		test1 = typeof f == "undefined" ? false : true;
		test2 = typeof fsubmit == "undefined" ? false : true;
		input.value = val;		
		if(test1 && test2){
			f.submit();
		}
	}

	//**************************************************************************
	
	function Print_Window(docid){	
		var width   = 640;
		var height  = 480;
		if (parseInt(navigator.appVersion) >= 4){
			var top     = (screen.availHeight - height) / 2;
			var screenY = top;
			var left    = (screen.availWidth - width) / 2;
			var screenX = left;
			var BrowseWindow = window.open("http://"+this.location.host+this.location.pathname+"?p_action=print&p_docid=" + docid, "Print", "width="+width+",height="+height+",screenX="+screenX+",screenY="+screenY+",top="+top+",left="+left+",toolbar,status,menubar,scrollbars,resizable");
		}else{
			var BrowseWindow = window.open("http://"+this.location.host+this.location.pathname+"?p_action=print&p_docid=" + docid, "Print", "width="+width+",height="+height+",toolbar,status,menubar,scrollbars,resizable");
		}
	}
	
	
	//**************************************************************************	
	// IE 5, 5.5 minimal array support, NS 4, 4.7 "switch" generates errors, crashes browser; hence the ugliness
	function browseCheck (customDate, setDate) {
		var dStr = customDate.replace(/[-\/]/g,'#')+'#';
		var dArr = new Array();
		var loop = true;		
		while(loop == true){
			dArr[dArr.length] = (dStr.substring(0, dStr.indexOf('#')));
			dStr = dStr.substring(dStr.indexOf('#') + 1, dStr.length);
			loop = dStr.indexOf('#') == -1 ? false : true;
		}		
		if (dArr == null || typeof dArr.length == "undefined" || dArr.length != 3){				
			alert('Please enter a valid date in either MM/DD/YYYY or YYYY/MM/DD format.');
			return false;
		}else if (dArr[0].length == 4 && dArr[2].valueOf() <= 31 && dArr[1].valueOf() <= 12){
			setDate.value = dub(dArr[0])+'-'+dub(dArr[1])+'-'+dub(dArr[2]);
			return true;
		}else if (dArr[0].valueOf() <= 12 && dArr[1].valueOf() <= 31 && dArr[2].length == 4){
			setDate.value = dub(dArr[2])+'-'+dub(dArr[0])+'-'+dub(dArr[1]);
			return true;
		}else{				
			alert('Please enter a valid date, either in mm/dd/yyyy or yyyy/mm/dd format.');
			return false;
		}
		function dub (val) {
			var n = Number(val);			
			return n < 10 ? '0'+String(n) : n;			
		}
	}

	
	//**************************************************************************
	/* modded by BC, 04-11-05 */   
	/*
	function emailCheck (str,alertMsg) {			
		am = alertMsg ? alertMsg : "The email address entered ("+str+") is invalid. Please correct the address and try again.";
		var valid = false;
		address = str.toLowerCase();
		var at = address.indexOf("@");
		var period = address.indexOf(".",at);
		if (((at > 0) && (period > at+1) && (address.length > period+1) && address.indexOf('minneapolis@fbi.gov') == -1)){valid = true;}			
		if (valid == false){alert(am);}
		return valid;
	}
	*/
	
	/*
	2005.05.06 - recurse over commas (free entry splitter)	
	*/	
	function emailCheck (str,alertMsg) {			
		var toArr = str.split(',');		
		var multiCheck = true;		
		for(var i=0;i<toArr.length;i++){
			//alert(i);
			if(!checkSub(toArr[i])){
				am = alertMsg ? alertMsg : "The email address entered ("+toArr[i]+") is invalid. Please correct the address and try again.";
				alert(am);
				multiCheck = false;
				break;
			}
		}		
		function checkSub (str) {
			var valid = false;
			var emCheck  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;							
			if (emCheck.test(str.trim())){valid = true;}		
			return valid;			
		}		
		return multiCheck;		
	} 
	
	
	//**************************************************************************
	/* added by BC, 04-11-05 */
	function displayHide(el,f,foc){							
		if(document.getElementById(el)){
			var prop = String(document.getElementById(el).style.display);
			document.getElementById(el).style.display = (prop == 'none') ? 'block' : 'none';
			if(document.forms[f].elements[foc] && prop == 'none')document.forms[f].elements[foc].focus();
		}		
	}
	
	//**************************************************************************
	
	/* new push functions, rewrittten onsubmit check added by BC, 04-22-05 */
	
	// set on page now var tb = document.forms['pushSignUp'].elements['toEmail'];						
	function addPushSelections(sel){							
		var rawTxt = tb.value + ', ' + sel;							
		var outputTxt = '';	
		var toArr = rawTxt.split(',');
		
		var addComma = false;
		for (var i=0; toArr.length>i;i++){								
			if(toArr[i].toString().length > 0){									
				outputTxt += (addComma ? ', ' : '') + toArr[i].toString().trim(); 
				addComma = true;									
			}
		}	
		tb.value = outputTxt;					
	}						
	function clearPushSelections(sel){
		tb.value = '';							
	}
	function pushCheck (currentForm, allElements) {							
		//populated unchecked
		var populated = false;							
		//validate email addresses in list, pop form as needed
		var toArr = tb.value.split(',');
		for (var i=0; toArr.length>i;i++){								
			var ec = toArr[i].toString().length > 0 && emailCheck(toArr[i].toString());					
			populated = ec ? true : false;
			if(!populated  && toArr[i].toString().length > 0) {
				var fullString = tb.value.toString();
				var subString = toArr[i].trim();
				var s = fullString.indexOf(subString);
				var e = s + subString.length;				
				setInputSelection(tb,s,e);
				return false;
				break; 
			}else if(ec){
				var input = document.createElement('INPUT');
				input.setAttribute('type', 'hidden');
		      input.setAttribute('name', 'f_email');
		      input.setAttribute('value', toArr[i].toString().trim());
		      currentForm.appendChild(input);
			}
		}
		// final check	
		if (populated){return true;}
		else{
			alert("Please enter at least one email address to send updates to.");
			return false;		
		}
	}
	
	/* could be useful elsewhere */	
	function setInputSelection(el,s,e){
		if (el.createTextRange) {
         var range = el.createTextRange();         
         range.moveStart("character", s);
         range.moveEnd("character", e - el.value.length);              
         range.select();
     } else if (el.setSelectionRange) {
         el.focus();
         el.setSelectionRange(s,e);
     }
	}
	
	/* added by BC, 04-11-05 */
	function displayLists(name,to,cc){							
		var main = '<b> List Name: "'+name+'"</b>';
		var toArr = to.split(',');
		var ccArr = cc.split(',');
		
		to = '<p/>to: ';
		var txt = '';
		for (var i=0; toArr.length>i;i++){
			txt += toArr[i] + ' ';
			
		}
		to += txt;
		
		if(ccArr.toString() != ''){
			cc += '<p/>cc: ';
			var txt = '';
			for (var i=0; ccArr.length>i;i++){
				txt += ccArr[i]+' ';
			}
		}
		
		cc += txt;
		
		var msgWindow = open('folderContents','window','resizable=no,width=450,height=175,scrollbars=yes');
		msgWindow.document.write('<html><head><title>'+name+'</title></head><body style="font-size:75%;font-family:arial;sans-serif">'+main+to+cc+'</body></html>');	
		msgWindow.document.close();

	}
	
	//**************************************************************************
	
	/* added by BC, 04-22-05 */
	String.prototype.trim = function(){ 
		return this.replace(/^\s*|\s*$/g,"");
	}
	
	/* added by BC, 04-11-05 */
	function email (f) {		
		
		//gather up the adress lists and evaluate, create a master array of to's and cc's
		var el = f.elements['addressSet'];		
		var to = new Array();
		var cc = new Array();		
		
		if(el && el.length > 1){
			//ie only thinks it's an object, a "for in" don't cut it, must treat as array			
			for(var c=0;c<el.length;c++){
				if (el[c].checked){
					popInput(eval(el[c].value));					
				}
			}
		}else if(el && el.checked){			
			popInput(eval(el.value));
		}
		
		// begin the setter variables, check addresses as they are added -- comma separate
		var to_str = '';
		var cc_str = '';
		

		
		//run throught the "to" addresses in the passed lists
		if(String(to.join()) != ''){
			for (var i in to){
				var pass = emailCheck(to[i]);
				if (!pass){return false; break;}
				else if(to[i].toString() != ''){to_str += (to_str != ''?',':'')+to[i]}															
			}
		}
		//add the free form input if it exists and is well formed
		var s = String(f.elements['address_text'].value ? f.elements['address_text'].value : '');
		if(s != '' && emailCheck(s) == false){
			return false;			
		}else if (s != ''){
			to_str = s != '' && emailCheck(s) ? to_str += (to_str != '' ? ',' : '')+s : str;
		}	
				
		//run throught the "cc" addresses in the passed lists			
		if(String(cc.join()).replace(',','') != ''){			
			for (var i in cc){
				var pass = cc[i] == '' || emailCheck(cc[i]);
				if (!pass){return false; break;}
				else if(cc[i].toString() != ''){cc_str += (cc_str != ''?',':'')+cc[i]}															
			}			
		}
		
		//final logic, make sure there is at least one "to" address	
		if (to_str != ''){
			f.elements['f_address'].value = to_str;
			f.elements['f_address_cc'].value = cc_str;
			return true;
		}else{
			alert('You need at least one "to" address in order to send your email.');
			return false;
		}		
		
		function popInput(tmp){
			to = to.concat(tmp[0].toString().split(','));
			cc = cc.concat(tmp[1].toString().split(','));						
		}				
	}
	
	//**************************************************************************
	/*
	function pushCheck (currentForm, allElements) {			
		var populated = false;
		for(var i=0;i<allElements.length;i++){
			if(allElements[i].name == 'f_email' && allElements[i].checked == true)
				populated = true;
		}	
		if (populated == true){
			return true;
		}else{
			alert("Please select at least one email address to send updates to.");
			return false;		
		}	
	}
	*/
	
	function folderExists(folderName) {
		if(typeof allFoldersList == 'undefined' || allFoldersList.indexOf('|' + folderName) == -1){
			return false;
		}else{
			return true;
		}
  	}
  	
  	//**************************************************************************
  	
  	function isValidNewFolderName(folderName) {
      if (folderName == ''){
           alert("Please enter a folder name.");
           return false;
       }
  	   else if (folderExists(folderName)) {
  	        alert('Folder name already in use. Please choose a unique name.');
  	        return false;
  	    }
  	   else if (folderName.length > 25) {
  	        alert('Folder name must be 25 characters or less, please use a shorter name.');
  	        return false;
  	    }  	    
  	    // reached end, everything ok
  	    return true;
  	}
  	
  	
  	function isValidList(listName, toEmail) {
	   var validList = false;
	       if(emailCheck(toEmail,"You must have at least one valid address in the 'to' field.") && listName != ''){
	       	validList = true;
	       }
	  if(listName == ''){ alert("Please enter a 'list name'."); validList = false;}		
	   if(listName.length > 25){alert('List name must be 25 characters or less, please use a shorter name.');validList = false;}	           
	   return (validList == true)? true : false;
	}
	
	
	//**************************************************************************
	/* 09-29-03 this will replace all checkbox functions, dynamically applies 
		checkbox value based on parameters and checkbox checked state.. */	
	
	function checkboxValue (currentForm, input, elementNum, checkedValue, uncheckedValue) {
		
		var cVal = (typeof checkedValue != "undefined") ? checkedValue : "true";
		var uVal = (typeof uncheckedValue != "undefined") ? uncheckedValue : "false";
		
		if(!input.checked) {
			currentForm.elements[elementNum].value = uVal;
		}
		else {
			currentForm.elements[elementNum].value = cVal;
		}
	}
	
	//**************************************************************************
	
	function clearSelections (multiString, formNum) {
		for(var i=0; i<document.forms[formNum].elements.length; i++){
			if(document.forms[formNum].elements[i].checked == true && multiString.indexOf(document.forms[formNum].elements[i].value) != -1){
				document.forms[formNum].elements[i].checked = false;
			}
		}
	}
	
	//**************************************************************************
	
	function addSelections (multiString, formNum) {
		for(var i=0; i<document.forms[formNum].elements.length; i++){
			if(document.forms[formNum].elements[i].checked == false && multiString.indexOf(document.forms[formNum].elements[i].value) != -1){
				document.forms[formNum].elements[i].checked = true;
			}
		}			
	}
	
	//**************************************************************************
	
	function multiCheck (currentForm, allElements) {
		var validated = true;
		var newMulti = '';
		var customSources = allElements['d_sources'].value == 'custom' && typeof(allElements['passthrough']) == 'undefined';
		var customVal = false;		
		var indexPage = false;	
		
		if(typeof(holdupSearch) == "undefined"){holdupSearch = false;}		
		
		for(var i = 0; allElements.length > i; i++){
			//append new multi value
			if(allElements[i].name == 'sourceCheckBox' && allElements[i].checked){				
				newMulti = newMulti + allElements[i].value + '|';
			}
			//flag index
			if(allElements[i].name == 'sourceCheckBox'){				
				indexPage = true;
			}
			//prevent bad chars (preliminary)
			if((allElements[i].name == 'p_text_base-0' || allElements[i].name == 'p_text_base-1') && allElements[i].value == '&'){				
				validated = false;
				alert('"&" is not a valid search term.');					
			}
		}  
		
		if(customSources && newMulti == ''){
			for(var j = 0; allElements.length > j; j++){
				//append new multi value
				if(allElements[j].name == 'sourceCheckBox'){				
					newMulti = newMulti + allElements[j].value + '|';
				}
				//flag index
				if(allElements[j].name == 'sourceCheckBox'){				
					indexPage = true;
				}
				//prevent bad chars (preliminary)
				if((allElements[j].name == 'p_text_base-0' || allElements[j].name == 'p_text_base-1') && allElements[j].value == '&'){				
					validated = false;
					alert('"&" is not a valid search term.');					
				}
			}  
		}
		
		/* if the newMulti, those boxes that are checked, exists replace the old multi, it is the new custom limiter,
			else repopulate the location or customlimiter form param, as a clearing method */
		
		if(newMulti != ''){
			currentForm.p_multi.value = newMulti;
			//currentForm.f_multi.value = newMulti;			
		}else if(indexPage){	//remove the search locking 
			//currentForm.f_multi.value = '';
		}
		
		/*if(customSources && newMulti == ''){
			alert('Please select at least one source before searching.');
			validated = false;
		}*/
		
		if(holdupSearch == true){
			validated = false;
		}
		
		if(validated == true){
			searchMessage();
		}
		
		return validated;
	}	
	
	//**************************************************************************
	
	function searchMessage(){	
		window.scrollTo(0,0);
		document.getElementById('searchingLayer').style.visibility = 'visible';						
		if(browserIsEligible()){
			document.getElementById('bgLayer').style.visibility = 'visible';
			if(typeof document.forms['searchForm'] != "undefined"){
				var el = document.forms['searchForm'].elements;
				for(var i=0;i<el.length;i++){
					if(el[i].type == 'select-one'|| el[i].type == 'text'){
						//alert(el[i].name+': '+el[i].type);
						el[i].style.backgroundColor = '#b2b2b2';
					}
				}
			}
		}	
		stretchBG();		
	}
	
	function stretchBG(){		
		if(browserIsEligible()){
		document.getElementById('bgLayer').style.width = document.body.scrollWidth;
		document.getElementById('bgLayer').style.height = document.body.scrollHeight;
		}
	}
	function hideSearchMessage(){		
		if(browserIsEligible()){
		document.getElementById('searchingLayer').style.visibility = 'hidden';	
		document.getElementById('bgLayer').style.visibility = 'hidden';	
		var el = document.forms['searchForm'].elements;
		for(var i=0;i<el.length;i++){
				if(el[i].type == 'select'||'text'){
					el[i].style.backgroundColor = 'ffffff';
				}
			}
		}
	}
	
	function browserIsEligible(){     
	     	var browserCleared = (NScheck || IEcheck || FFcheck) && isWin ? true : false;
	     	return browserCleared;
	}		
	
	function flashIsEligible(){
		// check for flash 6r65 or better		
		var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
		var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows			
		var flashVersion = 0;
		var flashBuild = 0;
		if (navigator.plugins["Shockwave Flash"]) {
     		 var flashDescription = navigator.plugins["Shockwave Flash"].description;
     		 flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
     		 flashBuild = number(flashDescription.substring(flashDescription.indexOf("r")+1, flashDescription.length));     		
     	}
	 	var flashCleared = (flashVersion > 6 || (flashVersion == 6 && flashBuild >= 65)) ? true : false;
		return flashCleared;
	}
	//**************************************************************************
	
	function popWindow(location,w,h,x,y){
        
	    var width   = 625;
	    var height  = 525;
	    var winLocString = location.toString();
	   
	   //get a unique name without having to pass one in
	    var tempString = winLocString.slice(winLocString.lastIndexOf('action=') + 7);   
	    var winName = tempString.slice(0, 3);
	    
		if (w) {width=w;}
		if (h) {height=h;}    
	        
	    if (parseInt(navigator.appVersion) >= 4)
	      {
	        var top = (screen.availHeight - height) / 2;
	        var screenY = (typeof y != "undefined") ? y : top;
	        var left = (screen.availWidth - width) / 2;
	        var screenX = (typeof x != "undefined") ? x : left;
	      
	        theWindow = window.open(location, winName, "width="+width+",height="+height+",screenX="+screenX+",screenY="+screenY+",top="+screenY+",left="+screenX+",resizable,scrollbars,toolbar,location,status,menubar");
	     
	     
	     
	      } 
	    else
	      {theWindow = window.open(location, winName, "width="+width+",height="+height+",resizable,scrollbars,toolbar,location,status,menubar");}
	      
	    // Only focus if the browser is NOT MSIE 3 or older
	    var browserName = navigator.appName;
	    var browserVer = parseInt(navigator.appVersion);
	    
	    if (browserName != "Microsoft Internet Explorer" || browserVer > 4)
	      {
	        //delay a bit here because IE4 encounters errors
	        //when trying to focus a recently opened window
	        setTimeout('theWindow.focus();',250);
	      }
	      
	}
  
 	//**************************************************************************//
 	//** BEGIN: functions to support custom lists                             **//
	//**************************************************************************//
	
 	var lastKeystrokeTime = null;
	var sourceRowList = null;
	var nameModified = null;
	var sourceListModified = null; 
	var customListId = null;
	var customListElement = null;
	var selectedOptionSourceId = null;
	var userLoggedIn = null;
	var findSourceList = null;
	 	
	/**** ??pep - temporary functions for performance testing***/
	var startTime = 0;
	
	function startTimer(){
		startTime = new Date().getTime();
	}
	
	function endTimer(){
		var endTime = new Date().getTime(); 
		return (endTime - startTime)/1000;
		startTime = 0;
	}
	/*************** end temporary functions *****************/

	function initCustomListGlobals(listID, loggedIn){ 
		customListId = listID;
		customListElement = document.getElementById(customListId + "_list_body");
		findSourceList = document.getElementById("findSourceList");
		setLineColor(null, true, true);  
		userLoggedIn = loggedIn;
	}
	
	function eventObject(event){
		this.event = event==null ?  window.event:event;
	} 
	
	eventObject.prototype.getRawEvent = function(){ 
		return this.event;  
	}

	eventObject.prototype.getKeyCode = function(){ 
		if(!this.event) return false; 
		if(this.event.keyCode) return this.event.keyCode;
		return false;  
	}        
	
	eventObject.prototype.getSrcElement = function(){
		if(!this.event) return false; 
		if(this.event.target) return this.event.target;
		if(this.event.srcElement) return this.event.srcElement;
		return false;  
	}

	eventObject.prototype.getType = function(){ 
		if(!this.event) return false; 
		if(this.event.type) return this.event.type;
		return false;  
	}

	eventObject.prototype.cancelBubble = function(){ 
		if(!this.event) return false; 
		if(this.event.stopPropagation) this.event.stopPropagation();
		else if(this.event.cancelBubble != null) this.event.cancelBubble = true;
		else return false;  
	}
        
        function elementWrapper(rawElement){ 
        	this.rawElement = rawElement;
        }
        
	elementWrapper.prototype.getText = function(){  
		//??pep - best not to use this function or the following function if this.rawElement is a cloned node. 
		//if this.rawElement is a cloned node, accessing element.textContent produces an error in Netscape.
		//using try-catch to trap the error will likely stop pages from rendering in older versions of Netscape.
		if(!this.rawElement) return false; 
		if(this.rawElement.text) return this.rawElement.text;
		else if(this.rawElement.textContent) return this.rawElement.textContent;
		else if(this.rawElement.innerText) return this.rawElement.innerText;
		else if(this.rawElement.innerHTML) return this.rawElement.innerHTML;
		else return false;
	}
		
	elementWrapper.prototype.setText = function(newText, appendText){ 
		if(!this.rawElement) return false;
		if(SAFcheck || OPcheck){
			this.rawElement.innerHTML = appendText!=null ? this.rawElement.innerHTML + newText:newText;  
		}
		else if(this.rawElement.text != null){
			this.rawElement.textContent = appendText!=null ? this.rawElement.text + newText:newText;  
		}
		else if(this.rawElement.textContent != null){
			this.rawElement.textContent = appendText!=null ? this.rawElement.textContent + newText:newText; 
		}
		else if(this.rawElement.innerText != null){
			this.rawElement.innerText = appendText!=null ? this.rawElement.innerText + newText:newText;
		}
		else return false;  
		return true;
	} 
	
	elementWrapper.getText = function(rawElement){
		return new elementWrapper(rawElement).getText();
	}
		
	elementWrapper.setText = function(rawElement, newText, appendText){
		return new elementWrapper(rawElement).setText(newText, appendText);
	} 
	
	function getChildNode(rawElement){
		var childNode = rawElement;
		for(var i=1; i < arguments.length; i++) {
			if(IEcheck)
				childNode = childNode.childNodes[arguments[i]];
			else
				childNode = getChildNodeByNumber(childNode, arguments[i]); 
		}
		return childNode; 
	} 
	
	function createElementWrapper(sTagName){ 
		var asNameValue = null;
		if(IEcheck && !isWin){
			var sInnerHTML = "<" + sTagName;
			for(var i=1; i < arguments.length; i++) {
					asNameValue = arguments[i].split("|");
					sInnerHTML += " " + asNameValue[0] + "='" + asNameValue[1] + "'"; 
			} 
			sInnerHTML += "/>"; 
			return document.createElement(sInnerHTML);
		}else{   
			var oNode = document.createElement(sTagName);
			for(var i=1; i < arguments.length; i++) {
					asNameValue = arguments[i].split("|");
					oNode.setAttribute(asNameValue[0],asNameValue[1]);			
			}
			return oNode;
		}
	}
	
	function getChildNodeById(parentNode, id){
		var iLength = parentNode.childNodes.length;
		for(var i=0; i <= iLength; i++){
			if(parentNode.childNodes[i].id == id){
				return parentNode.childNodes[i];
				if(parentNode.childNodes[i].childNodes && parentNode.childNodes[i].childNodes.length > 0){
					var oNode = getChildNodeById(parentNode.childNodes[i], id);
					if(oNode != null) return oNode;
				}
			}
		}
		return null;
	}
		
	function getChildNodeByNumber(parentNode, iNumber, iStartNode){
		if(IEcheck || SAFcheck)
			return parentNode.childNodes[iNumber];
		var iLength = parentNode.childNodes.length;
		var iCount = 0; 
		var iStartNode =  iStartNode ? iStartNode:0;
		for(var i=iStartNode; i < iLength; i++){
			if(parentNode.childNodes[i].nodeType == parentNode.ELEMENT_NODE){
				if(iCount == iNumber)return parentNode.childNodes[i];
				iCount++;
			}
		}
		return null;
	}

	function getElementNumber(parentNode, iNumber){
		if(IEcheck)
			return iNumber;
		var iLength = parentNode.childNodes.length;
		var iCount = 0;
		for(var i=0; i <= iLength; i++){
			if(parentNode.childNodes[i].nodeType == parentNode.ELEMENT_NODE){
				if(iCount == iNumber)return i;
				iCount++;
			}
		}
		return null;
	}
	
	function globalCustomOnClick(e){ 
		e = new eventObject(e);  
		var sourceElement = e.getSrcElement();
		if(sourceElement && sourceElement.id != "findSourceList" && sourceElement.parentNode.id != "findSourceList")
			findSourceList.style.display = "none";
	}
	
	function altDisplayInUse(){  
		return document.getElementById("locationAltDisplay").style.display != "none";
	}

	function toggleChildren(e, locId){
		if(altDisplayInUse())
			return;
		if(e){ 
			e = new eventObject(e);  
			globalCustomOnClick(e.getRawEvent()); 
			if(!e.getType() ||  e.getSrcElement().tagName == "A")
				return;
		}  		
  		var childElement, i=0;
  		toggleDisplay(document.getElementById(locId + "_toggle_plus"));
  		toggleDisplay(document.getElementById(locId + "_toggle_minus"));
  		do { 
  			i++;
  			childElement = document.getElementById(locId + "_" + i);
  			if(childElement) toggleDisplay(childElement, true);
  		} while(childElement != null);
		if(e) e.cancelBubble();
	}                
	 
	function expandParents(locId){
		var parentNodeIds = new Array();
		do { 
			parentNodeIds[parentNodeIds.length] = document.getElementById(locId).parentNode;
			locId = parentNodeIds[parentNodeIds.length-1].id.split("_")[0];
		} while(locId != "world"); 
		for(var j=parentNodeIds.length-1; j>=0; j--){ 
			parentNodeIds[j].onclick();
		}	
	}
	
	function toggleDisplay(element, useBlock, expandOnly){
		if(element) {
			var displayFormat = useBlock ? "block":"inline";
			if(element.style.display == "none")element.style.display = displayFormat;
			else if(!expandOnly)element.style.display = "none";
		}
	}
	
	function copyElementContents(fromElement, toElement, appendToExistingContent){
		if(fromElement && fromElement.innerHTML != null) {
			if(appendToExistingContent)
				toElement.innerHTML = toElement.innerHTML + fromElement.innerHTML;
			else
				toElement.innerHTML = fromElement.innerHTML;
			var titleCountNode = document.getElementById(fromElement.id + "_titleCount");
			if(titleCountNode && elementWrapper.getText(titleCountNode) != "1")
				toElement.innerHTML += " (" +  elementWrapper.getText(titleCountNode) + " titles)";
		}
	}
	
	function copyElementContentsById(fromElementId, toElementId, appendToExistingContent){
		var fromElement = document.getElementById(fromElementId);
		var toElement = document.getElementById(toElementId);
		if(fromElement && toElement)
			copyElementContents(fromElement, toElement, appendToExistingContent);   
	}
	
	function toggleCustomListView(viewMode, defaultLocation){ 
		switch(viewMode){     
			case "map":
				useMapView(defaultLocation);
				break;
			default:   
				useTreeView(defaultLocation);
				break;
		}
	}
	
	function useTreeView(defaultLocation){ 
		if(!defaultLocation || defaultLocation=="")defaultLocation = "world";
                clearAltDisplayView();
		document.getElementById("locationAltDisplay").style.display="none";
		document.getElementById("locationTree").style.display="";
	}

	function useMapView(defaultLocation){
		if(!defaultLocation || defaultLocation=="")defaultLocation = "world";
		populateMapDisplay(null, defaultLocation);
		document.getElementById("locationTree").style.display="none";  
		document.getElementById("locationAltDisplay").style.display=""; 
	}  
	
	function clearAltDisplayView(){
		var altDisplayElement = document.getElementById("locationAltDisplay");
		altDisplayElement.innerHTML = "";
	}      
	
	function populateMapDisplay(e, topElementId, numCols){
		e = new eventObject(e);		 
		//??pep - workaround for hrefs not firing from cloned elements 
        	if(e){    
 			e.cancelBubble();
       			var srcElement = e.getSrcElement();
        		if(srcElement && srcElement.href && srcElement.tagName != "IMG"){
	        		eval(srcElement.href);
	        		return;
	        	}
       		}     
       		
       		if(!numCols) numCols = 1;
       		
       		//clear current contents
                clearAltDisplayView(); 
                
		//create hidden input to store parentId. necessary for return path
		var parentIdElement = document.createElement("INPUT");
		parentIdElement.setAttribute("type","hidden");			
		parentIdElement.setAttribute("id","mapParentId");			
		parentIdElement.setAttribute("value",getParentId(topElementId));
					
		//create hidden input to store top element id. may be necessary for future reference. maybe not.
		var idElement = document.createElement("INPUT");
		idElement.setAttribute("type","hidden");			
		idElement.setAttribute("id","topElementId");			
		idElement.setAttribute("value", topElementId);

		//populate header div     
		var topElement = document.getElementById(topElementId);
		var headerElement = topElement.cloneNode(true);
		headerElement.style.display = "";
		headerElement.className = "custListHeader0_maptop";

		document.getElementById("locationAltDisplay").appendChild(headerElement);
		headerElement.appendChild(parentIdElement); 
		headerElement.appendChild(idElement); 
		
		//create container for scrolling			
		var contentsContainerElement = document.createElement("DIV");
		headerElement.appendChild(contentsContainerElement); 

		//populate return path - bread crumb trail
  	        populateReturnPath(contentsContainerElement, topElementId); 
                
		//populate selection lablel - narrow to: 
		updateClonedAttributes(headerElement.childNodes,"_maptop");
 
		//create container for scrolling			
		var tableContainerElement = document.createElement("DIV");
		contentsContainerElement.appendChild(tableContainerElement); 
		tableContainerElement.style.backgroundColor = "#FFFFFF";
		tableContainerElement.style.paddingTop = 10; 
		tableContainerElement.style.marginBottom = 15;
		tableContainerElement.style.marginLeft = 40;
		tableContainerElement.style.border = "solid #0000AA 1px";
		
 		//populate subheader columns    
		createColumns(tableContainerElement, topElement.id, numCols); 
		
		//workaround for display problem in IE6
		tableContainerElement.innerHTML = tableContainerElement.innerHTML; 
		
		//clean-up
		window.scrollTo(0,0); 	
		if(e)e.cancelBubble(); 
	}  
	
	/*??pep - keeping this for future use
	function addMapAreaHrefs(locationId){ 
		var imageMap = document.getElementById(locationId + "Map"); 
		for(var n in imageMap.childNodes){ 
			var childNode = imageMap.childNodes[n];
			if(childNode && childNode.tagName == "AREA") 
				childNode.href="javascript:populateMapDisplay(null, '" + childNode.alt + "')"; 
		}
	}*/	

	function populateReturnPath(containingNode, locationId){ 
		returnPathElement = document.getElementById("returnPath");  
		returnPathElement.innerHTML = "";
		if(locationId != "world") 
			returnPathElement.appendChild(createReturnPath()); 
	}    
	
	function createReturnPath(){  
		var linkArray = new Array();
		var pathContainer = document.createElement("SPAN"); 
		var parentId = document.getElementById("mapParentId").value; 
		
		var imageLinkElement = document.createElement("A");
		imageLinkElement.setAttribute("href","javascript:populateMapDisplay(null, '" + parentId + "')"); 
		var imageElement = document.createElement("IMG");
		imageElement.src = "http://images.newsbank.com/infoweb/agg/listArrow.gif"; 
		imageElement.style.marginRight = "4";
		imageElement.style.marginBottom = "-2"; 
		if(imageElement.style.cursor)
			imageElement.style.cursor = "pointer"; 
		imageElement.border = "0";
		imageLinkElement.appendChild(imageElement);
		pathContainer.appendChild(imageLinkElement);  
		do {              
			if(parentId) {
				var linkElement = document.createElement("A");
				linkElement.setAttribute("href","javascript:populateMapDisplay(null, '" + parentId + "')"); 
				linkElement.className = "custListReturnPath"; 
				var labelText = elementWrapper.getText(document.getElementById(parentId + "_name"));
				if(labelText.toUpperCase)
					labelText = labelText.toUpperCase();
				elementWrapper.setText(linkElement, labelText); 
				linkArray[linkArray.length] = linkElement; 
			}
			var parentId = getParentId(parentId); 
		}while(parentId);
		for(var j=linkArray.length-1; j>=0; j--) {
			pathContainer.appendChild(linkArray[j]);  
			if(j!=0){
				var separatorElement = document.createElement("SPAN");
				separatorElement.innerHTML = " - ";
				pathContainer.appendChild(separatorElement); 
			}
		}
		return pathContainer;
	}    
	
	function getParentId(childLocationId){ 
		if(!childLocationId)
			return null;
		var parentId = document.getElementById(childLocationId).parentNode.id.split("_")[0];
		if(parentId && parentId != "" && parentId != null) 
			return parentId;
		return parentId;
	}

	function createSelectionLabel(containingNode, displayedCols){ 
		var selectionLabel = document.createElement("DIV");
		selectionLabel.className = "custListReturnPath";
		containingNode.appendChild(selectionLabel); 
		elementWrapper.setText(selectionLabel, "Narrow to: "); 
	} 
	
	function createColumnSelector(containingNode, displayedCols){ 
		var colSelectLabel = document.createElement("SPAN");
		var colSelectInput = document.createElement("INPUT");
		colSelectLabel.innerHTML = "number of colums to display: ";
		colSelectLabel.style.marginLeft = "290";
		colSelectLabel.style.fontSize = "70%";
		colSelectLabel.style.fontWeight= "normal";
		colSelectLabel.style.color = "black";
		colSelectInput.id = "colSelectInput"; 
		colSelectInput.type = "text"; 
		colSelectInput.size = "2"; 
		colSelectInput.value = displayedCols; 
		colSelectInput.onkeyup = changeMapDisplay; 
		containingNode.appendChild(colSelectLabel); 
		containingNode.appendChild(colSelectInput); 
	} 
	
	function changeMapDisplay(){ 
		var cols = document.getElementById("colSelectInput").value;
		if(cols != "" && parseInt(cols)) 
			populateMapDisplay(null, document.getElementById("topElementId").value, parseInt(cols))	
	}

	function createColumns(containingNode, parentId, cols, displayDepth, currentDepth){ 
		if(!displayDepth) displayDepth = 2;  
		if(!currentDepth) currentDepth = 1;  
		if(!cols) cols = 2; 
		
		var colCount = 0;
		var colArray = new Array();  
		var nextNode = 0;
		var nodeArray = new Array();
		var childElement = null; 
				
		//create table element and  attach to container			
		var tableElement = document.createElement("TABLE");
		var rowElement = document.createElement("TR");
		tableElement.appendChild(rowElement);
		  
		  
		//create columns 
		for(var i=1; i<=cols; i++){
			colArray[i] = document.createElement("TD");
			colArray[i].setAttribute("id", parentId + "_Column" + i); 
			colArray[i].style.verticalAlign = "top"; 
			rowElement.appendChild(colArray[i]);
		} 
		 
		//copy cell contents   
		var j=0;
  		do { 
  			j++;
  			childElement = document.getElementById(parentId + "_" + j);
  			if(childElement){
				//??pep - safari fix: for:in syntax solves performance problem on ie, but safari does not support for:in for dom objects.
  				if(!SAFcheck){
	  				for(var n in childElement.childNodes){
	  					var oChild =  childElement.childNodes[n];   
	  					if(oChild.tagName == "DIV" && oChild.title == "contentNode"){
		  					copyNodeContents(oChild);
		  					break;
		  				}
		  			}
	  			}else{
	  				for(var n=0; n < childElement.childNodes.length; n++){
	  					var oChild =  childElement.childNodes[n];   
	  					if(oChild.tagName == "DIV" && oChild.title == "contentNode"){
		  					copyNodeContents(oChild);
		  					break;
		  				}
		  			}
		  		}
  			}
  		} while(childElement != null);   

 	  	nodeArray[nodeArray.length] = document.createElement("BR");
               
                //attach cell contents to appropriate columns
		for(var k=0; k < nodeArray.length; k++) {      
			var colNum = Math.ceil((k + 1)/Math.ceil(nodeArray.length/cols)); 
			colArray[colNum].appendChild(nodeArray[k]);
		} 
		containingNode.appendChild(tableElement); 

		function copyNodeContents(oChild){
			var contentNode = oChild.cloneNode(true); 
			if(contentNode.className != "custListPaper1")
				contentNode.setAttribute("onclick", "populateMapDisplay(event,'" + contentNode.id + "')");
			if(displayDepth == currentDepth && contentNode.className != "custListPaper1")
				contentNode.className = "custListLocation1_map";
			else
				contentNode.className = contentNode.className + "_map";
			contentNode.style.display = "";
			updateClonedAttributes(contentNode.childNodes, "_map");
			nodeArray[nodeArray.length] = contentNode;  
			if(displayDepth > currentDepth) 
				createColumns(contentNode, contentNode.id, 1, displayDepth, currentDepth + 1);
		}
	
	} 
	
	function updateClonedAttributes(nodeList, classExtension){
		//??pep - safari fix: for:in syntax solves performance problem on ie, but safari does not support for:in for dom objects.
		if(!SAFcheck){
			for(var i in nodeList)
				updateSubNode(nodeList[i]);
		}else{
			for(var i=0; i < nodeList.length; i++)
				updateSubNode(nodeList[i]);
  		}
  		
  		function updateSubNode(subNode){
			if(subNode){
				if(subNode.id)
					subNode.id += "_clone";
				if(subNode.style)  
					subNode.style.display = ""; 
				if(subNode.className && subNode.className != "custListPaperCount")
					subNode.className = subNode.className + classExtension;
				//??pep - the following conditional is a temporary workaround.
				//netscape is not accepting the classname .custListPaperCount_map. not sure why. 
				if(subNode.className && subNode.className == "custListPaperCount")
					subNode.className = "custListPaperCount_nsfix";  
				if(subNode.childNodes && subNode.childNodes.length > 0)
					updateClonedAttributes(subNode.childNodes, classExtension); 
			}
		}
	}
        
	function addRemoveSource(e, sourceId, bRemove){ 
		e = new eventObject(e);		 
		if(e)e.cancelBubble();

		if(!sourceId) return;   
		
		var sDisplay = !bRemove ? "":"none";
		var sActionLabel = !bRemove ? "remove":"add";
		var sourceRow = document.getElementById(customListId + "|" + sourceId);

		if(sourceRow)sourceRow.style.display = sDisplay;
		setLineColor();

		var actionElement = document.getElementById(sourceId + "_action");
		actionElement.innerHTML = '<a class="cusListSelectionButtons" onclick="' + sActionLabel + 'CustomListSource(event, \'' + sourceId + '\')">' + sActionLabel + '</a>';

		var cloneActionElement = document.getElementById(sourceId + "_action_clone");
		if(cloneActionElement)
			cloneActionElement.innerHTML = '<a class="cusListSelectionButtons_map" onclick="' + sActionLabel + 'CustomListSource(event, \'' + sourceId + '\')">' + sActionLabel + '</a>';

		if(sourceId == selectedOptionSourceId){
			var actionElement = document.getElementById("findSourceLink_container");
			actionElement.innerHTML = '<span id="findSourceLink" class="findSourceLink" onclick="' + sActionLabel + 'CustomListSource(event, \'' + sourceId + '\')">' + sActionLabel + '</span>';
		}
			
	}
	
	function addRemoveSources(e, sourceCodes, bRemove){ 
		window.document.body.style.cursor = "wait"
		 
		e = new eventObject(e);		 
		if(e)e.cancelBubble();
		if(!sourceCodes) return;
		
                var iRowsLength = customListElement.rows.length;
		var arraySourceCodes = sourceCodes.split("|");
		showUpdateMessage(arraySourceCodes.length);
		var asCodeKey = new Array();
		var asActionCodeKey = new Array();
		var asActionCloneCodeKey = new Array();
		var iFocusRow = null;
		var sDisplay = !bRemove ? "":"none";
		var sActionLabel = !bRemove ? "remove":"add";
	
		for (var sKey in arraySourceCodes){
			asCodeKey[customListId + "|" + arraySourceCodes[sKey]] = arraySourceCodes[sKey];
			asActionCodeKey[arraySourceCodes[sKey] + "_action"] = arraySourceCodes[sKey];			
                        asActionCloneCodeKey[arraySourceCodes[sKey] + "_action_clone"] = arraySourceCodes[sKey];
		}
		for(var i=0; i < iRowsLength; i++){
			if(asCodeKey[customListElement.rows[i].id]){ 
				if(!bRemove && customListElement.rows[i].style.display == "none"){
					getChildNode(customListElement.rows[i], 1).style.color = "#2244FF";
					iFocusRow = i; 
				}
				customListElement.rows[i].style.display = sDisplay;
				getChildNode(customListElement.rows[i], 0, 0).checked = false;
			} 
		}

		setLineColor(iFocusRow);
		
		if(!sourceRowList)
			sourceRowList = document.getElementsByTagName("SPAN");
		
		var iCounter = 0; 
		//??pep - safari fix: for:in syntax solves performance problem on ie, but safari does not support for:in for dom objects.
		if(!SAFcheck){
			for(var i in sourceRowList)
				updateInnerHTML();
		}else{
			for(var i=0; i < sourceRowList.length; i++)
				updateInnerHTML();
  		}

		if(asCodeKey[customListId + "|" + selectedOptionSourceId])
			document.getElementById("findSourceLink_container").innerHTML = '<span  id="findSourceLink" class="findSourceLink" onclick="' + sActionLabel + 'CustomListSource(event, \'' + selectedOptionSourceId + '\')">' + sActionLabel + '</a>';

		hideUpdateMessage();
		window.document.body.style.cursor = "default" 
		
		function updateInnerHTML(){
			if(sourceRowList[iCounter] && sourceRowList[iCounter].id && sourceRowList[iCounter].id.match(new RegExp("_action$|_action_clone$"))) {
				if(asActionCodeKey[sourceRowList[iCounter].id])
				        sourceRowList[iCounter].innerHTML = '<a class="cusListSelectionButtons" onclick="' + sActionLabel + 'CustomListSource(event, \'' + sourceRowList[iCounter].parentNode.id + '\')">' + sActionLabel + '</a>';
				if(asActionCloneCodeKey[sourceRowList[iCounter].id])
				        sourceRowList[iCounter].innerHTML = '<a class="cusListSelectionButtons_map" onclick="' + sActionLabel + 'CustomListSource(event, \'' + sourceRowList[iCounter].parentNode.id + '\')">' + sActionLabel + '</a>';
			} 
			iCounter++;
		}
	}
	
	function removeMultipleSourcesFromCustomList(e){
		var selectedSources = document.getElementsByTagName("INPUT");
		var sourceArray = new Array();
		for(var i = selectedSources.length-1; i >= 0; i--) {
			if(selectedSources[i].name.match(new RegExp("_sourceSelection"))!=null && selectedSources[i].checked)
				sourceArray[sourceArray.length] = selectedSources[i].value;	
		}
		addRemoveSources(e, sourceArray.join("|"), true)	
		setSelectionState();
		setLineColor(); 
	}
	
	function addCustomListSource(e, sourceId){   
		e = new eventObject(e);		 
		if(e)e.cancelBubble();
		addRemoveSource(e, sourceId);
	}
	
	function removeCustomListSource(e, sourceId){   
		e = new eventObject(e);		 
		if(e)e.cancelBubble();
		addRemoveSource(e, sourceId, true);
	}
	
	function showUpdateMessage(iMin){ 
		if(iMin > 25)
			document.getElementById("customListUpdate").style.display = "";
	}   
	
	function hideUpdateMessage(){ 
		//??pep - visibility update forces screen redraw - Opera bug workaround.
		document.body.style.visibility = "hidden";
		document.getElementById("customListUpdate").style.display = "none";
		document.body.style.visibility = "visible";
	}   
	
	function toggleAddRemoveLink(linkElement, sourceId, sLabel){   
		if(sLabel=='remove' || (!sLabel && linkElement.innerHTML.match(new RegExp('add')))){
			linkElement.innerHTML = linkElement.innerHTML.replace(/onclick="[^"]*"/,'onclick="removeCustomListSource(event, \'' + sourceId + '\')"');
			linkElement.innerHTML = linkElement.innerHTML.replace(/add/,"remove");
		} else {
			linkElement.innerHTML = linkElement.innerHTML.replace(/onclick="[^"]*"/,'onclick="addCustomListSource(event, \'' + sourceId + '\')"');
			linkElement.innerHTML = linkElement.innerHTML.replace(/remove/,"add");
		}
	}
	
	function setAllCustomListSources(selectionFlag){
		var iLength = customListElement.rows.length;
		for(var i=0; i < iLength; i++){
			if(customListElement.rows[i].style.display != "none")
				getChildNode(customListElement.rows[i], 0, 0).checked = selectionFlag;
		}
		setSelectionState();
	}
        
       function setSelectionState(srcRowId){     
        	var removeLink = document.getElementById("removeSourcesLink");
        	if(checkSelectionStatus()) removeLink.className = "contentSmallLink";
       		else removeLink.className = "contentSmallLinkDisabled";  
        }
        
	function checkSelectionStatus(){
		var selectedSources = document.getElementsByTagName("INPUT");
		for(var i = selectedSources.length-1; i >= 0; i--) {
			if(selectedSources[i].name.match(new RegExp("_sourceSelection"))!=null && selectedSources[i].checked) {
				return true;	
			}
		}
		return false;
	}
	
	function setLineColor(iFocusRow, noCountColorChange, isInit){ 
		var lineColor = "#ffffff";
                var iRowsLength = customListElement.rows.length;
		var totalSourceElement = document.getElementById("totalSources");
		var titleCount = 0;
		for(i=0; i < iRowsLength; i++){  
			var rowNode = customListElement.rows[i];
			if(rowNode && rowNode.style.display != "none") {
				rowNode.bgColor = lineColor;
				lineColor = lineColor=="#ffffff" ? "#ececec":"#ffffff";  
				titleCount += parseInt(elementWrapper.getText(getChildNode(rowNode, 1, 0)));
				if(iFocusRow==null)iFocusRow=i; 
			}  
		}
		elementWrapper.setText(document.getElementById("totalSources"), titleCount);
		if(!isInit) setListModifiedIndicators(true);
		var focusRow = customListElement.rows[iFocusRow];
		if(iFocusRow!=null && document.body.scrollTop==0){ 
			var checkboxNode = getChildNode(focusRow, 0, 0);
			if(checkboxNode && checkboxNode.focus && checkboxNode.style.display != "none")
				checkboxNode.focus(); 
		}
		if(!noCountColorChange && document.getElementById("totalSources"))
			document.getElementById("totalSources").style.color = "#99FFFF";
	}
	
	function setListModifiedIndicators(listModified, listNameModified){
		if(listModified != null)
			sourceListModified = listModified;
		if(listNameModified != null)
			nameModified = listNameModified;
		if(listModified || listNameModified){
			var searchClass = "contentSmallButton";
			if(getListItemCount()== 0)
				searchClass = "contentSmallButtonDisabled";
			setButtonStates(searchClass, null, null, "contentSmallButton", null, "contentSmallButton"); 
		} else
			setButtonStates(null, null, null, "contentSmallButtonDisabled", null, null); 
		var rowMessage =  document.getElementById("customListRowMessage");
		if(rowMessage)
			rowMessage.style.display = "none"; 
	}
	
	function setButtonStates(searchClass, deleteClass, newClass, saveClass, copyClass, cancelClass){ 
		if(searchClass && document.getElementById("searchButton"))
			document.getElementById("searchButton").className = searchClass;
		if(deleteClass && document.getElementById("deleteButton"))
			document.getElementById("deleteButton").className = deleteClass;
		if(newClass && document.getElementById("newButton"))
			document.getElementById("newButton").className = newClass;
		if(saveClass && document.getElementById("saveButton"))
			document.getElementById("saveButton").className = saveClass;
		if(copyClass && document.getElementById("copyButton"))
			document.getElementById("copyButton").className = copyClass;
		if(cancelClass && document.getElementById("cancelButton"))
			document.getElementById("cancelButton").className = cancelClass;
	}
	
	function findSource(e, searchString, keystrokeTime) { 
		e = new eventObject(e);
		if(e.getKeyCode() == 40){ //??pep should probably use DOM_VK_DOWN
			highlightOption(e.getRawEvent(), 0)
			return;
		}
		var findSourceLink = document.getElementById("findSourceLink");
		findSourceLink.style.color = "#535353";
		findSourceLink.href = "";
		if(lastKeystrokeTime && searchString.length > 2){
			window.setTimeout("doFindSource('" + searchString + "'," + keystrokeTime + ")",100);
		}
		lastKeystrokeTime = keystrokeTime;
		
	}
	function doFindSource(searchString, keystrokeTime) {
		if(keystrokeTime == lastKeystrokeTime){
			var searchStringRegEx = new RegExp(escape(searchString), "i");
			var locationTree = document.getElementById("locationTree");
			var searchableText = escape(elementWrapper.getText(locationTree));
			clearOptions(findSourceList);
			if(searchableText.match(searchStringRegEx)) {
				//??pep - safari fix: for:in syntax solves performance problem on ie, but safari does not support for:in for dom objects.
				if(!SAFcheck){
					for(var r in customListElement.rows)
						addSourceOption(r, searchStringRegEx);
				}else{
					for(var r=0; r < customListElement.rows.length; r++)
						addSourceOption(r, searchStringRegEx);
		  		}
			}
			if(findSourceList.options.length > 0)
				findSourceList.style.display = "";
			else
				findSourceList.style.display = "none";  
				
		}
	}
	
	function addSourceOption(sRow, searchStringRegEx){
		var rowText = escape(elementWrapper.getText(customListElement.rows[sRow]));
		if(rowText && rowText.match(searchStringRegEx)){
			var sourceMatch = document.createElement("OPTION");
			sourceMatch.innerHTML = getChildNode(customListElement.rows[sRow],1).innerHTML;
			sourceMatch.removeChild(sourceMatch.childNodes[0]);
			sourceMatch.setAttribute("value", customListElement.rows[sRow].id.split("|")[1]);
			sourceMatch.setAttribute("onclick", "selectOption(event)");
			findSourceList.appendChild(sourceMatch);
		}
	}
	
	function clearOptions(selectElement){ 
		selectElement.innerHTML = "";
	}
	
	function selectOption(e){
		e = new eventObject(e);
		if(e.getKeyCode() == 13 || (e.getType()=="click" && e.getKeyCode() == 0)){ //??pep should probably use DOM_VK_ENTER and CLICK
			var findSourceLinkContainer = document.getElementById("findSourceLink_container");
			var findSourceLink = document.getElementById("findSourceLink");
			var findSourceInput = document.getElementById("findSourceInput");
			var sourceId = findSourceList.options[findSourceList.selectedIndex].value;
			var sourceElement = document.getElementById(sourceId + "_data").cloneNode(true);
			sourceElement.removeChild(sourceElement.childNodes[0]);
			sourceElement.removeChild(sourceElement.childNodes[0]);
			findSourceInput.value = sourceElement.innerHTML.replace(/&amp;/,"&");
			var sLabel = document.getElementById(customListId + "|" + sourceId).style.display=="none" ? "add":"remove";
			findSourceLinkContainer.innerHTML = '<span  id="findSourceLink" class="findSourceLink" onclick="' + sLabel + 'CustomListSource(event, \'' + sourceId + '\')">' + sLabel + '</span>';
			selectedOptionSourceId = sourceId;
			findSourceList.style.display = "none";
		}		
	}
	
	function highlightOption(e, optionNumber){
		e = new eventObject(e);
		findSourceList.focus();
		findSourceList.options[0].selected = true;	
		e.cancelBubble();			
	}
	
	function getListItemCount(){ 
		return parseInt(elementWrapper.getText(document.getElementById("totalSources")));
	}
	
	function UserDialog(elementId, callBack, bNoShow){  
		this.dialogContainerElement = document.getElementById(elementId);
		this.layoutDivId = elementId;
		this.callBack = callBack;
		this.callBackParams = new Array(); 
		this.customData = new Array();
		this.displayDiv = new Object(); 
		this.setDialogContainer("generic");
		for(var i=0; (i+3)<arguments.length; i++)
			this.callBackParams[i] = arguments[i+3]; 
		if(!bNoShow)
			this.showDialog();
	}
	
	UserDialog.prototype.setDialogContainer = function(sDisplayOption){ 
		if(sDisplayOption == "standard")
			this.dialogContainerElement = document.getElementById(this.layoutDivId);
		if(sDisplayOption == "generic"){
			var genericDialogContainer = document.getElementById(this.layoutDivId + "_generic");
			if(!genericDialogContainer) {
				genericDialogContainer = document.createElement("DIV");
				genericDialogContainer.setAttribute("id", this.layoutDivId + "_generic");
				document.body.appendChild(genericDialogContainer);
				genericDialogContainer.innerHTML = document.getElementById(this.layoutDivId).innerHTML; 
				genericDialogContainer.style.position = "absolute";
				genericDialogContainer.style.top = "300px";
				genericDialogContainer.style.left = "400px";
				genericDialogContainer.className = "contentDialog";
				genericDialogContainer.style.zIndex = 100;
			}	
			this.dialogContainerElement = genericDialogContainer;		
		}
	}

	UserDialog.prototype.setCustomData = function(data, sKey){ 
		if(!sKey)sKey = "default";
		this.customData[sKey]=data;
	}

	UserDialog.prototype.getCustomData = function(sKey){ 
		if(!sKey)sKey = "default";
		return this.customData[sKey];
	} 
	
	UserDialog.prototype.getDialogId = function(){ 
		return this.dialogContainerElement.id;
	}

	UserDialog.prototype.getDialogContainer = function(){ 
		return this.dialogContainerElement;
	} 

	UserDialog.prototype.setInitFunction = function(fInit){ 
		this.initFunction = fInit;
	}

	UserDialog.prototype.callInitFunction = function(){ 
		this.initFunction();
	}

	UserDialog.prototype.showDialog = function(){ 
		this.dialogContainerElement.style.display = "block";
		if(this.initFunction)this.callInitFunction();
	}

	UserDialog.prototype.hideDialog = function(){ 
		this.dialogContainerElement.style.display = "none";
	}    
	
	UserDialog.prototype.clearDialog = function(){
		this.hideDialog();
		destroyObject(this);
	}
	
	UserDialog.prototype.getState = function(){
		var dialogDisplay = this.dialogContainerElement.style.display;
		if(dialogDisplay=="block" || dialogDisplay=="inline" || dialogDisplay=="") 
			return "visible";
		if(dialogDisplay=="none") 
			return "hidden";  
		return null;
	}    
	
	UserDialog.prototype.executeCallBack = function(bRetainDialog){
		var argString = "";
		for(var i=0; i < this.callBackParams.length; i++){
			if(typeof(this.callBackParams[i])=="string")
				argString += "'" + this.callBackParams[i] + "'"; 
			else
				argString += this.callBackParams[i];
			if(i != this.callBackParams.length - 1)
				argString += ", ";
		} 
		eval(this.callBack  + "(" + argString + ")"); 
		if(!bRetainDialog) this.hideDialog();
	}           
	
	UserDialog.prototype.getCallBackParameter = function(paramNum){
		return this.callBackParams[paramNum];
	}           

	UserDialog.prototype.setCallBackParameter = function(paramNum, paramValue){
		this.callBackParams[paramNum] = paramValue;
	}           

	UserDialog.prototype.setCursor = function(cursorType){
		this.dialogContainerElement.style.cursor = cursorType;
	}   
		        
	function destroyObject(objRef){
		objRef = null;
	}   

	function click_FileArticle(articleID){ 
		var fileArticleForm = document.getElementById("fileArticlesForm");
		if(fileArticleForm)
			fileArticleForm.submit();
	} 

	function click_FileArticleCancel(){
		fileArticleDialog.clearDialog(); 
	} 
	
	function click_SaveChanges(){
		confirmationDialog.setCursor("wait");
		confirmationDialog.setCallBackParameter(2, true);
		confirmationDialog.executeCallBack(true);
	}

	function click_DiscardChanges(){
		confirmationDialog.setCursor("wait");
		confirmationDialog.setCallBackParameter(2, false);
		confirmationDialog.executeCallBack(true);
	}

	function click_CancelChanges(){
		confirmationDialog.hideDialog(); 
		document.getElementById("viewListSelect").selectedIndex = 0;
	}
	
	function click_AcceptListName(listName){
		var newListNameContainer = document.getElementById("customListNameInput");
		if(newListNameContainer){
			newListNameContainer.value = document.getElementById("customListNameDialogInput").value;
			nameModified = true;
		}
		var shortcutCheckbox = document.getElementById("customListNameDialogCheckbox");
		if(shortcutCheckbox)
			listNameDialog.setCustomData(shortcutCheckbox.checked, "bAddShortcut");
		listNameDialog.executeCallBack(true);
	}

	function click_CancelListName(){
		listNameDialog.clearDialog();
	} 
	
	function click_addShortcut(bAdd){
		shortcutDialog.setCustomData(bAdd); 
		shortcutDialog.executeCallBack();
	}

	function initListNameDialog(){
		document.getElementById("customListNameDialogInput").value = ""; 
		document.getElementById("customListNameDialogInput").focus();
	} 
	
	var confirmationDialog = null;
	var listNameDialog = null;
	var shortcutDialog = null;
	var fileArticleDialog = null;
	
	function fileArticle(articleId){
		fileArticleDialog = new UserDialog("fileArticleDialog_" + articleId);
	}
	
	function changeList(hrefNav, hrefRootSave, saveChanges, skipDialog, saveAction){
		if(!hrefNav) return; 
		if(sourceListModified && !skipDialog){ 
			confirmationDialog = new UserDialog("customListConfirmation", "changeList", null, hrefNav, hrefRootSave, null, true, saveAction); 
			return;
		}
		if(saveChanges){ 
			if(!saveAction || saveAction=="" || saveAction=="undefined")saveAction = "clSaveCurrent";  
			hrefRootSave += "&f_forcedaction=clientRedirect&f_clientRedirect=" + escape(hrefNav);
			saveCustomList(saveAction, null, hrefRootSave, "");
		} else 
			document.location.href = hrefNav;
	}
	
	function changeSearchList(hrefNav, hrefRootSave, saveChanges, skipDialog, saveAction){
		if(!hrefNav) return; 
		document.location.href = hrefNav;
	}
	
	function newCustomList(hrefRoot){
		var newListHref = hrefRoot + '&p_action=customsearchedit&d_sources=custom&f_dataid=&d_listID=';
		changeList(newListHref, hrefRoot);
	}
	
	function saveAndSearch(action, listName, hrefRoot){
		if(getListItemCount()== 0) {
			alert("There are no publications in the list.");
			return;
		}
		if(action == "clNoSave")
			searchTempCustomList(action, hrefRoot, 'explore');
		else {
			var searchListHref = hrefRoot;
			var saveAction = "";
			if(!customListId){
				saveAction = "clSaveNew";
				searchListHref += '&f_gotonew=yes';
				searchListHref += '&f_clName=' + getListName(null, true);
			}else{  				
				searchListHref += '&f_dataid='+customListId+'&d_listID='+customListId;
			}	
			searchListHref += '&p_action=explore';
			changeList(searchListHref, hrefRoot, null, null, saveAction);
		}
	} 
	
	function searchTempCustomList(action, hrefRoot, forcedAction, bUseExistingId){
		var idString = "";
		if(bUseExistingId && customListId)
			idString += '&f_dataid='+customListId+'&d_listID='+customListId;
		var hrefPath = hrefRoot + '&p_action=' + forcedAction + '&f_searchString='+getCustomSearchString()+'&f_susraction='+action+'&f_gotonew=yes'+idString;	
		submitToServer(hrefPath);

	}
	 
	function cancelCustomList(hrefRoot){  
		if(customListId)
			searchTempCustomList('clNoSave', hrefRoot, 'explore', true);
		else  
			history.back();
	}
	
	function getListName(listName, getNewName){
		if(getNewName) {
			var newListNameContainer = document.getElementById("customListNameInput");
			if(!newListNameContainer) return false;
			return newListNameContainer.value;
		}
		if(listName == null)return listName;
		return document.getElementById("customListNameOriginal").value;
	}
	 
	function saveCustomList (action, listName, hrefRoot, forcedAction, noRefresh, listId) {
		var bAddShortcut = null;
		var multiValue = getCustomSearchString(); 
		if(!userLoggedIn){
			submitToServer(hrefRoot + '&p_action=customsearchedit&f_searchString='+multiValue+'&f_loginRequest=yes&d_sources=custom&d_listID=');	
			return;
		}
		listName = getListName(listName);
		var newListName = getListName(null, true);
		if(newListName == null)return;
		
		var pageRefresh = "";
		if(noRefresh)
			pageRefresh = "&we_output=none"; 
		if(newListName == '' || (action == 'clSaveNew' && !nameModified)){
			listNameDialog = new UserDialog("customListNameDialog", "saveCustomList", true, action, listName, hrefRoot, forcedAction, noRefresh, listId); 
			listNameDialog.setInitFunction(initListNameDialog);
			listNameDialog.showDialog();
			return;
		}
		if(action=='clSaveNew' && listName==newListName){
			if(!confirm("Create a new list with a duplicate name?"))
				return;
		}
		if(newListName.indexOf("%")!=-1 && (action == 'clSaveNew' || action == 'clSaveCurrent')){
			alert("List names may not contain an percent sign(%).  Please rename your list.");
			return;
		}
		if(!listId)
			listId = customListId;
		
		if(action == 'clSaveNew'){
			if(!shortcutDialog && (!listNameDialog || listNameDialog.getState()!="visible")){
				shortcutDialog = new UserDialog("shortcutDialog", "saveCustomList", true, action, listName, hrefRoot, forcedAction, noRefresh, listId); 
				shortcutDialog.showDialog();
				return;
			}else if(shortcutDialog){
				bAddShortcut = shortcutDialog.getCustomData() ? "yes":"no"; 
			}else if(listNameDialog)
				bAddShortcut = listNameDialog.getCustomData("bAddShortcut") ? "yes":"no"; 
			var hrefPath = hrefRoot + '&p_action=susave&f_searchString='+multiValue+'&f_clName='+escape(newListName)+'&f_susraction='+action+'&f_displayFavorite='+bAddShortcut+'&d_sources=custom&d_listID=&f_gotonew=yes' + pageRefresh;	
		}else if(action == 'clSaveCurrent'){
			var hrefPath = hrefRoot + '&p_action=susave&f_searchString='+multiValue+'&f_clName='+escape(newListName)+'&f_susraction='+action+'&f_dataid='+listId+'&d_listID='+listId + pageRefresh;
		}else if(action == 'clDelete'){
			var hrefPath = hrefRoot + '&p_action=sudelete&f_susraction='+action+'&f_dataid='+listId+'&d_listID='+listId + pageRefresh;
		}
		if(forcedAction)
			hrefPath += '&f_forcedaction=' + forcedAction;
		if(isFavorite(listId))			
			hrefPath += '&f_displayFavorite=yes';
		setListModifiedIndicators();
		submitToServer(hrefPath);
	}
	
	function submitToServer(href, method){
		var formParts =  href.split("?");
		var formInputs = formParts[1].split("&");
		if(!method)method="POST";
		var formElement = document.getElementById('customListSubmitForm');
		formElement.method = method;
		formElement.action = formParts[0]!="" ? formParts[0]:document.location.pathname;
		//??pep - safari fix: for:in syntax solves performance problem on ie, but safari does not support for:in for dom objects.
		if(!SAFcheck){   
			for(var f in formInputs) 
				appendInputToForm(f);
		}else{		
			for(var f=0; f < formInputs.length; f++)  
				appendInputToForm(f);
		}		
		formElement.submit();
				
		function appendInputToForm(inputString){
			var inputNameValue = formInputs[inputString].split("=");
			inputNameValue[1] = unescape(inputNameValue[1]);
			if(IEcheck && !OPcheck){
				var inputElement = document.createElement("<INPUT type='hidden' name='" + inputNameValue[0] + "'></INPUT>"); 
				inputElement.value =  inputNameValue[1];
			}else{
				var inputElement = document.createElement("INPUT");
				inputElement.name = inputNameValue[0];
				inputElement.type = "hidden";
				inputElement.value = inputNameValue[1];
			}
			formElement.appendChild(inputElement);	
		}	
	}
	
	function getCustomSearchString(){ 
		var customSearchString = "";    
		if(customListElement){
			var sourceArray = new Array();
			var iLength = customListElement.rows.length;
			for(var i=0; i < iLength; i++){
				if(customListElement.rows[i].style.display != "none")
					sourceArray[sourceArray.length] = customListElement.rows[i].id.split("|")[1];
			}
			if(sourceArray.length > 0)
				customSearchString = sourceArray.join("|");
		}
		return customSearchString;	
	}
	        
	function deleteCustomList(hrefRoot, forcedAction, noRefresh, targetCustomListId){  
		if(confirm("Delete this list?")){ 
			if(document.getElementById("customListNameInput"))
				saveCustomList("clDelete", null, hrefRoot, forcedAction, noRefresh, targetCustomListId);
			else {   
				var pageRefresh = "";
				if(noRefresh) pageRefresh = "&we_output=none";
				hrefRoot += '&p_action=sudelete&f_forcedaction='+forcedAction+'&f_susraction=clDelete&f_dataid='+targetCustomListId+'&d_listID='+targetCustomListId + '&d_sources=location&d_place=&f_clearSearch=yes' + pageRefresh; 
				submitToServer(hrefRoot);
			}

		}
	}
	
	function addToFavorites(hrefRoot, listId, multiValue, listName, sourceType){ 
		toggleFavorite(hrefRoot, listId, multiValue, listName, sourceType)
	}          

	function removeFromFavorites(hrefRoot, listId, multiValue, listName, sourceType){
		toggleFavorite(hrefRoot, listId, multiValue, listName, sourceType, true)
	}          
		

	function toggleFavorite(hrefRoot, listId, multiValue, listName, sourceType, bRemove){
		var listRow = document.getElementById("navRow_" + listId);
		
		var userAction = "clSaveCurrent"; 
		//if(sourceType.match(new RegExp("cusBucket"))!=-1) userAction = "cbSavePrefs"; 
		//else if(sourceType.match("location")!=-1) userAction = "cbSavePrefs"; 
		
		if(listRow){
			var displayFavorite = bRemove ? "no":"yes";
			document.getElementById("exec").src = hrefRoot + '&we_output=none&p_action=susave&f_searchString='+multiValue+'&f_susraction=' + userAction + '&f_clName='+escape(listName)+'&f_dataid='+listId+'&d_listID='+listId + '&f_displayFavorite='+displayFavorite; 
			//hrefRoot += '&we_output=none&p_action=susave&f_searchString='+multiValue+'&f_susraction=clSaveCurrent&f_clName='+escape(listName)+'&f_dataid='+listId+'&d_listID='+listId + '&f_displayFavorite='+displayFavorite; 
			//submitToServer(hrefRoot);
			listRow.style.display = bRemove ? "none":"";
			var addRemoveButton = document.getElementById("addRemoveFavoriteButton");
			if(!bRemove){
				addRemoveButton.href = addRemoveButton.href.replace(/addToFavorites/,"removeFromFavorites");
				addRemoveButton.innerHTML = addRemoveButton.innerHTML.replace(/Add Shortcut/,"Remove Shortcut");
			} else {
				addRemoveButton.href = addRemoveButton.href.replace(/removeFromFavorites/,"addToFavorites");
				addRemoveButton.innerHTML = addRemoveButton.innerHTML.replace(/Remove Shortcut/,"Add Shortcut");
			}
		}
	} 
	
	function editList(hrefRoot, listId, multiValue){
		var sURL = hrefRoot + '&d_search_type=keyword&p_action=customsearchedit&f_searchString='+multiValue+'&d_sources=custom&d_place='+listId+'&d_listID='+listId; 
		submitToServer(sURL);
	}
	
	function isFavorite(listId){ 
		var listRow = document.getElementById("navRow_" + listId);
		if(listRow)
			return listRow.style.display!="none";
		return null;
	}          
	
	function scrollFoundSources (direction, positionOverride){
		var positionElement = document.getElementById("listPosition");
		var lengthElement = document.getElementById("listLength");
		var backElement = document.getElementById("backSelection");
		var forwardElement = document.getElementById("forwardSelection");
		var listPosition = parseInt(new elementWrapper(positionElement).getText());
		var listLength = parseInt(new elementWrapper(lengthElement).getText());
		if(!positionOverride) {
			switch(direction){
				case "forward":
					if(listPosition <  listLength)
						listPosition++;
					break;
				case "back":
					if(listPosition > 0)
						listPosition--;
					break;
			}
		} else
			listPosition = 	positionOverride;	
			
		new elementWrapper(positionElement).setText(listPosition);
		
		if(listLength == 1){
			forwardElement.className = "disabledLookupArrow";
			backElement.className = "disabledLookupArrow";
			return;
		}	
		if(listPosition <  listLength)
			forwardElement.className = "enabledLookupArrow";
		else
			forwardElement.className = "disabledLookupArrow";
		if(listPosition !=  0)
			backElement.className = "enabledLookupArrow";
		else
			backElement.className = "disabledLookupArrow";
	}   
	
	function listNameAction(nameElement){
		if(nameElement)
			replaceInputValue(nameElement, "", "(enter new list name here)")
	}   
	
	function replaceInputValue(inputElement, replaceValue, conditionalValue){ 
		if(inputElement && (conditionalValue == null || conditionalValue == inputElement.value))
			inputElement.value = replaceValue;
	} 
	
 	//**************************************************************************//
 	//** END: functions to support custom lists                               **//
	//**************************************************************************//
                                                                                              
        function fileSave(hrefStandard){                                 
		//var httpDownloadElement = document.createElement("IFRAME");
		//document.body.appendChild(httpDownloadElement); 
		var httpDownloadElement = document.getElementById("dle");
		alert("href: " + hrefStandard + "&action=fileSave");
		httpDownloadElement.src = hrefStandard + "&p_action=fileSave";
        }