//
// JavaScript Browser Sniffer
// Eric Krok, Andy King, Michel Plungjan 010329
// see
// http://www.webreference.com/ for more information
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
// please send any improvements to aking@internet.com and we'll
// roll the best ones in
//
// adapted from Netscape's Ultimate client-side JavaScript client sniff.
// and andy's sniffer
// Revised May 7 99 to add is.nav5up and is.ie5up (see below). (see below).
// Revised June 11 99 to add addit props, checks
// Revised June 23 99 added screen props - gecko m6 doesn't support yet - abk
//                    converted to var is_ from is object to work everywhere
// 990624 - added cookie forms links frames checks - abk
// 001031 - ie4 mod 5.0 -> 5. (ie5.5 mididentified - abk)
//          is_ie4 mod tp work with ie6+ - abk
// 001120 - ns6 released, document.layers false, put back in
//        - is_nav6 test added - abk
// 001121 - ns6+ added, used document.getElementById, better test, dom-compl
// 010117 - actual version for ie3-5.5 by Michel Plungjan
// 010118 - actual version for ns6 by Michel Plungjan
// 010217 - netscape 6/mz 6 ie5.5 onload defer bug docs - abk
//
//
// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav5, is_nav5up, is_ie3, is_ie4, is_ie4up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//        is_sun, is_sun4, is_sun5, is_suni86
//        is_irix, is_irix5, is_irix6
//        is_hpux, is_hpux9, is_hpux10
//        is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//        is_linux, is_sco, is_unixware, is_mpras, is_reliant
//        is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.

//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when Nav5 and IE5 (or later) are released, so
// in conditional code forks, use is_nav4up ("Nav4 or greater")
// and is_ie4up ("IE4 or greater") instead of is_nav4 or is_ie4
// to check version in code which you want to work on future
// versions.
//

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    // Note: On IE, start of appVersion return 3 or 4
    // which supposedly is the version of Netscape it is compatible with.
    // So we look for the real version further on in the string

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       is_major = parseInt(is_minor);
    }

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    var nav6Pos = agt.indexOf('netscape6');
    if (nav6Pos !=-1) {
       is_minor = parseFloat(agt.substring(nav6Pos+10))
       is_major = parseInt(is_minor)
    }

    var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

/*	var is_nav6 = (is_nav && (agt.indexOf('netscape6') != -1)); // new 001120 - abk
	var is_nav6up = (is_nav && is_getElementById);              // new 001121 - abk
*/
	var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
	var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

    var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
    var is_nav5up = (is_nav && is_minor >= 5);

    var is_ie   = (iePos!=-1);
    var is_ie3  = (is_ie && (is_major < 4));

    var is_ie4   = (is_ie && is_major == 4);
    var is_ie4up = (is_ie && is_minor >= 4);
    var is_ie5   = (is_ie && is_major == 5);
    var is_ie5up = (is_ie && is_minor >= 5);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_webtv = (agt.indexOf("webtv") != -1);

    // *** JAVASCRIPT VERSION CHECK ***
    // Useful to workaround Nav3 bug in which Nav3
    // loads <SCRIPT LANGUAGE="JavaScript1.2">.
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0
    else if (is_nav3 || is_opera) is_js = 1.1
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3
    else if (is_nav5 && !(is_nav6)) is_js = 1.4
    else if (is_nav6) is_js = 1.5

    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.

    else if (is_nav && (is_major > 5)) is_js = 1.4
    else if (is_ie && (is_major > 5)) is_js = 1.3
    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);
    var is_aix2  = (agt.indexOf("aix 2") !=-1);
    var is_aix3  = (agt.indexOf("aix 3") !=-1);
    var is_aix4  = (agt.indexOf("aix 4") !=-1);
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var is_mpras    = (agt.indexOf("ncr")!=-1);
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
                 is_sco ||is_unixware || is_mpras || is_reliant ||
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
// additional checks, abk
	var is_anchors = (document.anchors) ? "true":"false";
	var is_regexp = (window.RegExp) ? "true":"false";
	var is_option = (window.Option) ? "true":"false";
	var is_all = (document.all) ? "true":"false";
// cookies - 990624 - abk
	document.cookie = "cookies=true";
	var is_cookie = (document.cookie) ? "true" : "false";
	var is_images = (document.images) ? "true":"false";
	var is_layers = (document.layers) ? "true":"false"; // gecko m7 bug?
// new doc obj tests 990624-abk
	var is_forms = (document.forms) ? "true" : "false";
	var is_links = (document.links) ? "true" : "false";
	var is_frames = (window.frames) ? "true" : "false";
	var is_screen = (window.screen) ? "true" : "false";

// java
	var is_java = (navigator.javaEnabled());


/**
 * Constants for creating number strings.
 */
ORDINAL_SUFFIXES = new Array("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th");
ORDINALS_ONES_TEENS = new Array("zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth");
ORDINALS_TENS = new Array("twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth");
NUMBER_STRINGS_ONES_TEENS = new Array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen");
NUMBER_STRINGS_TENS = new Array("twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety");

/**
 * Constants for the months of the year and days of the week.
 */
MONTH_STRINGS = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
DAY_STRINGS = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");


/**
 * Converts the specified number into an ordinal value.
 *
 * parma:  nValue  the number to convert to an ordinal
 * return:  the ordinal for a given number
 */
function getOrdinalString(nValue)
{
    var strValueOrdinal = "";

    var nAbsValue = Math.abs(nValue);

    // only works for less than 100
    if (nAbsValue < 100)
    {
        if (nAbsValue < 20)
        {
            strValueOrdinal = ORDINALS_ONES_TEENS[nAbsValue];
        }
        else if ((nAbsValue % 10) == 0)
        {
            strValueOrdinal = ORDINALS_TENS[Math.floor(nAbsValue / 10) - 2];
        }
        else
        {
            strValueOrdinal = NUMBER_STRINGS_TENS[Math.floor(nAbsValue / 10) - 2] + "-" + ORDINALS_ONES_TEENS[nAbsValue % 10];
        }
    }
    else
    {
        strValueOrdinal = "one hundredth or greater";
    }

    return strValueOrdinal;
}


/**
 * Sets a cookie to the given value.  All parameters are optional,
 * except the name and value.
 *
 * param:  strName      the name of the cookie to set
 * param:  strValue     the value to set for the cookie
 * param:  dateExpires  the expiration date for the cookie
 * param:  strPath      the path in which to store the cookie
 * param:  strDomain    the domain in which to store the cookie
 * param:  strSecure    true to make the cookie secure, false or null otherwise
 */
function setCookie(strName, strValue, dateExpires, strPath, strDomain, strSecure)
{
  document.cookie = strName + "=" + escape(strValue) +
  ((dateExpires == null) ? "" : "; expires=" + dateExpires.toGMTString()) +
  ((strPath == null) ? "" : "; path=" + strPath) +
  ((strDomain == null) ? "" : "; domain=" + strDomain) +
  ((strSecure == null) ? "" : "; secure");
}


/**
 * Gets a cookie with the specified name.
 *
 * param:  strCookieName  the name of the cookie to return
 * return:  the value of the cookie if it exists, null if it does not
 */
function getCookie(strCookieName)
{
  var strSearch = strCookieName + "=";
  var strDocCookie = document.cookie;

  if (strDocCookie.length > 0)
  {
    var nBegin = strDocCookie.indexOf(strSearch);

    if (nBegin != -1)
    {
      nBegin += strSearch.length;
      var nEnd = strDocCookie.indexOf(";", nBegin);

      if (nEnd == -1) nEnd = strDocCookie.length;

      return unescape(strDocCookie.substring(nBegin, nEnd));
    }
  }

  return null;
}


/**
 * Gets a search parameter with the specified name from the specified search string.
 *
 * param:  strURLSearch  the search portion of the URL in which to look for the parameter key
 * param:  strParamKey   the parameter key to search for
 * return:  the value corresponding to the key, or null if the key cannot be found
 */
function getSearchParamValue(strURLSearch, strParamKey)
{
    var strParamSearch = strParamKey + "=";

    if (strURLSearch.length > 0)
    {
        var nBegin = strURLSearch.indexOf(strParamSearch);

        if (nBegin != -1)
        {
              nBegin += strParamSearch.length;
              var nEnd = strURLSearch.indexOf("&", nBegin);

              if (nEnd == -1) nEnd = strURLSearch.length;

              return strURLSearch.substring(nBegin, nEnd);
        }
    }

    return null;
}


/**
 * Formats the specified date object as a string of the form Mmm DD, YYYY.
 *
 * param:  dateToFormat
 * return:  the date as a string
 */
function formatDateMmDDYYYY(dateToFormat)
{
    return MONTH_STRINGS[dateToFormat.getMonth()] + " " + dateToFormat.getDate() + ", " + dateToFormat.getFullYear();
}


/**
 * Removes all HTML tags from a string.  This is not intelligent wrt quoted strings, escaped strings, etc.
 *
 * param:  strCode  the string with the tags
 * return:  the string without the tags
 */
function removeHTMLTags(strCode)
{
    var strReturn = "";
    var nCurrentIdx = 0;
    var nStartTagIdx;
    var nEndTagIdx;
    
    while (nCurrentIdx < strCode.length)
    {
        // find the beginning of the next tag
        nStartTagIdx = strCode.indexOf("<", nCurrentIdx);

        if (nStartTagIdx != -1)
        {
            // found: add string prior to tag to return value
            strReturn += strCode.substring(nCurrentIdx, nStartTagIdx);
            
            // find the end of the tag
            nEndTagIdx = strCode.indexOf(">", nStartTagIdx);

            if (nEndTagIdx != -1)
            {
                nCurrentIdx = nEndTagIdx + 1;
            }
            else
            {
                nCurrentIdx = strCode.length;
            }
        }
        else
        {
            // not found: add the rest of the string to the return value
            strReturn += strCode.substring(nCurrentIdx, strCode.length);
            
            nCurrentIdx = strCode.length;
        }
    }
        
    return strReturn;
}


/**
 * Converts ", &, <, > to their respective entity names.
 *
 * param:  strSource  the string to escape
 * return:  the converted string
 */
function convertToEntity(strSource)
{
    var strReturn = "";
    var cCurrent;
    
    for (nCharIdx = 0; nCharIdx < strSource.length; nCharIdx++)
    {
        cCurrent = strSource.charAt(nCharIdx);
        
        if (cCurrent == '"')
        {
            strReturn += "&quot;";
        }
        else if (cCurrent == '&')
        {
            strReturn += "&amp;";
        }
        else if (cCurrent == '<')
        {
            strReturn += "&lt;";
        }
        else if (cCurrent == '>')
        {
            strReturn += "&gt;";
        }
        else
        {
            strReturn += cCurrent;
        }
    }

    return strReturn;
}


/**
 * Constant for the date of Sophie's birth.
 */
SOPHIE_BIRTH = new Date(2001, 6, 3);

/**
 * Calculate Sophie's age at the specified date.
 *
 * param:  dateBase  the date used to calculate her age
 * return:  a string indicating her age
 */
function getSophieAge(dateBase)
{
    return getAge(SOPHIE_BIRTH, dateBase);
}


/**
 * Constant for the date of Sophie's birth.
 */
EVA_BIRTH = new Date(2003, 8, 22);

/**
 * Calculate Eva's age at the specified date.
 *
 * param:  dateBase  the date used to calculate her age
 * return:  a string indicating her age
 */
function getEvaAge(dateBase)
{
    return getAge(EVA_BIRTH, dateBase);
}


/**
 * Calculate an age at the specified date.
 *
 * param:  dateBirth  the birth date used to calculate the age
 * param:  dateBase   the date used to calculate the age
 * return:  a string indicating her age
 */
function getAge(dateBirth, dateBase)
{
    var strAge = "";
    var nDays = Math.floor((dateBase.getTime() - dateBirth.getTime()) / (1000 * 60 * 60 * 24));
    if (nDays > 27)
    {
        var nWeeks = Math.floor(nDays / 7);
        if (nWeeks > 13)
        {
            var nMonths = (dateBase.getYear() - dateBirth.getYear()) * 12 + dateBase.getMonth() - dateBirth.getMonth() - ((dateBase.getDate() < dateBirth.getDate()) ? 1 : 0);
            if (nMonths > 23)
            {
                var nYears = Math.floor(nMonths / 12);
                var nMonthsRemainder = nMonths % 12;
                if ((nYears < 12) && (nMonthsRemainder != 0))
                {
                    if (nYears < 4)
                    {
                        strAge = nYears + " year" + ((nYears == 1) ? "" : "s") + " " + nMonthsRemainder + " month" + ((nMonthsRemainder == 1) ? "" : "s");
                    }
                    else
                    {
                        if (nYears < 8)
                        {
                            strAge = nYears + ((nMonthsRemainder < 5) ? "" : ((nMonthsRemainder < 9) ? "&frac12;" : "&frac34;")) + " years";
                        }
                        else
                        {
                            strAge = nYears + ((nMonthsRemainder < 5) ? "" : "&frac12;") + " years";
                        }
                    }
                }
                else
                {
                    strAge = nYears + " year" + ((nYears == 1) ? "" : "s");
                }
            }
            else
            {
                if (nMonths == 12)
                {
                    strAge = "1 year";
                }
                else
                {
                    var dateDaysRemainder = new Date(dateBirth.getYear() + Math.floor((dateBirth.getMonth() + nMonths) / 12), (dateBirth.getMonth() + nMonths) % 12, dateBirth.getDate());
                    var nDaysRemainder = (dateBase.getTime() - dateDaysRemainder.getTime()) / (1000 * 60 * 60 * 24);
                    strAge = nMonths + (((nMonths < 12) && (nDaysRemainder > 12)) ? "&frac12;": "") + " month" + ((nMonths == 1) ? "" : "s");
                }
            }
        }
        else
        {
            strAge = nWeeks + (((nDays % 7) > 3) ? "&frac12;" : "") + " week" + ((nWeeks == 1) ? "": "s");
        }
    }
    else
    {
        strAge = nDays + " day" + ((nDays == 1) ? "": "s");
    }
    
    return strAge;
}


/**
 * Converts the HTML document name into a month-year string.
 *
 * param: strDocName  the name of the document to convert
 */
function docNameToDate(strDocName)
{
    var strDocNameYear = strDocName.substr(strDocName.length - 11, 4);
    var strDocNameMonth = strDocName.substr(strDocName.length - 7, 2);

    return MONTH_STRINGS[parseInt(strDocNameMonth, 10) - 1] + " " + strDocNameYear;
}


/**
 * Returns the string name for the day of the week for the specified index.
 *
 * param:  nDayOfWeekIdx  a zero-based index for the day of the week starting with Sunday
 */
function getDayOfWeekName(nDayOfWeekIdx)
{
    if ((nDayOfWeekIdx >= 0) && (nDayOfWeekIdx < DAY_STRINGS.length))
    {
        return DAY_STRINGS[nDayOfWeekIdx];
    }

    return "";
}


/**
 * Returns a date based on a filepath.  Assumes the filename starts with YYYY-MM-DD_.
 *
 * param:  strFilepath  the path of the file
 * return: a string of the form Mmmm, d, yyyy
 */
function getDateStringFromFilepath(strFilepath)
{
    var strFilename;
    var nLastSeparatorIdx = strFilepath.lastIndexOf('/');
    if (nLastSeparatorIdx == -1)
    {
        strFilename = strFilepath;
    }
    else
    {
        strFilename = strFilepath.substr(nLastSeparatorIdx + 1);
    }
    
    // parse the string YYYY-MM-DD_
    //                  0123456789
    var nYear = parseInt(strFilename.substr(0, 4));
    var nMonth = parseInt(strFilename.substring(((strFilename.charAt(5) != 0) ? 5 : 6), 7));
    var nDay = parseInt(strFilename.substring(((strFilename.charAt(8) != 0) ? 8 : 9), 10));

    var strDateString = "";
    
    if (nYear > 0)
    {
        if ((nMonth > 0) && (nMonth <= MONTH_STRINGS.length))
        {
            strDateString += MONTH_STRINGS[nMonth - 1] + " ";

            if (nDay > 0)
            {
                strDateString += nDay + ", ";
            }
        }
        
        strDateString += nYear;
    }
    
    return  strDateString;
}

