/**
 * 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 = 0;

        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();
        }

        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



function closedialogue()
{

if (typeof(dialogueWin) != 'undefined')
{
  if (typeof(dialogueWin) == 'object')
  {
	if (!dialogueWin.closed)
	{
		dialogueWin.close();
	}
	if (dialogueWin.opener){dialogueWin.opener.document.dialogueWin = null;}
	dialogueWin.opener = null;
	dialogueWin = null;
 }
}//dialoguwwin exists
}//end function


/**
 * Select Image Controller Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */

        function get_hidden_frame_info(ReturnTo, SQLQuery, ActionType, NothingReturnedMsg, FrameNum, ReturnFrame)    {
                        var html_string = "locationse83f.html?action=" + ActionType + "&sql=" + SQLQuery + "&return_to=" + ReturnTo +  "&nothing_returned_msg=" + NothingReturnedMsg + "&return_to_frame=" + ReturnFrame;

                        parent[FrameNum].location=(html_string);
        }


/**
 * 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_changeProp(objStrNS,objStrIE,theProp,theValue) { //v2.0
//  var NS = (navigator.appName == 'Netscape');
//  var objStr = (NS)?objStrNS:objStrIE;
//  if (( NS && (objStr.indexOf('document.layers[')!=0 || document.layers!=null)) ||
//      (!NS && (objStr.indexOf('document.all[')   !=0 || document.all   !=null))) {
//    var obj = eval(objStr);
//    if ((obj != null) && (theProp.indexOf("style.") != 0 || obj.style != null)) {
//      eval(objStr+'.'+theProp + '="'+theValue+'"');
//  } }
//}

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)
}

/**
 * LISTBOX
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */

var _id = 0, _pid = 0, _lid = 0, _pLayer;
var _mLists = new Array();
var ImageRoot = "";
document.lists = _mLists;
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav4 = (navigator.appName == "Netscape") ? true : false;
  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}
function List(visible, width, height, bgColor) {
  this.setIndent = setIndent;
  this.addItem = addItem;
  this.addList = addList;
  this.build = build;
  this.rebuild = rebuild;
  this.setFont = _listSetFont;
  this._writeList = _writeList;
  this._showList = _showList;
  this._updateList = _updateList;
  this._updateParent = _updateParent;
  this.onexpand = null; this.postexpand = null;
  this.lists = new Array(); // sublists
  this.items = new Array(); // layers
  this.types = new Array(); // type
  this.strs = new Array();  // content
  this.x = 0;
  this.y = 0;
  this.visible = visible;
  this.id = _id;
  this.i = 18;
  this.space = true;
  this.pid = 0;
  this.fontIntro = false;
  this.fontOutro = false;
  this.width = width || 350;
  this.height = height || 22;
  this.parLayer = false;
  this.built = false;
  this.shown = false;
  this.needsUpdate = false;
  this.needsRewrite = false;
  this.parent = null;
  this.l = 0;
  if(bgColor) this.bgColor = bgColor;
  else this.bgColor = null;
  _mLists[_id++] = this;
}
function _listSetFont(i,j) {
  this.fontIntro = i;
  this.fontOutro = j;
}
function setIndent(indent) { this.i = indent; if(this.i < 0) { this.i = 0; this.space = false; } }
function setClip(layer, l, r, t, b) {
  if(isNav4) {
    layer.clip.left = l; layer.clip.right = r;
    layer.clip.top = t;  layer.clip.bottom = b;
  } else {
    layer.style.pixelWidth = r-l;
    layer.style.pixelHeight = b-t;
    layer.style.clip = "rect("+t+","+r+","+b+","+l+")";
  }
}
function _writeList() {
  self.status = "List: Writing list...";
  var layer, str, clip;
  for(var i = 0; i < this.types.length; i++) {
    layer = this.items[i];
    if(isNav4) layer.visibility = "hidden";
    else layer.style.visibility = "hidden";
    str = "";
    if(isNav4) layer.document.open();
    str += "<TABLE WIDTH="+this.width+" NOWRAP BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
    if(this.types[i] == "list") {
      str += "<TD WIDTH=15 NOWRAP VALIGN=MIDDLE><A TARGET='_self' HREF=\"javascript:expand("+this.lists[i].id+");\"><IMG BORDER=0 SRC=\""+ImageRoot+"true.gif\" NAME=\"_img"+this.lists[i].id+"\"></A></TD>";
      _pid++;
    } else if(this.space)
      str += "<TD WIDTH=15 NOWRAP>&nbsp;</TD>";
    if(this.l>0 && this.i>0) str += "<TD WIDTH="+this.l*this.i+" NOWRAP>&nbsp;</TD>";
    str += "<TD HEIGHT="+(this.height-3)+" WIDTH="+(this.width-15-this.l*this.i)+" VALIGN=MIDDLE ALIGN=LEFT>";
    if(this.fontIntro) str += this.fontIntro;
    str += this.strs[i];
    if(this.fontOutro) str += this.fontOutro;
    str += "</TD></TABLE>";
    if(isNav4) {
      layer.document.writeln(str);
      layer.document.close();
    } else layer.innerHTML = str;
    if(this.types[i] == "list" && this.lists[i].visible)
      this.lists[i]._writeList();
  }
  this.built = true;
  this.needsRewrite = false;
  self.status = '';
}
function _showList() {
  var layer;
  for(var i = 0; i < this.types.length; i++) {
    layer = this.items[i];
    setClip(layer, 0, this.width, 0, this.height-1);
    var bg = layer.oBgColor || this.bgColor;
    if(isIE4) {
      if((bg == null) || (bg == "null")) bg = "";
      layer.style.backgroundColor = bg;
    } else layer.document.bgColor = bg;
    if(this.types[i] == "list" && this.lists[i].visible)
      this.lists[i]._showList();
  }
  this.shown = true;
  this.needsUpdate = false;
}
function setImageRoot(NewRoot) {
        ImageRoot = NewRoot;
}
function _updateList(pVis, x, y) {
  var currTop = y, layer;
  for(var i = 0; i < this.types.length; i++) {
    layer = this.items[i];
    if(this.visible && pVis) {
      if(isNav4) {
        layer.visibility = "visible";
        layer.top = currTop;
        layer.left = x;
      } else {
        layer.style.visibility = "visible";
        layer.style.pixelTop = currTop;
        layer.style.pixelLeft = x;
      }
      currTop += this.height;
    } else {
      if(isNav4) layer.visibility = "hidden";
      else layer.style.visibility = "hidden";
    }
    if(this.types[i] == "list") {
      if(this.lists[i].visible) {
        if(!this.lists[i].built || this.lists[i].needsRewrite) this.lists[i]._writeList();
        if(!this.lists[i].shown || this.lists[i].needsUpdate) this.lists[i]._showList();
        if(isNav4) layer.document.images[0].src = ImageRoot + "true.gif";
        else eval('document.images._img'+this.lists[i].id+'.src = ImageRoot + "true.gif"');
      } else {
        if(isNav4) layer.document.images[0].src = ImageRoot + "false.gif";
        else eval('document.images._img'+this.lists[i].id+'.src = ImageRoot + "false.gif"');
      }
      if(this.lists[i].built)
        currTop = this.lists[i]._updateList(this.visible && pVis, x, currTop);
    }
  }
  return currTop;
}
function _updateParent(pid, l) {
  var layer;
  if(!l) l = 0;
  this.pid = pid;
  this.l = l;
  for(var i = 0; i < this.types.length; i++)
    if(this.types[i] == "list")
      this.lists[i]._updateParent(pid, l+1);
}
function expand(i) {
  _mLists[i].visible = !_mLists[i].visible;
  if(_mLists[i].onexpand != null) _mLists[i].onexpand(_mLists[i].id);
  _mLists[_mLists[i].pid].rebuild();
  if(_mLists[i].postexpand != null) _mLists[i].postexpand(_mLists[i].id);
}
function build(x, y) {
  this._updateParent(this.id);
  this._writeList();
  this._showList();
  this._updateList(true, x, y);
  this.x = x; this.y = y;
}
function rebuild() { this._updateList(true, this.x, this.y); }
function addItem(str, bgColor, layer) {
  var testLayer = false;
  if(!document.all) document.all = document.layers;
  if(!layer) {
    if(isIE4 || !this.parLayer) testLayer = eval('document.all.lItem'+_lid);
    else {
      _pLayer = this.parLayer;
      testLayer = eval('_pLayer.document.layers.lItem'+_lid);
    }
    if(testLayer) layer = testLayer;
    else {
      if(isNav4) {
        if(this.parLayer) layer = new Layer(this.width, this.parLayer);
        else layer = new Layer(this.width);
      } else return;
    }
  }
  if(bgColor) layer.oBgColor = bgColor;
  this.items[this.items.length] = layer;
  this.types[this.types.length] = "item";
  this.strs[this.strs.length] = str;
  _lid++;
}
function addList(list, str, bgColor, layer) {
  var testLayer = false;
  if(!document.all) document.all = document.layers;
  if(!layer) {
    if(isIE4 || !this.parLayer) testLayer = eval('document.all.lItem'+_lid);
    else {
      _pLayer = this.parLayer;
      testLayer = eval('_pLayer.document.layers.lItem'+_lid);
    }
    if(testLayer) layer = testLayer;
    else {
      if(isNav4) {
        if(this.parLayer) layer = new Layer(this.width, this.parLayer);
        else layer = new Layer(this.width);
      } else return;
    }
  }
  if(bgColor) layer.oBgColor = bgColor;
  this.lists[this.items.length] = list;
  this.items[this.items.length] = layer;
  this.types[this.types.length] = "list";
  this.strs[this.strs.length] = str;
  list.parent = this;
  _lid++;
}

/**
 * Select Box Movement Component 1.0
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */

function MoveItems(FormFrom, FormTo, FormSource, FormReturn, NoRemoveFrom, Unique, HistoryNoGo, MoveAll) {
//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);
}


function MoveItems2(FormFrom, FormTo, FormSource, FormReturn, NoRemoveFrom) {
//moved here as a backup
	var i=FormFrom.length -1;
	var z=FormTo.length;
	while (i >= 0) {
		if (FormFrom.options[i].selected==true) {
			FormTo.options[z] = new Option(FormFrom.options[i].text, FormFrom.options[i].value);
                        if (NoRemoveFrom !=  1) {
			  FormFrom.options[i] = null;
                        }
			z++;
      		}
		i--;
	}
	history.go(0)
        getItemsList(FormSource, FormReturn);
}

function MoveListToTextBox(FormFrom, FormTo) {
        var NewValue = FormFrom[FormFrom.selectedIndex].value;
        if (NewValue) {
                FormTo.value = NewValue;
        }
        else {
                alert("You must select an image from the search results box first");
        }
}

function AddItem(FormTo, text, value) {

  var z = FormTo.length;
  FormTo.options[z] = new Option(text, value);
  history.go(0);
}


function getItemsList(ItemList, PopulatedTextField) {
	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 && PopulatedTextField) {
                PopulatedTextField.value = ReturnImages;
        }
        else {
                if (PopulatedTextField) {
                        PopulatedTextField.value = "";
                }
        }
}

function getItemsListALL(FormFrom, FormTo) {
        var FormSelected = FormFrom;
	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) {
                PopulatedTextField.value = ReturnImages;
        }
        else {
                PopulatedTextField.value = "";
        }
}

function getListBoxImages(FormFrom, FormTo, FileName) {
        var i=FormFrom.length -1;
        var j=FormTo.length -1;
	var ReturnImages;
	while (i >= 0) {
                if (FormFrom.options[i].selected==true) {
                        if (!(ReturnImages)) {
                                ReturnImages = FormFrom.options[i].value + ",";
                        }
                        else {
                                ReturnImages = ReturnImages + FormFrom.options[i].value + ",";
                        }
                }
                i--;
	}
        var i=FormTo.length -1;
        while (i >= 0) {
                if (FormTo.options[i].selected==true) {
                        if (!(ReturnImages)) {
                                ReturnImages = FormTo.options[i].value + ",";
                        }
                        else {
                                ReturnImages = ReturnImages + FormTo.options[i].value + ",";
                        }
                }
                i--;
        }
        if (ReturnImages) {
                //alert(ReturnImages);
                var openString = FileName + "?action=previewImages&images=" + ReturnImages;
                dialogueWin=window.open(openString,"imagePreview","HEIGHT=500,WIDTH=500,resizeable,scrollbars");
                dialogueWin.creator=self;
                dialogueWin.focus();
        }
        else {
                alert("You must highlight at least one image\nin order to generate a preview");
        }
}

function getListBoxImagesSingle(FormFrom, FileName) {
        var i=FormFrom.length -1;
        var ReturnImages;
	while (i >= 0) {
                if (FormFrom.options[i].selected==true) {
                        if (!(ReturnImages)) {
                                ReturnImages = FormFrom.options[i].value + ",";
                        }
                        else {
                                ReturnImages = ReturnImages + FormFrom.options[i].value + ",";
                        }
                }
                i--;
	}
        if (ReturnImages) {
                //var openString = FileName + "?action=setframe&arg1=previewImages%26images%3D" + ReturnImages;
                var openString = FileName + "?action=previewImages&images=" + ReturnImages;
                dialogueWin=window.open(openString,"imagePreview","HEIGHT=500,WIDTH=500,resizable,scrollbars");
                dialogueWin.creator=self;
                dialogueWin.focus();
        }
        else {
                alert("You must highlight at least one image\nin order to generate a preview");
        }
}

function getTextBoxImage(FormFrom, FileName) {
        var ReturnImages = FormFrom.value;
        if (ReturnImages) {
                //var openString = FileName + "?action=setframe&arg1=previewImages%26images%3D" + ReturnImages;
                var openString = FileName + "?action=previewImages&images=" + ReturnImages;
                dialogueWin=window.open(openString,"imagePreview","HEIGHT=500,WIDTH=500,resizable,scrollbars");
                dialogueWin.creator=self;
                dialogueWin.focus();
        }
        else {
                alert("There is no image to preview");
                return false;
        }
}

function populateTextField(SelectForm, TargetField) {
        var ReturnValue = SelectForm[SelectForm.selectedIndex].text;
        TargetField.value = ReturnValue;
}

function getPictureData(FormElement, targetList, FileName, PictureType, PictureCategory) {
         //arg2 was added later.  It is intended to be the second argument in a call to get_sql_from_archive().
                var valueString = FormElement.value;
                var SearchString = "_SEARCH_searchpictures_";
                parent[2].location = FileName + "?action=fillselect&sql=" + SearchString + "&value=" + valueString + "&picturetype=" + PictureType + "&return_to=" + targetList.name + "&nothing_returned_msg=No+Entries&return_to_frame=0&picturecategory="+PictureCategory;
                FormElement.focus();
        }


function revertImage(targetList, newValue) {
                var optionRevert = new Option(newValue.text, newValue.value);
                //clear the list box
                clearListbox(targetList);
                //Populate List with Orriginal Option...
                targetList.options[0]=optionRevert;
                targetList.options[0].selected=true;
        }
function clearListbox(targetList) {
                var array_length = targetList.options.length;
                var i=array_length;
                while (i >= 0 ) {
                        targetList.options[i] = null;
                        i--;
                }
        }


function swapItems(selbox, dir) {
  ///selbox, dir=up or down
  ///this function just swaps items in a listbox
   i = selbox.selectedIndex;
   if (i < 0) {return 0;}

   if (dir == "down")
   {
      if (i != selbox.length-1)
	{
	  temptext = selbox[i].text;
          tempid   = selbox[i].value;
          selbox[i].text = selbox[i+1].text;
          selbox[i].value = selbox[i+1].value;
          selbox[i+1].text = temptext;
          selbox[i+1].value = tempid;
          selbox.selectedIndex++;
	}

   }
   else   ///dir = up
   {
      if (i > 0)
      {
        temptext = selbox[i-1].text;
        tempid   = selbox[i-1].value;
        selbox[i-1].text = selbox[i].text;
        selbox[i-1].value = selbox[i].value;
        selbox[i].text = temptext;
        selbox[i].value = tempid;
        selbox.selectedIndex--;
      }
   }//direction is up
   return(0)
}//end function swapItems


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; }
	}

  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 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)
        }
}

/**
 * resize.js 0.3 970811
 * by gary smith
 * js component for "reloading page onResize"
 */

if(!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

function resizeIt() {
    if (saveInnerWidth < window.innerWidth ||
        saveInnerWidth > window.innerWidth ||
        saveInnerHeight > window.innerHeight ||
        saveInnerHeight < window.innerHeight )
    {
        window.history.go(0);
    }
}

/**
 * UTILITIES
 * by Shawn Neumann, Feb 1999
 * Copyright (c) 1999 EPIC Solutions International Inc.
 *
 */


function helpold(helpstr, title)
{
helpwin = window.open("product25c1.html?action=help&amp;helpstr="+escape(helpstr)+"&title="+title, helpwin, "HEIGHT=150,WIDTH=300,TOOLBAR=0,SCROLLBARS=1,STATUS=0,RESIZEABLE=0");
helpwin.focus();

}

function help(helpindex, title, filename)
{

if (filename)
{
 loc = filename + "?action=help&helpindex="+helpindex+"&title="+title;
 var helpwin = window.open(loc, helpwin, "HEIGHT=150,WIDTH=300,TOOLBAR=0,SCROLLBARS=1,STATUS=0,RESIZEABLE=0");
 helpwin.focus();
}
else
{

   loc = "product17e0.html?action=help&amp;helpindex="+helpindex+"&title="+title;

 helpwin = window.open(loc, helpwin, "HEIGHT=150,WIDTH=300,TOOLBAR=0,SCROLLBARS=1,STATUS=0,RESIZEABLE=0");
helpwin.focus();
}

//don't forget to write an onunload opener=0 in the help script.
}

function helpWindow(helpindex, title, caller)
{
 helpwin = window.open( caller + "?action=testhelp&helpindex="+helpindex+"&title="+title, helpwin, "HEIGHT=150,WIDTH=300,TOOLBAR=0,SCROLLBARS=1,STATUS=0,RESIZEABLE=0");
helpwin.focus();
//don't forget to write an onunload opener=0 in the help script.
}

/**
 * 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='#ffffff';
    }
    d.style.color='#ffffff';
    d.style.backgroundColor='#999999';
    scrollbox_flag = d;
    
}


