function nf(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function redirect(url) {
	top.location.href = url;
}
		
function notice(el,t,b) {
	$(el).attr('title',t).html(b).dialog({
		bgiframe: true,
		resizable: false,
		draggable: false,
		modal: true,
		buttons: {
			'Ok': function() {
				$(this).dialog('close');
			}
		}
	});	
}

function choice(el,t,b,ok,ok_cbf,can,can_cbf) {
	var buts = {};
	buts[ok] = function() { ok_cbf.call(); $(this).dialog('close'); };
	buts[can] = function() { can_cbf.call(); $(this).dialog('close'); };
	$(el).attr('title',t).html(b).dialog({
		bgiframe: true,
		resizable: false,
		draggable: false,
		modal: true,
		buttons: buts
	});
}

//http://stackoverflow.com/questions/130404/javascript-data-formatting-pretty-printer
function DumpObjectIndented(obj, indent)
{
  var result = "";
  if (indent == null) indent = "";

  for (var property in obj)
  {
    var value = obj[property];
    if (typeof value == 'string')
      value = "'" + value + "'";
    else if (typeof value == 'object')
    {
      if (value instanceof Array)
      {
        // Just let JS convert the Array to a string!
        value = "[ " + value + " ]";
      }
      else
      {
        // Recursive dump
        // (replace "  " by "\t" or something else if you prefer)
        var od = DumpObjectIndented(value, indent + "  ");
        // If you like { on the same line as the key
        //value = "{\n" + od + "\n" + indent + "}";
        // If you prefer { and } to be aligned
        value = "\n" + indent + "{\n" + od + "\n" + indent + "}";
      }
    }
    result += indent + "'" + property + "' : " + value + ",\n";
  }
  return result.replace(/,\n$/, "");
}