﻿// JScript Common Function
function stripNonNumeric( str ) {
      str += '';
      var rgx = /^\d|\.|-$/;
      var out = '';
      for( var i = 0; i < str.length; i++ ) {
        if( rgx.test( str.charAt(i) ) ){
          if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) ||
                 ( str.charAt(i) == '-' && out.length != 0 ) ) ){
            out += str.charAt(i);
          }
        }
      }
      return out;
    }

    function num2money(n_value) {
      // validate input
      if (isNaN(Number(n_value)))
      return 'ERROR';

      // save the sign
      var b_negative = Boolean(n_value < 0);
      n_value = Math.abs(n_value);

      // round to 1/100 precision, add ending zeroes if needed
      var s_result = String(Math.round(n_value*1e2)%1e2 + '00').substring(0,2);

      // separate all orders
      var b_first = true;
      var s_subresult;
      while (n_value > 1) {
      s_subresult = (n_value >= 1e3 ? '00' : '') + Math.floor(n_value%1e3);
      s_result = s_subresult.slice(-3) + (b_first ? '.' : ',') + s_result;
      b_first = false;
      n_value = n_value/1e3;
      }
      // add at least one integer digit
      if (b_first)
      s_result = '0.' + s_result;

      // apply formatting and return
      return b_negative
      ? '(&euro; ' + s_result + ')'
      : '&euro; ' + s_result;
    }
    
    function disabledcombo(id, disabled) {
      document.getElementById(id).disabled = disabled;
      //custom function
      if(document.getElementById(id).refresh!=undefined)
      document.getElementById(id).refresh();
    }

    function loadUrl(byURL) {
      if (byURL != undefined) {
        setTimeout(function(){window.location = byURL;}, 0);        
      }  
    }
