var css = document.createElement("style");
css.type = "text/css";
css.media = "screen";
var style = "#register {visibility: hidden;} h1 {visibility: hidden;}";
if (css.styleSheet) {
	css.styleSheet.cssText = style;
} else {
	css.appendChild(document.createTextNode(style));
}
document.getElementsByTagName("head")[0].appendChild(css);

function getElement(id) {
	return document.getElementById(id);
}

function setWelcome() {
	var
		now = new Date(),
		minutes = now.getMinutes(),
		hours = now.getHours(),
		date = now.getDate(),
		month = now.getMonth(),
		year = now.getFullYear(),
		welcome;
	
	if (hours>=0 && hours<12) {
		welcome = "Morning";
	}
	if (hours>=12 && hours<17) {
		welcome = "Afternoon";
	}
	if (hours>=17) {
		welcome = "Evening";
	}
	
	if (month == 0) {
		month = "January";
	}
	if (month == 1) {
		month = "February";
	}
	if (month == 2) {
		month = "March";
	}
	if (month == 3) {
		month = "April";
	}
	if (month == 4) {
		month = "May";
	}
	if (month == 5) {
		month = "June";
	}
	if (month == 6) {
		month = "July";
	}
	if (month == 7) {
		month = "August";
	}
	if (month == 8) {
		month = "September";
	}
	if (month == 9) {
		month = "October";
	}
	if (month == 10) {
		month = "November";
	}
	if (month == 11) {
		month = "December";
	}
	getElement("welcomeTitle").innerHTML = "Good " + welcome;
	getElement("register").style.visibility = "visible";
	
	var suffix = "th";
	if (date == 1 || date == 11 || date == 21 || date == 31) {
		suffix = "st";
	}
	if (date == 2 || date == 12 || date == 22) {
		suffix = "nd";
	}
	if (date == 3 || date == 13 || date == 23) {
		suffix = "rd";
	}
	if (minutes<10) {
		minutes = "0" + minutes.toString();
	}
	getElement("bodyDate").innerHTML = hours + ":" + minutes + ", " + date + suffix + " " + month;
}

function updateWelcome() {
	window.setInterval("setWelcome()", 1000);
}