//***
//** globals
//***

// preload the icon rollover images
var priIcon       = new Object();
priIcon.msg        = "Print Body in Black/White";
priIcon.click     = new Image();
priIcon.click.src = "images/header/printon.gif"
priIcon.over      = new Image();
priIcon.over.src  = "images/header/printover.gif"
priIcon.off       = new Image();
priIcon.off.src   = "images/header/printoff.gif"
var emlIcon       = new Object();
emlIcon.msg       = "Email me";
emlIcon.click     = new Image();
emlIcon.click.src = "images/header/emailon.gif"
emlIcon.over      = new Image();
emlIcon.over.src  = "images/header/emailover.gif"
emlIcon.off       = new Image();
emlIcon.off.src   = "images/header/emailoff.gif"

//***
//** functions
///**

///////////////////////////////////////////////////////////////////////
// IconRollover
// IN: icon, state
// Determines by state what image to show for the specified icon
// POST: correct function has been performed
//
function IconRollover(icon,state){
	if( state == 'over' ){
		document.images[icon].src = NameToIcon(icon).over.src;
		StatBar(NameToIcon(icon).msg,true);
	} else if( state == 'click'){
		document.images[icon].src = NameToIcon(icon).click.src;
	} else {
		document.images[icon].src = NameToIcon(icon).off.src;
		StatBar("",false);
	}
}

///////////////////////////////////////////////////////////////////////
// RollOver
// IN: int || string
//     string
// shows comments for current hot image in comments area or
// default blank image if the mouse is not over a link
// NOTE: if an int is passed as 1rst arg, it is used as the index
//       if string, it is converted to the index
// PRE:  arg1 is within bounds or if string, is a valid name for a page
//       object
// POST: correct comment is displayed
//
function RollOver(index,state){
	var pos = (typeof index == 'number' ? index : NameToIndex(index));
	if( state ){
		StatBar(arrPage[pos].title);
		document.images['comment'].src = arrPage[pos].pic.comment;
		
	} else {
		StatBar('');
		document.images['comment'].src = comOut.src;
	}
}

//***
//** utility
//***

///////////////////////////////////////////////////////////////////////
// NameToIcon
// IN:  string
// RET: object
// Deteremines the icon object based on the name
// POST: FCTVAL = icon object specified by name null if non-existent
//
function NameToIcon(name){
	switch(name){
		case 'print' :
			return priIcon; break;
		case 'email' :
			return emlIcon; break;
		default :
			return null; break;
	}
}

///////////////////////////////////////////////////////////////////////
// StatBar
// IN: string
// displays str in the status bar
// POST: str is displayed in status bar
// NOTE: return false after calling
//
function StatBar(str){
	window.status = str;
}

//***
//** others
//***

///////////////////////////////////////////////////////////////////////
// WriteDate
// Writes the current date and time seperated by a paragraph break
// Post: Current date written at current location in page
//
function WriteDate(){
	var dte = new Date;
	var dteString = (dte.getMonth() + 1) + "/" + dte.getDate() + "/" + dte.getYear();
	document.write(dteString);
	document.write("<br>");
	dteString = dte.getHours() + ":" + (dte.getMinutes() < 10 ? "0" : "") + dte.getMinutes();
	document.write(dteString);
}
