function IsNull(sObj, s)
{
  if (sObj == null)
    return (s);
  else
    return (sObj);
}

function IsBlank(sObj, s)
{
  if (sObj == null || String(sObj) == "" || String(sObj) == "undefined")
    return (s);
  else
    return (sObj);
}

function IsUniqueIdentifier(nId)
{
  return (new RegExp(/^\{{0,1}[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}\}{0,1}$/).test(nId));
}

function DebraceUniqueIdentifier(nId)
{
  if (nId != null && nId.substr(0, 1) == '{' && nId.substr(nId.length - 1, 1) == '}')
  {
    return nId.substr(1, nId.length - 2);
  }
  else
  {
    return nId;
  }
}

function BraceUniqueIdentifier(nId)
{
  if (nId != null && nId.substr(0, 1) != '{' && nId.substr(nId.length - 1, 1) != '}')
  {
    return '{' + nId + '}';
  }
  else
  {
    return nId;
  }
}

function ForDisplay(s)
{
  var
    regExp;
    
  if (s == null)
    s = "";
  s = String(s);

  regExp = /&/g;
  s = s.replace(regExp, '&amp;');
  regExp = /</g;
  s = s.replace(regExp, '&lt;');
  regExp = />/g;
  s = s.replace(regExp, '&gt;');

  return (s);
}

function ForDisplayF(s)
{
  s = ForDisplay(s);
  if (s == null || s == '')
  {
    return '&nbsp;'
  }
  else
  {
    return s;
  }
}

function ForInput(s)
{
  var
    nIndex;
    
  if (s == null)
    s = "";
  s = String(s);

  s = s.replace(/&/g, '&amp;');
  s = s.replace(/"/g, '&quot;');
  return (s);
}

function Trim(s)
{
  if (s == null)
    return null;
  s = String(s);
  while (s.charAt(0) == " ")
    s = s.substr(1);
  while (s.charAt(s.length - 1) == " ")
    s = s.substr(0, s.length - 1);
  return (s);
}

function FormatDate(fmt, date)
{
  var
    day, twodigitday,
    month, twodigitmonth, monthName,
    year, twodigityear,
    res,
    monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    
  if (date == null)
  {
    return (null);
  }
  day = date.getDate();
  twodigitday = "0" + day;
  twodigitday = twodigitday.substr(twodigitday.length - 2);
  weekName = WeekNumToName(GetDayOfWeek(date));

  month = date.getMonth() + 1;
  twodigitmonth = "0" + month;
  twodigitmonth = twodigitmonth.substr(twodigitmonth.length - 2);
  monthName = monthNames[month - 1];

  year = date.getFullYear();
  twodigityear = String(year).substr(2);

  hours = String(date.getHours());
  hours12 = hours;
  ampm = 'am';
  if (hours12 >= 12)
  {
    ampm = 'pm';
  }
  if (hours12 > 12)
  {
    hours12 -= 12;
  }
  if (hours.length < 2)
    hours = "0" + hours;
  minutes = String(date.getMinutes());
  if (minutes.length < 2)
    minutes = "0" + minutes;
  seconds = String(date.getSeconds());
  if (seconds.length < 2)
    seconds = "0" + seconds;

  sHoursMinsAmPm = '';
  if (Number(hours) != 0 || Number(minutes) != 0)
  {
    sHoursMinsAmPm = hours12 + ':' + minutes + ampm;
  }
  
  res = fmt;
  res = res.replace("yyyy", year);
  res = res.replace("yy", twodigityear);
  res = res.replace("dddd", "£");
  res = res.replace("ddd", "$");
  res = res.replace("dd", twodigitday);
  res = res.replace("d", day);
  res = res.replace("mmmm", "!");
  res = res.replace("mmm", "#");
  res = res.replace("mm", twodigitmonth);
  res = res.replace("m", month);
  res = res.replace("£", weekName);
  res = res.replace("$", weekName.substr(0, 3));
  res = res.replace("!", monthName);
  res = res.replace("#", monthName.substr(0, 3));
  res = res.replace("hh", hours);
  res = res.replace("h:nn", sHoursMinsAmPm);
  res = res.replace("nn", minutes);
  res = res.replace("ss", seconds);

  return (Trim(res));
}

function FormatIntElem(oElem, bSeparator)
{
  var
    nInt, sInt;
    
  sInt = IsBlank(oElem.value, '');
  if (sInt != '')
  {
    sInt = sInt.replace(/,/g, '');
    nInt = Number(sInt);
    if (IsNumber(nInt))
    {
      sInt = FormatNum(nInt, 0);
      if (!bSeparator)
      {
        sInt = sInt.replace(/,/g, '');
      }
      oElem.value = sInt;
    }
  }
}

function FormatFloatElem(oElem, bSeparator, nDecimalPlaces, sSymbol)
{
  var
    nFloat, sFloat;
    
  sFloat = IsBlank(oElem.value, '');
  if (sFloat != '')
  {
    sFloat = sFloat.replace(/,/g, '');
    sFloat = (sSymbol != null ? sFloat.replace(sSymbol, '') : sFloat);
    nFloat = Number(sFloat);
    if (IsNumber(nFloat))
    {
      sFloat = FormatNum(nFloat, nDecimalPlaces);
      if (!bSeparator)
      {
        sFloat = sFloat.replace(/,/g, '');
      }
      sFloat = (sSymbol == null || sSymbol == '%' ? '' : sSymbol + ' ') + sFloat + (sSymbol == '%' ? '%' : '');
      oElem.value = sFloat;
    }
  }
}

function FormatDateElem(oElem)
{
  var
    dDate;
    
  dDate = StrToDate(oElem.value);
  if (dDate != null)
  {
    oElem.value = FormatDate("d mmm yyyy", dDate);
  }
}

function FormatTimeElem(oElem)
{
  var
    dTime;
    
  dTime = StrToTime(oElem.value);
  if (dTime != null)
  {
    oElem.value = FormatDate("h:nn", dTime);
  }
}

function MonthNameToNum(sMonth)
{
  var
    sMonthNames = new Array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");

  sMonth = String(sMonth).toLowerCase();
  for (nMonth = 0; nMonth < 12; nMonth++)
  {
    sMonth = sMonth.replace(sMonthNames[nMonth], nMonth + 1);
  }
  for (nMonth = 0; nMonth < 12; nMonth++)
  {
    sMonth = sMonth.replace(sMonthNames[nMonth].substr(0, 3), nMonth + 1);
  }
  
  return sMonth;
}

function WeekNumToName(nWeekNum)
{
  //0 = Monday
  var
    asWeekNames = new Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
    
  return asWeekNames[Number(nWeekNum)];
}

function GetDayOfWeek(dDate)
{
  //Monday = 0
  if (dDate == null)
  {
    return null;
  }
  nDayOfWeek = dDate.getDay();
  return (nDayOfWeek + 7 - 1) % 7;
}

function StrToDate(sDate)
{
  var
    sSeparator, 
    nSep1Pos, nSep2Pos, 
    sDayPart, sMonthPart, sYearPart,
    nDay, nMonth, nYear,
    dDate;
    
  sDate = String(IsBlank(sDate, ""));
  
  sSeparator = "";  
  if (sDate.indexOf(" ") > -1)
    sSeparator = " ";
  if (sDate.indexOf("/") > -1)
    sSeparator = "/";
  if (sDate.indexOf("-") > -1)
    sSeparator = "-";
  if (sDate.indexOf(".") > -1)
    sSeparator = ".";
  
  if (sSeparator == "")  
    return null;
    
  nSep1Pos = sDate.indexOf(sSeparator);
  nSep2Pos = sDate.indexOf(sSeparator, nSep1Pos + 1);
  
  if (nSep1Pos < 0 || nSep2Pos < 0)
    return null;

  sDayPart = sDate.substr(0, nSep1Pos);
  sMonthPart = sDate.substring(nSep1Pos + 1, nSep2Pos);
  sYearPart = sDate.substr(nSep2Pos + 1);
  
  sMonthPart = MonthNameToNum(sMonthPart);

  nDay = Number(sDayPart);
  nMonth = Number(sMonthPart);
  nYear = Number(sYearPart);

  if (nDay >= 1 && nDay <= 31 && nMonth >= 1 && nMonth <= 12 && nYear >= 0)
    ;
  else
    return null;  

  if (nYear < 10)
    nYear = 2000 + nYear;
  else
  if (nYear < 80)
    nYear = 2000 + nYear;
  else
  if (nYear < 100)
    nYear = 1900 + nYear;
  else
  if (nYear < 1900)
    return null;
  else
  if (nYear > 2100)
    return null;
      
  dDate = new Date(nYear, nMonth - 1, nDay);
  return dDate;
}

function StrToTime(sTime)
{
  var
    nHour, nMinute, nSecond, asComp, bPm;
    
  nHour = -1;
  nMinute = -1;
  nSecond = -1;
  sTime = String(IsBlank(sTime, '')).replace(/ /g, '');
  if (new RegExp(/^[0-9]{1,2}(:[0-9]{1,2}){0,1}(:[0-9]{1,2}){0,1}$/).test(sTime))
  {
    //24 hour, with or without minutes, with or without seconds
    asComp = sTime.split(':');
    nHour = Number(asComp[0]);
    nMinute = (asComp.length > 1 ? Number(asComp[1]) : 0);
    nSecond = (asComp.length > 2 ? Number(asComp[2]) : 0);
  }
  else
  if (new RegExp(/^[0-9]{1,2}(:[0-9]{1,2}){0,1}(:[0-9]{1,2}){0,1}(am|pm)$/i).test(sTime))
  {
    //24 or 12 hour, with or without minutes, with or without seconds, with am or pm suffix
    bPm = new RegExp(/pm/i).test(sTime);
    sTime = sTime.replace(/(am|pm)/i, '');
    asComp = sTime.split(':');
    nHour = Number(asComp[0]);
    nMinute = (asComp.length > 1 ? Number(asComp[1]) : 0);
    nSecond = (asComp.length > 2 ? Number(asComp[2]) : 0);
    if (nHour < 12 && nHour >= 1 && bPm)
    {
      nHour += 12;
    }
    else
    if (nHour == 12 && !bPm)
    {
      nHour = 0;
    }
  }
  
  if (nHour >= 0 && nHour <= 23 &&
      nMinute >= 0 && nMinute <= 59 &&
      nSecond >= 0 && nSecond <= 59)
  {
    return new Date(0, 0, 0, nHour, nMinute, nSecond, 0);
  }
  return null;
}

function DateTimeToDate(d)
{
  return new Date(d.getFullYear(), d.getMonth(), d.getDate());
}

function GetIsLeapYear(nYear)
{
  var
    dDate;
    
  dDate = new Date(nYear, 1, 29);
  return (dDate.getMonth() == 1);
}

function GetDaysInYear(nYear)
{
  return (GetIsLeapYear(nYear) ? 366 : 365);
}

function GetMonthStart(dDate)
{
  var
    nYear, nMonth;
    
  nYear = dDate.getFullYear();
  nMonth = dDate.getMonth();
  return (new Date(nYear, nMonth, 1));
}

function GetDaysInMonth(dDate)
{
  var
    nDaysInMonth, nYear, nMonth;
    
  anDaysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  nYear = dDate.getFullYear();
  nMonth = dDate.getMonth();
  
  nDaysInMonth = anDaysInMonth[nMonth];
  if (nMonth + 1 == 2)
  {
    if (GetIsLeapYear(nYear))
    {
      nDaysInMonth++;
    }
  }
  return nDaysInMonth;
}

function DateAdd(sInterval, nAmount, dDate)
{
  var
    nYear, nMonth, nDay;
    
  if (dDate == null)
  {
    return null;
  }
  
  switch (sInterval)
  {
  case "day":
    nYear = dDate.getFullYear();
    nMonth = dDate.getMonth();
    nDay = dDate.getDate();
    return new Date(nYear, nMonth, nDay + nAmount);
  case "month":
    nYear = dDate.getFullYear();
    nMonth = dDate.getMonth();
    nDay = dDate.getDate();
    nMonth += nAmount;
    while (nMonth > 11)
    {
      nMonth -= 12;
      nYear++;
    }
    while (nMonth < 0)
    {
      nMonth += 12;
      nYear--;
    }
    nDaysInMonth = GetDaysInMonth(new Date(nYear, nMonth, 1));
    if (nDaysInMonth < nDay)
    {
      nDay = nDaysInMonth;
    }
    return (new Date(nYear, nMonth, nDay));
  case "year":
    nYear = dDate.getFullYear();
    nMonth = dDate.getMonth();
    nDay = dDate.getDate();
    nYear += nAmount;
    if (nMonth == 1 && nDay == 29 && !GetIsLeapYear(nYear))
    {
      nDay = 28;
    }
    return (new Date(nYear, nMonth, nDay));
  default:
    return null;
  }
}

function DateDiff(sInterval, dDate1, dDate2)
{
  var
    dMonday1, dMonday2;
    
  if (dDate1 == null || dDate2 == null)
  {
    return null;
  }
  
  switch (sInterval)
  {
  case 'minute':
    return Math.round((dDate1.getTime() - dDate2.getTime()) / (1000 * 60));
  case 'hour':
    return Math.round((dDate1.getTime() - dDate2.getTime()) / (1000 * 60 * 60));
  case 'day':
    dDate1 = DateTimeToDate(dDate1);
    dDate2 = DateTimeToDate(dDate2);
    return Math.round((dDate1.getTime() - dDate2.getTime()) / (1000 * 60 * 60 * 24));
  case 'day.':
    return (dDate1.getTime() - dDate2.getTime()) / (1000 * 60 * 60 * 24);
  case 'weekday':
    return NetworkDays(dDate1, dDate2);
  case 'week':
    dMonday1 = DateAdd('day', -GetDayOfWeek(dDate1), dDate1);
    dMonday2 = DateAdd('day', -GetDayOfWeek(dDate2), dDate2);
    if (dMonday1.getTime() > dMonday2.getTime())
    {
      return -Math.floor(DateDiff('day', dMonday2, dMonday1) / 7);
    }
    else
    {
      return Math.floor(DateDiff('day', dMonday1, dMonday2) / 7);
    }
  case 'month':
    return (dDate1.getFullYear() * 12 + dDate1.getMonth() - dDate2.getFullYear() * 12 - dDate2.getMonth());
  default:
    return null;
  }
}

function IsNumber(n)
{
  if (n == null)
    return (false);
  if (String(n) == "undefined" && n != "undefined")
    return (false);
  if (String(n) == "")
    return (false);
  return (!isNaN(n));
}

function IsInteger(n, s)
{
  if (n == null)
    return s;
  if (String(n) == "undefined" && n != "undefined")
    return s;
  if (String(n) == "")
    return s;
  return (isNaN(n) ? s : Math.floor(Number(n)));
}

function NumberToCurrency(nNum, sSymbol)
{
  if ((!IsNumber(nNum)) || (!isFinite(nNum)))
  {
    return null;
  }
  nNum = Math.round(Number(nNum));
  bIsNeg = (nNum < 0);
  nNum = Math.abs(nNum);
  s = new String("");
  res = new String("");
  while (nNum > 0)
  {
    s = String(nNum % 10) + s;
    res = String(nNum % 10) + res;
    nNum = Math.floor(nNum / 10);
    if ((s.length % 3) == 0)
    {
      res = "," + res;
    }
  }
  if (res.substr(0, 1) == ",")
    res = res.substr(1);
  if (res == "")
    res = "0";
  if (bIsNeg)
    res = "-" + res;
  if (sSymbol != "")
    res = sSymbol + " " + res;
  return (res);
}

function CurrencyToNumber(sNum)
{
  if (sNum == null)
    return null;
  sNum = String(sNum);
  sNum = sNum.replace(new RegExp(/\$/g), '');
  sNum = sNum.replace(new RegExp(/\u00A3/g), ''); //\u00A3 = pound symbol
  sNum = sNum.replace(new RegExp(/,/g), '');
  sNum = sNum.replace(new RegExp(/ /g), '');
  if (IsNumber(sNum))
  {
    return Number(sNum);
  }
  else
  {
    return null;
  }
}

function PercentToNumber(sNum)
{
  if (sNum == null)
    return null;
  sNum = String(sNum);
  sNum = sNum.replace(new RegExp(/%/g), '');
  sNum = sNum.replace(new RegExp(/,/g), '');
  sNum = sNum.replace(new RegExp(/ /g), '');
  if (IsNumber(sNum))
  {
    return Number(sNum);
  }
  else
  {
    return null;
  }
}

function FormatNum(nNum, nDecimalPlaces)
{
  var
    nIndex;
    
  for (nIndex = 0; nIndex < nDecimalPlaces; nIndex++)
    nNum = Number(nNum) * 10.0;
  nNum = Math.round(Number(nNum));
  bIsNeg = (nNum < 0);
  nNum = Math.abs(nNum);
  s = "";
  res = "";
  while (nNum > 0)
  {
    s = String(nNum % 10) + s;
    res = String(nNum % 10) + res;
    nNum = Math.floor(nNum / 10);
  }
  if (res == "")
    res = "0";
  if (nDecimalPlaces > 0)
  {
    while (res.length < nDecimalPlaces)
      res = "0" + res;
    intpart = res.substr(0, res.length - nDecimalPlaces);
    decpart = "." + res.substr(res.length - nDecimalPlaces);
  }
  else
  {
    intpart = res;
    decpart = "";
  }
  if (intpart == "")
    intpart = "0";
  nLen = intpart.length
  for (nIndex = nLen - 1; nIndex > 0; nIndex--)
  {
    if ((nLen - nIndex) % 3 == 0)
    {
      intpart = intpart.substr(0, nIndex) + "," + intpart.substr(nIndex);
    }
  }
  if (bIsNeg)
    intpart = "-" + intpart;
  return (intpart + decpart);
}

function FormatNumOrNull(nNum, nDecimalPlaces)
{
  if (nNum == null)
    return null;
  else
    return FormatNum(nNum, nDecimalPlaces);
}

function FormatNumPrecision(nNum, nMinDp, nMaxDp)
{
  var
    sRes;
    
  sRes = FormatNum(nNum, nMaxDp);
  if (sRes != null)
  {
    while (sRes.lastIndexOf('0') == sRes.length - 1 &&
           sRes.lastIndexOf('.') < sRes.length - 1 - nMinDp)
    {
      sRes = sRes.substr(0, sRes.length - 1);
    }         
    if (sRes.lastIndexOf('.') == sRes.length - 1)
    {
      sRes = sRes.substr(0, sRes.length - 1);
    }
  }
  return sRes;
}

function FormatNumPrecisionOrNull(nNum, nMinDp, nMaxDp)
{
  if (nNum == null)
    return null;
  else
    return FormatNumPrecision(nNum, nMinDp, nMaxDp);
}

function StrRemove(sStr, sToRemove)
{
  sStr = String(sStr);
  sToRemove = String(sToRemove);
  var nIndex = sStr.indexOf(sToRemove);
  while (nIndex >= 0)
  {
    sStr = sStr.substr(0, nIndex) + sStr.substr(nIndex + 1);
    nIndex = sStr.indexOf(sToRemove);
  }
  return (sStr);
}

function GetValidFileName(s)
{
  s = String(s);
  s = StrRemove(s, "\\");
  s = StrRemove(s, "/");
  s = StrRemove(s, ":");
  s = StrRemove(s, "*");
  s = StrRemove(s, "?");
  s = StrRemove(s, "\"");
  s = StrRemove(s, "<");
  s = StrRemove(s, ">");
  s = StrRemove(s, "|");
  return (s);
}

function RemoveTrailingReturns(s)
{
  var
    sChar;
  
  if (s == null)
    return s;
  s = String(s);
  sChar = s.charAt(s.length - 1);  
  while (sChar == "\r" || sChar == "\n")
  {
    s = s.substr(0, s.length - 1);
    sChar = s.charAt(s.length - 1);  
  }
  return s;
}

function HtmlToPlainText(s)
{
  if (s == null)
    return '';
  s = String(s);
  s = s.replace(/<br ?\/?>/gi, '\r\n');
  s = s.replace(new RegExp(/<(.*?)>/g), '').replace(new RegExp(/<(.*)/), '');
  s = s.replace(/&nbsp;/gi, ' ');
  s = s.replace(/&lt;/gi, '<');
  s = s.replace(/&gt;/gi, '>');
  s = s.replace(/&amp;/gi, '&');
  s = s.replace(/&pound;/gi, '£');
  s = s.replace(/&euro;/gi, '€');
  s = s.replace(/&copy;/gi, '©');
  s = s.replace(/&reg;/gi, '®');
  s = s.replace(/&quot;/gi, '"');
  s = s.replace(/&apos;/gi, '\'');
  s = s.replace(/&ndash;/gi, '-');
  s = s.replace(/&mdash;/gi, '-');
  return s;
}

function ExpandUrlProtocol(sProtocol)
{
  if (sProtocol == null)
    return 'http://';
    
  sProtocol = Trim(String(sProtocol)).toLowerCase();
  if (sProtocol != '')
  {
    nSep = sProtocol.indexOf('://');
    if (nSep >= 0)
    {
      sProtocol = sProtocol.substr(0, nSep);
    }
    if (sProtocol == 'http' ||
        sProtocol == 'https' ||
        sProtocol == 'ftp')
    {
      return sProtocol + '://';
    }
  }
  return 'http://';
}

function ExpandUrl(sUrl)
{
  if (sUrl == null)
    return null;
    
  sUrl = Trim(String(sUrl));
  if (sUrl != '')
  {
    sProtocol = null;
    sDomain = null;
    sPath = null;
    
    nSep = sUrl.indexOf('://');
    if (nSep > 0 && nSep <= 6)
    {
      sProtocol = sUrl.substr(0, nSep);
      sUrl = sUrl.substr(nSep + 3);
    }
    nSep = sUrl.indexOf('/');
    if (nSep >= 0)
    {
      sDomain = sUrl.substr(0, nSep);
      sPath = sUrl.substr(nSep);
    }
    else
    {
      sDomain = sUrl;
      sPath = '/';
    }
    
    if (sDomain.length > 0)
    {
      sUrl = ExpandUrlProtocol(sProtocol) + sDomain + sPath;
      return sUrl;
    }
  }
  return null;
}

function LoadFromFileEx(oFs, sFileName)
{
  var
    oTs, sFile;
    
  oTs = oFs.OpenTextFile(sFileName, 1);
  sFile = oTs.ReadAll();
  oTs.Close();
  return sFile;
}

function LoadFromFile(sFileName)
{
  var
    oFs, sFile;
    
  oFs = new ActiveXObject("Scripting.FileSystemObject");
  sFile = LoadFromFileEx(oFs, sFileName);
  oFs = null;
  return sFile;
}

function GetCookie(sName)
{
  var
    asCookie, nIndex, asKeyVal;
    
  asCookie = String(IsBlank(document.cookie, '')).split(';');
  for (nIndex = 0; nIndex < asCookie.length; nIndex++)
  {
    asKeyVal = Trim(asCookie[nIndex]).split('=');
    if (asKeyVal[0] == sName)
    {
      return asKeyVal[1];
    }
  }
  return null;
}

function SetCookie(sName, sValue)
{
  var
    d;

  d = new Date();
  d.setYear(d.getFullYear() + 1);
  document.cookie = sName + '=' + escape(sValue) + ';expires=' + d.toGMTString();
}

function SetTimedCookie(sName, sValue, nTimeoutSecs)
{
  var
    dNow, dTimeout;
    
  dNow = new Date();
  dTimeout = new Date();
  dTimeout.setTime(dNow.getTime() + nTimeoutSecs * 1000);
  document.cookie = sName + '=' + escape(sValue) + ';expires=' + dTimeout.toGMTString();
}

function SetGlobalCookie(sName, sValue)
{
  var
    d;
    
  d = new Date();
  d.setYear(d.getFullYear() + 1);
  document.cookie = sName + '=' + escape(sValue) + ';expires=' + d.toGMTString() + ';path=/';
}

function OnMouseOver(e)
{
  var
    oElem;

  try
  {
    oElem = (window.event ? window.event.srcElement : e.target);
    if (oElem)
    {
      if (oElem.tagName == "BUTTON" && oElem.className != "nav-control-current" && oElem.disabled == false)
      {
        oElem.style.textDecoration = "underline";
      }
    }
  }
  catch (e)
  {
  }
}

function OnMouseOut(e)
{
  var
    oElem;
    
  try
  {
    oElem = (window.event ? window.event.srcElement : e.target);
    if (oElem)
    {
      if (oElem.tagName == "BUTTON" && oElem.className != "nav-control-current" && oElem.disabled == false)
      {
        oElem.style.textDecoration = "none";
      }
    }
  }
  catch (e)
  {
  }
}

document.onmouseover = OnMouseOver;
document.onmouseout = OnMouseOut;

function CheckActiveXAvailable(bWantPrompt)
{
  var
    oDs;
    
  try
  {
    oFs = new ActiveXObject("Scripting.FileSystemObject");
    oFs = null;
    return true;
  }
  catch (e)
  {
    if (bWantPrompt)
    {
      return !PromptActiveXInfo();
    }
    return false;
  }
}

function PromptActiveXInfo()
{
  if (confirm("Your Internet Explorer settings need to change in order to use features on this page.\n\nPlease take a moment to make this change now.\n\nClick OK for instructions."))
  {
    return true;
  }
  return false;
}

function GetScreenHeight()
{
  return window.screen.availHeight - 30;
}

function GetScreenWidth()
{
  return window.screen.availWidth - 10;
}

function SetUrlArgVal(sUrl, sArg, sVal)
{
  var
    bSet, sQuery, asUrl, asQuery, nIndex;
    
  bSet = false;
  sQuery = '';
  asUrl = sUrl.split('?');
  if (asUrl.length > 1)
  {
    asQuery = asUrl[1].split('&');
    for (nIndex = asQuery.length - 1; nIndex >= 0; nIndex--)
    {
      if (asQuery[nIndex].indexOf(sArg + '=') == 0)
      {
        asQuery[nIndex] = sArg + '=' + escape(sVal);
        bSet = true;
      }
    }
    if (!bSet && IsBlank(sVal, null) != null)
    {
      asQuery.push(sArg + '=' + escape(sVal));
    }
    sQuery = asQuery.join('&');
    sUrl = asUrl[0] + '?' + sQuery;
  }
  else
  {
    if (IsBlank(sVal, null) != null)
    {
      sUrl += '?' + sArg + '=' + escape(sVal);
    }
  }
  return sUrl;
}

function UrlToScrollOffsetUrl(sUrl)
{
  var
    sQuery, asUrl, asQuery, nIndex;
    
  sQuery = '';
  asUrl = sUrl.split('?');
  if (asUrl.length > 1)
  {
    asQuery = asUrl[1].split('&');
    for (nIndex = asQuery.length - 1; nIndex >= 0; nIndex--)
    {
      if (asQuery[nIndex].indexOf('sy=') == 0)
      {
        asQuery.splice(nIndex, 1);
      }
    }
    sQuery = asQuery.join('&');
  }
  if (sQuery != '')
  {
    sUrl = asUrl[0] + '?' + sQuery + '&';
  }
  else
  {
    sUrl = asUrl[0] + '?';
  }
  sUrl += 'sy=' + document.body.scrollTop;
  return sUrl;
}

function ReloadSelf()
{
  var
    sUrl;
    
  if (document.body.onunload != null)
  {
    pfUnload = document.body.onunload;
    pfUnload();
  }
  sUrl = String(document.location);
  if (sUrl.indexOf('#') > 0)
  {
    sUrl = sUrl.substr(0, sUrl.indexOf('#'));
  }
  sUrl = UrlToScrollOffsetUrl(sUrl);
  document.location = sUrl;
}

function NavigateParent(sUrl)
{
  var
    oOpener, bInPopup, sTarget, aoBase;
 
  oOpener = null;
  if (window.dialogArguments)
  {
    oOpener = window.dialogArguments.parentWindow;
  }
  else
  if (window.parent != window.top)
  {
    oOpener = IsBlank(window.parent.opener, null);
  }
  bInPopup = oOpener != null;
  if (bInPopup)
  {
    oOpener.document.location = sUrl;
    window.parent.close();
  }
  else
  {
    sTarget = '';
    aoBase = document.getElementsByTagName('BASE');
    if (aoBase.length > 0)
    {
      sTarget = aoBase[0].target;
    }
    if (IsBlank(sTarget, '') != '')
    {
      window.open(sUrl, sTarget);
    }
    else
    {
      document.location = sUrl;
    }
  }
  return false;
}

function OpenUrlScroll(sUrl)
{
  sUrl = UrlToScrollOffsetUrl(sUrl);
  document.location = sUrl;
}

function Popup_OnKeyUp(e)
{
  var
    nKeyCode, oCancelButton;

  nKeyCode = (window.event ? window.event.keyCode : e.which);
  if (nKeyCode == 27)
  {
    oCancelButton = document.getElementById('CancelButton');
    if (oCancelButton != null)
    {
      oCancelButton.click();
    }
    else
    {
      window.parent.close();
    }
  }
}

function GetAbsoluteLeft(oElem)
{
  var
    nLeft;
    
  nLeft = 0;
  while (oElem.offsetParent != null)
  {
    nLeft += oElem.offsetLeft;
    oElem = oElem.offsetParent;
  }
  return nLeft;
}

function GetAbsoluteTop(oElem)
{
  var
    nTop;
    
  nTop = 0;
  while (oElem.offsetParent != null)
  {
    nTop += oElem.offsetTop;
    oElem = oElem.offsetParent;
  }
  return nTop;
}

function GetEventSrcElement()
{
  if (window.event)
  {
    var e = window.event;
  }
  return (e.srcElement ? e.srcElement : e.target);
}

function CreateIFrame()
{
  var
    oIFrame;
    
  oIFrame = document.createElement('IFRAME');
  oIFrame.style.display = 'none';
  if (String(document.location).indexOf('https://') == 0)
  {
    oIFrame.src = '../system/blank.htm';
  }
  document.body.insertBefore(oIFrame, null);
  return oIFrame;
}

function CreateActiveXObject(sElemHtml)
{
  document.write(sElemHtml);
}

function IsClientWindowsXP()
{
  return String(window.clientInformation.userAgent).match(/Windows NT 5.[1-9]/);
}

function GetPopupDialogPos(oElem, nPopupWidth, nPopupHeight)
{
  var
    nLeft, nTop, nPopupLeft, nPopupTop;
    
  nLeft = (window.screenLeft ? window.screenLeft : window.screenX) + GetAbsoluteLeft(oElem) + 16;
  nTop = (window.screenTop ? window.screenTop : window.screenY) + GetAbsoluteTop(oElem);
  return { m_nLeft: nLeft,
           m_nTop:  nTop,
           m_nWidth: nPopupWidth,
           m_nHeight: nPopupHeight };
}

function OnPopupCalendar(sElemId)
{
  var
    oElem, dDate, sUrl, oImgElem, oDialogPos, sArgs;

  oElem = document.getElementById(sElemId);
  dDate = StrToDate(oElem.value);
  sUrl = '../desktop/pe-calendar.asp?date=' + IsNull(FormatDate('d mmm yyyy', dDate), '');
  oImgElem = document.getElementById(sElemId + '_icon');
  oDialogPos = GetPopupDialogPos(IsNull(oImgElem, oElem), 306, 376);
  sArgs = 'dialogLeft:' + (oDialogPos.m_nLeft + 2) + 'px;' +
          'dialogTop:' + (oDialogPos.m_nTop + 2) + 'px;' +
          'dialogWidth:' + oDialogPos.m_nWidth + 'px;' +
          'dialogHeight:' + oDialogPos.m_nHeight + 'px;' +
          'center:no;help:no;resizable:yes;status:no;';
  dDate = window.showModalDialog(sUrl, document, sArgs);
  if (dDate != null)
  {
    oElem.value = FormatDate('d mmm yyyy', dDate);
    DispatchChangeEvent(oElem);
  }  
}

function OnPopupCalculator(sElemId, bSeparator, nDecimalPlaces, sSymbol)
{
  var
    oElem, sUrl, oDialogPos, sArgs, nVal, sVal;
    
  oElem = document.getElementById(sElemId);
  sUrl = '../desktop/pe-calculator.asp?val=' + escape(oElem.value);
  oDialogPos = GetPopupDialogPos(oElem, 288, 362);
  sArgs = 'dialogLeft:' + (oDialogPos.m_nLeft + 2) + 'px;' +
          'dialogTop:' + (oDialogPos.m_nTop + 2) + 'px;' +
          'dialogWidth:' + oDialogPos.m_nWidth + 'px;' +
          'dialogHeight:' + oDialogPos.m_nHeight + 'px;' +
          'center:no;help:no;resizable:yes;status:no;';
  nVal = window.showModalDialog(sUrl, document, sArgs);
  if (nVal != null)
  {
    sVal = (sSymbol == null ? '' : sSymbol + ' ') + FormatNum(nVal, nDecimalPlaces);
    if (!bSeparator)
    {
      sVal = sVal.replace(/,/g, '');
    }
    oElem.value = sVal;
    DispatchChangeEvent(oElem);
  }  
}

function DispatchChangeEvent(oElem)
{
  if (oElem.fireEvent)
  {
    oElem.fireEvent('onchange');
  }
  else
  {
    var oDomEvent = document.createEvent('HTMLEvents');
    oDomEvent.initEvent('change', false, false);
    oElem.dispatchEvent(oDomEvent);
  }
}
