var g_oCalcPopupFillField = null;
var g_oDatePopupFillField = null;
var g_bDatePopupAs101Format = null;

function ShowCalculator(oFillElement, iBorderStyle)
{
  g_oCalcPopupFillField = oFillElement;
  var cParams = GenerateCenteredWindowLeftTop(258,248)+"toolbar=no,scrollbars=no,status=no,width=258,height=248,resizable=yes,menubar=no,location=no,center=yes,dialog=yes,modal=yes,dependent=yes";
  var oDlg = open("/cfr/calculator.htm","Calculator",cParams,true);
  try {
    oDlg.focus();
  }
  catch(e){}
}

function CalculatorCallback(cResultValue)
{
  if (g_oCalcPopupFillField != null)
    {
      if (cResultValue != null)
        {
          g_oCalcPopupFillField.value = cResultValue;
          try {
            g_oCalcPopupFillField.focus();
          }
          catch(e){}
        }
    }
  else if (CalculatorPopupCallback)
    CalculatorPopupCallback(cResultValue);
}

function ShowCalendar(oFillElement, iBorderStyle, bAs101Format)
{
  g_oDatePopupFillField = oFillElement;
  g_bDatePopupAs101Format = bAs101Format;

  if (bAs101Format == null)
    bAs101Format = false;

  var cInitValue = "";
  if (oFillElement != null)
    cInitValue = oFillElement.value; //use LocalDateToDate101(oFillElement.value) for localized  version of this file

  var oInitValObj = new Object();
  oInitValObj.value = cInitValue;
  if (IsValidDate(oInitValObj, g_cDateFmtMask))
    cInitValue = oInitValObj.value;
  else
    cInitValue = "";
    
  var cParams = GenerateCenteredWindowLeftTop(250,238)+"toolbar=no,scrollbars=no,status=no,width=250,height=238,resizable=yes,menubar=no,location=no,center=yes,dialog=yes,modal=yes,dependent=yes";
  var oDlg = open("/cfr/calendar.htm?InitValue="+cInitValue,"Calendar",cParams,true);
  try {
    oDlg.focus();
  }
  catch(e){}
}

function CalendarCallback(dRetval)
{
  var cResStr = "";

  if (g_bDatePopupAs101Format)
    cResStr = MDYToDate101(dRetval.getMonth()+1,dRetval.getDate(),dRetval.getFullYear());
  else
    cResStr = MDYToLocalDate(dRetval.getMonth()+1,dRetval.getDate(),dRetval.getFullYear());

  if (g_oDatePopupFillField)
    {
      g_oDatePopupFillField.value = cResStr;
      try {
        g_oDatePopupFillField.focus();
      }
      catch(e){}
    }
  else if(CalendarPopupCallback)
    CalendarPopupCallback(dRetval);
}

function ShowColorPicker(oFillElement, cInitialColor, iBorderStyle)
{
  if (cInitialColor == null && oFillElement != null)
    cInitialColor = oFillElement.value;
  var cParams = GenerateCenteredWindowLeftTop(635,430)+"toolbar=no,scrollbars=no,status=no,width=635,height=430,resizable=yes,menubar=no,location=no,center=yes,dialog=yes,modal=yes,dependent=yes";
  var oDlg = open("/cfr/colorpicker.htm" + (cInitialColor ? "?InitialColor="+cInitialColor : ""),"ColorPicker",cParams,true);
  try {
    oDlg.focus();
  }
  catch(e){}
}

