/******************************************** 
 *
 * Date.js
 *
 * Copyright (c) Perific AB 2003
 *
 *
 ********************************************/
 
/********************************************
 *
 * Writes todays date in the format "September 3, 2003"
 *
 ********************************************/
function date() {
	var months = new Array(13);
	months[1] = "January";
	months[2] = "February";
	months[3] = "March";
	months[4] = "April";
	months[5] = "May";
	months[6] = "June";
	months[7] = "July";
	months[8] = "August";
	months[9] = "September";
	months[10] = "October";
	months[11] = "November";
	months[12] = "December";

	var dateObj = new Date()
	var lmonth = months[dateObj.getMonth() + 1]
	var date = dateObj.getDate()
	var fyear = dateObj.getYear()
	
	document.write( lmonth + " " + date + ", " + fyear )
}

/********************************************
 *
 * Writes modified date of the document in the format "September 3, 2003"
 *
 ********************************************/
function modifiedDate() {
	var months = new Array(13);
	months[1] = "January";
	months[2] = "February";
	months[3] = "March";
	months[4] = "April";
	months[5] = "May";
	months[6] = "June";
	months[7] = "July";
	months[8] = "August";
	months[9] = "September";
	months[10] = "October";
	months[11] = "November";
	months[12] = "December";
	var dateObj = new Date(document.lastModified);
	var lmonth = months[dateObj.getMonth() + 1];
	var date = dateObj.getDate();
	var fyear = dateObj.getYear();
	
	document.write( lmonth + " " + date + ", " + fyear )
}

/********************************************
 *
 * Writes the year in the format "2003"
 *
 ********************************************/
function year() {
	var date;

	date = new Date();
	
	document.write( date.getFullYear() );
}

/********************************************
 *
 * Return days left to "date"
 *
 ********************************************/
function getDaysToDate( year, month, day ) {
	today = new Date
	futureDate = new Date( year, month - 1, day )
	
	thisYear = today.getYear()
	if ( thisYear < 1900 ) {
		thisYear = thisYear + 1900
	}
	today.setYear( thisYear )
	days = Math.floor(futureDate.getTime()/(1000*60*60*24)) - Math.floor(today.getTime()/(1000*60*60*24))
	
	return days + 1
}

/********************************************
 *
 * Writes days left to "date"
 *
 ********************************************/
function daysToDate( year, month, day ) {
	document.write( getDaysToDate( year, month, day) )
}
	
        

