 
   // ---------------------------------------------------------------------
   // -- validateAll
   // ---------------------------------------------------------------------
   function validateAll(form) 
   {
     // Here goes the call to STRUTS validation.
     return validateStruts(form);
   }

  
   // ---------------------------------------------------------------------
   // -- buttonValue
   // ---------------------------------------------------------------------
   function buttonValue(value, form, isOnSubmit) 
   {
      if (!form)
      {
      	if (this.tagName == 'form')
      	{
      		form = this;
      		isOnSubmit = true;
      	}
      	else
      	{
      		form = document.forms[0];
      	}
      }
      return _buttonValue(value, form, isOnSubmit, true);
   }
   
   // ---------------------------------------------------------------------
   // -- buttonValueConfirm
   // ---------------------------------------------------------------------
   function buttonValueConfirm(value, form, isOnSubmit)
   {
      if (!form)
      {
      	if (this.tagName == 'form')
      	{
      		form = this;
      		isOnSubmit = true;
      	}
      	else
      	{
      		form = document.forms[0];
      	}
      }
      return _buttonValue(value, form, isOnSubmit, true, true);
   }

   // ---------------------------------------------------------------------
   // -- buttonValueNoValidate
   // ---------------------------------------------------------------------
   function buttonValueNoValidate(value, form, isOnSubmit) 
   {
      if (!form)
      {
      	if (this.tagName == 'form')
      	{
      		form = this;
      		isOnSubmit = true;
      	}
      	else
      	{
      		form = document.forms[0];
      	}
      }
      return _buttonValue(value, form, isOnSubmit);
   }

   // ---------------------------------------------------------------------
   // -- _buttonValue
   // ---------------------------------------------------------------------
   function _buttonValue(value, form, isOnSubmit, bValidate, bConfirm)
   {  	  
      // set the buttonPressed value
      form.buttonPressed.value = value;
      
      // process submission
      var returnValue = true;
      if (bValidate)
      {
         if (value == 'CANCEL' && bConfirm) 
         {
	        returnValue = confirm('Are you sure you want to exit?\nAll changes will be lost.');
         } 
         else 
         {
            returnValue = validateAll(form);
         }
      }
      
      // submit the form
      if (returnValue && !isOnSubmit) form.submit();
      
      // return the result
      return returnValue;
   }
   
   // ---------------------------------------------------------------------
   // -- selectAll - select all check boxes with the given prefix
   // -- @param trigger - source checkbox that triggers the action
   // ---------------------------------------------------------------------
   function selectAll(prefix, trigger)
   {
      var coln = trigger.form.elements;
      var check = trigger.checked;
	
      for (var i=0;i<coln.length;i++)
      {
         var elem = coln[i];
         if (elem == trigger || elem.disabled) continue;
         if (elem.name.indexOf(prefix) == 0)
         {
         	if (elem.checked != check) elem.click();
         }
      }
   }

   // ---------------------------------------------------------------------
   // -- redisplay
   // ---------------------------------------------------------------------
   function redisplay(fld, value) 
   {
      document.getElementById(fld).innerHTML = value;
   }
   
   // ---------------------------------------------------------------------
   // -- getCookie
   // ---------------------------------------------------------------------
   function getCookie(name)
   {
        var cookieFound = 0;
        var start = 0;
        var end = 0;
        var CookieString = document.cookie;

        var i =0;
        while (i <= CookieString.length)
        {
                start = i;
                end = start + name.length;
                if (CookieString.substring(start,end) == name)
                {
                        cookieFound = true;
                        break;
                }
                i++;
        }

        if (cookieFound)
        {
                start = end + 1;
                end = document.cookie.indexOf(";",start);
                if (end < start)
                        end = document.cookie.length;
                return document.cookie.substring(start,end);
        }

        return "";
	}
   
   // ---------------------------------------------------------------------
   // -- setCookie
   // ---------------------------------------------------------------------
	function setCookie(cookieName, cookieValue, nDays)
	{
		 var today = new Date();
		 var expire = new Date();
		 if (nDays==null || nDays==0) nDays=1;
		 expire.setTime(today.getTime() + 3600000*24*nDays);
		 document.cookie = cookieName+"="+escape(cookieValue)
		                 + ";expires="+expire.toGMTString();
	}

   
   // ---------------------------------------------------------------------
   // -- generateHTMLDotList
   // ---------------------------------------------------------------------
   function generateHTMLDotList(msgString, separator) 
   {
      var resultStr = "<ul>";
      var strArr = msgString.split(separator);

      for (i=0; i<strArr.length; i++) 
      {
         if (strArr[i] != "") 
         {
           resultStr = resultStr + "<li>"+strArr[i]+"</li>";
         }
      }
      return (resultStr+"&nbsp;</ul>");
   }

   // ---------------------------------------------------------------------
   // Select a specific option in a select box.
   // selObj:   Object that must be a selection box.
   // selValue: Value in option list to be selected.
   // ---------------------------------------------------------------------
   function activateSelection(selObj, selValue) 
   {
       var ix = 0;
       var len = selObj.length;
       for (i=0; i<len; i++) 
       {
          if (selObj.options[i].value == selValue) 
          {
            ix = i;
          }
       }
       selObj.selectedIndex=ix;
   }

   // ---------------------------------------------------------------------
   // Prevent right mouse button clicking
   // ---------------------------------------------------------------------
   //document.oncontextmenu = doNothing
   function doNothing() 
   {
       alert('You cannot use the right mouse button in the EBL Application!');
       return false
   }
   
   // ---------------------------------------------------------------------
   // check that a field is numeric
   // ---------------------------------------------------------------------
   function checkNumeric(field, name)
   {
		if (isNaN(field.value)) // fields with a number in it
		{
			alert('Numeric value required for ' + name);
			return false;
		}

		return true;
   }
   
   // ---------------------------------------------------------------------
   // Display the given message in the window's status bar.
   // ---------------------------------------------------------------------
   function statusBar(message)
   {
      // Need the setTimeout, apparently, for a netscape timimg problem.
      setTimeout("window.status='"+message+"';", 0);
      return true;
   }
   

   