﻿jQuery.noConflict();
function showDialog(t, w, h, f, m, c, esc, hc, o, r, d) {
  if (w == 0) {
    w = 'auto';
  }
  if (h == 0) {
    h = 'auto';
  }
  jQuery('#' + f).dialog(
  {
    //autoReposition: true,
    autoOpen: false,
    width: w,
    height: h,
    modal: m,
    title: '' + t + '',
    hide: 'fold',
    dialogClass: '' + c + '',
    closeOnEscape: esc,
    resizable: r,
    draggable: d,
    open: function () {
      jQuery(this).parent().appendTo("form");
      if (hc == true) {
        jQuery(".ui-dialog-titlebar-close").hide();
      }
    }
  });
  if (o == 'open') { jQuery('#' + f).dialog('open'); } else { jQuery('#' + f).dialog('close'); };
};
function textfocus(e, phrase) {
  if (trim(e.value) == phrase) e.value = '';
}

function textblur(e, phrase) {
  if (trim(e.value) == '') e.value = phrase;
}
function trim(x) {
  while (x.substring(0, 1) == ' ') {
    x = x.substring(1, x.length);
  }
  while (x.substring(x.length - 1, x.length) == ' ') {
    x = x.substring(0, x.length - 1);
  }
  return x;
}

function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g, '');
  if (isNaN(num))
    num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num * 100 + 0.50000000001);
  cents = num % 100;
  num = Math.floor(num / 100).toString();
  if (cents < 10)
    cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
    num = num.substring(0, num.length - (4 * i + 3)) + ',' +
	num.substring(num.length - (4 * i + 3));
  return (((sign) ? '' : '-') + '$' + num + '.' + cents);
}
