function dspDate()
{
	// Create an array of day names.
	var dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	// Create an array of month names.
	var monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	// Create a date object that default to current time.
	var d = new Date();
	var day = d.getDate();
	var dayPostfix = "";
	if (day > 29)
		day -= 30;
	else if (day > 19)
		day -= 20;
	if (day == 1)
		dayPostfix = "st";
	else if(day == 2)
		dayPostfix = "nd";
	else if(day == 3)
		dayPostfix = "rd";
	else
		dayPostfix = "th";
	var year = d.getYear();
	if (year < 2000)
		year += 1900;
	// display the date in long date format.
	document.write(dayName[d.getDay()] + ", " + monName[d.getMonth()] + " " + d.getDate() + dayPostfix + ", " + year);
}

function contactMe()
{
	var name = "%65%6D%61%63%6B";
	var domain = "%69%63%61%2E%63%6F%6D"; 
	document.write('<li><a href=\"mailto:' + name + '@' + domain +'?subject=[EMO Web-Query]\" title=\"Send me an email (no Spam please).\">Contact</a>');
}

function getPageName() {
	var sUrl = document.URL;
	var iPos = sUrl.lastIndexOf("/") + 1;
	sUrl = sUrl.substr(iPos);
	iPos = sUrl.lastIndexOf("?");
	if(iPos != -1)
		sUrl = sUrl.substring(0, iPos);
	iPos = sUrl.lastIndexOf("#");
	if(iPos != -1)
		sUrl = sUrl.substring(0, iPos);
	return sUrl;
}
function getComment(no) {
	location.href=getPageName()+'#comment'+no;
}

// Style sheet stuff
function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && 
				a.getAttribute("title") && 
				a.getAttribute("media") !="print") {
			a.disabled = true;
			if(a.getAttribute("title") == title)
				a.disabled = false;
		}
	}
}
function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}
function getPreferredStyleSheet() {
	return ('main');
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function padZero(n) {
	return ((n <= 9) ? ("0" + n) : n);
}
addEvent(window, "DOMContentLoaded", function () {
	// Because Safari and Konqueror will not behave with larger than container background images.
//	if(/KHTML|WebKit/i.test(navigator.userAgent)) {
//		document.body.className = "webkit";
//	}
	var as = document.getElementById("nav").getElementsByTagName("a");
	if(!as) return;
	if(location.href.indexOf("\.nsf") == -1){
		as[0].className="current";
		return;
	}
	
	var curHref = "";
	var iPos = location.href.indexOf("?");
	
	if(iPos == -1){
		curHref = location.href;
	}else{
		curHref = location.href.substring(0, iPos);
	}
	iPos = curHref.indexOf("#");
	if(iPos != -1){
		curHref = curHref.substring(0, iPos);
	}
	for(var j = 0; j < 2; j++){
		for(var i = 0; i < as.length; i++){
			if(as[i].href.indexOf("\/archive\?") == -1){
				var tmpHref = as[i].href;
			
				iPos = tmpHref.indexOf("?");
				if(iPos != -1){
					tmpHref = tmpHref.substring(0, iPos);
				}
				iPos = tmpHref.indexOf("#");
				if(iPos != -1){
					tmpHref = tmpHref.substring(0, iPos);
				}
//if(i == 2){ alert(tmpHref == curHref); alert("("+curHref+")\n("+tmpHref+")"); }
				if(tmpHref == curHref){
					as[i].className = "current";
					return;
				}
			}else if(as[i].href == location.href){
				as[i].className = "current";
				return;
			}
		}
		if(document.getElementById("navigation"))
			as = document.getElementById("navigation").getElementsByTagName("a");
	}
});
