	Date.prototype.theDate           = _getTheDate;
	Date.prototype.theProgDate       = _getProgDate;

	Date.prototype.theTime           = _getTheTime;
	Date.prototype.clockTime         = _clockTime;
	Date.prototype.theProgTime       = _getProgTime;
	Date.prototype.getMilitaryTime   = _getMilTime;
	Date.prototype.getTimeZone       = _getTimeZone;

	Date.prototype.getJulian         = _getJulian;
	Date.prototype.fromJulian        = _fromJulian;

	Date.prototype.getTimeImage      = _getTimeImage;

	Date.prototype.getWeekOf         = _getWeekOf;
	Date.prototype.getLongMonthName  = _getLongMonthName;
	Date.prototype.getShortMonthName = _getShortMonthName;
	Date.prototype.getLongDayName    = _getLongDayName;
	Date.prototype.getShortDayName   = _getShortDayName;

	Date.prototype.getDayOfYear      = _getDayOfYear;
	Date.prototype.getWeekOfYear     = _getWeekOfYear;
	Date.prototype.getMonthOfYear    = _getMonthOfYear;

	Date.prototype.addDays           = _AddDaysToDate;
	Date.prototype.addMonths         = _AddMonthsToDate;
	Date.prototype.addYears          = _AddYearsToDate;

	function _getLongMonthName()
	{
		var strMonthName = new Array
			(   "January",   "February",   "March",    "April",
				"May",        "June",      "July",     "August",
				"September",  "October",   "November", "December"
			);
	
		return strMonthName[this.getMonth()];
	}

	function _getShortMonthName()
	{
		var strMonthName = new Array
			(   "Jan",   "Feb",   "Mar",   "Apr",   "May",   "Jun",
				"Jul",   "Aug",   "Sept",  "Oct",   "Nov",   "Dec"
			);
	
		return strMonthName[this.getMonth()];
	}

	function _getLongDayName()
	{
		var strDayName = new Array
			(   "Sunday",   "Monday",   "Tuesday",   "Wednesday",
				"Thursday", "Friday",   "Saturday"
			)

		return strDayName[this.getDay()];
	}

	function _getShortDayName()
	{
		var strDayName = new Array
			(   "Sun",    "Mon",   "Tues",   "Wed",
				"Thurs",  "Fri",   "Sat"
			)
	
		return strDayName[this.getDay()];
	}

	function _getWeekOf()
	{
		sunday = ((arguments[0]==null) || (!arguments[0])); // Check for optional argument

		return (new Date(this - ((this.getDay() - ((sunday) ? 0 : 1)) *24*60*60*1000)));
	}

	function _getDayOfYear()
	{
	     var strDate = new Date(this.getTime());
	     var strYear = new Date(strDate.getYear(),0,1);
	     strYear = strYear.getTime() - (strYear.getDay()-1)*(24*60*60*1000);

	     return(Math.ceil((strDate.getTime() - strYear)/(24*60*60*1000)));
	}

	function _getWeekOfYear()
	{
	     var strDate = new Date(this.getTime());
	     var strYear = new Date(strDate.getYear(),0,1);
	     strYear = strYear.getTime() - (strYear.getDay()-1)*(24*60*60*1000);

	     return(Math.ceil((strDate.getTime() - strYear)/(7*24*60*60*1000)));
	}

	function _getMonthOfYear()
	{
	     var strDate = this.getMonth() + 1;

	     return(strDate)
	}

	function _AddDaysToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + 1;
		var strDay   = this.getDate() + inputVal;
		var strYear  = this.getFullYear();

		var strHour    = this.getHours();
		var strMinutes = this.getMinutes();
		var strSeconds = this.getSeconds();

		return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _AddMonthsToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + inputVal;
		var strDay   = this.getDate();
		var strYear  = this.getFullYear();

		var strHour    = this.getHours();
		var strMinutes = this.getMinutes();
		var strSeconds = this.getSeconds();

		return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _AddYearsToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + 1;
		var strDay   = this.getDate();
		var strYear  = this.getFullYear() + inputVal;

		var strHour    = this.getHours();
		var strMinutes = this.getMinutes();
		var strSeconds = this.getSeconds();

		return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _AddHoursToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + 1;
		var strDay   = this.getDate();
		var strYear  = this.getFullYear();

		var strHour    = this.getHours() + inputVal;
		var strMinutes = this.getMinutes();
		var strSeconds = this.getSeconds();

	return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _AddMinutesToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + 1;
		var strDay   = this.getDate();
		var strYear  = this.getFullYear();

		var strHour    = this.getHours();
		var strMinutes = this.getMinutes() + inputVal;
		var strSeconds = this.getSeconds();

		return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _AddSecondsToDate( inputVal )
	{
		if ( ! inputVal )
			return this

		var strMonth = this.getMonth() + 1;
		var strDay   = this.getDate();
		var strYear  = this.getFullYear();

		var strHour    = this.getHours();
		var strMinutes = this.getMinutes();
		var strSeconds = this.getSeconds() + inputVal;

		return new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds )
	}

	function _getTheDate()
	{
		var strMonth = this.getMonth() + 1;
		var strDay = this.getDate();
		var strYear = this.getFullYear();
		return strMonth + '/' + strDay + '/' + strYear
	}

	function _getProgDate()
	{
		var strMonth = this.getMonth() + 1;
		var strDay = this.getDate();
		var strYear = this.getFullYear();
		return strYear + '' + strMonth + '' + strDay
	}

	function _getTheTime()
	{
		var intHour      = this.getHours();        // Get Hour
		var intCurMinute = this.getMinutes();      // Get Minutes
		var intCurSecond = this.getSeconds();      // Get Seconds
		var strTimeZone  = this.getTimeZone();     // Get Time Zone

	    var strCurHour   = ((intHour      >  12) ? intHour - 12        : intHour);          // fix military time
	    	strCurHour   = ((strCurHour   ==  0) ? strCurHour = 12     : strCurHour);       // fix midnight time
		    strCurHour   = ((strCurHour   <  10) ? '0'  + strCurHour   : strCurHour);       // Add ZERO, maybe
		    intCurMinute = ((intCurMinute <  10) ? '0'  + intCurMinute : intCurMinute);     // Add ZERO, maybe
		    intCurSecond = ((intCurSecond <  10) ? '0'  + intCurSecond : intCurSecond);     // Add ZERO, maybe
		var strAmpm      = ( intHour      >= 12) ? "pm"                : "am";              // determine PM or PM

		strCurTime  = strCurHour  + ":" + intCurMinute  + ":" + intCurSecond + " ";
		strCurTime += strAmpm     + " " + strTimeZone;

		return strCurTime;     // the time string 'HH:MM:SS AM|PM'
	}

	function _getProgTime( returnLength )
	{
		if ( ! returnLength  || returnLength > 6 )
			returnLength = 6;

		var milTime = this.getMilitaryTime() + '';
			milTime = milTime.replace ( /:/g, '' );  // strip out the colons

		return milTime.substring ( 0, returnLength )
	}

	function _getMilTime()
	{
		var intHour      = this.getHours();        // Get Hour
		var intMinute    = this.getMinutes();      // Get Minutes
		var intSecond    = this.getSeconds();      // Get Seconds
		var strTimeZone  = this.getTimeZone();     // Get Time Zone

	    var intHour   = ((intHour   <  10) ? '0' + intHour   : intHour);    // Add ZERO, maybe
		    intMinute = ((intMinute <  10) ? '0' + intMinute : intMinute);  // Add ZERO, maybe
		    intSecond = ((intSecond <  10) ? '0' + intSecond : intSecond);  // Add ZERO, maybe

		return intHour  + ":" + intMinute  + ":" + intSecond + " "+ strTimeZone;
	}

	function fromMilitaryTime ( milTime )
	{
		if ( ! milTime )
			return null

		milTime = new String ( milTime );

		milTime = milTime.replace ( /:/g, '');

		intHour   = new Number ( milTime.substr( 0,2 ) );
		intMinute = new Number ( milTime.substr( 2,2 ) );
		intSecond = new Number ( milTime.substr( 4,2 ) );

		return new Date( 0, 0, 1, intHour, intMinute, intSecond )
	}


function _clockTime ( clockTime )
{
	clockTime.toLowerCase();

	var regEx = /^(\d*):(\d*):?(\d*)\s*([AP])m?/i;
	var myResults = clockTime.match( regEx );

	if ( ! myResults )
		return null

	var lvl = myResults[4];
	var hr  = new Number ( myResults[1] );
	var min = new Number ( myResults[2] );
	var sec = new Number ( myResults[3] );

	if ( lvl == 'p' )
	{
		if ( hr != 12 )
		{
			hr = hr + 12;
		}
	}
	else if ( hr == 12 )
	{
		hr = 0;
	}

	this.setHours( hr );
	this.setMinutes( min );
	this.setSeconds( sec );
	
}

    function _getTimeZone()
	{
		var strDate = new Date(this);

			strDate = strDate.toString();

			strDate = strDate.split(" ");

		return strDate[4]
	}

	function _getTimeImage ( strImgPath )
	{
		if ( ! strImgPath )
			return 'Please indicate Path to Images.'

		var strCurTime = this.theTime()

		var strImgTime = '';

		var OpenImg = '<IMG SRC="' + strImgPath + 'dg-'

		for (Count = 0; Count < strCurTime.length; Count++)
		{
			myTemp = strCurTime.substring(Count, Count+1);

			if (myTemp == ':') myTemp = 'c'
			if (myTemp == ' ') myTemp = 'b'
			if (Count  ==  10 ) break	            // we will not do 'm' in AM|PM or TZ

			strImgTime += OpenImg + myTemp + '.gif">';
		}

		return strImgTime;           // string of HTML code for display time image
	}

	function fromJulian ( jd )
	{
		var jdate_tmp;
		var m, d, y;

		jdate_tmp = jd - 1721119;

		y = parseInt ( (4 * jdate_tmp - 1 ) / 146097 );

		jdate_tmp = 4 * jdate_tmp - 1 - 146097 * y;

		d = parseInt ( jdate_tmp / 4 );

		jdate_tmp = parseInt ( ( 4 * d + 3 ) / 1461 );

		d = 4 * d + 3 - 1461 * jdate_tmp;
		d = parseInt( ( d + 4 ) / 4 );
		m = parseInt ( ( 5 * d - 3 ) / 153 );
		d = 5 * d - 3 - 153 * m;
		d = parseInt ( ( d + 5 ) / 5 );
		y = 100 * y + jdate_tmp;

		if ( m < 10 )
		{
			m += 3;
		}
		else
		{
			m -= 9;
			++y;
		}

		return m + '/' + d + '/' + y
	}

	function _fromJulian ( jDate )
	{
		if ( ! jDate )
			return this

		return new Date ( fromJulian( jDate ) );
	}

	function toJulian ( inputDate )
	{
		if ( ! inputDate )
		{
			var myDate = new Date();
		}
		else
		{
			var myDate = new Date( inputDate );
		}

		return myDate.getJulian();
	}	// toJulian ( inputDate )

	function _getJulian ( )
	{
		// Retrieve the Date pieces
		var m = this.getMonth() + 1;    // ZERO based function
		var d = this.getDate();
		var y = this.getFullYear();

		if (m > 2) 
		{
			m -= 3;
		}
		else
		{
			m += 9;
			--y;
		}

		var c = parseInt ( y / 100 );
		var ya = y - ( 100 * c );
		var jd = parseInt ( ( 146097 * c      ) / 4 ) +
			     parseInt ( ( 1461   * ya     ) / 4 ) +
			     parseInt ( ( 153    * m  + 2 ) / 5 ) + d + 1721119;

		return jd;
	}	// _getJulian ( )
