calDateFormat = "yyyyMMDD";
monthArray = new Array('January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
monthShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
weekdayList  = new Array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
weekdayArray = new Array('Mo','Tu','We','Th','Fr','Sa', 'Su');
today = new Date();

var weekStartDay = 0;
monthArray[0] = 'January';
monthArray[1] = 'February';
monthArray[2] = 'March';
monthArray[3] = 'April';
monthArray[4] = 'May';
monthArray[5] = 'June';
monthArray[6] = 'July';
monthArray[7] = 'August';
monthArray[8] = 'September';
monthArray[9] = 'October';
monthArray[10] = 'November';
monthArray[11] = 'December';
monthShort[0] = 'Jan';
monthShort[1] = 'Feb';
monthShort[2] = 'Mar';
monthShort[3] = 'Apr';
monthShort[4] = 'May';
monthShort[5] = 'Jun';
monthShort[6] = 'Jul';
monthShort[7] = 'Aug';
monthShort[8] = 'Sep';
monthShort[9] = 'Oct';
monthShort[10] = 'Nov';
monthShort[11] = 'Dec';
weekdayList[0] = 'Monday';
weekdayList[1] = 'Tuesday';
weekdayList[2] = 'Wednesday';
weekdayList[3] = 'Thursday';
weekdayList[4] = 'Friday';
weekdayList[5] = 'Saturday';
weekdayList[6] = 'Sunday';
weekdayArray[0] = 'Mo';
weekdayArray[1] = 'Tu';
weekdayArray[2] = 'We';
weekdayArray[3] = 'Th';
weekdayArray[4] = 'Fr';
weekdayArray[5] = 'Sa';
weekdayArray[6] = 'Su';
var rangeLen=4;
earlyYear=today.getFullYear();
earlyYearReport=2003;
lateYear=today.getFullYear()+rangeLen;
windowOpen="N";
fullUpdate="Y";
updateCall = null;
topBackground    = "#EEEEEE";
bottomBackground = "#EEEEEE";
tableBGColor     = "#CCCCCC";
cellColor        = "white";
headingCellColor = "#8CB3D7";
headingTextColor = "#FFFFFF";
dateColor        = "#666666";
focusColor       = "#FF0000";
hoverColor       = "#000000";
fontStyle        = "11px arial, helvetica, sans-serif";
headingFontStyle = "11px arial, helvetica, sans-serif";
bottomBorder  = false;
tableBorder   = 0;
var isNav = false;
var isIE  = false;
if (navigator.appName == "Netscape") {
    isNav = true;
}
else {
    isIE = true;
}
buildCalParts();
function setUpdateCall(func)
{
    updateCall = func;
}
function setDateField(dayField,monthField,yearField,oracleField) {

    calOracleField = oracleField;
    calDayField = dayField;
    calMonthField = monthField;
    calYearField = yearField;

    setInitialDate(oracleField.value);


    calDocTop    = buildTopCalFrame();
    calDocBottom = buildBottomCalFrame();
    fullUpdate="Y";
    windowOpen="Y";
}
function setInitialDate(inDate) {
    var year = inDate.substring(0,4);
    var month = inDate.substring(4,6);
    var day = inDate.substring(6,8);
    calDate = new Date(year, month - 1, day);
    calDay = calDate.getDate();
    calDate.setDate(1);
}
function buildTopCalFrame() {

    var calDoc =
        "<HTML>" +
        "<HEAD>" +
        "</HEAD>" +
        "<BODY BGCOLOR='" + topBackground + "'>" +
        "<FORM NAME='calControl' onSubmit='return false;'>" +
        "<CENTER>" +
        "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>" +
        "<TR><TD COLSPAN=7>" +
        "<CENTER>" +
        getMonthSelect() +
        "<SELECT NAME='year' onChange='parent.opener.setYear()' STYLE='font:" + fontStyle + "'>";
      selectedYear = calDate.getFullYear();
      for(i=earlyYear;i<=lateYear;i++)
      {
        if(i==selectedYear)
        {
          calDoc+="<OPTION VALUE='"+i+"' SELECTED>"+i+"</OPTION>";
        }
        else
        {
          calDoc+="<OPTION VALUE='"+i+"'>"+i+"</OPTION>";
        }
      }
      calDoc+= "</SELECT>" +
        "</CENTER>" +
        "</TD>" +
        "</TR>" +
        "</TABLE>" +
        "</CENTER>" +
        "</FORM>" +
        "</BODY>" +
        "</HTML>";
    return calDoc;
}
function buildBottomCalFrame() {

    var calDoc = calendarBegin;

    month   = calDate.getMonth();
    year    = calDate.getFullYear();

    day     = calDay;
    var i   = 0;

    var days = getDaysInMonth();

    if (day > days) {
        day = days;
    }

    var firstOfMonth = new Date (year, month, 1);

    var startingPos  = (firstOfMonth.getDay() + 6 - weekStartDay) % 7;
    days += startingPos;

    var columnCount = 0;

    for (i = 0; i < startingPos; i++) {
        calDoc += blankCell;
    columnCount++;
    }

    var currentDay = 0;
    var dayType    = "weekday";

    for (i = startingPos; i < days; i++) {
    var paddingChar = "&nbsp;";

        if (i-startingPos+1 < 10) {
            padding = "&nbsp;&nbsp;";
        }
        else {
            padding = "&nbsp;";
        }

        currentDay = i-startingPos+1;

        if (currentDay == day) {
            dayType = "focusDay";
        }
        else {
            dayType = "weekDay";
        }

        calDoc += "<TD align=center bgcolor='" + cellColor + "'>" +
                  "<a class='" + dayType + "' href='javascript:parent.opener.returnDate(" +
                  currentDay + ")'>" + padding + currentDay + paddingChar + "</a></TD>";
        columnCount++;

        if (columnCount % 7 == 0) {
            calDoc += "</TR><TR>";
        }
    }

    for (i=days; i<42; i++)  {
        calDoc += blankCell;
    columnCount++;

        if (columnCount % 7 == 0) {
            calDoc += "</TR>";
            if (i<41) {
                calDoc += "<TR>";
            }
        }
    }

    calDoc += calendarEnd;

    return calDoc;
}
function writeCalendar() {

    calDocBottom = buildBottomCalFrame();

      self.newWin.frames['bottomCalFrame'].document.open();
      self.newWin.frames['bottomCalFrame'].document.write(calDocBottom);
      self.newWin.frames['bottomCalFrame'].document.close();
}
function setToday() {

    calDate = new Date();

    var month = calDate.getMonth();
    var year  = calDate.getFullYear();

    self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;

    self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = year-earlyYear;

    writeCalendar();
}
function setYear() {

    var year  = self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex+earlyYear;

    calDate.setFullYear(year);
    writeCalendar();
}
function setCurrentMonth() {

    var month = self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
    calDate.setMonth(month);
    writeCalendar();
}
function setPreviousYear() {
    var year  = self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex+earlyYear;
    if (isFourDigitYear(year) && year > 1000) {
        year--;
        calDate.setFullYear(year);
        self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = year-earlyYear;
        writeCalendar();
    }
}
function setPreviousMonth() {
    var year  = self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex+earlyYear;
    if (isFourDigitYear(year)) {
        var month = self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;

        if (month == 0) {
            month = 11;
            if (year > 1000) {
                year--;
                calDate.setFullYear(year);
                self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = year-earlyYear;
            }
        }
        else {
            month--;
        }
        calDate.setMonth(month);
        self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
        writeCalendar();
    }
}
function setNextMonth() {
    var year = self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex+earlyYear;
    if (isFourDigitYear(year)) {
        var month = self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;

        if (month == 11) {
            month = 0;
            year++;
            calDate.setFullYear(year);
            self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = year-earlyYear;
        }
        else {
            month++;
        }
        calDate.setMonth(month);
        self.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
        writeCalendar();
    }
}
function setNextYear() {
    var year  = self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex+earlyYear;
    if (isFourDigitYear(year)) {
        year++;
        calDate.setFullYear(year);
        self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = year-earlyYear;
        writeCalendar();
    }
}
function getDaysInMonth(paramDate)  
{
    var workDate = paramDate || calDate;

    var days;
    var month = workDate.getMonth()+1;
    var year  = workDate.getFullYear();

    if (month==1 || month==3 || month==5 || month==7 || month==8 ||
        month==10 || month==12)  {
        days=31;
    }

    else if (month==4 || month==6 || month==9 || month==11) {
        days=30;
    }

    else if (month==2)  {
        if (isLeapYear(year)) {
            days=29;
        }

        else {
            days=28;
        }
    }
    return (days);
}
function isLeapYear(Year) {
    if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
        return (true);
    }
    else
    {
        return (false);
    }
}
function isFourDigitYear(year) {
    if (year.length != 4) {
        self.newWin.frames['topCalFrame'].document.calControl.year.selectedIndex = calDate.getFullYear();
        self.newWin.frames['topCalFrame'].document.calControl.year.select();
        self.newWin.frames['topCalFrame'].document.calControl.year.focus();
    }
    else {
        return true;
    }
}
function getMonthSelect() {

    var activeMonth = calDate.getMonth();

    monthSelect = "<SELECT NAME='month' onChange='parent.opener.setCurrentMonth()' STYLE='font:" + fontStyle + "'>";

    for (i in monthArray) {

        if (i == activeMonth) {
            monthSelect += "<OPTION SELECTED>" + monthArray[i] + "\n";
        }
        else {
            monthSelect += "<OPTION>" + monthArray[i] + "\n";
        }
    }
    monthSelect += "</SELECT>";

    return monthSelect;
}
function buildCalParts() {
    var weekdays = "<TR BGCOLOR='" + headingCellColor + "'>";
    for (i = 0; i < 7; i ++) {
        weekdays += "<TD class='heading' align=center>" + weekdayArray[(i + weekStartDay) % 7] + "</TD>";
    }
    weekdays += "</TR>";
    blankCell = "<TD align=center bgcolor='" + cellColor + "'>&nbsp;&nbsp;&nbsp;</TD>";

    calendarBegin =
        "<HTML>" +
        "<HEAD>" +
        "<STYLE type='text/css'>" +
        "<!--" +
        "TD.heading { text-decoration: none; color:" + headingTextColor + "; font: " + headingFontStyle + "; }" +
        "A.focusDay:link { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
        "A.focusDay:visited { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
        "A.focusDay:hover { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
        "A.weekday:link { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
        "A.weekday:visited { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
        "A.weekday:hover { color: " + hoverColor + "; font: " + fontStyle + "; }" +
        "-->" +
        "</STYLE>" +
        "</HEAD>" +
        "<BODY BGCOLOR='" + bottomBackground + "'" +
        "<CENTER>";

        if (isNav) {
            calendarBegin +=
                "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'><TR><TD>";
        }

        calendarBegin +=
            "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'>" +
            weekdays +
            "<TR>";

    calendarEnd = "";

        if (bottomBorder) {
            calendarEnd += "<TR></TR>";
        }

        if (isNav) {
            calendarEnd += "</TD></TR></TABLE>";
        }

        calendarEnd +=
            "</TABLE>" +
            "</CENTER>" +
            "</BODY>" +
            "</HTML>";
}
function jsReplace(inString, find, replace) {
    var outString = "";
    if (!inString) {
        return "";
    }

    if (inString.indexOf(find) != -1) {

        t = inString.split(find);

        return (t.join(replace));
    }
    else {
        return inString;
    }
}
function doNothing() {
}
function makeTwoDigit(inValue) {
    var numVal = parseInt(inValue, 10);

    if (numVal < 10) {

        return("0" + numVal);
    }
    else {
        return numVal;
    }
}
function updateDate(dayField,monthField,yearField,oracleField)
{
    windowOpen="N";
    fullUpdate="Y";
    calOracleField = oracleField;
    calDayField = dayField;
    calMonthField = monthField;
    calYearField = yearField;

    inDay = parseInt(calDayField[calDayField.selectedIndex].value, 10);

    calDate = new Date();
    calDate.setDate(1);
    calDate.setMonth(calMonthField.selectedIndex);
    calDate.setYear(calYearField.selectedIndex+earlyYear);
    var mDays = getDaysInMonth();

    if(inDay > mDays)
    {
        calDayField.value = mDays;
        inDay = mDays;
    }

    refreshDatesSelect(dayField, mDays);

    returnDate(inDay);
}

function buildDaySelectorWithObject(dateField, select)
{
    fullUpdate = "N";
    setInitialDate(dateField.value);
    calOracleField=dateField;
    dayCode = "";
    var i;

    for(i = 1; i <= 31; i++)
    {
        var option = document.createElement("option");
        option.text = i;
        option.value = makeTwoDigit(i);

        if(ie || mac)
        {
            select.add(option);
        }
        else
        {
            select.add(option, null);
        }
    }

    select.selectedIndex = calDay - 1;

    returnDate(calDay);
}

function buildMonthSelectorWithObject(dateField, select)
{
    fullUpdate = "N";
    setInitialDate(dateField.value);
    calOracleField = dateField;

    monthCode = "";
    var i;

    for(i = 0; i < 12; i++)
    {
        var option = document.createElement("option");
        option.text = monthShort[i];
        option.value = monthShort[i];
/*
        if(calDate.getMonth() == i)
        {
            option.selected = true;
        }
*/
        if(ie || mac)
        {
            select.add(option);
        }
        else
        {
            select.add(option, null);
        }
    }

    select.selectedIndex = calDate.getMonth();

    returnDate(calDay);
}

function buildYearSelectorWithObject(dateField, showPrevYears, select) 
{
    if (typeof(showPrevYears) == 'undefined')
    {
        showPrevYears = 2;
    }

    switch(showPrevYears)
    {
        case 0:
            break;

        case 1:
            // show previous years [earlyYearReport..current year]: for Reports
            earlyYear = earlyYearReport;
            lateYear = today.getFullYear();
            break;

        case 2:
            // show both previous and next years
            earlyYear = earlyYearReport;
            break;
    }

    fullUpdate = "N";
    setInitialDate(dateField.value);
    calOracleField = dateField;

    yearCode = "";
    var i;

    for(i = earlyYear; i <= lateYear; i++)
    {
        var option = document.createElement("option");
        option.text = i;
        option.value = i;

        if(calDate.getFullYear() == i)
        {
            option.selected = true;
        }

        if(ie || mac)
        {
            select.add(option);
        }
        else
        {
            select.add(option, null);
        }
    }

    returnDate(calDay);
    return yearCode;
}

function buildDaySelector(dateField)
{
  fullUpdate="N";
  setInitialDate(dateField.value);
  calOracleField=dateField;
  dayCode="";
  var i;
  for(i=1; i<=31; i++)
  {
    if(calDay==i)
    {
      dayCode+="<option value="+makeTwoDigit(i)+" selected>"+i+"</option>\n";
    }
    else
    {
      dayCode+="<option value="+makeTwoDigit(i)+">"+i+"</option>\n";
    }
  }
  returnDate(calDay);
  return dayCode;
}
function buildMonthSelector(dateField)
{
  fullUpdate="N";
  setInitialDate(dateField.value);
  calOracleField=dateField;
  monthCode="";
  var i;
  for(i=0;i<12;i++)
  {
    if(calDate.getMonth()==i)
    {
      monthCode+="<option value="+monthShort[i]+" selected>"+monthShort[i]+"</option>\n";
    }
    else
    {
      monthCode+="<option value="+monthShort[i]+">"+monthShort[i]+"</option>\n";
    }
  }
  returnDate(calDay);
  return monthCode;
}
function buildYearSelector(dateField, showPrevYears)
{
  if(typeof(showPrevYears) == 'undefined') showPrevYears = 2;
  switch(showPrevYears)
  {
    case 0:
      break;
    case 1:

      earlyYear = earlyYearReport;
      lateYear = today.getFullYear();
      break;
    case 2:

      earlyYear = earlyYearReport;

      break;
  }
  fullUpdate="N";
  setInitialDate(dateField.value);
  calOracleField=dateField;
  yearCode="";
  var i;

  for(i=earlyYear;i<=lateYear;i++)
  {
    if(calDate.getFullYear()==i)
    {
      yearCode+="<option value="+i+" selected>"+i+"</option>\n";
    }
    else
    {
      yearCode+="<option value="+i+">"+i+"</option>\n";
    }
  }

  returnDate(calDay);
  return yearCode;
}
function setOracleField(hiddenOracleField)
{
    var year = calDate.getFullYear();
    var month = calDate.getMonth() + 1;
    var day = calDay;
    month = (month > 9) ? month : "0" + month;
    day = (day > 9) ? day : "0" + day;
    hiddenOracleField.value = "" + year + month + day;
}

function returnDate(inDay)
{
    calDate.setDate(inDay);

    var day             = calDate.getDate();
    var month           = calDate.getMonth()+1;
    var year            = calDate.getFullYear();
    var monthString     = monthArray[calDate.getMonth()];
    var monthAbbrev     = monthString.substring(0,3);
    var weekday         = weekdayList[calDate.getDay()];
    var weekdayAbbrev   = weekday.substring(0,3);
    outDate             = calDateFormat;

    if (calDateFormat.indexOf("DD") != -1)
    {
        day     = makeTwoDigit(day);
        outDate = jsReplace(outDate, "DD", day);
    }

    else if (calDateFormat.indexOf("dd") != -1) {
        outDate = jsReplace(outDate, "dd", day);
    }

    if (calDateFormat.indexOf("MM") != -1) {
        month = makeTwoDigit(month);
        outDate = jsReplace(outDate, "MM", month);
    }

    else if (calDateFormat.indexOf("mm") != -1) {
        outDate = jsReplace(outDate, "mm", month);
    }

    if (calDateFormat.indexOf("yyyy") != -1) {
        outDate = jsReplace(outDate, "yyyy", year);
    }

    else if (calDateFormat.indexOf("yy") != -1) {
        var yearString = "" + year;
        var yearString = yearString.substring(2,4);
        outDate = jsReplace(outDate, "yy", yearString);
    }

    else if (calDateFormat.indexOf("YY") != -1) {
        outDate = jsReplace(outDate, "YY", year);
    }

    if (calDateFormat.indexOf("Month") != -1)
    {
        outDate = jsReplace(outDate, "Month", monthString);
    }

    else if (calDateFormat.indexOf("month") != -1)
    {
        outDate = jsReplace(outDate, "month", monthString.toLowerCase());
    }

    else if (calDateFormat.indexOf("MONTH") != -1)
    {
        outDate = jsReplace(outDate, "MONTH", monthString.toUpperCase());
    }

    if (calDateFormat.indexOf("Mon") != -1)
    {
        outDate = jsReplace(outDate, "Mon", monthAbbrev);
    }

    else if (calDateFormat.indexOf("mon") != -1)
    {
        outDate = jsReplace(outDate, "mon", monthAbbrev.toLowerCase());
    }

    else if (calDateFormat.indexOf("MON") != -1)
    {
        outDate = jsReplace(outDate, "MON", monthAbbrev.toUpperCase());
    }

    if (calDateFormat.indexOf("Weekday") != -1)
    {
        outDate = jsReplace(outDate, "Weekday", weekday);
    }

    else if (calDateFormat.indexOf("weekday") != -1)
    {
        outDate = jsReplace(outDate, "weekday", weekday.toLowerCase());
    }

    else if (calDateFormat.indexOf("WEEKDAY") != -1)
    {
        outDate = jsReplace(outDate, "WEEKDAY", weekday.toUpperCase());
    }

    if (calDateFormat.indexOf("Wkdy") != -1)
    {
        outDate = jsReplace(outDate, "Wkdy", weekdayAbbrev);
    }

    else if (calDateFormat.indexOf("wkdy") != -1)
    {
        outDate = jsReplace(outDate, "wkdy", weekdayAbbrev.toLowerCase());
    }

    else if (calDateFormat.indexOf("WKDY") != -1)
    {
        outDate = jsReplace(outDate, "WKDY", weekdayAbbrev.toUpperCase());
    }

    if (fullUpdate == "Y")
    {
//        calDayField.selectedIndex = day - 1;

        if (!setSelected(calDayField, makeTwoDigit(day)))
        {
            calDate.setDate(parseInt(calDayField[calDayField.selectedIndex].value, 10));
            var day = calDate.getDate();
            returnDate(day);
            return;
        }

        calMonthField.selectedIndex = month - 1;
        calYearField.selectedIndex  = year - earlyYear;
    }

    if (windowOpen == "Y")
    {
        self.newWin.blur();
        self.newWin.close();
    }

    calOracleField.value = outDate;

    if (updateCall != null)
    {
        eval(updateCall);
    }
}

function updateDateField(formName, fieldName, jsDate)
{
    var frm     = document[formName];
    var year    = jsDate.getFullYear();
    var month   = jsDate.getMonth() + 1;
    var day     = jsDate.getDate();

    if (fieldName == "returning")
    {
        var curDate = new Date();

        curDate.setFullYear(frm["_year_" + fieldName].selectedIndex + earlyYear);
        curDate.setMonth(frm["_month_" + fieldName].selectedIndex);
        curDate.setDate(frm["_day_" + fieldName][frm["_day_" + fieldName].selectedIndex].value);

        if (curDate < jsDate)
        {
            var mDays = getDaysInMonth(jsDate);

            refreshDatesSelect(frm["_day_" + fieldName], mDays);

            for(var i = 0; i < frm["_day_" + fieldName].options.length; i++)
            {
                if(frm["_day_" + fieldName].options[i].value == day)
                {
                    frm["_day_" + fieldName].options[i].selected = true;
                    break;
                }
            }

            frm["_month_" + fieldName].selectedIndex = month - 1;
            frm["_year_" + fieldName].selectedIndex  = year - earlyYear;
            month = (String(month).length == 2) ? month : "0" + month;
            day = (String(day).length == 2) ? day : "0" + day;
            var date = "" + year + month + day;
            frm[fieldName].value = date;
        }
    }
    else
    {
        for(var i = 0; i < frm["_day_" + fieldName].options.length; i++)
        {
            if(frm["_day_" + fieldName].options[i].value == day)
            {
                frm["_day_" + fieldName].options[i].selected = true;
                break;
            }
        }

        frm["_month_" + fieldName].selectedIndex = month - 1;
        frm["_year_" + fieldName].selectedIndex  = year - earlyYear;
        month = (String(month).length == 2) ? month : "0" + month;
        day = (String(day).length == 2) ? day : "0" + day;
        var date = "" + year + month + day;
        frm[fieldName].value = date;
    }
}

function getJSDate(jsDate)
{
    var year  = jsDate.getFullYear();
    var month = jsDate.getMonth() + 1;
    var day   = jsDate.getDate();
    month = (String(month).length == 2) ? month : "0" + month;
    day = (String(day).length == 2) ? day : "0" + day;
    return "" + year + month + day;
}
function getStringDate(date)
{
    return (date.substring(4, 6) + "/" +
            date.substring(6, 8) + "/" +
            date.substring(0, 4));
}