/*
$Header: /cvs/genlib/asp/core.js,v 1.14 2007/06/05 18:23:08 ben Exp $
============================================================
When   		Who   	What
------------------------------------------------------------
2000-04-09  jtc   	Added documentation; added time/date format
					functions.
2001-02-09	jtc		added focusOn()
2002-10-09	jtc		merged CCC with VSS repository - added formfocus() back in
2007-02-16	jtc		Five years later... added formfocus() in again after Joseph removed.
============================================================

Notes:

*/

/*	Use as an onLoad function - set focus to a specified element. 
	Standard usage in an asp file would be something like this: 
		onloadfunc = "focusOn(studentform['fname']);";
*/
function formfocus(formname, elname)
{
	/*	This manages to fake out the error handling if formname doesn't exist. */
	if ("object" == eval("typeof document." + formname)) {
		
		/*	Assume the element specified exists at this point. Could be modified to
			do the same thing we're doing above, but usually this would represent
			a programming error, I think. */
		var elstr = "document." + formname + "['" + elname + "']";
//		alert(elstr);
		var element = eval(elstr);
		if (element) element.focus();
	}
}

/*	2000-01-31 - modified so an empty date string returns a blank string. */
/*	2000-04-10 - jtc - modified to use getFullYear() instead of getYear() - started
	running into 2/4 problems in some places. */
function format_date_mdy(datestr)
{
	if (datestr == "") return "";
	var tmpdate = new Date(datestr);
	var format = new String((tmpdate.getMonth() + 1) + "/" + tmpdate.getDate() + "/" + tmpdate.getFullYear());
//	Response.write(format + "<br>");
	return format;
}

function format_time_civhm(datestr)
{
	if (datestr == "") return "";
	var tmpdate = new Date(datestr);
	var hours = tmpdate.getHours();
	var minutes = tmpdate.getMinutes();
	var m = " am";
//	hours = "" + ((hours < 10) ? "0" : "") + hours;
	if (hours > 12){
		hours = (hours - 12)
		m = " pm"
	}
	minutes = "" + ((minutes < 10) ? "0" : "") + minutes;
	var format = new String(hours + ":" + minutes + m);
	return format;
}

/*	Kick off a popup window. 
    2001-08-29 - jnn - added the optional 'extra' parameter in which you can pass a string 
	                   containing any of the other extra properties for the new window
					   including scrollbars, resizable, toolbar, menubar, status...
					   (which are off by default - 'no' - and can be turned on by 
					   setting to 'yes')
*/
function openWindow(url, name, w, h /* , extra */) 
{
  // initialize winX and winY to default values
  // for cases where Screen object isn't supported
  var winX = 0;
  var winY = 0;
  var extra = '';
  
  with (openWindow) {
    if (arguments.length >= 5) extra = new String("," + arguments[4]);
  }

  // only set new values if 4.0 browser
  if (parseInt(navigator.appVersion) >= 4) {
    winX = (screen.availWidth - w)*.5;
    winY = (screen.availHeight - h)*.5;
  }

  popupWin = window.open(url, name, 'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + extra);
  return popupWin;
}



function showInline (elName) {
	var theElement = document.getElementById(elName);
	if (theElement) {
		theElement.style.display = "inline";
	}
}

function hideInline (elName) {
	var theElement = document.getElementById(elName);
	if (theElement) {
		theElement.style.display = "none";
	}
}

function strip_to_digits (instr) {
	var outstr = instr.replace(/\D/g, '');
	return outstr;
}

