//---------------------------------------------------------------------------
//
//  scrptcal.js 
//  a component of ScriptCalendar 
//  (c)2000 Dan Shipe 
//  www.scriptcalendar.com
//  salesadmin@scriptcalendar.com
//
//    Date     By   Ver   Description
// ----------  ---  ----  ---------------------------------------------------
// 02-23-2005  DS   6.00  Initial creation
// 03-08-2005  DS   6.01  Fixed bug in to allow events on 8th and 9th to display
// 03-24-2005  DS   6.02  Implement key in IFrame tag
// 04-10-2005  DS   6.03  Added "small" theme
// 04-15-2005  DS   6.04  Added support for a printable css
// 05-31-2005  DS   6.05  Remove current date from prev month
// 06-15-2005  DS   6.06  Correct bug in PopupAddParam
// 08-04-2005  DS   6.07  Modifications to code
// 08-08-2005  DS   6.08  Add OverrideSpecialEvents & event filter
// 11-03-2005  DS   6.09  Fixed bug in Dead cell display
// 03-01-2006  DS   6.10  Fixed bug in OverrideSpecialEvent display
// 06-01-2006  DS   6.11  Fixed bug in XML octal conversion
// 09-01-2006  DS   6.12  Added classes for the moth and year dropdown
// 09-05-2006  DS   6.13  Revise licensing
// 09-10-2006  DS   6.14  fixed rounding bug in WeekOfMonth
// 03-01-2007  DS   6.15  add additional handlers to the scHandlr.js
// 03-15-2007  DS   6.16  fixed bug when running from localhost
// 03-18-2007  DS   6.17  improve xml loading for firefox 2 
// 04-03-2007  DS   6.18  fixed xml filter bug
// 04-10-2007  DS   7.00  enhancements
// 09-24-2007  DS   7.01  allow for relatively positioned calendar
// 09-25-2007  DS   7.02  fix handling of anchor tag when re-posting
// 10-12-2007  DS   7.03  changes for outlook theme
// 10-16-2007  DS   7.04  cleanup for outlook theme
// 10-23-2007  DS   7.05  fix bug in the initialDate property
// 02-12-2008  DS   7.06  added specialEventsFirst flag

var calObject_e9d3f;
var mfntImport;
var matchLicense_e9d3lca;
var eventArray_e9d3g = new Array();
var easterDay_e9d3i;
var e9d3h = "scDate"; // replaced throughout
var mlngPopupType;
var mblnPopupAddParam;
var mstrPopupProp;
var ua=navigator.userAgent.toLowerCase();
var MAC=ua.indexOf("mac")!=-1;
var OP=ua.indexOf("opera")!=-1;
var KO=ua.indexOf("konqueror")!=-1;
var IE=ua.indexOf("msie")!=-1&&!OP && ua.indexOf("webtv")==-1;
var NN=ua.indexOf("gecko")!=-1;


function scriptcalendar() {
  var todaysDate_e9d3p = new Date();

  this.license = new Array();
  this.xmlFile = false;
  this.xslFile = false;
  this.initialDate = todaysDate_e9d3p;
  this.deadCellType = 0;
  this.dateSelector = 1+2+4+8;
  this.prevHtml = "&laquo;";
  this.nextHtml = "&raquo;";
  this.dateRangeStart = 2006;
  this.dateRangeEnd = 2012;
  this.cellWidth = 100;
  this.cellHeight = 100;
  this.padding = "0";
  this.spacing = "2";
  this.beginMonday = false;
  this.displayWeekNumber= false;
  this.showFutureEvents= true;
  this.showPastEvents= true;
  this.enableHandlers= true;
  this.overrideSpecialEvent = false;
  this.expandCellHeight = false;
  this.expandEventStyle= 0;
  this.specialEventsFirst= false;
  this.addOverLib= false;
  this.overLibConfig= "CSSCLASS, BGCLASS, 'OLBackground', FGCLASS, \
                       'OLForeground', TEXTFONTCLASS, 'OLFont'";
  this.popupType= 1;
  this.popupAddParam= true;
  this.popupProperties= "width=600,height=400,scrollbars=yes,resizable=yes," +
                        "titlebar=yes,toolbar=yes,menubar=yes,location=yes," +
                        "status=yes";
  this.filter = fscRequestQueryString("scFilter");
  this.filterNames= "";
  this.eventArray = new Array();
  this.monthStartDate = new Array(1,1,1,1,1,1,1,1,1,1,1,1);
  this.longDays = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );
  this.longMonths = new Array("January", "February", "March", "April", "May", 
                              "June", "July", "August", "September", "October", 
                              "November", "December" );
  calObject_e9d3f = this;
};


scriptcalendar.prototype.initialize = function() {
  var licenseString_e9d3v;
  var d;
  var objIFrame = parent.document.getElementById("scIFrame");
  if (objIFrame) {
     if (objIFrame.name.length != 0) {
        this.license = objIFrame.name.split(",");
     };
  };

  var licenseString_e9d3v = fscRequestQueryString("scLicense");
  if (licenseString_e9d3v.length != 0) {
     this.license = licenseString_e9d3v.split(",");
  };

  matchLicense_e9d3lca = false;
  d = validateLicense_e9d3c();
  for (var i=0; i < this.license.length; i++) {
      licenseString_e9d3v = e9d3a(this.license[i]);
      if (licenseString_e9d3v.length > d.length) {
         licenseString_e9d3v = licenseString_e9d3v.substring(licenseString_e9d3v.length-d.length);
      };

      if (licenseString_e9d3v==d) matchLicense_e9d3lca = true;
  };

  if (d=="1") matchLicense_e9d3lca = true;
  mlngPopupType = this.popupType;
  mblnPopupAddParam = this.popupAddParam;
  mstrPopupProp = this.popupProperties;
  if (!(this.xmlFile)) {
     this.main(false);
  } else {
     fscImportXml(this.xmlFile, "calObject_e9d3f.main"); 
  };
};

scriptcalendar.prototype.main = function(objEvtXml) {
  var e9d3u;
  var objXml;
  var e9d3o = this.initialDate;
  strDate = fscRequestQueryString("scDate");
  if (strDate.length != 0) e9d3o = new Date(strDate);
  if (objEvtXml) this.xmlToArray(objEvtXml);
  if (!(this.xslFile)) {
     e9d3u = this.getCalendarHtmlString(e9d3o);
  } else {
     objXml = this.getCalendarXml(e9d3o);
     e9d3u = e9d3W(objXml, this.xslFile);
     e9d3u = e9d3u.htmlEncode();
  };
  if (this.filterNames.length != 0) {this.createFilter(); };

  var objElmParent = document.getElementById("scParent");
  if (objElmParent == null) objElmParent = document.body;
  var objElmCalendar = setElement_e9d3T(objElmParent, "div", "");
  objElmCalendar.innerHTML = e9d3u;
  if (this.popupType==2) {
     this.createPopup();
  };
};


scriptcalendar.prototype.getCalendarXml = function(e9d3n) {
  var e9d3m;
  var e9d3l;
  var e9d3o;
  var e9d3p;
  var e9d3q;
  var e9d3s;
  var e9d3t;
  var e9d3E;
  var blnHasRegularEvent;
  var e9d3x;
  var e9d3y;
  var strDate;
  var e9d3v;
  var e9d3z;
  var e9d3A;
  var e9d3C;
  var i;
  var j;
  var m;
  var y;
  var e9d3F;
  var e9d3G;
  var e9d3H;
  var e9d3I;
  var e9d3J;
  var e9d3M;
  var e9d3N;
  var e9d3K;
  var e9d3L;
  var e9d3O;
  var e9d3P;
  m = e9d3n.getMonth();
  y = e9d3n.getFullYear();
  if (y < this.dateRangeStart) {
     m=0;
     y=this.dateRangeStart;
  };

  if (y > this.dateRangeEnd) {
     m=11;
     y=this.dateRangeEnd;
  };

  e9d3n = new Date(y, m, e9d3n.getDate());
  e9d3o = new Date(y, m, 1);
  e9d3q = new Date(y, m, 1);
  e9d3p = new Date();
  e9d3p = new Date( e9d3p.getFullYear(), e9d3p.getMonth(), e9d3p.getDate());
  e9d3o.setDate(e9d3o.getDate() + this.monthStartDate[m] -1);
  e9d3o.setDate( e9d3o.getDate() - this.getWeekday(e9d3o) );

  if (e9d3o.getDate() == 2 ) e9d3o.setDate( e9d3o.getDate() - 7 );
  e9d3E = 1 - this.getWeekday(e9d3o);
  strDisplayYM = e9d3n.format("yymm", false);
  strCalYM = e9d3o.format("yymm", false);
  e9d3m = this.getPartialEventArray(e9d3n);
  e9d3F = e9d3V();
  e9d3P = setElement_e9d3T(e9d3F, "calendar", "");
  setAttribute_e9d3U(e9d3P, "border", "0");
  setAttribute_e9d3U(e9d3P, "cellpadding", this.padding);
  setAttribute_e9d3U(e9d3P, "cellspacing", this.spacing);
  setAttribute_e9d3U(e9d3P, "columns", "7");
  e9d3G = setElement_e9d3T(e9d3F.documentElement, "properties", "");
  for (var prop in this) {
      setAttribute_e9d3U(e9d3G, prop, this[prop]);
  };

  e9d3P = setElement_e9d3T(e9d3F.documentElement, "calendardate", e9d3q.toString() );
  setAttribute_e9d3U(e9d3P, "year", e9d3q.getFullYear().toString().pad(4));
  setAttribute_e9d3U(e9d3P, "month", e9d3q.getMonth().toString().pad(2));
  setAttribute_e9d3U(e9d3P, "day", e9d3q.getDate().toString().pad(2));
  e9d3P = setElement_e9d3T(e9d3F.documentElement, "currentdate", e9d3p.toString() );
  setAttribute_e9d3U(e9d3P, "year", e9d3p.getFullYear().toString().pad(4));
  setAttribute_e9d3U(e9d3P, "month", e9d3p.getMonth().toString().pad(2));
  setAttribute_e9d3U(e9d3P, "day", e9d3p.getDate().toString().pad(2));
  e9d3I = setElement_e9d3T(e9d3F.documentElement, "selectors", "");
  e9d3v="";
  if (this.dateSelector&4) 
     e9d3v=this.prevHtml;

  e9d3P = setElement_e9d3T(e9d3I, "selector", e9d3v);
  setAttribute_e9d3U(e9d3P, "uniqueid", "prev");
  setAttribute_e9d3U(e9d3P, "onclick", "fscChangeDate(new Date(" + 
                          e9d3q.add("m", -2).format("yy, mm, dd", false) + 
                          ")); " );
  setAttribute_e9d3U(e9d3P, "onmouseover", "this.style.cursor='hand'; " );
  i=1;
  if (this.displayWeekNumber) i=2;

  setAttribute_e9d3U(e9d3P, "colspan", i);
  e9d3v="&#160;";
  if (this.dateSelector&1)  {
     e9d3v = "<select id=\"cboMonth\" name=\"cboMonth\" ";
     e9d3v+= " onChange=\"fscChangeDate(new Date(" + y;
     e9d3v+= " , this.value, 1)); \" class=\"scMonthDropdown\">" + 
             this.monthOptions(m) + "</select>" + e9d3v;
  }

  if (this.dateSelector&16) 
     e9d3v += this.longMonths[m] + " ";

  if (this.dateSelector&2) 
     e9d3v += "<select id=\"cboYear\" name=\"cboYear\" " + 
              " onChange=\"fscChangeDate(new Date(this.value, " + 
              m + ", 1)); \" class=\"scYearDropdown\">" + 
              this.yearOptions(y) + "</select>";

  if (this.dateSelector&32) e9d3v += y;

  e9d3P = setElement_e9d3T(e9d3I, "selector", e9d3v );
  setAttribute_e9d3U(e9d3P, "uniqueid", "date");
  setAttribute_e9d3U(e9d3P, "colspan", "5");
  e9d3v="";

  if (this.dateSelector&8) e9d3v=this.nextHtml;
  e9d3P = setElement_e9d3T(e9d3I, "selector", e9d3v);
  setAttribute_e9d3U(e9d3P, "uniqueid", "next");
  setAttribute_e9d3U(e9d3P, "onclick", "fscChangeDate(new Date(" + 
        e9d3q.format("yy, mm, dd", false) + ")); " );
  setAttribute_e9d3U(e9d3P, "onmouseover", "this.style.cursor='hand'; " );
  setAttribute_e9d3U(e9d3P, "colspan", "1");
  e9d3J = setElement_e9d3T(e9d3F.documentElement, "weekdayheaders", "");
  if (this.displayWeekNumber) {
     e9d3P = setElement_e9d3T(e9d3J, "weekdayheader", "");
  };

  for (i=0; i<7; i++) {
      e9d3P = setElement_e9d3T(e9d3J, "weekdayheader", this.longDays[i] );
  };
  e9d3M = setElement_e9d3T(e9d3F.documentElement, "weeks", "");
  for (e9d3s=0; e9d3s<6 && 
                e9d3o.format("yymm", false)==e9d3n.format("yymm", false);
       e9d3s++) {
      e9d3N = setElement_e9d3T(e9d3M, "week", "");
      setAttribute_e9d3U(e9d3N, "index", e9d3s+1);
      setAttribute_e9d3U(e9d3N, "fulldate", e9d3o);
      setAttribute_e9d3U(e9d3N, "year", e9d3o.getFullYear() );
      setAttribute_e9d3U(e9d3N, "month", e9d3o.getMonth() );
      setAttribute_e9d3U(e9d3N, "date", e9d3o.getDate() );
      setAttribute_e9d3U(e9d3N, "adjusteddate", e9d3E );
      setAttribute_e9d3U(e9d3N, "weekofmonth", e9d3o.weekOfMonth() );
      setAttribute_e9d3U(e9d3N, "weekofyear", e9d3o.weekOfYear() );
      e9d3K = setElement_e9d3T(e9d3N, "weekdays", "");
      for (e9d3t=0; e9d3t<7; e9d3t++) {
          e9d3C = true;

          if (e9d3o.format("yymm", false) == e9d3n.format("yymm", false) ) 
             e9d3C=false;

          strDate = e9d3o.getFullYear() + ", " + e9d3o.getMonth() + ", " + 
                    e9d3o.getDate();
          e9d3L = setElement_e9d3T(e9d3K, "weekday", "");
          setAttribute_e9d3U(e9d3L, "index", (e9d3s*7)+(e9d3t+1));
          setAttribute_e9d3U(e9d3L, "fulldate", e9d3o);
          setAttribute_e9d3U(e9d3L, "year", e9d3o.getFullYear() );
          setAttribute_e9d3U(e9d3L, "month", e9d3o.getMonth() );
          setAttribute_e9d3U(e9d3L, "date", e9d3o.getDate() );
          setAttribute_e9d3U(e9d3L, "adjusteddate", e9d3E );
          setAttribute_e9d3U(e9d3L, "dayofyear", e9d3o.dayOfYear() );
          setAttribute_e9d3U(e9d3L, "weekofyear", e9d3o.weekOfYear() );
          setAttribute_e9d3U(e9d3L, "weekofmonth", e9d3o.weekOfMonth() );
          setAttribute_e9d3U(e9d3L, "padding", this.padding );
          setAttribute_e9d3U(e9d3L, "width", this.cellWidth );
          setAttribute_e9d3U(e9d3L, "height", this.cellHeight );
          setAttribute_e9d3U(e9d3L, "dead", e9d3C );
          if (this.enableHandlers) {
             setAttribute_e9d3U(e9d3L, "onmousedown", 
                   "fscCellOnMouseDown(event, this," + strDate + ")" );
             setAttribute_e9d3U(e9d3L, "onmouseover", 
                   "fscCellOnMouseOver(event, this," + strDate + ")" );
             setAttribute_e9d3U(e9d3L, "onmouseout", 
                   "fscCellOnMouseOut(event, this," + strDate + ")" );
             setAttribute_e9d3U(e9d3L, "onmouseup", 
                   "fscCellOnMouseUp(event, this," + strDate + ")" );
          };

          e9d3x = "scDatePast";
          if ( e9d3o > e9d3p ) e9d3x = "scDateFuture";

          if ( e9d3o.getMonth() != e9d3q.getMonth() || 
               e9d3o.getFullYear() != e9d3q.getFullYear() ) 
             e9d3x = "scDateDead";

          if ( e9d3o.equalsTo(e9d3p) && 
               e9d3o.getMonth() == e9d3q.getMonth() && 
               e9d3o.getFullYear() == e9d3q.getFullYear() ) 
             e9d3x = "scDateCurrent";
             if (e9d3C && !(this.deadCellType&1)) {
                e9d3O = false;
             } else {
                e9d3O = setElement_e9d3T(e9d3L, "number", e9d3o.getDate());
                if (this.enableHandlers) { 
                   setAttribute_e9d3U(e9d3O, "onmousedown", 
                         "fscNumberMouseDown(event, this," + strDate + ")" );
                   setAttribute_e9d3U(e9d3O, "onmouseover", 
                         "fscNumberMouseOver(event, this," + strDate + ")" );
                   setAttribute_e9d3U(e9d3O, "onmouseout", 
                         "fscNumberMouseOut(event, this," + strDate + ")" );
                   setAttribute_e9d3U(e9d3O, "onmouseup", 
                         "fscNumberMouseUp(event, this," + strDate + ")" );
                };
             };
             e9d3m = this.addSpecialEvents(e9d3o, e9d3m);
             blnHasRegularEvent = false;
             e9d3z = "";
             e9d3A = "";
             for (i=0; i < e9d3m.length; i++) {
                 e9d3l = e9d3m[i];
                 e9d3y = this.showEvent(e9d3o, e9d3n, e9d3p, e9d3l, 
                                        blnHasRegularEvent);
                 if (e9d3y) {
                    if (e9d3l.isRegular) blnHasRegularEvent = true;
                    if (e9d3z=="") {
                       e9d3z=" ";
                       if (e9d3l.style) e9d3z = e9d3l.style;
                    };
                    if (e9d3l.style) e9d3A = e9d3l.style;
                 };
                 if (e9d3y) this.addEventXml(e9d3l, e9d3L);
             };
             if (this.expandEventStyle) {
                if (e9d3O) 
                   setAttribute_e9d3U(e9d3O, "class", "scNumber " + e9d3z);

                setAttribute_e9d3U(e9d3L, "class", "scWeekday " + e9d3x + " " + e9d3A);
             } else {
                if (e9d3O) 
                   setAttribute_e9d3U(e9d3O, "class", "scNumber");
                setAttribute_e9d3U(e9d3L, "class", "scWeekday " + e9d3x);
             };
             e9d3o.setDate( e9d3o.getDate() + 1 );
             e9d3E++;
      };
  };
  return e9d3F;
};

scriptcalendar.prototype.getCalendarHtmlString = function(e9d3n) {
  var e9d3m;
  var e9d3l;
  var e9d3o;
  var e9d3p;
  var e9d3q;
  var blnHasRegularEvent;
  var e9d3s;
  var e9d3t;
  var e9d3E;
  var e9d3C;
  var blnHasNumber;
  var e9d3u;
  var e9d3y;
  var strDate;
  var e9d3v;
  var e9d3z;
  var e9d3A;
  var strDateCls;
  var strRow;
  var strCell;
  var strStyle;
  var intDow;
  var i;
  var j;
  var m;
  var y;
  m = e9d3n.getMonth();
  y = e9d3n.getFullYear();
  if (y < this.dateRangeStart) {
     m=0;
     y=this.dateRangeStart;
  };
  if (y > this.dateRangeEnd) {
     m=11;
     y=this.dateRangeEnd;
  };

  e9d3n = new Date(y, m, e9d3n.getDate());
  e9d3o = new Date(y, m, 1);
  e9d3q = new Date(y, m, 1);
  e9d3p = new Date();
  e9d3p = new Date( e9d3p.getFullYear(), e9d3p.getMonth(), e9d3p.getDate());
  e9d3o.setDate(e9d3o.getDate() + this.monthStartDate[m] -1);
  e9d3o.setDate( e9d3o.getDate() - this.getWeekday(e9d3o) );
  if (e9d3o.getDate() == 2 ) 
     e9d3o.setDate( e9d3o.getDate() - 7 );

  e9d3E = 1 - this.getWeekday(e9d3o);
  e9d3m = this.getPartialEventArray(e9d3n);
  e9d3u = "";
  e9d3u += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
  e9d3u += "<tr><td>";
  e9d3u += "<div id=\"divScriptcalendarContainer\" class=\"scCalendar\">";
  e9d3u += "<table border=\"0\"";
  e9d3u += " cellpadding=\"" + this.padding + "\"";
  e9d3u += " cellspacing=\"" +this.spacing + "\"";
  e9d3u += " width=\"" + ( parseInt(this.cellWidth) + 
           parseInt(this.spacing)) * 7 + "\"";
  e9d3u += " >";
  e9d3u += "<tr>";

  if (this.displayWeekNumber) {
     e9d3u += "<th>";
     e9d3u += "<div class=\"scHeader\" >";
     e9d3u += "<span class=\"scSelector\">&nbsp;</span>";
     e9d3u += "</div>";
     e9d3u += "</th>";
  };

  e9d3u += "<th align=\"center\" valign=\"middle\">";
  e9d3u += "<div class=\"scHeader\"";
  e9d3v = e9d3q.add("m", -2).format("yy, mm, dd", false);
  e9d3u += " onclick=\" fscChangeDate(new Date(" + e9d3v + "));\" ";
  e9d3u += " onmouseover=\"this.style.cursor='hand';\" ";
  e9d3u += " >";
  e9d3v="";

  if (this.dateSelector&4) e9d3v = this.prevHtml;

  e9d3u += "<span class=\"scSelector\">" + e9d3v + "</span>";
  e9d3u += "</div></th>";
  e9d3v = "";

  if (this.dateSelector&1) 
     e9d3v+= "<select id=\"cboMonth\" name=\"cboMonth\" " + 
             "onChange=\"fscChangeDate(new Date(" + y + 
             ", this.value, 1));\" class=\"scMonthDropdown\">" + 
             this.monthOptions(m) + "</select>";

  if (this.dateSelector&16) e9d3v += this.longMonths[m] + " ";

  if (this.dateSelector&2) 
     e9d3v+="<select id=\"cboYear\" name=\"cboYear\" " + 
            " onChange=\"fscChangeDate(new Date(this.value, " + m + 
            ", 1)); \" class=\"scYearDropdown\">" + 
            this.yearOptions(y) + "</select>";

  if (this.dateSelector&32) 
     e9d3v += y;

  e9d3u += "<th colspan=\"5\" align=\"center\" valign=\"bottom\" >";
  e9d3u += "<div class=\"scHeader\">" + e9d3v + "</div></th>";
  e9d3u += "<th align=\"center\" valign=\"middle\" >";
  e9d3u += "<div class=\"scHeader\"";
  e9d3v = e9d3q.format("yy, mm, dd", false);
  e9d3u += " onclick=\"fscChangeDate(new Date(" + e9d3v + "));\" ";
  e9d3u += " onmouseover=\"this.style.cursor='hand'; \" ";
  e9d3u += " >";
  e9d3v="";

  if (this.dateSelector&8) e9d3v = this.nextHtml;
  e9d3u += "<span class=\"scSelector\">" + e9d3v + "</span>";
  e9d3u += "</div></th>";
  e9d3u += "</tr>";
  e9d3u += "<tr>";

  if (this.displayWeekNumber) {
     e9d3u += "<th align=\"center\" valign=\"middle\" >";
     e9d3u += "<div class=\"scHeader\">";
     e9d3u += "&nbsp;";
     e9d3u += "</div>";
     e9d3u += "</th>";
  };
  for (j=0; j<this.longDays.length; j++) {
      e9d3u += "<th align=\"center\" valign=\"middle\" >";
      e9d3u += "<div class=\"scHeader\">";
      e9d3u += this.longDays[j];
      e9d3u += "</div>";
      e9d3u += "</th>";
  };

  e9d3u += "</tr>";
  for (e9d3s=0; e9d3s<6 && 
                e9d3o.format("yymm", false) <= e9d3n.format("yymm", false);
       e9d3s++) {
      strRow = "<tr>";
      if (this.displayWeekNumber) {
         strStyle = "";
         strRow += "<td align=\"center\" valign=\"middle\">";
         strRow += "<div class=\"scHeader scWeekNumber\" style=\"" + 
                   strStyle + "\">";
         strRow += e9d3o.weekOfYear();
         strRow += "</div></td>";
      };

      for (e9d3t=0; e9d3t<7; e9d3t++) {
          e9d3C = true;
          if ( e9d3o.format("yymm", false)==e9d3n.format("yymm", false) ) 
             e9d3C=false;

          strDate = e9d3o.getFullYear() + ", " + e9d3o.getMonth() + 
                    ", " + e9d3o.getDate();
          strDateCls = "scDatePast";
          if ( e9d3o > e9d3p ) 
             strDateCls = "scDateFuture";

          if (e9d3o.getMonth() != e9d3q.getMonth() || 
              e9d3o.getFullYear() != e9d3q.getFullYear()) 
             strDateCls = "scDateDead";

          if (e9d3o.equalsTo(e9d3p) && 
              e9d3o.getMonth() == e9d3q.getMonth() && 
              e9d3o.getFullYear() == e9d3q.getFullYear()) 
             strDateCls = "scDateCurrent";
          strNumberCls = "scNumberPast";

          if (e9d3o > e9d3p) 
             strNumberCls = "scNumberFuture";

          if (e9d3o.getMonth() != e9d3q.getMonth() || 
              e9d3o.getFullYear() != e9d3q.getFullYear()) 
             strNumberCls = "scNumberDead";

          if (e9d3o.equalsTo(e9d3p) && 
              e9d3o.getMonth() == e9d3q.getMonth() && 
              e9d3o.getFullYear() == e9d3q.getFullYear()) 
             strNumberCls = "scNumberCurrent";

          strStyle = " width: " + this.cellWidth + "px;";
          if (this.expandCellHeight) {
             if (IE) {
                strStyle += " height: " + this.cellHeight + 
                            "px; overflow: visible;";
             } else {
                strStyle += " min-height: " + this.cellHeight + 
                            "px; overflow: visible; ";
             };
          } else {
             strStyle += " height: " + this.cellWidth + 
                         "px; overflow: hidden; ";
          };

          strCell = "<td valign=\"top\"";
          strCell += " class=\"" + strDateCls + "\"";
          strCell += " style=\"" + strStyle + "\"";
          strCell += " >";
          if (this.expandCellHeight) {
             if (IE) {
                strStyle = "height: 100%; ";
             };
          };
          e9d3v = "";
          e9d3v += "<div class=\"*weekdaycls*\" style=\"" + strStyle + "\"";
          if (this.enableHandlers) {
             e9d3v += " onmousedown=\"fscCellOnMouseDown(event, this," + 
                      strDate + ")\" ";
             e9d3v += " onmouseover=\"fscCellOnMouseOver(event, this," + 
                      strDate + ")\" ";
             e9d3v += " onmouseout=\"fscCellOnMouseOut(event, this," + 
                      strDate + ")\" ";
             e9d3v += " onmouseup=\"fscCellOnMouseUp(event, this," + 
                      strDate + ")\" ";
          };
          e9d3v += " >";
          strCell += e9d3v;
          if (e9d3C && !(this.deadCellType&1)) {
             blnHasNumber = false;
          } else {
             blnHasNumber = true;
             strCell += "<div class=\"*numbercls*\"";
             if (this.enableHandlers) { 
                strCell += " onmousedown=\"fscNumberOnMouseDown(event, this," + 
                           strDate + ")\" ";
                strCell += " onmouseover=\"fscNumberOnMouseOver(event, this," + 
                           strDate + ")\" ";
                strCell += " onmouseout=\"fscNumberOnMouseOut(event, this," + 
                           strDate + ")\" ";
                strCell += " onmouseup=\"fscNumberOnMouseUp(event, this," + 
                           strDate + ")\" ";
             };

             strCell += " >";
             strCell += e9d3o.getDate();
             strCell += "</div>";
          };

          e9d3m = this.addSpecialEvents(e9d3o, e9d3m);
          blnHasRegularEvent = false;
          e9d3z = "";
          e9d3A = "";
          for (i=0; i<e9d3m.length; i++) {
              e9d3l = e9d3m[i];
              e9d3y = this.showEvent(e9d3o, e9d3n, e9d3p, e9d3l, 
                                     blnHasRegularEvent);
              if (e9d3y) {
                 if (e9d3l.isRegular) 
                    blnHasRegularEvent = true;
                 if (e9d3l.style && e9d3z.length==0) 
                    e9d3z = e9d3l.style;
                 if (e9d3l.style) 
                    e9d3A = e9d3l.style;
              };
              if (e9d3y) 
                 strCell += this.addEventHtmlString(e9d3l);
          };
          intDow = this.getWeekday(e9d3o);
          strDateCls += " scWeekday" + intDow;
          strNumberCls += " scNumber" + intDow;

          if (this.expandEventStyle) {
             if (blnHasNumber) 
                strCell = strCell.replace("*numbercls*", 
                                     "scNumber " + strNumberCls + " " + e9d3z);
             strCell = strCell.replace("*weekdaycls*", 
                                     "scWeekday " + strDateCls + " " + e9d3A);
          } else {
             if (blnHasNumber) 
                strCell = strCell.replace("*numbercls*", 
                                          "scNumber " + strNumberCls);
             strCell = strCell.replace("*weekdaycls*", 
                                       "scWeekday " + strDateCls);
          };
          strCell += "</div></td>";
          e9d3o = e9d3o.add("d", 1);
          e9d3E++;
          strRow += strCell;
      };
      strRow += "</tr>";
      e9d3u += strRow;
  };

  e9d3u += "</table>";
  e9d3u += "</div>";
  e9d3u += "</td></tr></table>";
  return e9d3u;
};

scriptcalendar.prototype.showEvent = function(eventDate_e9d3o, currYear_e9d3n, 
                 currMonth_e9d3p, currDay_e9d3l, blnHasRegularEvent) {

  var tmpShowEvent_e9d3y = false;
  if (eventDate_e9d3o.equalsTo(currDay_e9d3l.date) && 
      eventDate_e9d3o.format("yymm", false)==currYear_e9d3n.format("yymm", false) ) 
     tmpShowEvent_e9d3y = true;

  if (eventDate_e9d3o.equalsTo(currDay_e9d3l.date) && 
      currDay_e9d3l.day!=eventDate_e9d3o.getDate() ) 
     tmpShowEvent_e9d3y = true;

  if (eventDate_e9d3o.equalsTo(currDay_e9d3l.date) && this.deadCellType&4 ) 
     tmpShowEvent_e9d3y = true;

  if (!(this.showPastEvents) && eventDate_e9d3o < currMonth_e9d3p ) 
     tmpShowEvent_e9d3y=false;

  if (!(this.showFutureEvents) && eventDate_e9d3o > currMonth_e9d3p ) 
     tmpShowEvent_e9d3y=false;

  if (this.overrideSpecialEvent && blnHasRegularEvent && 
      currDay_e9d3l.isRegular==false) 
     tmpShowEvent_e9d3y=false;

  if (this.filterNames.length > 0 && currDay_e9d3l.filter) {
     if (this.filter.indexOf(currDay_e9d3l.filter)==-1) {
        tmpShowEvent_e9d3y=false;
     };
  };

 /* KEN
  var e9d3lcab = 4;
  var e9d3lcac = 3;
  var e9d3lcad = 2;
  if (!(matchLicense_e9d3lca) && 
      eventDate_e9d3o.getDate() > (e9d3lcac * e9d3lcad + e9d3lcab) ) 
     tmpShowEvent_e9d3y=false;
*/
  return tmpShowEvent_e9d3y;
};

scriptcalendar.prototype.addEventXml = function(e9d3l, objParent, 
                                                strLastClass) {
  var objNode;
  objNode = setElement_e9d3T(objParent, "event");
  setElement_e9d3T(objNode, "month", e9d3l.month);
  setElement_e9d3T(objNode, "day", e9d3l.day);
  setElement_e9d3T(objNode, "year", e9d3l.year);
  setElement_e9d3T(objNode, "text", e9d3l.text);
  if (e9d3l.popuplink) 
     setElement_e9d3T(objNode, "popuplink", e9d3l.popuplink);

  if (e9d3l.tooltip) 
     setElement_e9d3T(objNode, "tooltip", e9d3l.tooltip);

  if (e9d3l.script) 
     setElement_e9d3T(objNode, "script", e9d3l.script);

  var strEventClass = "scevent";
  if (e9d3l.style) 
     strEventClass += " " + e9d3l.style;

  setAttribute_e9d3U(objNode, "class", strEventClass);
  if (this.enableHandlers) {
     strDate = e9d3l.year + ", " + e9d3l.month + ", " + e9d3l.day;
     setAttribute_e9d3U(objNode, "onmousedown", 
           "fscEventMouseDown(event, this," + strDate + ")" );
     setAttribute_e9d3U(objNode, "onmouseover", 
           "fscEventMouseOver(event, this," + strDate + ")" );
     setAttribute_e9d3U(objNode, "onmouseout", 
           "fscEventMouseOut(event, this," + strDate + ")" );

     setAttribute_e9d3U(objNode, "onmouseup", 
           "fscEventMouseUp(event, this," + strDate + ")" );
  };
  return objNode;
};

scriptcalendar.prototype.addEventHtmlString = function(eventObject_e9d3l) {
  var e9d3u = eventObject_e9d3l.text;
  if (eventObject_e9d3l.popuplink) 
     e9d3u = "<a href=\"javascript:fscPopup('" + eventObject_e9d3l.popuplink + 
             "', '" + eventObject_e9d3l.date.format("yy, mm, dd", false) + "');\">" + 
             e9d3u + "</a>";
  var strResult = "<div";
  if (eventObject_e9d3l.script) {
     strResult += " onclick=\"" + eventObject_e9d3l.script + "\"";
  };

  if (eventObject_e9d3l.tooltip) {
     strResult += " title=\"" + eventObject_e9d3l.tooltip + "\"";
  };

  var strEventClass = "scevent";
  if (eventObject_e9d3l.style) 
     strEventClass += " " + eventObject_e9d3l.style;

  strResult += " class=\"" + strEventClass + "\"";
  if (this.enableHandlers) {
     strDate = eventObject_e9d3l.year + ", " + eventObject_e9d3l.month + ", " + eventObject_e9d3l.day;
     strResult += " onmousedown=\"fscEventOnMouseDown(event, this," + 
                  strDate + ")\" ";
     strResult += " onmouseover=\"fscEventOnMouseOver(event, this," + 
                  strDate + ")\" ";
     strResult += " onmouseout=\"fscEventOnMouseOut(event, this," + 
                  strDate + ")\" ";
     strResult += " onmouseup=\"fscEventOnMouseUp(event, this," + 
                  strDate + ")\" ";
  };
  strResult += " >" + e9d3u + "</div>";
  return strResult;
};


scriptcalendar.prototype.monthOptions = function(intMonth) {
  var strSelected;
  var e9d3u = "";
  for ( var i=0; i<=11; i++ ) {
      strSelected = "";
      if ( i==intMonth ) 
         strSelected = "selected=\"true\"";

      e9d3u += "<option value=\"" + (i) + "\" " + strSelected + " >" + 
               this.longMonths[i] + "</option>";
  };
  return e9d3u;
};

scriptcalendar.prototype.yearOptions = function(intYear) {
  var strSelected;
  var e9d3u = "";
  for (var i=this.dateRangeStart; i<=this.dateRangeEnd; i++ ) {
      strSelected = "";

      if ( i==intYear ) 
         strSelected = "selected=\"true\"";

      e9d3u += "<option value=\"" + i + "\" " + strSelected + " >" + i + 
               "</option>";
  };
  return e9d3u;
};

scriptcalendar.prototype.addSpecialEvents = function(e9d3o, e9d3m) {
  arrSpecial = scSpecialEvent(e9d3o);
  if (arrSpecial) {
     if (this.specialEventsFirst) {
        return arrSpecial.concat(e9d3m);
     } else {
        return e9d3m.concat(arrSpecial);
     };
  };
  return e9d3m;
};

scriptcalendar.prototype.getPartialEventArray = function(dteParam) {
  var arrTemp = new Array();
  var eventObject_e9d3l;
  var e9d3y;
  var i;
  var year;
  var month;
  var e9d3r;
  var m = dteParam.getMonth();
  var y = dteParam.getFullYear();
  var strEventDate;
  var blnIsDate;
  var dteFirst = new Date(y, m, 1);
  var strFirstYM = dteFirst.format("yymm", false);
  var strPrevYM = dteFirst.add("m", -1).format("yymm", false);
  var strNextYM = dteFirst.add("m", 1).format("yymm", false);
  var strEventYM;
  if (eventArray_e9d3g) {
     for (i=0; i< eventArray_e9d3g.length; i++) {
         eventObject_e9d3l = eventArray_e9d3g[i];
         year = y;
         if (eventObject_e9d3l.year) 
            year = eventObject_e9d3l.year;
         month = m;
         if (eventObject_e9d3l.month) 
            month = eventObject_e9d3l.month-1;

         strEventDate = fscDateString(year, month+1, eventObject_e9d3l.day, false);
         blnIsDate = strEventDate.isDate();
         e9d3r = new Date( year, month, 1);
         e9d3r = e9d3r.add( "d", eventObject_e9d3l.day-1 );
         strEventYM = e9d3r.format("yymm", false);
         e9d3y = false;
         if (blnIsDate && strFirstYM == strEventYM) 
            e9d3y=true;
         if (!blnIsDate && this.deadCellType&2) {
            if (strEventYM == strPrevYM && e9d3r.getDate()>=22) 
               e9d3y=true;
            if (strEventYM == strNextYM && e9d3r.getDate()<=6) 
               e9d3y=true;
         };
         if (blnIsDate && this.deadCellType&4) {
            if (strEventYM == strPrevYM && e9d3r.getDate() >= 22) 
               e9d3y=true;
            if (strEventYM == strNextYM && e9d3r.getDate() <= 6) 
               e9d3y=true;
         };
         if (e9d3y) {
            eventObject_e9d3l.year = e9d3r.getFullYear();
            eventObject_e9d3l.month = e9d3r.getMonth();
            eventObject_e9d3l.date = e9d3r;
            arrTemp[arrTemp.length] = eventObject_e9d3l;
         };
     };
     return arrTemp;
  };
  return false;
};

scriptcalendar.prototype.xmlToArray = function(objEvtDoc) {
  var i, j;
  var objNode;
  var objNodeChild;
  var eventObject_e9d3l;
  var strMonth, strDay, strYear, strText, strPopupLink, strStyle, strTooltip, 
      strScript, strFilter;
  for (i=0; i<objEvtDoc.documentElement.childNodes.length; i++) {
      objNode = objEvtDoc.documentElement.childNodes[i];
      if (objNode.nodeName=="event") {
         for (j=0; j<objNode.childNodes.length; j++) {
             objNodeChild = objNode.childNodes[j];
             if (objNodeChild.nodeName=="month") 
                strMonth = parseInt(fscGetNodeText(objNodeChild),10);
             if (objNodeChild.nodeName=="day") 
                strDay = parseInt(fscGetNodeText(objNodeChild),10);
             if (objNodeChild.nodeName=="year") 
                strYear = parseInt(fscGetNodeText(objNodeChild),10);
             if (objNodeChild.nodeName=="text") 
                strText = fscGetNodeText(objNodeChild);
             if (objNodeChild.nodeName=="popuplink") 
                strPopupLink = fscGetNodeText(objNodeChild);
             if (objNodeChild.nodeName=="style") 
                strStyle = fscGetNodeText(objNodeChild);
             if (objNodeChild.nodeName=="tooltip") 
                strTooltip = fscGetNodeText(objNodeChild);
             if (objNodeChild.nodeName=="script") 
                strScript = fscGetNodeText(objNodeChild);
             if (objNodeChild.nodeName=="filter") 
                strFilter = fscGetNodeText(objNodeChild);
         };
         eventObj_e9d3l = new EventObj(parseInt(strMonth), parseInt(strDay), 
                              parseInt(strYear), strText, strPopupLink, 
                              strStyle, strTooltip, strScript, strFilter);
         eventArray_e9d3g[eventArray_e9d3g.length] = eventObj_e9d3l;
      };
  };
};

scriptcalendar.prototype.getWeekday = function(dteParam) {
  var d = dteParam.getDay();
  if (this.beginMonday) d--;
  if (d==-1) d=6;
  return d;
};

function fscChangeDate(e9d3o) {
  var fileLocation_e9d3B = window.location.toString();
  var strDate = (e9d3o.getMonth()+1).toString() + "/1/" + 
                 e9d3o.getFullYear().toString();
  fileLocation_e9d3B = fscRemoveQueryStrParam(fileLocation_e9d3B, "scDate");
  fileLocation_e9d3B = fscAddQueryStrParam(fileLocation_e9d3B, "scDate", strDate);
  window.location = fileLocation_e9d3B;
};

scriptcalendar.prototype.createPopup = function() {
  var objElmPopup;
  var objElmIFrame;
  objElmPopup = setElement_e9d3T(document.body, "div", "");
  setAttribute_e9d3U(objElmPopup, "id", "scDivPopup");
  setAttribute_e9d3U(objElmPopup, "name", "scDivPopup");
  setAttribute_e9d3U(objElmPopup, "class", "scPopupContainer");
  objElmPopup.onclick = fscHidePopup;
  objElmSpan = setElement_e9d3T(objElmPopup, "span", "");
  objElmSpan.innerHTML = "&nbsp;&#x00d7;&nbsp;<br/>";
  objElmIFrame = setElement_e9d3T(objElmPopup, "iframe", "");
  setAttribute_e9d3U(objElmIFrame, "id", "scIfmPopup");
  setAttribute_e9d3U(objElmIFrame, "name", "scIfmPopup");
  setAttribute_e9d3U(objElmIFrame, "class", "scPopupIFrame");
  setAttribute_e9d3U(objElmIFrame, "border", "0");
  setAttribute_e9d3U(objElmIFrame, "scrolling", "yes");
  setAttribute_e9d3U(objElmIFrame, "height", "100%");
  setAttribute_e9d3U(objElmIFrame, "width", "100%");
};

function fscHidePopup() {
  objDiv = document.getElementById("scDivPopup");
  objDiv.style.display = "none";
};

function fscPopup(fileLocation_e9d3B, strDate) {
  if (mblnPopupAddParam) 
     fileLocation_e9d3B = fscAddQueryStrParam(fileLocation_e9d3B, "scDate", strDate);

  if (mlngPopupType==2) {
     var objPopup = findObjectById_e9d35("scIfmPopup");
     objPopup.src = fileLocation_e9d3B;
     objPopup = findObjectById_e9d35("scDivPopup");
     objPopup.style.display="block";
  } else if (mlngPopupType==3) {
     window.top.location = fileLocation_e9d3B;
  } else {
     var objWindow = window.open(fileLocation_e9d3B, "_blank", mstrPopupProp);
  };
};

scriptcalendar.prototype.createFilter = function() {
  var objElmContainer;
  var objElmSpan;
  var objElmCheckbox;
  var arrNames = this.filterNames.split(",");
  var htmlText_e9d3u;
  var strChecked;
  objElmContainer = setElement_e9d3T(document.body, "div", "");
  setAttribute_e9d3U(objElmContainer, "class", "scFilterContainer");
  setAttribute_e9d3U(objElmContainer, "onclick", "this.style.display='none';");
  for (i=0; i < arrNames.length; i++) {
      objElmSpan = setElement_e9d3T(objElmContainer, "span", "");
      setAttribute_e9d3U(objElmSpan, "class", "scFilterItem");
      strChecked="checked=\"checked\"";
      if (this.filter.indexOf(arrNames[i]) == -1) strChecked="";

      htmlText_e9d3u = "<input type=\"checkbox\" name=\"chkScFilter\" " + 
              " id=\"chkScFilter" + (i+1) + 
              "\" onClick=\"chkScFilter_onClick(this); \" value=\"" + 
              arrNames[i] + "\" " + strChecked + ">";
      htmlText_e9d3u += arrNames[i];
      objElmSpan.innerHTML = htmlText_e9d3u;
  };
};

function chkScFilter_onClick(chk) {
  var arrNames = calObject_e9d3f.filterNames.split(",");
  var fileLocation_e9d3B = window.location.toString();
  var strValue = "";
  var objCheck;
  var i;
  for (i=0; i<arrNames.length; i++) {
      objCheck = document.getElementById("chkScFilter" + (i+1));
      if (objCheck) {
         if (objCheck.checked) 
            strValue += objCheck.value + ",";
      };
  };
  if (strValue.length > 0) 
     strValue = strValue.substring(0, strValue.length-1);

  fileLocation_e9d3B = fscRemoveQueryStrParam(fileLocation_e9d3B, "scFilter");
  fileLocation_e9d3B = fscAddQueryStrParam(fileLocation_e9d3B, "scFilter", strValue);
  window.location = fileLocation_e9d3B;
};

function EventObj(m, d, y, strText, strPopuplink, strStyle, 
                  strTooltip, strScript, strFilter) {
  var e9d3r;
  this.day = 0;
  if (m) this.month = m;
  if (d) this.day = d;
  if (y) this.year = y;
  if (strText) this.text = strText;
  if (strPopuplink) this.popuplink = strPopuplink;
  if (strStyle) this.style = strStyle;
  if (strTooltip) this.tooltip = strTooltip;
  if (strScript) this.script = strScript;
  if (strFilter) this.filter = strFilter;
  this.isRegular = false;
  if (m && y) {
     e9d3r = new Date( y, m-1, 1);
     e9d3r = e9d3r.add("d", d-1);
     this.date = e9d3r;
  };
};

function fscEvent(m, d, y, strText, strPopuplink, strStyle, 
                  strTooltip, strScript, strFilter) {
  var eventObj_e9d3l = new EventObj(m, d, y, strText, strPopuplink, strStyle, 
                           strTooltip, strScript, strFilter);
  eventObj_e9d3l.isRegular = true;
  eventArray_e9d3g[eventArray_e9d3g.length] = eventObj_e9d3l;
};

function dcEvent(m, d, y, strText, strPopuplink, strStyle, strTooltip, 
                 strScript) {
  fscEvent(m, d, y, strText, strPopuplink, strStyle, strTooltip, strScript);
};

Date.SECOND = 1000;
Date.MINUTE = 60 * Date.SECOND;
Date.HOUR = 60 * Date.MINUTE;
Date.DAY = 24 * Date.HOUR;
Date.WEEK = 7 * Date.DAY;
Date.prototype.getDaysPerMonth = function(month) {
  var arrDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var year = this.getFullYear();
  if (typeof month == "undefined") month = this.getMonth();
  if ((0 == (year%4)) && 
      ((0 != (year%100)) || (0 == (year%400))) && 
      month == 1) return 29;

  return arrDays[month];
};

Date.prototype.weekOfYear = function() {
  var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 
                     0, 0);
  var then = new Date(this.getFullYear(), 0, 1, 0, 0, 0);
  var time = now - then;
  var day = then.getDay();

  (day > 3) && (day -= 4) || (day += 3);
  var result = Math.round(((time / Date.DAY) + day) / 7);
  return result;
};

Date.prototype.dayOfYear = function() {
  var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 
                     0, 0);
  var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
  var time = now - then;
  return Math.floor(time / Date.DAY);
};

Date.prototype.weekOfMonth = function() {
  var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 
                     0, 0);
  var then = new Date(this.getFullYear(), this.getMonth(), 1, 0, 0, 0);
  var time = now - then;
  var result = (Math.floor(time / Date.WEEK + 0.01)) + 1;
  return result;
};

Date.prototype.equalsTo = function(dte) {
  return ((this.getFullYear() == dte.getFullYear()) && 
          (this.getMonth() == dte.getMonth()) &&
          (this.getDate() == dte.getDate()));
};

Date.prototype.add = function(interval, num) {
  var result = new Date(this.getFullYear(), this.getMonth(), this.getDate());
  switch (interval.toLowerCase()) {
    case "yyyy": {
         result.setFullYear(result.getFullYear() + num);
         break;
    };
    case "q": {
         result.setMonth(result.getMonth() + (num*3));
         break;
    };
    case "m": {
         result.setMonth(result.getMonth() + num);
         break;
    };
    case "y":
    case "d":
    case "w": {
         result.setDate(result.getDate() + num);
         break;
    };
    case "ww": {
         result.setDate(result.getDate() + (num*7));
         break;
    };
    case "h": {
         result.setHours(result.getHours() + num);
         break;
    };
    case "n": { 
         result.setMinutes(result.getMinutes() + num);
         break;
    };
    case "s": {
         result.setSeconds(result.getSeconds() + num);
         break;
    };
    case "ms": {
         result.setMilliseconds(result.getMilliseconds() + num);
         break;
    };
    default: {
         return "invalid interval: '" + interval + "'";
    };
  };
  return result;
};

Date.prototype.format = function(symbols, useMilitary) {
  var hours = this.getHours();
  if (hours>12 && useMilitary==false) hours = hours-12;
  var yy = this.getFullYear().toString();
  var mm = "00" + (this.getMonth() + 1).toString();
  var dd = "00" + this.getDate().toString();
  var hh = "00" + hours.toString().toString();
  var nn = "00" + this.getMinutes().toString();
  var ss = "00" + this.getSeconds().toString();
  mm = mm.substr(mm.length-2,2);
  dd = dd.substr(dd.length-2,2);
  hh = hh.substr(hh.length-2,2);
  nn = nn.substr(nn.length-2,2);
  ss = ss.substr(ss.length-2,2);
  symbols = symbols.replace("yy", yy);
  symbols = symbols.replace("mm", mm);
  symbols = symbols.replace("dd", dd);
  symbols = symbols.replace("hh", hh);
  symbols = symbols.replace("nn", nn);
  symbols = symbols.replace("ss", ss);
  return symbols;
};

Date.prototype.getEaster = function() {
  var Y = this.getFullYear();
  var C = Math.floor(Y/100);
  var N = Y - 19*Math.floor(Y/19);
  var K = Math.floor((C - 17)/25);
  var I = C - Math.floor(C/4) - Math.floor((C - K)/3) + 19*N + 15;
  I = I - 30*Math.floor((I/30));
  I = I - Math.floor(I/28)*(1 - Math.floor(I/28)*Math.floor(29/(I + 1))* 
          Math.floor((21 - N)/11));
  var J = Y + Math.floor(Y/4) + I + 2 - C + Math.floor(C/4);
  J = J - 7*Math.floor(J/7);
  var L = I - J;
  var M = 3 + Math.floor((L + 40)/44);
  var D = L + 28 - 31*Math.floor(M/4);
  return new Date(Y,M-1,D);
};

function fscEaster(Y) {
  if (fscIsDate(easterDay_e9d3i)) {
     if (easterDay_e9d3i.getFullYear==Y) {
        return easterDay_e9d3i;
     };
  };
  var tmpEasterDay_e9d3p = new Date(Y, 1, 1);
  easterDay_e9d3i = tmpEasterDay_e9d3p.getEaster();
  return easterDay_e9d3i;
};

function fscDateString(y, m, d, blnYMD) {
  var e9d3v = "";
  var strYear = y.toString();
  strYear = strYear.pad(4);
  var strMonth = m.toString();
  strMonth = strMonth.pad(2);
  var strDay = d.toString();
  strDay = strDay.pad(2);
  if (blnYMD) return strYear + strMonth + strDay;
  return strMonth + "/" + strDay + "/" + strYear;
};

function fscIsDate(m,d,y) {
  var dte = new Date(y,m,d);
  if ( (dte.getFullYear() == y) && (dte.getMonth() == m) && 
       (dte.getDate() == d) ) 
     return true;
  return false;
};

String.prototype.isDate = function() {
  var datePat = /^(\d{1,2})(\/|)(-?\d{1,2})(\/|)(\d{2,4})$/;
  var matchArray = this.match(datePat);
  var strReason = "";
  if (matchArray == null) strReason = "pattern match failed";
  var lngMonth = parseInt(matchArray[1], 10);
  var lngDay = parseInt(matchArray[3], 10);
  var lngYear = parseInt(matchArray[5], 10);
  if (strReason.length==0 && (lngMonth < 1 || lngMonth > 12) )
     strReason="invalid month";
  if (strReason.length==0 && (lngDay < 1 || lngDay > 31) ) 
     strReason="invalid day";
  if (strReason.length==0 && 
      (lngMonth==4 || lngMonth==6 || lngMonth==9 || lngMonth==11) && 
      lngDay==31) 
     strReason="31 days";
  if (strReason.length==0) {
     if (lngMonth == 2) {
        var isleap = (lngYear % 4 == 0 && 
                      (lngYear % 100 != 0 || lngYear % 400 == 0));
        if (lngDay > 29 || (lngDay==29 && !isleap)) 
           strReason="leap year";
     };
  };
  if (strReason.length==0) return true;
     return false;
};

String.prototype.htmlEncode = function() {
   var e9d3v = this;
   e9d3v = e9d3v.replace("&lt;", "<");
   e9d3v = e9d3v.replace("&gt;", ">");
   e9d3v = e9d3v.replace("&amp;", "&");
   return e9d3v;
};

String.prototype.pad = function(num) {
  var strResult = "00000000000000000000" + this;
  var lngValue = strResult.length - num;
  strResult = strResult.substring(lngValue);
  return strResult;
};

String.prototype.globalReplace = function(fromString, toString) { 
  var inputString = this;
  var temp = inputString;
  if (fromString == "") return inputString;
  if (toString.indexOf(fromString) == -1) { 
     while (temp.indexOf(fromString) != -1) { 
        var toTheLeft = temp.substring(0, temp.indexOf(fromString));
        var toTheRight = temp.substring(temp.indexOf(fromString)+
                                        fromString.length, temp.length);
        temp = toTheLeft + toString + toTheRight;
     };
  } else { 
     var midStrings = new Array("~", "`", "_", "^", "#");
     var midStringLen = 1;
     var midString = "";
     while (midString == "") { 
        for (var i=0; i < midStrings.length; i++) { 
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) {
                tempMidString += midStrings[i];
            };
            if (fromString.indexOf(tempMidString) == -1) { 
               midString = tempMidString;
               i = midStrings.length + 1;
            };
        };
     };
     while (temp.indexOf(fromString) != -1) { 
        var toTheLeft = temp.substring(0, temp.indexOf(fromString));
        var toTheRight = temp.substring(temp.indexOf(fromString) +
                                        fromString.length, temp.length);
        temp = toTheLeft + midString + toTheRight;
     };
     while (temp.indexOf(midString) != -1) { 
        var toTheLeft = temp.substring(0, temp.indexOf(midString));
        var toTheRight = temp.substring(temp.indexOf(midString)+
                                        midString.length, temp.length);
        temp = toTheLeft + toString + toTheRight;
     };
  };
  return temp;
};

String.prototype.urlEncode = function() {
  var SAFECHARS = "0123456789";
  SAFECHARS += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  SAFECHARS += "abcdefghijklmnopqrstuvwxyz";
  SAFECHARS += "-_.!~*'()";
  var HEX = "0123456789ABCDEF";
  var plaintext = this;
  var encoded = "";
  for (var i = 0; i < plaintext.length; i++ ) {
      var ch = plaintext.charAt(i);
      if (ch == " ") { 
         encoded += "+";
      } else if (SAFECHARS.indexOf(ch) != -1) { 
         encoded += ch;
      } else { 
         var charCode = ch.charCodeAt(0);

         if (charCode > 255) { 
            alert("Unicode Character '" + ch + 
                  "' cannot be encoded using standard URL encoding.\n" + 
                  "(URL encoding only supports 8-bit characters.)\n" + 
                  "A space (+) will be substituted." );
            encoded += "+";
         } else {
            encoded += "%";
            encoded += HEX.charAt((charCode >> 4) & 0xF);
            encoded += HEX.charAt(charCode & 0xF);
         };
      };
  };
  return encoded;
};

String.prototype.urlDecode = function() { 
  var HEXCHARS = "0123456789ABCDEFabcdef";
  var encoded = this;
  var plaintext = "";
  var i = 0;
  while (i < encoded.length) { 
     var ch = encoded.charAt(i);
     if (ch == "+") { 
        plaintext += " ";
        i++;
     } else if (ch == "%") {
        if (i < (encoded.length-2) && 
            HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && 
            HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
           plaintext += unescape( encoded.substr(i,3) );
           i += 3;
        } else {
           alert( 'Bad escape combination near ...' + encoded.substr(i) );
           plaintext += "%[ERROR]";
           i++;
        };
     } else { 
        plaintext += ch;
        i++;
     };
  };
  return plaintext;
};


String.prototype.stripHtml = function() {
  var pattern = "<[a-zA-Z\\/][^>]*>";
  var regex = eval("/(" + pattern + ")/g");
  return this.replace(regex, "");
};

function setElement_e9d3T(objParent, strName, strValue) {
  var objDoc = objParent.ownerDocument;
  if (!objDoc) objDoc = objParent;
  var objNode = objDoc.createElement(strName);
  if (strValue) {
     var objNodeText = objDoc.createTextNode(strValue);
     objNode.appendChild(objNodeText);
  };
  objParent.appendChild(objNode);
  return objNode;
};

function setAttribute_e9d3U(objParent, strName, strValue) {
  var objDoc = objParent.ownerDocument;
  if (!objDoc) objDoc = objParent;
  var objNode = objDoc.createAttribute(strName);
  if (strValue) objNode.nodeValue = strValue;
  objParent.attributes.setNamedItem(objNode);
};

function fscImportXml( strFile, strFunction ) {
  if (window.ActiveXObject) {
     var objDoc = fscLoad(strFile);
     eval( strFunction + '(objDoc);' );
     return true;
  };
  if (document.implementation && document.implementation.createDocument) {
     var objDoc = fscLoad(strFile);
     eval( strFunction + '(objDoc);' );
     return true;
  };
  var hdnDiv = document.createElement('DIV');
  hdnDiv.style.visibility = 'hidden';
  hdnDiv.style.position = 'absolute';
  hdnDiv.style.top = '0px';
  hdnDiv.style.left = '0px';
  if (!window.fscXmlTimer ) {
     window.fscXmlTimer = window.setInterval('fscImportXmlCheck();',100);
  };
  hdnDiv.innerHTML = '<iframe src="' + strFile + 
                     '" name="fscXmlFrame" height="0" width="0"><\/iframe>';

  mfntImport = strFunction;
  document.body.appendChild(hdnDiv);
  return true;
};

function fscImportXmlCheck() {
  if (mfntImport && window.frames['fscXmlFrame'] ) {
     if (window.fscXmlTimer) window.clearInterval( window.fscXmlTimer );
     eval( mfntImport + '(window.frames.fscXmlFrame.window.document);' );
  };
};

/*
// KEN:  Don't think this is used
*/
function createDOMObject_e9d3V() {
  if (window.ActiveXObject) {
     var objDoc = new ActiveXObject("Microsoft.XMLDOM");
     return objDoc;
  };
  if (document.implementation && document.implementation.createDocument) {
     var objDoc = document.implementation.createDocument( "", "", null );
     return objDoc;
  };
  alert("ERROR - e9d3V" + "\n" + "Browser can't create DOM object.");
  return false;
};

function fscLoad(fileLocation_e9d3B) {
  if (window.ActiveXObject) {
     var objDoc = e9d3V();
     objDoc.async = false;
     objDoc.load(fileLocation_e9d3B);
     return objDoc;
  };
  if (document.implementation && document.implementation.createDocument) {
     var objDoc = e9d3V();
     objDoc.async = false;
     objDoc.load(fileLocation_e9d3B);
     return objDoc;
  };
  if (document.implementation) {
     var pipe = new XMLHttpRequest();
     pipe.open("GET", fileLocation_e9d3B, false);
     pipe.send(null);
     return pipe.responseXML;
  };
  return false;
};

function e9d3W(objXml, strXsltFile) {
  if (window.ActiveXObject) {
     var objXslt = new ActiveXObject("Microsoft.XMLDOM");
     objXslt.async = false;
     objXslt.load(strXsltFile);
     var strHTML = objXml.transformNode(objXslt);
     return strHTML;
  };
  if (document.implementation) {
     var processor = new XSLTProcessor();
     var objXslt = fscLoad(strXsltFile, true);
     processor.importStylesheet(objXslt);
     var node = processor.transformToDocument(objXml);
     var strHTML = e9d3X(node);
     return strHTML;
  };
  alert("ERROR - fscGetNodeText");
  return "";
};

function e9d3X(objDoc) {
  if (window.ActiveXObject) {
     return objDoc.xml;
  };
  if (document.implementation && document.implementation.createDocument) {
     var objSerializer = new XMLSerializer();
     return objSerializer.serializeToString(objDoc);
  };
  alert("ERROR - e9d3X");
  return "";
};

function fscGetNodeText(objNode) {
  var objChild;
  for (var i=0; i<objNode.childNodes.length; i++) {
      objChild = objNode.childNodes[i];
      if (objChild.nodeName=='#text') {
         if (objChild.nodeValue.length != 0) {
            return objChild.nodeValue;
         };
      };
  };
  return null;
};

function fscRequestQueryString(strKey) {
  var fileLocation_e9d3B = window.location.toString();
  var intPosition = fileLocation_e9d3B.indexOf("?");
  if (intPosition == -1) return "";
  var strQueryStr = fileLocation_e9d3B.substr(intPosition+1, fileLocation_e9d3B.length-intPosition);
  intPosition = strQueryStr.indexOf("#");
  if (intPosition != -1) strQueryStr = strQueryStr.substr(0, intPosition);

  var arrKeyValue;
  var arrQueryStr = strQueryStr.split("&");
  for (i=0; i<arrQueryStr.length; i++) {
      arrKeyValue = arrQueryStr[i].split("=");
      if ( arrKeyValue[0].toLowerCase() == strKey.toLowerCase() ) { 
         return arrKeyValue[1].urlDecode();
      };
  };
  return "";
};

function fscAddQueryStrParam(fileLocation_e9d3B, strKey, strValue) {
  var strAnchor = "";
  var c = "?";
  var i;
  i = fileLocation_e9d3B.indexOf("#");
  if (i != -1) {
     strAnchor = fileLocation_e9d3B.substr(i, fileLocation_e9d3B.length - i);
     fileLocation_e9d3B = fileLocation_e9d3B.substr(0,i);
  };
  i = fileLocation_e9d3B.indexOf("?");
  if (i != -1) c="&";
  fileLocation_e9d3B += c + strKey + "=" + strValue.urlEncode() + strAnchor;
  return fileLocation_e9d3B;
};

function fscRemoveQueryStrParam(fileLocation_e9d3B, strKey) {
  var strResult;
  var intStart;
  var intEnd;
  var strAnchor = "";
  intStart = fileLocation_e9d3B.indexOf("#");
  if (intStart != -1){
     strAnchor = fileLocation_e9d3B.substr(intStart, fileLocation_e9d3B.length - intStart);
     fileLocation_e9d3B = fileLocation_e9d3B.substring(0, intStart);
  };
  intStart = fileLocation_e9d3B.indexOf(strKey);
  if (intStart == -1) {
     strResult = fileLocation_e9d3B;
  } else {
     intEnd = fileLocation_e9d3B.indexOf("&", intStart);
     if (intEnd != -1) {
        strResult = fileLocation_e9d3B.substring(0, intStart) + fileLocation_e9d3B.substring(intEnd+1);
     } else {
        strResult = fileLocation_e9d3B.substring(0, intStart-1);
     };
  };
  strResult += strAnchor;
  return strResult;
};

function validateLicense_e9d3c() {

  return "1";

   // override this: Ken
  var a = "abcdefghijklmnopqrstuvwxyz";
  var d;
  var i;
  var n;
  var c;
  var e;
  var t;
  var u = window.location.toString().toLowerCase();
  for (i=0; i<a.length; i++) {
      c = a.charAt(i);
      if (u.indexOf(c + ":")==0) return "1";
  };
  if (u.indexOf("localhost")!=-1) return "1";
  if (u.indexOf("file:/")!=-1) return "1";

  n = u.length;
  i = u.indexOf(":/" + "/") + 3;   
  d = u.substring(i, n);
  i = d.indexOf("/");
  d = d.substring(0,i);
  n = d.length;
  i = d.lastIndexOf(".");
  e = d.substring(i, n);
  t = d.substring(0, i);
  n = t.length;
  i = t.lastIndexOf(".");
  d = t.substring(i+1, n);
  d += e;
  d = stripNonAlpha_e9d3b(d);
  return d;
};

function stripNonAlpha_e9d3b(strInput_e9d3w) {
  var strBad = "!@#$%^&*()-_=+[{]}\|;:',<.>/?" + '"';
  var strResult = "";
  var c;
  for (var i=0; i< strInput_e9d3w.length; i++) {
      c = strInput_e9d3w.charAt(i);
      if (strBad.indexOf(c)==-1) strResult += c;
  };
  return strResult;
};
function e9d3a(strCode) {
  var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmonpqrstuvwxyz1234567890";
  var k = "dateStylePast";
  var i;
  var j;
  var c;
  var e9d3d;
  var e9d3e;
  var r="";
  j = 0;
  for (i=0; i<strCode.length; i++ ) {
      c = strCode.charAt(i);
      e9d3d = a.indexOf(c);
      c = k.charAt(j);
      e9d3e = a.indexOf(c);
      e9d3d = e9d3d - e9d3e;
      if ( e9d3d < 0 ) e9d3d = e9d3d + a.length;
      r = r + a.charAt(e9d3d);
      j++;
      if ( j >= k.length ) j=0;
  };
  return r;
};

function findObjectById_e9d35(strID) { 
  if( document.getElementById ) return document.getElementById(strID);
  if( document.all ) return document.all[strID];
  if ( document.layers ) return document.layers[strID];
  if( document[szID] ) return document[strID];
  return false;
};

function fscOutput(text) {
  var obj;
  if (document.createElement && (obj = document.createElement('textarea'))) {
     setAttribute_e9d3U(obj, "rows", "5");
     setAttribute_e9d3U(obj, "cols", "80");
     obj.appendChild(document.createTextNode(text));
     document.body.appendChild(obj);
  };
};

/*
  KEN:  Debug function - not used in regular workings
*/
function fscShowProperties(obj) {
  var i;
  var strOutput;
  var strTerm;
  var e9d3w;
  var strSpace;
  var e9d3ts;
  var lngMaxLen = 100;
  e9d3ts=3;
  if (document.layers) e9d3ts=3;
  strSpace = " ";
  strOutput = obj.name + "\n\n";
  i=1;
  for (var prop in obj) {
      strTerm = "\n";
      if (i==e9d3ts) strTerm = "\n";
      i=i+1;
      if (i>e9d3ts) i=1;
      e9d3w = "." + prop + " = " + obj[prop];
      if (e9d3w.length<lngMaxLen) 
         e9d3w += strSpace.substring(0, lngMaxLen-e9d3w.length);
      if (e9d3w.length>lngMaxLen) 
         e9d3w = e9d3w.substring(0, lngMaxLen);
      strOutput += e9d3w + strTerm;
  };

  fscOutput(strOutput);
  return true;
};
