function fone(what) {
	p = "(";
	p += what.substr(7,3);
	p += ") ";
	p += what.substr(4,3);
	p += "-";
	p += what.substr(0,4);
	document.write(p);
}

function decode(who) {
	who = who.replace(/2/g, 'd');
	who = who.replace(/3/g, 'e');
	who = who.replace(/4/g, 'a');
	who = who.replace(/0/g, '@');
	who = who.replace(/8/g, '.');
	who = who.replace(/9/g, 'net');
	who = who.replace(/7/g, 'com');
	return who;
}

function send(who) {
	document.location.href= 'mailto:' + decode(who) + 
		'?subject=Wedsite mail';
}

function sendrsvp(who) {
	document.location.href = 'mailto:' + decode(who) + 
		'?subject=Wedding RSVP from emilyandchristopher.com&body=' +
		'Kindly respond by the first of August. Please indicate ' +
		'whether you will be able to attend, and the names of those ' +
		'who will be attending:';
}

function pernt(who) {
	document.write(decode(who));
}

function WriteCountdown() {
	now = new Date();
	then = new Date(0);
	then.setUTCFullYear(2002);
	
	then.setUTCMonth(7); // months count from zero; 7 is August
	then.setUTCDate(31);
	
//	for testing:
//	then.setUTCMonth(6); // months count from zero; 7 is August
//	then.setUTCDate(24);

	then.setUTCHours(11 + 5); // +5 hours from EST to UTC
	diff = new Date(then - now);
	diff = Math.floor(diff.valueOf()/1000/24/60/60);
	if (diff > 1) {
		document.write("We have " + diff + " days left to prepare.");
	} else if (diff == 1) {
		document.write("We have one crazy day left to prepare.");
	} else if (diff == 0) {
		document.write("It&rsquo;s here!");
	} else if (diff > -7) {
		document.write("Leave us alone! We are in an <a href=\"javascript:alert('Rhode Island, if you must know.  :)');\">undisclosed location</a>!");
	} else {
		diff = 0 - diff;
		document.write("Emily and Christopher Hansen have been married " + diff + " blissful days.");
	}
	document.write(" Ack!");
}

function over(which) {
	which.style.backgroundColor = "#857991";
	which.style.border = "#341b67 solid 1px";
	which.style.color = "white";
}

function down(which) {
	which.style.backgroundColor = "#341b67"
}

function out(which) {
	which.style.backgroundColor = "#eee";
	which.style.border = "#eee solid 1px";
	which.style.color = "#aaa";
}

function WriteNavbar(which, when) {
	document.write('<div class="updated">Last updated ' + when + '</div>');
	document.write('<table width=100% cellspacing=2 cellpadding=2 class="bartab">');
	document.write('	<tr>');
	document.write('		<td id="wedding" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'index.html\'">Wedding');
	document.write('		</td>');
	document.write('		<td id="rsvp" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'rsvp.html\'">RSVP');
	document.write('		</td>');
	document.write('		<td id="hotels" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'hotels.html\'">Hotels');
	document.write('		</td>');
	document.write('		<td id="maps" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'maps.html\'">Maps');
	document.write('		</td>');
	document.write('		<td id="directions" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'directions.html\'">Directions');
	document.write('		</td>');
	document.write('	</tr>');
	document.write('	<tr>');
	document.write('		<td id="photos" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"');
	document.write('			onclick="location.href=\'photos.html\'">Photos');
	document.write('		</td>');
	document.write('		<td id="touristy" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'touristy.html\'">Touristy');
	document.write('		</td>');
	document.write('		<td id="rolodex" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'rolodex.html\'">Rolodex');
	document.write('		</td>');
	document.write('		<td id="registry" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
	document.write('			onclick="location.href=\'registry.html\'">Registry');
	document.write('		</td>');
	document.write('		<td id="home" width="20%" class="barlink"');
	document.write('			onmouseover="javascript:over(this)"');
	document.write('			onmousedown="javascript:down(this)" ');
	document.write('			onmouseout="javascript:out(this)"	');
//	document.write('			onclick="location.href=\'http://www.emilyandchristopher.com\'"><span style="color: #666">e</span>and<span style="color: #666">c</span>.com');
	document.write('			onclick="location.href=\'http://www.emilyandchristopher.com\'">Web Home');
	document.write('		</td>');
	document.write('	</tr>');
	document.write('</table>');
	
	var w = document.getElementById(which);
	w.style.backgroundColor = "#341b67";
	w.style.border = "#341b67 solid 1px";
	w.style.color = "white";
	w.style.cursor = "auto";
	w.onclick = "";
	w.onmouseover = "";
	w.onmouseout = "";
}
