// JavaScript
function mail(str, uid, svr) {
	var oat = "@";
	var add = uid + oat + svr;
	return 'mailto:' + str + ' <' + add + '>';
}

function cont(disp) {
	spc=' ';	dot='.';
	cfa='cfa';	edu='edu';
	madd = mail('Chi-kwan'+spc+'Chan', 'ck'+'chan', cfa+dot+'harvard'+dot+edu);
	return '<a href="'+madd+'">'+disp+'</a>';
}

function info() {
	var arr = location.pathname.substring(1,location.pathname.length-1).toLowerCase().split('/');
	var pfx = ''; 
	for(var i = 1; i < arr.length; i++)
		pfx = pfx + '../';
	if(arr.length <= 1)
		return {pfx:pfx, crr:'alstudio', lvl:0};
	else
		return {pfx:pfx, crr:arr[1], lvl:(arr.length - 1)};
}

function link(str) {
	var inf = info();
	var pth = inf.pfx;
	if(str == 'e-mail')
		return cont(str);
	if(str != 'alstudio')
		pth = pth + str;
	if(str == inf.crr) {
		if(inf.lvl > 1)
			return '<a href="' + pth + '"><span class="youarehere">' + str + '</span></a>';
		else
			return '<span class="youarehere">' + str + '</span>';
	}
	else
		return '<a href="' + pth + '">' + str + '</a>';
}

function sect(arr) {
	document.write('[ ' + link(arr[0]));
	for(var i = 1; i < arr.length; i++) {
		document.write(' | ' + link(arr[i]));
	}
	document.write(' ]');
}

function menu() {
	sect(['alstudio']);
	document.write(' - ');
	sect(['profile', 'astrophysics', 'computation', 'gallery', 'calendar']);
        document.write(' - ');
	sect(['e-mail']);
}

function affl() {
	document.write(cont('Chi-kwan Chan')+', '+
		'<a href="http://www.cfa.harvard.edu/itc/index.htm">Institute for Theory and Computation</a>, '+
		'<a href="http://www.cfa.harvard.edu/">Harvard-Smithsonian Center for Astrophysics</a>, '+
		'<a href="http://www.harvard.edu/">Harvard University</a>'
	);
}
