var pjmcd_delay = 10; // update countdown every few seconds
var pjmcd_eventstart = new Date("Oct 23 2005 11:00:00 PDT");
var pjmcd_event = new Date("Oct 23 2005 11:45:00 PDT");

function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}

function update_countdown () {
	myRef = getRefToDiv ('pjmcd_countdown');
	now = new Date();
	if (pjmcd_eventstart > now) {
		seconds = Math.round ((pjmcd_eventstart - now) / 1000);
		message = 'until start';
	} else {
		seconds = Math.round ((pjmcd_event - now) / 1000);
		message = 'left';
	}
	if (seconds < 0) {
		myRef.innerHTML = 'THE END';
		return;
	}
	minutes = Math.floor (seconds / 60);
	seconds %= 60;
	if (minutes > 1) {
		myRef.innerHTML = minutes + ' minutes ' + message;
		// keep ticking
		pjmcd_ID = window.setTimeout("update_countdown();", pjmcd_delay*1000);
	} else {
		myRef.innerHTML = '<font color=red>Time ' + message + ': ' + minutes + ':' + (seconds<10?'0':'') + seconds + '</font>';
		pjmcd_ID = window.setTimeout("update_countdown();", 1000);
	}
}

function display_countdown ()
{
	html_code = '<div id="pjmcd_countdown">initialize</div>';
	document.write (html_code);
	update_countdown();
}

function smarter_reload (myAnchor) {
// reload doesn't seem to work
	pjmrefresh_ID =
		window.setTimeout ("window.location.reload(true);", 1000);
	window.location.hash = myAnchor;
}

