/* File: scripts.js
 * ----------------
 * Written by Michael Liu
 * Summer, 2001.
 * michaelliu@stanford.edu
 *
 */


/* GET DATE
 * ------------------
 * Returns current date and time in form Month day, Year.  Returned value
 * is plain text of current date.
 */

function getDate() {
	date = new Date();
	year = date.getYear();
	if (year < 2000) year += 1900;
	month = date.getMonth();
	switch (month) {
		case 0 : month = "January"; break;
		case 1 : month = "February"; break;
		case 2 : month = "March"; break;
		case 3 : month = "April"; break;
		case 4 : month = "May"; break;
		case 5 : month = "June"; break;
		case 6 : month = "July"; break;
		case 7 : month = "August"; break;
		case 8 : month = "September"; break;
		case 9 : month = "October"; break;
		case 10 : month = "November"; break;
		case 11 : month = "December"; break;
		default : break;
	}
	document.write(month+" "+date.getDate()+", "+year);
}

function getYear() {
	date = new Date();
	year = date.getYear();
	if (year < 2000) year += 1900;
	document.write(year);
}

/* GET RANDOM IMAGE
 * ----------------
 * Returns a random image based on title, image type, and the range of pictures
 * available. The return value is an html image tag with appropriate fields, including
 * 0 border.
 * NOTE: name pictures (0, range-1). For example, passed in range 10 will return picture
 * names from 0-9.
 */

function getRandomImage(title, type, range) {
	var randomNum = Math.floor(Math.random() * range);
	document.write("<img src=\"images/"+title+randomNum+"."+type+"\" border=0 />");
}

// Swaps image from document.images of name 'img' array url
function swapImage(img, active) {
    if (!document.images) return;
    if (active) document.images[img].src = eval(img + 'On.src');
    else document.images[img].src = eval(img + 'Off.src')
}
