function windowOnLoad( func ) {
  var old_onload = window.onload;
  if ( typeof window.onload != 'function' ) {
    window.onload = func;
  } else {
    window.onload = function() {
      if ( old_onload ) { old_onload(); }
      func();
    }
  }
}

/**/

/* function $(x) {
  return document.getElementById(x);
} */

/**/
var AJAX = new function() {

  var o, url, handler, id;

  this.request = function( _u, _p, _h, _i ) {

    if( navigator.appName == "Microsoft Internet Explorer" ) {
      o = new ActiveXObject( "Microsoft.XMLHTTP" );
    } else {
      o = new XMLHttpRequest();
    }

    var p, get_params = [];
    for ( p in _p ) {
      get_params.push( p + "=" + _p[p] );
    }

    url = _u + "?" + get_params.join( "&" );
    handler = _h;

    if ( _i > 0 ) {
      id = setInterval( doRequest, _i * 1000 );
    }

  }

  this.stop = function() {
    clearTimeout( id );
  }

  function doRequest() {
    o.open( 'get', url );
    o.onreadystatechange = function() {
      if ( o.readyState == 4 ) {
        handler( o.responseText );
      }
    };
    o.send( null );
  };
}

/**
*
*/
Number.prototype.nf = function( decimals, dec_point, thousands_sep ) {

  var n = this, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
  var d = dec_point == undefined ? "," : dec_point;
  var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
  var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;

  return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
