//*****Gets filename of web page ****************

function getfilename(){
	var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
	var filename = location.href.substring(dir.length,location.href.length+1);
	return filename;
}


//*****Determines the date of last file modification ****************

// function getdate(){
//	var date = document.lastModified;
//	return date;
// }


//*****Determines the current page number from navigational arrows ****************

function getcurrentpage(){
	// assumes the filename is of the form XXXNNN.htm where X is alphanumeric and N is numeric

	// determines position of the '.' in the href and substracts 2 to get a two digit number
	var dir = location.href.substring(0,location.href.lastIndexOf('.')-2);

	// determines the page number: starts from the position of first digit and goes
	// to the position of the last '.'

	var currentPageNumber = location.href.substring(dir.length,location.href.lastIndexOf('.'));
	
	// strips the leading 0 if it exists
	 if (currentPageNumber.substring(0,1) == '0') {
	 	currentPageNumber = currentPageNumber.substring(currentPageNumber.length,1);
	 }
	// Return value to the calling script	
	return currentPageNumber;
}


// This section determines the date and then transforms the boring nn/nn/nnnn format into
// a more understandable Month Day, Year format
// "Repurposed" from http://blazonry.com/javascript/datefns.txt
function getDisplayMonth(iMonth) {

    // pass in an month as an integer
    // return the month string

    var monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

    return monthArray[iMonth];
}

function getDisplayDate() {

    // uses getDisplayMonth()
    // returns passed Date formatted nicely
    // Month day, Year  mmmm dd, yyyy

    theDate = new Date(document.lastModified);

    // split into day, month, year
    iDay = theDate.getDate();
    iMonth = theDate.getMonth();
    iYear = theDate.getFullYear();

    sDisplayDate = getDisplayMonth(iMonth) + " " + iDay + ", " + iYear;

    return sDisplayDate;
}