  //****************************************************************--
  // Utility functions for added WebSpeed functionality             --
  // Created By   : Chris Larson                                    --
  // Created On   : 5-28-00                                         --
  //                                                                --
  // Last Updated : v1.0  5-28-00                                   --
  // 05-28-00     : Created utilities.js and added captureEvent()   --
  // 05-30-00     : Added openList function                         --
  // 12.17.00     : Copied file to Epicor/JavaScript                --
  // 09/04/03 SEV scr3759 Added floatRangeCheck() and intRangeCheck --
  // 05/03/07 HCampos scr32429 Added ShowHideRows() and SwitchImage --
  //****************************************************************--


  //------------------------------------------------------------------
  // captureEvent() : Created to capture events triggered by users. --
  //                  This function can also display a confirm      --
  //                  message.                                      --
  // Required Field : <input name="event" type="hidden" value="">   --
  // Required Field : <input name="vchange" type="hidden" value=""> --
  //------------------------------------------------------------------
  function captureEvent(eventName,promptMsg) {
    if(promptMsg == "" || promptMsg == " ") {
      document.forms[0].event.value = eventName;
      return true;
    } else {
      if(document.forms[0].vchange.value == "yes") {

        if(confirm(promptMsg)) {
          document.forms[0].event.value = eventName;
          return true;
        } else {
          return false;
        }

      } else {
        document.forms[0].event.value = eventName;
        return true;
      }
    }
  }

  //------------------------------------------------------------------
  // valueChange() : Created to capture events triggered by users.  --
  //                 This function can also display a confirm       --
  //                 message.                                       --
  // Required Field : <input name="vchange" type="hidden" value=""> --
  //------------------------------------------------------------------
  function valueChange() {
    document.forms[0].vchange.value = "yes";
  }

  //------------------------------------------------------------------
  // Function	: stsDisp()                                         --
  // Purpose  : Message to be displayed in status.                  --
  //------------------------------------------------------------------
  function stsDisp(msg) {
    window.status = msg;
    return true;
  }

  //------------------------------------------------------------------
  // Function : floatRangeCheck()                                   --
  // Purpose  : if the given field's value is not a decimal, or     --
  //            not in the given range, it sends an alert() and     --
  //            returns false                                       --
  //------------------------------------------------------------------
  function floatRangeCheck( fld, minNum, maxNum) {
    //remove commas
    var re = /,/g
    var cNum = fld.value.replace( re , "");
    if ( isNaN( parseFloat( cNum ) ) ) {
      alert( "Invalid Amount." );
      return false;
    } else if ( parseFloat( cNum ) < parseFloat(minNum) ) {
      alert( "Value must not be less than " + minNum + "." );
      return false;
    } else if ( parseFloat( cNum ) > parseFloat(maxNum) ) {
      alert( "Value must not exceed " + maxNum + "." );
      return false;
    }
    return true;
  }
  //------------------------------------------------------------------
  // Function	: getArgs()                                         --
  // Purpose  : Parse the URL parameters                            --
  //------------------------------------------------------------------
  function getArgs( argName ) {
    var params = "&" + location.search.substring(1);

	//Find the parameter
    var pos = params.indexOf( '&' + argName + '=' );
    if ( pos == -1 ) return '';
	var value = params.substring( pos + argName.length + 2 );


	//Stript off the rest of the string
	pos = value.indexOf( '&' );
    if ( pos > -1 ) value = value.substring( 0, pos );
	
	return unescape( value );
  }

  //------------------------------------------------------------------
  // Function : intRangeCheck()                                     --
  // Purpose  : if the given field's value is not an integer, or    --
  //            not in the given range, it sends an alert() and     --
  //            returns false                                       --
  //------------------------------------------------------------------
  function intRangeCheck( fld, minNum, maxNum) {
    //remove commas
    var re = /,/g
    var cNum = fld.value.replace( re , "");
    if ( isNaN( parseInt( cNum ) ) ) {
      alert( "Invalid Amount." );
      return false;
    } else if ( parseInt( cNum ) < parseInt(minNum) ) {
      alert( "Value must not be less than " + minNum + "." );
      return false;
    } else if ( parseInt( cNum ) > parseInt(maxNum) ) {
      alert( "Value must not exceed " + maxNum + "." );
      return false;
    }
    return true;
  }
  
  
  //------------------------------------------------------------------
  // Function : ShowHideRows(id)									--
  // Purpose  : Hide/Show de rows related to the Input "id"			--
  //------------------------------------------------------------------  
  function ShowHideRows(id)
  {
	if (document.getElementById && document.createTextNode)
    {
		var tr=document.getElementById(id);
		if(tr)
		{
			if(tr.style.display == 'none')
			{
				// To make tr tags disappear we set display to none, as usual to make them appear again
				// we set style to block for IE but for firefox we use table-row
				try
				{
					tr.style.display='table-row';
				} catch(e) {tr.style.display = 'block';}
			}
			else {tr.style.display = 'none';}
		}     
	}
  }
  
  //------------------------------------------------------------------
  // Function : SwitchImage(id,on,off)			  									    --
  // Parameters: id - Id of the IMG tag which contains the image
  //			 on - One of the images: file name  (Status ON image)
  //			 off - One of the images: file name (Status OFF image)
  // Purpose  : Switches the images on the elements related to the Input "id"			--
  //------------------------------------------------------------------  
  function SwitchImage(id,on,off)
  {
	if (document.getElementById && document.createTextNode)
    {
		//Get the SRC of the image
		var str=document.getElementById(id).src;				
		
		//Paths 
		var offpath = str.replace(on,off);
		var onpath = str.replace(off,on);

		//Set the new path
		if(str==offpath)
			document.getElementById(id).src = onpath;
		else
			document.getElementById(id).src = offpath;					
			
		
	}
  }

