// JavaScript Document

var	total = 557;
var num;


function opener() {
	doTime();
	doDate();
	RandImg();
}

function showDate() {
	doTime();
	doDate();
}

function doTime() {
	d = new Date();
	h = d.getHours();
	m = d.getMinutes();
	if (h > 12) {h = h - 12}
	time = h + ((m<10) ? ":0" : ":") + m ;
	document.getElementById('txtTime').innerHTML = time;
	clocktime = setTimeout("doTime()",1000);
	
}

function doDate() {
	days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	today = new Date();
	thisDay = today.getDay();
	thisDate = today.getDate();
	thisMonth = today.getMonth();
	
	todayDay = days[thisDay];
	todayMonth = months[thisMonth];
	document.getElementById('txtDate').innerHTML = todayDay + ", " + todayMonth + " " + thisDate;

}

function rand(size) {
	return Math.round(Math.random() * size);
}

function checker() {
		if (num >= 100) {
			document.images.imgSwap.src= "images/pics/MM" + num + ".jpg";	
		} else if (num >= 10) {
			document.images.imgSwap.src= "images/pics/MM0" + num + ".jpg";
		} else {
			document.images.imgSwap.src= "images/pics/MM00" + num + ".jpg";
		}	
}

function RandImg() {
	//need to find size of pics folder, set as var first- total
		//total = 369;
		num = rand(total) + 1;
		checker();
		//return num;
}

function next() {
	num++;
	if (num > total) {
		num = 1;
		document.images.imgSwap.src= "images/pics/MM001.jpg";
		} else {
		checker();
		}
}

function previous() {
	num--;
	if (num <= 0) {
		num = total;
		document.images.imgSwap.src= "images/pics/MM" + total + ".jpg";
		} else {
		checker();
		}
	
}
