/**
 * Select Image Controller Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */
 
 
function MoveDown(obj) {
//cs added these
//used for swapping order of items in a multi-select box.
	if (obj.selectedIndex  < 0 ) { return; }
	if (obj.selectedIndex == obj.length - 1) { return; }
	if (obj.length == 1) { return; }

	a = obj[obj.selectedIndex].value;
	b = obj[obj.selectedIndex].text;

	obj[obj.selectedIndex].value = obj[obj.selectedIndex + 1].value;
	obj[obj.selectedIndex].text = obj[obj.selectedIndex + 1].text;


	obj[obj.selectedIndex + 1].value = a;
	obj[obj.selectedIndex + 1].text = b;
	obj[obj.selectedIndex + 1].selected = true;
}

function MoveUp(obj){
//cs added these
	if (obj.selectedIndex  < 0 ) { return; }
	if (obj.selectedIndex == 0) { return; }
	if (obj.length == 1) { return; }

	a = obj[obj.selectedIndex].value;
	b = obj[obj.selectedIndex].text;

	obj[obj.selectedIndex].value = obj[obj.selectedIndex - 1].value;
	obj[obj.selectedIndex].text = obj[obj.selectedIndex - 1].text;

	obj[obj.selectedIndex - 1].value = a;
	obj[obj.selectedIndex - 1].text = b;
	obj[obj.selectedIndex - 1].selected = true;

}



	function serialize_select(sel, el) {
		//by chris
		    //sel is the name of the select box,
		    // el is the element in which to store the serialized value


		    finalanswer = "";
		    for (i=0; i < sel.length; i++){

			finalanswer += sel[i].value;

			if (i != sel.length-1){
			    finalanswer += "?";
			}
		    }

		    el.value = finalanswer;

	    return 1;

		    //sel.form.submit();

		}



        var popupWin;

        function openWindow(url, name, rs, w, h, sc, tb) {
                var resize = (rs) ? "resizable=yes," : "";
                var scrollbars = (sc) ? "scrollbars=yes," : "";
                var toolbars = (tb) ? "menubar=yes," : "";
                var repalceStr = toolbars + resize + scrollbars + "width=" + w + ",height=" + h;

                popupWin = window.open(url, name, repalceStr);

            popupWin.focus();
            //return popupWin; //- this was causing problems...
        }

        var dialogueWin = 0;

        function openDialogue(url, name, w, h, e) {

                dialogueWin = window.open(url, name,'resizable=yes,width=' + w + ',height=' + h + ",left="+( e.screenX + 10) + ",top="+(e.screenY  + 10));
                dialogueWin.focus();
        }


        function close_POPs() {
            //   if (typeof(dialogueWin) != 'undefined' && typeof(dialogueWin) == 'object')
             //  {
		if (dialogueWin && !dialogueWin.closed)
		{

			     dialogueWin.close();
                             dialogueWin.opener = null;
		}//dialogueWin was not closed
            //   }//dialogueWin was a valid object
        }


	function open_window_safely(winname, arg1, arg2, arg3)
	{
        /// arg1 arg 2 and arg 3 are the three arguments of the normal window.open() function.

		var handle;
		if (typeof(winname) == 'undefined')
		{

                        handle = window.open(arg1, arg2, arg3);
		}
		else
		{
			if (winname.closed) {
				handle = winname;
				handle.opener = null;
				handle = window.open(arg1, arg2, arg3);
			}
			else
			{
				handle = winname;
				handle.document.location = arg1;

			}

		}
		return handle;
	}//end function open_win_safely




/**
 * Select Image Controller Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */
       function MM_preloadImages() {
                if (document.images) {
                        var imgFiles = MM_preloadImages.arguments;
                        var preloadArray = new Array();
                        for (var i=0; i<imgFiles.length; i++) {
                                preloadArray[i] = new Image;
                                preloadArray[i].src = imgFiles[i];
                        }
                }
        }



        function MM_swapImage() {
                var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
                for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
                        objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
                          if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
                                (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
                                objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
                                obj = eval(objStr);
                                if (obj != null) {
                                        swapArray[j++] = obj;
                                        swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
                                        obj.src = MM_swapImage.arguments[i+2];
                                }
                        }
                document.MM_swapImgData = swapArray; //used for restore
        }


        function MM_swapImgRestore() { //v1.2
                if (document.MM_swapImgData != null)
                for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
                document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
        }

        function WM_imageSwap(daImage, daSrc){
            var objStr,obj;

            // Check to make sure that images are supported in the DOM.
            if(document.images){
                // Check to see whether you are using a name, number, or object
                if (typeof(daImage) == 'string') {
                    // This whole objStr nonesense is here solely to gain compatability
                    // with ie3 for the mac.
                    objStr = 'document.' + daImage;
                    obj = eval(objStr);
                    obj.src = daSrc;
                } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
                    daImage.src = daSrc;
                }
            }
        }

/**
 * Select Box Movement Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */

function MM_showHideLayers() { //v1.0
  var i, visStr, args;
  args = MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) { //with arg triples (objNS,objIE,visStr)
    visStr   = args[i+2];
    if (navigator.appName == 'Netscape') {
      if (document.layers != null) eval(args[i]+".visibility = '"+visStr+"'");
    } else { //IE
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      if (document.all != null) eval(args[i+1]+".style.visibility = '"+visStr+"'");
  } }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}



function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}










function getRadioValue(rad)
   ///given  radio object, this function returns the value of the currently selected item
{

   //alert(rad.length);
   for (i=0; i< rad.length; i++)
	{
           if (rad[i].checked == true){ return rad[i].value; }
	}
	if (rad && !rad.length) {
		return rad.value;
	}

  return(0)
}

function selectAll(obj, deselect, noRefresh)
{
   ///this function selects all items in a given listbox, indicated by obj.
   ///if deselect is 1, the select will be deselected rather than selected.
   /// if norefresh is 1, the function will be suppressed from refreshing the page.  This is so if the list is in another page,
   //// the user script can take care of which page needs to be refreshed.


  for (i=0; i < obj.length; i++)
	{
		deselect ? obj[i].selected = false : obj[i].selected = true;
	}

 if (noRefresh){  history.go(0); }

}

function checkAll(docForm, flag) {
	for (i = 0; i < docForm.elements.length; i++) {
		formElem = docForm.elements[i];
		switch (formElem.type) {
			case 'checkbox':
				if (flag.checked) {
					formElem.checked = true;								
				}
				else {
					formElem.checked = false;												
				}
		}
	}
}

function getAllFromSelect(ItemList) {
	var FormSelected = ItemList;
        if (FormSelected) {
                var i=FormSelected.length -1;
        }
	var ReturnImages;
	while (i >= 0) {
		if (i == FormSelected.length -1) {
			ReturnImages = FormSelected.options[i].value + "|";
		}
		else if (i == 0) {
			ReturnImages = ReturnImages + FormSelected.options[i].value + "|";
		}
		else {
			ReturnImages = ReturnImages + FormSelected.options[i].value + "|";
		}
		i--;
	}
        if (ReturnImages) {
                return(ReturnImages);
        }
        else {
                return(0)
        }
}

function getAllSelectedItems(FormSelected) {
        if (FormSelected) {
                var i=FormSelected.length -1;
        }
  var ReturnImages = "";
	while (i >= 0) {
    if ( FormSelected.options[i].selected ) {
        ReturnImages = ReturnImages + FormSelected.options[i].value + "|";
    }
    i--;
	}
        if (ReturnImages) {
                return(ReturnImages);
        }
        else {
                return(0)
        }
}






/**
 * Select Image Controller Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */

        function checkEmail(checkStringForm) {
                checkString = checkStringForm.value;
                //alert("Hello " + checkStringForm.value);
                var newstr = "";
                var at = false;
                var dot = false;
                if ( checkString.length == 0) {
                        return true;
                }
                //DO SOME PRELIMINARY CHECKS ON THE DATA
                // IF EMAIL ADDRESS HAS A '\@' CHARACTER
                if (checkString.indexOf("\@") != -1) {
                        at = true;
                        //    IF EMAIL ADDRESS HAS A '.' CHARACTER
                }
                else if (checkString.indexOf(".") != -1) {
                        dot = true;
                }
                // PARSE REMAINDER OF STRING
                for (var i = 0; i < checkString.length; i++) {
                        ch = checkString.substring(i, i + 1)
                        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "\@") || (ch == ".") || (ch == "_")
                        || (ch == "-") || (ch >= "0" && ch <= "9")) {
                                newstr += ch;
                                if (ch == "\@") {
                                        at=true;
                                }
                                if (ch == ".") {
                                        dot=true;
                                }
                        }
                }
                if ((at == true) && (dot == true)) {
                        return newstr;
                }
                else {
                // DISPLAY ERROR MESSAGE
                        alert ("Sorry, the email address you entered is not in the correct format.");
                        checkStringForm.value = "";
                        checkStringForm.focus();
                        return false;
                }

        }

function clearDate(FormElement) {
        //alert(FormElement);
        if (FormElement.value == "YYYY-MM-DD") {
                FormElement.value = "";
        }
}



function toggleSelectAll(CB_form, Base_checkbox, checkbox_prefix) {
//selects all checkboxes in a form:

    for (var i=0; i< CB_form.elements.length; i++) {
      e = CB_form.elements[i];

                if (e.type == "checkbox" && e.name.search(checkbox_prefix) != -1 ) {

                        e.checked = Base_checkbox.checked;
                }
        }
}

var scrollbox_flag;
function scrollbox_selectRow(d) {
    if (scrollbox_flag) {
            scrollbox_flag.style.color="#000000";
            scrollbox_flag.style.backgroundColor='';
    }
    d.style.color='#ffffff';
    d.style.backgroundColor='#999999';
    scrollbox_flag = d;    
}


function getCurrentStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (window.getComputedStyle) {
		var y = window.getComputedStyle(x,null).getPropertyValue(styleProp);
	}
	else if (x.currentStyle) {
		var y = eval('x.currentStyle.' + styleProp);
	}
	return y;
}

function showDiv(d,id) {
	var h = d.height;
	if (!h) {
		h = 'auto';
	}
	d.style.height = h;	
	if (d.marginTop) {
		d.style.marginTop = d.marginTop;
	}
	if (d.marginBottom) {
		d.style.marginBottom = d.marginBottom;
	}
	if (d.paddingTop) { 
		d.style.paddingTop = d.paddingTop;
	}
	if (d.paddingBottom) {
		d.style.paddingBottom = d.paddingBottom;
	}
	if (d.marginRight) {
		d.style.marginRight = d.marginRight;
	}
	if (d.marginLeft) {
		d.style.marginLeft = d.marginLeft;
	}
	if (d.paddingRight) { 
		d.style.paddingRight = d.paddingRight;
	}
	if (d.paddingLeft) {
		d.style.paddingLeft = d.paddingLeft;
	}
	d.style.visibility = 'visible';
}

function hideDiv(d,id) {
	// store values for restoring later
	
	if (!d.height)
		d.height = getCurrentStyle(id, "height");
	if (!d.marginTop)
		d.marginTop = getCurrentStyle(id, "margin-top");
	if (!d.marginBottom)	
		d.marginBottom = getCurrentStyle(id, "margin-bottom");
	if (!d.marginRight)		
		d.marginRight = getCurrentStyle(id, "margin-right");
	if (!d.marginLeft)		
		d.marginLeft = getCurrentStyle(id, "margin-left");
	if (!d.paddingBottom)			
		d.paddingBottom = getCurrentStyle(id, "padding-bottom");
	if (!d.paddingTop)
		d.paddingTop = getCurrentStyle(id, "padding-top");
	if (!d.paddingRight)		
		d.paddingRight = getCurrentStyle(id, "padding-right");
	if (!d.paddingLeft)		
		d.paddingLeft = getCurrentStyle(id, "padding-left");

	d.style.height = '0px';
	d.style.marginTop = '0px';
	d.style.paddingTop = '0px';
	d.style.marginBottom = '0px';
	d.style.paddingBottom = '0px';
	d.style.visibility = 'hidden';
}

function showDiv(d,id) {
	var h = d.height;
	if (!h) {
		h = 'auto';
	}
	d.style.height = h;	
	if (d.marginTop) {
		d.style.marginTop = d.marginTop;
	}
	if (d.marginBottom) {
		d.style.marginBottom = d.marginBottom;
	}
	if (d.paddingTop) { 
		d.style.paddingTop = d.paddingTop;
	}
	if (d.paddingBottom) {
		d.style.paddingBottom = d.paddingBottom;
	}
	if (d.marginRight) {
		d.style.marginRight = d.marginRight;
	}
	if (d.marginLeft) {
		d.style.marginLeft = d.marginLeft;
	}
	if (d.paddingRight) { 
		d.style.paddingRight = d.paddingRight;
	}
	if (d.paddingLeft) {
		d.style.paddingLeft = d.paddingLeft;
	}
	d.style.visibility = 'visible';
}

function hideDiv(d,id) {
	// store values for restoring later
	
	if (!d.height)
		d.height = getCurrentStyle(id, "height");
	if (!d.marginTop)
		d.marginTop = getCurrentStyle(id, "margin-top");
	if (!d.marginBottom)	
		d.marginBottom = getCurrentStyle(id, "margin-bottom");
	if (!d.marginRight)		
		d.marginRight = getCurrentStyle(id, "margin-right");
	if (!d.marginLeft)		
		d.marginLeft = getCurrentStyle(id, "margin-left");
	if (!d.paddingBottom)			
		d.paddingBottom = getCurrentStyle(id, "padding-bottom");
	if (!d.paddingTop)
		d.paddingTop = getCurrentStyle(id, "padding-top");
	if (!d.paddingRight)		
		d.paddingRight = getCurrentStyle(id, "padding-right");
	if (!d.paddingLeft)		
		d.paddingLeft = getCurrentStyle(id, "padding-left");

	d.style.height = '0px';
	d.style.marginTop = '0px';
	d.style.paddingTop = '0px';
	d.style.marginBottom = '0px';
	d.style.paddingBottom = '0px';
	d.style.visibility = 'hidden';
}


// AJAX // The following are some basic universal AJAX functions

function formData2QueryString(docForm) {

	if (!docForm) {
		docForm = document.forms[0];
	}

		
	var strSubmitContent = '';
	var formElem;
	var strLastElemName = '';
	
	for (i = 0; i < docForm.elements.length; i++) {
		
		formElem = docForm.elements[i];
		switch (formElem.type) {
			// Text fields, hidden form elements
			case 'text':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'select-one':
				var v = escape(formElem.value);
				v = v.replace(/\+/g, '%2B');
				strSubmitContent += formElem.name + '=' + v + '&'
				break;
			// Multi-option select
		      case 'select-multiple':

		      	var str = "";
		        var isSet = false;
		        for(var j = 0; j < formElem.options.length; j++) {
		          var currOpt = formElem.options[j];
		          if(currOpt.selected) {
						var opt = escape(currOpt.value);
		              	opt = opt.replace(/\+/g, '%2B');
		              if (isSet) {		              	
		                str += opt + '|';
		              }
		              else {
		              
		                str += formElem.name + '=|' + opt +'|';
		                isSet = true;
		              }
		          }
		        }
		        strSubmitContent += str + '&';
		        
		        break;
		
				
			// Radio buttons
			case 'radio':
				if (formElem.checked) {
					var f = escape(formElem.value);
	              	f = f.replace(/\+/g, '%2B');
					strSubmitContent += formElem.name + '=' + f + '&'
				}
				break;
				
			// Checkboxes
			case 'checkbox':
				if (formElem.checked) {
					// Continuing multiple, same-name checkboxes
					//alert(formElem.name);
					var felm = escape(formElem.value);
					felm = felm.replace(/\+/g, '%2B');
					strSubmitContent += formElem.name + '=' + felm + '&'
					//if (formElem.name == strLastElemName) {
					//	alert(strLastElemName);
					//	// Strip of end ampersand if there is one
					//	if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) {
					//		alert('here');
					//		strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
					//	}
					//	// Append value as comma-delimited string
					//	strSubmitContent += ',' + escape(formElem.value);
					//	alert(strSubmitContent);
					//}
					//else {
					//	strSubmitContent += formElem.name + '=' + escape(formElem.value);
					//}
					////alert(strSubmitContent);
					//strSubmitContent += '&';
				}
				break;
				
		}
		strLastElemName = formElem.name
	}
	
	// Remove trailing separator
	strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
	return strSubmitContent;
}

// This is the actual AJAX Posting mechanism.  It will tell you which js function will get triggered with the response
function xmlhttpPost(strURL, strSubmit, strResultFunc, miscArray) {

        var xmlHttpReq = false;
        
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
                xmlHttpReq = new XMLHttpRequest();
                //commenting until FF1.5 fixed
                //xmlHttpReq.overrideMimeType('text/xml');
                if (xmlHttpReq.overrideMimeType) {
					xmlHttpReq.overrideMimeType('text/plain');                
				}
        }
        // IE
        else if (window.ActiveXObject) {
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        
		xmlHttpReq.open('POST', strURL, true);
        xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlHttpReq.onreadystatechange = function() {
                if (xmlHttpReq.readyState == 4) {
	                //alert(xmlHttpReq.responseText.length);
					if (!d7_ajax_hook(xmlHttpReq.responseText)){
						//cs 2005-06-16 minimum code for login and error handling...	
						return;
					}
                    eval(strResultFunc + '(xmlHttpReq.responseText, xmlHttpReq, miscArray);');
                }
        }
        if (strSubmit) {
        	strSubmit += "&ajax=1";
        }
        else {
           	strSubmit += "ajax=1";
        }
        //alert(strSubmit);
        xmlHttpReq.send(strSubmit);        
}



function d7_ajax_hook(responseText) {

	login_exp = new RegExp("AJAXLOGIN")  

//	if (responseText.substr(0,9) == "AJAXLOGIN"){
	if (responseText.match(login_exp)) {

		ajaxlogin();
		return 0;
	}

	error_exp = new RegExp("AJAXERROR")  

//	if (responseText.substr(0,9) == "AJAXERROR"){
	if (responseText.match(error_exp)) {
		ajaxerror(responseText);
		return 0;
	}

	return 1;

}

function ajaxlogin() {
//cs 2005-06-16

	top.document.location.reload();

}

function ajaxerror(err) {
//cs 2005-06-16
	err = err.replace(/AJAXERROR\: /g,"");
	var w = window.open("", "RouteOne_Error", 'toolbar,width=500,height=400,scrollbars');
	w.document.write(err);
	//alert(err);

}

function dropInElement(inStr, ajax, elementID) {
	var e = document.getElementById(elementID);
	e.innerHTML = inStr;
}

function MoveItems(FormFrom, FormTo, FormSource, FormReturn, NoRemoveFrom, Unique, HistoryNoGo, MoveAll) {
// PLEASE REMOVE THIS CODE - DO NOT USE THIS FUNCTION
//why? it's used by the SelectBox class.
//formfrom, formto: the form to transfer from and to
//formsource, form return: source is  a list , retrun a textbox. the text box is filled with all the list text.
//noremove from prevents item from source from being deleted.
//unique won't copy from -> to if from is already in to.
//HistoryNoGo prevents listbox from resizing. Useful if you haven't deleted an item from the list.

	var i=FormFrom.length -1;
        var z=FormTo.length; // = +1; // - 1;
	if (z == -1) { z = 0; }
        var initlen = FormTo.length - 1;
        var j=initlen;

        var uniqueflag = 1;

        // var oneSelected = FormFrom[FormFrom.selectedIndex].text;



	while (i >= 0) {

                if (MoveAll || FormFrom.options[i].selected) { //
                        // alert(FormFrom.options[i].text);

			if (Unique == 1) {
                                for (j=initlen; j>=0; j--) {
                                  if (FormTo.options[j].value == FormFrom.options[i].value) {
					uniqueflag = 0;
                                  }

				}
                        }
                	if (uniqueflag == 1) {


                                FormTo.options[z] = new Option(FormFrom.options[i].text, FormFrom.options[i].value);
                                z++;

                        }
      			else {
			 uniqueflag = 1;
			}

                        if (NoRemoveFrom !=  1) {
                          FormFrom.options[i] = null;
                        }
      		}

                i--;
	}
    if (!HistoryNoGo) {
        history.go(0);
       }
        getItemsList(FormSource, FormReturn);
}


var selectedItems;
var previousSelected;
var classMatch = /selected/;
var multiselect = '0';
function toggleTableRow(r, id, newFunction) {

	if (previousSelected && multiselect != 1) {
		var p = previousSelected;
		changeClass('remove', p, 'selected');
		if (previousSelected.id == id) {
			previousSelected = null;	
			return;
		}	
	}
	if (r.className.search(classMatch) != -1) {
		changeClass('remove', r, 'selected');
		}
	else {
		changeClass('add', r, 'selected');
		}

	if (!previousSelected || (previousSelected && previousSelected.id != id)) {
		previousSelected = r;	
	}
	eval(newFunction + '(id)');
}

function changeClass(a,o,c1,c2)
{
// a is is the action we want to do
// o is the DOM element 
// c1 is first class
// c2 is second class
  switch (a){
    case 'swap':
      o.className=!changeClass('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
    break;
    case 'add':
      if(!changeClass('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove':
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}


// This section should seemlessly manage the clicking of tr's in table lists.  
// Passing off the results to a pre-determined function

var table_list_page;

var tableList = function() {

	this.env = new Object();

	table_list_page = this;
	this.ref = 'table_list_page';

	// set environment variable
  	this.set_env = function(name, value) {
	      this.env[name] = value;    
    	};

	this.env.testenv = 'shawn';

	this.init = function() {
		var tl = document.getElementById('theTable');
		var row;
	    for(var r=0; r<tl.tBodies[0].childNodes.length; r++) {   	
	        row = tl.tBodies[0].childNodes[r];
			
	        if (!row.id) { 
	        	continue; 
	        }
			row.targetFunction = this.env.targetFunction;
	        row.onmouseup = function (e) {
			func = e.target.parentNode.targetFunction; 
			toggleTableRow(e.target.parentNode, findRowID(e), func); 
		};
        }
	}
	//alert(row);
	
}


findRowID = function(e, id)
    {
    
	return e.target.parentNode.id;
    };

// set onload handler
window.onload = function(e)
  {
  if(typeof initMenus!="undefined") {
	  eval ( initMenus() );
  }
  if (window.table_list_page)
    table_list_page.init();
  };

// set onload handler
//window.onload = tableList;


function savePrefs(action, f) {
	items = formData2QueryString(f);	
	items = items +'&action='+action;
	f.disabled = true;
	xmlhttpPost("/index.html?action=ajax", items , "gotSavedPrefs" );	
	return false;
}

function gotSavedPrefs() {
	//f.disabled = false;
}


function truncateParagraph(id, len) {
	if (!len) {
		len = 100;
	}
	var p = document.getElementById(id);
	if (p) {
	
	  var trunc = p.innerHTML;
	  if (trunc.length > len) {
	
	    /* Truncate the content of the P, then go back to the end of the
	       previous word to ensure that we don't truncate in the middle of
	       a word */
	    trunc = trunc.substring(0, len);
	    trunc = trunc.replace(/\w+$/, '');
	
	    /* Add an ellipses to the end and make it a link that expands
	       the paragraph back to its original size */
	    trunc += '<a href="#" ' +
	      'onclick="this.parentNode.innerHTML=' +
	      'unescape(\''+escape(p.innerHTML)+'\');return false;">' +
	      '...<\/a>';
	    p.innerHTML = trunc;
	  }
	}
}




/*
	Date Format 1.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT license
	With code by Scott Trenda (Z and o flags, and enhanced brevity)
*/

/*** dateFormat
	Accepts a date, a mask, or a date and a mask.
	Returns a formatted version of the given date.
	The date defaults to the current date/time.
	The mask defaults ``"ddd mmm d yyyy HH:MM:ss"``.
*/
var dateFormat = function () {
	var	token        = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloZ]|"[^"]*"|'[^']*'/g,
		timezone     = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (value, length) {
			value = String(value);
			length = parseInt(length) || 2;
			while (value.length < length)
				value = "0" + value;
			return value;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask) {
		// Treat the first argument as a mask if it doesn't contain any numbers
		if (
			arguments.length == 1 &&
			(typeof date == "string" || date instanceof String) &&
			!/\d/.test(date)
		) {
			mask = date;
			date = undefined;
		}

		date = date ? new Date(date) : new Date();
		if (isNaN(date))
			throw "invalid date";

		var dF = dateFormat;
		mask   = String(dF.masks[mask] || mask || dF.masks["default"]);

		var	d = date.getDate(),
			D = date.getDay(),
			m = date.getMonth(),
			y = date.getFullYear(),
			H = date.getHours(),
			M = date.getMinutes(),
			s = date.getSeconds(),
			L = date.getMilliseconds(),
			o = date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4)
			};

		return mask.replace(token, function ($0) {
			return ($0 in flags) ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":       "ddd mmm d yyyy HH:MM:ss",
	shortDate:       "m/d/yy",
	mediumDate:      "mmm d, yyyy",
	longDate:        "mmmm d, yyyy",
	fullDate:        "dddd, mmmm d, yyyy",
	shortTime:       "h:MM TT",
	mediumTime:      "h:MM:ss TT",
	longTime:        "h:MM:ss TT Z",
	isoDate:         "yyyy-mm-dd",
	isoTime:         "HH:MM:ss",
	isoDateTime:     "yyyy-mm-dd'T'HH:MM:ss",
	isoFullDateTime: "yyyy-mm-dd'T'HH:MM:ss.lo"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask) {
	return dateFormat(this, mask);
}

/*
end of date format script
*/

