/* =================================================== *
 * GET DAY OF WEEK, MONTH, DAY, YEAR
 * =================================================== */

var d         = new Date();
var weekday   = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname = new Array("January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var daynum    = new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");

/* =================================================== *
 * GET TIME
 * =================================================== */

var time      = new Date();
var hours     = time.getHours();
var minutes   = time.getMinutes();
var seconds   = time.getSeconds();

timeDay       = (hours   <  12 ? "AM" : "PM");
hours         = (hours   <= 12 ? hours : hours - 12);
hours         = (hours   <  10 ? "0" : "") + hours;
hours         = (hours   == 00 ? "12" : hours);
minutes       = (minutes <  10 ? "0" : "") + minutes;
seconds       = (seconds <  10 ? "0" : "") + seconds;

var clock     = hours + ":" + minutes + " " + timeDay;
	
/* =================================================== *
 * DISPLAY DAY, DATE, AND TIME (MASTHEAD)
 * =================================================== */

function displayDayDateTime() {
	document.write(weekday[d.getDay()] + " &#8226; ");
	document.write(monthname[d.getMonth()] + " ");
	document.write(daynum[d.getDate()-1] + ", ");
	document.write(d.getFullYear() + " &#8226; ");
	document.write(clock);
	}
	
/* =================================================== *
 * DISPLAY SCREEN ID
 * =================================================== */

function fileName() { // extracts the current filename and returns it as a string
	
	var fileName = location.href.substring(location.href.lastIndexOf("/") + 1);
	
	if(fileName.indexOf("?") != -1)
		fileName = fileName.substring(0,fileName.indexOf("?"));
	if(fileName.indexOf("#") != -1)
		fileName = fileName.substring(0,fileName.indexOf("#"));
	
	return(fileName);
	}

	
/* =================================================== *
 * POPUP WINDOW: GLOBAL VARIABLE(S)
 * =================================================== */

var POPWIN  = null;

/* =================================================== *
 * POPUP WINDOW: CLOSE EXISTING POPUP WINDOW
 * =================================================== */

function closePopWin(theWin) {
  if ((theWin != null) && (theWin.closed != true))
  	theWin.close();
	}

/* =================================================== *
 * POPUP WINDOW: DISPLAY POPUP WINDOW
 * =================================================== */

function popWindow(loc,w,h) {

  closePopWin(POPWIN);	// closes an existing popup window if user opens 
                				// new window before closing existing window
	
	if (!(w)) var winW = screen.width - 100; 
	else      var winW = w + 20;
	if (!(h)) var winH = screen.height - 150; 
	else      var winH = h + 20;
		
	var params  = "width=" + winW + ",height=" + winH + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50";

	POPWIN = window.open(loc,"FHSC",params);
	POPWIN.focus;
	}

/* =================================================== *
 * POPUP WINDOW
 * =================================================== */

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if (window.focus) {win.focus()}
}


