<!-- Original:  Kedar R. Bhave (softricks@hotmail.com) -->
<!-- Web Site:  http://www.softricks.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->


var weekend = [0,6];
var fridayDay = [5];
var sundayDay = [0];
var weekendColor = "#e0e0e0";
var fridayColor = "blue";
var fontface = "Verdana";
var fontsize = 2;

var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

Calendar.Months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
	if ((p_month == null) && (p_year == null))	return;

	if (p_WinCal == null)
		this.gWinCal = ggWinCal;
	else
		this.gWinCal = p_WinCal;
	
	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}

	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;

function Calendar_get_month(monthNo) {
	return Calendar.Months[monthNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	
	
	
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return Calendar.DOMonth[monthNo];
	
		return Calendar.lDOMonth[monthNo];
	} else
		return Calendar.DOMonth[monthNo];
}

function Calendar_print() {
	ggWinCal.print();
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	
	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	
	// Begin Table Drawing code here..
	vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
	
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;
	
	vCode = vCode + "</TABLE>";
	
	return vCode;
}

Calendar.prototype.show = function() {
	var vCode = "";
	
	this.gWinCal.document.open();

	// Setup the page...
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("</head>");

	this.wwrite("<body " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");
	this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
	this.wwriteA(this.gMonthName + " " + this.gYear);
	this.wwriteA("</B><BR>");

	// Show navigation buttons
	var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
	var prevMM = prevMMYYYY[0];
	var prevYYYY = prevMMYYYY[1];

	var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
	var nextMM = nextMMYYYY[0];
	var nextYYYY = nextMMYYYY[1];
	
	this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
		");" +
		"\"><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\"><<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\">><\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
		");" +
		"\">>><\/A>]</TD></TR></TABLE><BR>");

	// Get the complete calendar code for the month..
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);

	this.wwrite("</font></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.showY = function() {
	var vCode = "";
	var i;
	var vr, vcxf, vx, vy;		// Row, Column, X-coord, Y-coord
	var vxf = 285;			// X-Factor
	var vyf = 200;			// Y-Factor
	var vxm = 10;			// X-margin
	var vym;				// Y-margin
	if (isIE)	vym = 75;
	else if (isNav)	vym = 25;
	
	this.gWinCal.document.open();

	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("<style type='text/css'>\n<!--");
	for (i=0; i<12; i++) {
		vc = i % 3;
		if (i>=0 && i<= 2)	vr = 0;
		if (i>=3 && i<= 5)	vr = 1;
		if (i>=6 && i<= 8)	vr = 2;
		if (i>=9 && i<= 11)	vr = 3;
		
		vx = parseInt(vxf * vc) + vxm;
		vy = parseInt(vyf * vr) + vym;

		this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
	}
	this.wwrite("-->\n</style>");
	this.wwrite("</head>");

	this.wwrite("<body " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");
	this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
	this.wwrite("Year : " + this.gYear);
	this.wwrite("</B><BR>");

	// Show navigation buttons
	var prevYYYY = parseInt(this.gYear) - 1;
	var nextYYYY = parseInt(this.gYear) + 1;
	
	this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\">>><\/A>]</TD></TR></TABLE><BR>");

	// Get the complete calendar code for each month..
	var j;
	for (i=11; i>=0; i--) {
		if (isIE)
			this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
		else if (isNav)
			this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

		this.gMonth = i;
		this.gMonthName = Calendar.get_month(this.gMonth);
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
		this.wwrite(vCode);

		if (isIE)
			this.wwrite("</DIV>");
		else if (isNav)
			this.wwrite("</LAYER>");
	}

	this.wwrite("</font><BR></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.wwrite = function(wtext) {
	this.gWinCal.document.writeln(wtext);
}

Calendar.prototype.wwriteA = function(wtext) {
	this.gWinCal.document.write(wtext);
}

Calendar.prototype.cal_header = function() {
	var vCode = "";
	
	vCode = vCode + "<TR>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
	vCode = vCode + "</TR>";
	
	return vCode;
}

Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);

	var vFirstDay=vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";

	/*
	Get day for the 1st of the requested month/year..
	Place as many blank cells before the 1st day of the month as necessary. 
	*/

	vCode = vCode + "<TR>";
	for (i=0; i<vFirstDay; i++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'>&nbsp;</FONT></TD>";
	}

	// Write rest of the 1st week
	for (j=vFirstDay; j<7; j++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
			"<A HREF='#' " + "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + this.format_data(vDay) + "';window.close();\">" + 
			this.format_day(vDay, j) + "</A>" + "</FONT></TD>";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>";

	// Write the rest of the weeks
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR>";

		for (j=0; j<7; j++) 
		 {   
			vCode = vCode +	"<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + 
			  "'><A HREF='#' " + "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + this.format_data(vDay) + "';window.close();\">" +
			  this.format_day(vDay, j) + "</A>" + "</FONT></TD>";
			
			vDay=vDay + 1;

			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
		 }
		}

		if (j == 6)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}
	
	// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	for (m=1; m<(7-j); m++) {
		if (this.gYearly)
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>&nbsp;</FONT></TD>";
		else
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
	}
	
	return vCode;
}

Calendar.prototype.format_day = function(vday, vcntr) {
	var vNowDay = gNow.getDate();
	var vNowMonth = gNow.getMonth();
	var vNowYear = gNow.getFullYear();

	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
		return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
	else if (vcntr == fridayDay[0])
		return ("<FONT COLOR=\"BLUE\"><B>" + vday + "</B></FONT>");	
	else
		return (vday);
}

Calendar.prototype.write_weekend_string = function(vday) {
	var i;

	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i])
			return (" BGCOLOR=\"" + weekendColor + "\"");
	}
	
	return "";
}

Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

	switch (this.gFormat) {
		case "MM\/DD\/YYYY" :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
			break;
		case "MM\/DD\/YY" :
			vData = vMonth + "\/" + vDD + "\/" + vY2;
			break;
		case "MM-DD-YYYY" :
			vData = vMonth + "-" + vDD + "-" + vY4;
			break;
		case "MM-DD-YY" :
			vData = vMonth + "-" + vDD + "-" + vY2;
			break;

		case "DD\/MON\/YYYY" :
			vData = vDD + "\/" + vMon + "\/" + vY4;
			break;
		case "DD\/MON\/YY" :
			vData = vDD + "\/" + vMon + "\/" + vY2;
			break;
		case "DD-MON-YYYY" :
			vData = vDD + "-" + vMon + "-" + vY4;
			break;
		case "DD-MON-YY" :
			vData = vDD + "-" + vMon + "-" + vY2;
			break;

		case "DD\/MONTH\/YYYY" :
			vData = vDD + "\/" + vFMon + "\/" + vY4;
			break;
		case "DD\/MONTH\/YY" :
			vData = vDD + "\/" + vFMon + "\/" + vY2;
			break;
		case "DD-MONTH-YYYY" :
			vData = vDD + "-" + vFMon + "-" + vY4;
			break;
		case "DD-MONTH-YY" :
			vData = vDD + "-" + vFMon + "-" + vY2;
			break;

		case "DD\/MM\/YYYY" :
			vData = vDD + "\/" + vMonth + "\/" + vY4;
			break;
		case "DD\/MM\/YY" :
			vData = vDD + "\/" + vMonth + "\/" + vY2;
			break;
		case "DD-MM-YYYY" :
			vData = vDD + "-" + vMonth + "-" + vY4;
			break;
		case "DD-MM-YY" :
			vData = vDD + "-" + vMonth + "-" + vY2;
			break;

		default :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
	}

	return vData;
}

function Build(p_item, p_month, p_year, p_format) {
	var p_WinCal = ggWinCal;
	gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);

	// Customize your Calendar here..
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="red";
	gCal.gHeaderColor="blue";

	// Choose appropriate show function
	if (gCal.gYearly)	gCal.showY();
	else	gCal.show();
}

function show_calendar() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year	: 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item	: Return Item.
	*/

	p_item = arguments[0];
	if (arguments[1] == null)
		p_month = new String(gNow.getMonth());
	else
		p_month = arguments[1];
	if (arguments[2] == "" || arguments[2] == null)
		p_year = new String(gNow.getFullYear().toString());
	else
		p_year = arguments[2];
	if (arguments[3] == null)
		p_format = "MM/DD/YYYY";
	else
		p_format = arguments[3];

	vWinCal = window.open("", "Calendar", 
		"width=250,height=250,status=no,resizable=no,top=200,left=200");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, p_month, p_year, p_format);
}
/*
Yearly Calendar Code Starts here
*/
function show_yearly_calendar(p_item, p_year, p_format) {
	// Load the defaults..
	if (p_year == null || p_year == "")
		p_year = new String(gNow.getFullYear().toString());
	if (p_format == null || p_format == "")
		p_format = "MM/DD/YYYY";

	var vWinCal = window.open("", "Calendar", "scrollbars=yes");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, null, p_year, p_format);
}

function setCallToken()
 {
 var msg2 = "start, end turned into month, year\n";
 var start_date = document.callSched.elements["callStartDate_d"].value;
 var location = document.callSched.elements["callLocation_L"].value;
 var number = start_date.substr(0,2) - 0;
 
 var month = Calendar_get_month(number-1);
 var year = start_date.substr(6,4);

 document.callSched.elements["-token.1"].value = month;
 document.callSched.elements["-token.2"].value = year;
 document.callSched.elements["-token.3"].value = location;

// msg2 += "start date= " + start_date + " month= " + month + "  year= " + year + " number= " + number + " \n";
//  alert(msg2);
//   return false;
 
 document.callSched.submit();
 }
 
function setFacToken()
 {
 var msg2 = "start, end turned into month, year\n";
 var location = document.attCall.elements["callFacLocation"].value;
 var start_date = document.attCall.elements["callFacStartDate_d"].value;
 var number = start_date.substr(0,2) - 0;
 
 var month = Calendar_get_month(number-1);
 var year = start_date.substr(6,4);

 document.attCall.elements["-token.0"].value = location;
 document.attCall.elements["-token.1"].value = month;
 document.attCall.elements["-token.2"].value = year;

// msg2 += "start date= " + start_date + " month= " + month + "  year= " + year + " number= " + number + " \n";
//  alert(msg2);
//   return false;
 
 document.attCall.submit();
 }
 
 
 function isblank(s)
{
   for ( var i = 0; i < s.length; i++)
   {
      var c = s.charAt(i);
	  if ( (c != ' ') && (c != '\n') && (c != '\t') && (c != '\r') ) 
	    return false;
    }
	return true;
}


 //used by the admin side of the conference search pages
 function getSundayDate()
 {
    var msg = "get Sunday date = \n";
    var series = document.confSearch.elements["confSeries_t"].value;
    var week = document.confSearch.elements["confWeek_c"].value;
	var cDate = document.confSearch.elements["confDate_d"].value;
    var month = document.confSearch.elements["confMonth_c"].value;
	var year = 	document.confSearch.elements["confYear_c"].value;
	
	if ( (cDate == "") || (cDate == null) || isblank(cDate) )
	{
	var weekString = "";
	document.confSearch.elements["confWeek_c"].value = "";
	document.confSearch.elements["confDate_d"].value = "";
	}
	else
	{
	var week_start = start_of_week(cDate);
	var confDate = new Date (week_start);
	var year = confDate.getFullYear();
	var janString = "01/01/" + year;
	var janDate = new Date(janString);
	var totSecs = confDate.getTime() - janDate.getTime();
	var weeks = Math.floor(totSecs / (1000 * 60 * 60 *24 * 7)) +2;
	var weekString = "=" + weeks + "_" + year;
	var monthString = "=" + confDate.getMonth() + 1;
		
	document.confSearch.elements["confWeek_c"].value = weekString;
	document.confSearch.elements["confDate_d"].value = "";
	document.confSearch.elements["confMonth_c"].value = "";
	document.confSearch.elements["confYear_c"].value = "";
	}
	
    document.confSearch.elements["-token.0"].value = series;
    document.confSearch.elements["-token.1"].value = cDate;
    document.confSearch.elements["-token.2"].value = weekString;
    document.confSearch.elements["-token.3"].value = month;
    document.confSearch.elements["-token.4"].value = year;
	
	//  msg +=  "confDate =  " + confDate + "year= " + year + "  janString= " + janString + "   janDate= " + janDate + "   weeks=" + weeks + "   weekString=" + weekString + " \n";
    //  msg += " series=" + series + " \n";
    //  msg +=  "form series=" + document.confSearch.elements["confSeries_t"].value + " \n";
    //  msg +=  "form confDate=" + document.confSearch.elements["confDate_d"].value + " \n";
    //  msg +=  "form weekString=" + document.confSearch.elements["confWeek_c"].value + " \n";
    //  msg +=  "token series=" + document.confSearch.elements["-token.0"].value + " \n";
    //  msg +=  "token confDate=" + document.confSearch.elements["-token.1"].value + " \n";
    //  msg +=  "token weekString=" + document.confSearch.elements["-token.2"].value + " \n";
    //  alert(msg);
   
   return true;
 }
 
 //used by the residents side of the conference search pages
 function getSundayDateR()
 {
    var msg = "get Sunday date = \n";
    var series = document.confSearchR.elements["confSeries_t"].value;
    var week = document.confSearchR.elements["confWeek_c"].value;
	var cDate = document.confSearchR.elements["confDate_d"].value;
    var month = document.confSearchR.elements["confMonth_c"].value;
	var year = 	document.confSearchR.elements["confYear_c"].value;

	if ( (cDate == "") || (cDate == null) || isblank(cDate) )
	{
	var weekString = "";
	document.confSearchR.elements["confWeek_c"].value = "";
	document.confSearchR.elements["confDate_d"].value = "";
	}
	else
	{
	var week_start = start_of_week(cDate);
	var confDate = new Date (week_start);
	var year = confDate.getFullYear();
	var janString = "01/01/" + year;
	var janDate = new Date(janString);
	var totSecs = confDate.getTime() - janDate.getTime();
	var weeks = Math.floor(totSecs / (1000 * 60 * 60 *24 * 7)) +2;
	var weekString = "=" + weeks + "_" + year;
	var monthString = "=" + confDate.getMonth() + 1;
	document.confSearchR.elements["confWeek_c"].value = weekString;
	document.confSearchR.elements["confDate_d"].value = "";
	document.confSearchR.elements["confMonth_c"].value = "";
	document.confSearchR.elements["confYear_c"].value = "";
	}
	
    document.confSearchR.elements["-token.1"].value = series;
    document.confSearchR.elements["-token.2"].value = cDate;
    document.confSearchR.elements["-token.3"].value = weekString;
    document.confSearchR.elements["-token.4"].value = month;
    document.confSearchR.elements["-token.5"].value = year;

//	  msg +=  "confDate =  " + confDate + " \n";
//	  msg +=  "cDate =  " + cDate + " \n";
//	  msg +=  "     year= " + year + " \n";
//	  msg +=  "janString= " + janString + " \n";
//	  msg +=  "  janDate= " + janDate + " \n";
//	  msg +=  "    weeks=" + weeks + " \n";
//	  msg +=  "    days=" + days + " \n";
//	  msg +=  " weekString=" + weekString + " \n";
//	  msg +=  " week_start=" + week_start + " \n";
 //     msg +=  "   form confDate=" + document.confSearchR.elements["confDate_d"].value + " \n";
  //    msg +=  " form weekString=" + document.confSearchR.elements["confWeek_c"].value + " \n";
//      alert(msg);
   
   return true;
//   return false;
 }
 
function isLeapYear( year ){
  // is it leap year ? returns a boolean
  return ( (0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))); 
  // ie, if the year divides by 4, but not by 100 except when it divides by
  // 400, it is leap year
} 

function start_of_week(c_date)
{

  var today = new Date(c_date);
  var day = today.getDate();
  var month = today.getMonth() + 1;
  var year = today.getFullYear();
  var offset = today.getDay();
  var week;

  if(offset != 0) 
  {
     day = day - offset;
     if ( day < 1) 
	 {
        if ( month == 1) day = 31 + day;
        if (month == 2) day = 31 + day;
        if (month == 3) 
		{
           if ( (0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) 
		   {
              day = 29 + day;
           }
           else 
		   {
              day = 28 + day;
           }
        }
        if (month == 4) day = 31 + day;
        if (month == 5) day = 30 + day;
        if (month == 6) day = 31 + day;
        if (month == 7) day = 30 + day;
        if (month == 8) day = 31 + day;
        if (month == 9) day = 31 + day;
        if (month == 10) day = 30 + day;
        if (month == 11) day = 31 + day;
        if (month == 12) day = 30 + day;
        if (month == 1) 
		{
           month = 12;
           year = year - 1;
        }
        else 
		{
           month = month - 1;
        }
     }
  }

week = month + "/" + day + "/" + year; // i.e. 10-31-99
return (week);
}


 function validate_conf(f)
{
 var empty_fields = "";
 var msg="Please enter values in at least the following fields to create a valid entry ... \n  Series\n   Date\n   Time\n   Title\n   Location\n";
 var empty_text = false;
 var no_series = false;
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
	  
//      if ( (e.type == "select-one") && (e.selectedIndex < 1) ) 
///	  {
//	      no_series = true;	  
//      }
//	  else
//	  {
//   	      document.confadd.elements["-token.0"].value = e.value;
//	  }
	  
//	  if ( (e.type == "text")  || (e.type == "textarea") ) 
//	  {
	        if ( (e.name == "confSeries_t") && ( (e.value == null) || (e.value == "")  || isblank(e.value) ))
		         empty_text = true;

	        if ( (e.name == "confDate_d") && ( (e.value == null) || (e.value == "")  || isblank(e.value) ))
		         empty_text = true;
	
	        if ( (e.name == "confTime_m") && ( (e.value == null) || (e.value == "")  || isblank(e.value) ))
		         empty_text = true;

	        if ( (e.name == "confTitle_t") && ( (e.value == null) || (e.value == "")  || isblank(e.value) ))
		         empty_text = true;

	        if ( (e.name == "confLocation_t") && ( (e.value == null) || (e.value == "")  || isblank(e.value) ))
		         empty_text = true;
//	  }
    // empty_fields += "   " + e.name + "  e.type:"  + e.type + " ---val: " + e.value + " checked: " + e.checked + " \n";
	  continue;
  }
  
  if ( (empty_text) || (no_series) ) 
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
  else
  {
     return true;
  }
}

//Put in here because the page that uses it also used the calendar 
// functions from this file. the page could not find this function
// in the top of its own file
// because it was told that all the 'src' was in here
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function closeEvalHelpWindow(theURL,winName,features) { //v2.0
var win = window.open(theURL,winName,features);
win.close();
}

function testOnclick ()
{
var msg = "test on click button\n";
alert(msg);

}

 function setTokenCalllist(){

 var location = document.calllist.elements["callLocation_L"].value;
 var month = document.calllist.elements["callStartMonth_c"].value;
 var year  = document.calllist.elements["callStartYear_c"].value;
 
 document.calllist.elements["-token.3"].value = location;
 document.calllist.elements["-token.1"].value = month;
 document.calllist.elements["-token.2"].value = year;
 
// document.calllist.submit();
 }

 function setTokenCallFac(){

 var location = document.callfaclist.elements["callFacLocation"].value;
 var month = document.callfaclist.elements["callFacStartMonth_c"].value;
 var year  = document.callfaclist.elements["callFacStartYear_c"].value;
 
 document.callfaclist.elements["-token.1"].value = location;
 document.callfaclist.elements["-token.2"].value = month;
 document.callfaclist.elements["-token.3"].value = year;
 
// document.callfaclist.submit();
 }

 function setTokenAttCall(){

 var location = document.attCall.elements["callFacLocation"].value;
 var month = document.attCall.elements["callFacStartMonth_c"].value;
 var year  = document.attCall.elements["callFacStartYear_c"].value;
 
 document.attCall.elements["-token.1"].value = location;
 document.attCall.elements["-token.2"].value = month;
 document.attCall.elements["-token.3"].value = year;
 
 document.attCall.submit();
 }

 function setTokenCallSched(){

 var location = document.callSched.elements["callLocation_L"].value;
 var month = document.callSched.elements["callStartMonth_c"].value;
 var year  = document.callSched.elements["callStartYear_c"].value;
 
 document.callSched.elements["-token.3"].value = location;
 document.callSched.elements["-token.1"].value = month;
 document.callSched.elements["-token.2"].value = year;
 
 document.callSched.submit();
 }

 function validateDuty(f)
{
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1 ))
        {
           empty_fields += "   " + e.name + " requires a value\n";
	       continue;
       }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
  else
  {
 var location = document.duty_hours3.elements["rliActualLocation"].value;
 var month    = document.duty_hours3.elements["rliMonthName_c"].value;
 var year     = document.duty_hours3.elements["rliYear_c"].value;
 
 document.duty_hours3.elements["-token.1"].value = location;
 document.duty_hours3.elements["-token.2"].value = month;
 document.duty_hours3.elements["-token.3"].value = year;
 document.duty_hours3.submit();
  }
}

 function validateDHreport(f)
{
 var msg="NOTICE: Duty hours cannot be submitted prior to the end of the month. \n Hours for this month will be saved but not submitted. \n Please login the 1st of next month to submit these hours.";
 var early = false;
// var name     = document.dutyHoursSubmit.elements["rliFullName_t"].value;
// var location = document.dutyHoursSubmit.elements["rliActualLocation"].value;
// var month    = document.dutyHoursSubmit.elements["rliMonthName_c"].value;
// var year     = document.dutyHoursSubmit.elements["rliYear_c"].value;
 var name     = document.dutyHoursSubmit.elements["-token.0"].value;
 var location = document.dutyHoursSubmit.elements["-token.1"].value;
 var month    = document.dutyHoursSubmit.elements["-token.2"].value;
  // report year, academic year, e.g. 2005-2006
 var year     = document.dutyHoursSubmit.elements["-token.3"].value;

 document.dutyHoursSubmit.elements["-token.0"].value = name;
 document.dutyHoursSubmit.elements["-token.1"].value = location;
 document.dutyHoursSubmit.elements["-token.2"].value = month;
 document.dutyHoursSubmit.elements["-token.3"].value = year;

//report month as number, based on academic year, e.g. year is July-June, July=1, June=12
 var currentMonth    = document.dutyHoursSubmit.elements["-token.6"].value;
 var reportMonth     = document.dutyHoursSubmit.elements["-token.5"].value;
 
// var mo1 = parseInt(currentMonth);
// var mo2 = parseInt(reportMonth);
//********************************************************
//  var today = new Date();  //get current date
 // var todayMonth = today.getMonth();
 // var todayYear = today.getFullYear();
  
  //create date that is the last day of the previous month
  //i.e. today is 7/8/2006, checkDate will be 6/30/2006  
//  var checkDate = Calendar.calc_month_year(todayMonth, todayYear, -1);
//  var newMonth = checkDate.getMonth();
//  var newYear = checkDate.getFullYear();
 // checkDate.setDate(Calendar.get_daysofmonth(newMonth, newYear))

//create placeholder for year
//var reportYr = "";
//if (mo2 == 1 || mo2 == 2 || mo2 == 3 || mo2 == 4 || mo2 = 5 || mo2 == 6)
// {
//     reportYr = parseInt(year.substr(1, 4));
// }
// else 
// {
//     reportYr = parseInt(year.substr(6, 4));
// }
   
 //life will be much simpler to calculate on calendar year, not academic year
//if (mo2 == 1)  
//    reportMo = 7;
// if (mo2 == 2)  
//    reportMo = 8;
//if (mo2 == 3)  
//    reportMo = 9;
// if (mo2 == 4)  
//    reportMo = 10;
// if (mo2 == 5)  
//    reportMo = 11;
// if (mo2 == 6)  
//    reportMo = 12;
// if (mo2 == 7)  
//    reportMo = 1;
// if (mo2 == 8)  
//    reportMo = 2;
// if (mo2 == 9)  
//    reportMo = 3;
// if (mo2 == 10)  
//    reportMo = 4;
// if (mo2 == 11)
//   reportMo = 5;
// if (mo2 == 12) 
//   reportMo = 6;
      
// var reportDate = new Date(reportYr,reportMo,1,0,0,0,0);
 
// alert("report:" + reportDate  + "; current:" + currentDate);
//  if ( (reportDate <= checkDate)
//  {
//	early = false;
//  }
//  else
//  {
//	 document.dutyHoursSubmit.elements["-Script"].value = ""; 
//     alert(msg);
//	 early = true;
//  }
 
//----
//all fields must have values, only moonlighting fields can be 0
 var msg2="NOTICE: Duty hours cannot be submitted with blank fields...\n And all fields must be non-zero except for institutional and external moonlighting fields.";
 var empty = false;

 var avg_hrs   = document.dutyHoursSubmit.elements["rliDutyHours_avg_n"].value;
 var inst_moon = document.dutyHoursSubmit.elements["rliDutyHours_instMoonlight_n"].value;
 var cont_hrs  = document.dutyHoursSubmit.elements["rliDutyHours_max_n"].value;
 var free      = document.dutyHoursSubmit.elements["rliDutyHours_free_n"].value;
 var off_duty  = document.dutyHoursSubmit.elements["rliDutyHours_off_n"].value;
 var ext_moon  = document.dutyHoursSubmit.elements["rliDutyHours_extMoonlight_n"].value;  
  
 if ( (avg_hrs == null) || isblank(avg_hrs) || (avg_hrs < 1) || 
	  (inst_moon == null) || isblank(inst_moon) ||
	  (cont_hrs == null) || isblank(cont_hrs) || (cont_hrs < 1) ||
	  (free == null) || isblank(free)	|| (free < 1) ||
	  (off_duty == null) || isblank(off_duty) || (off_duty < 1) ||
	  (ext_moon == null) || isblank(ext_moon) )
 {
	 document.dutyHoursSubmit.elements["-Script"].value = ""; 
	 alert(msg2);
     empty = true;
 }

 if (empty)
 {
      return false;
 }
 else
 {
   return true;
 }
//-----
}

 function setDutyHoursValues(f)
{
 var msg = "";
 var name     = document.dutyHoursList.elements["rliFullName_t"].value;
 var location = document.dutyHoursList.elements["rliActualLocation"].value;
 var month    = document.dutyHoursList.elements["rliMonthName_c"].value;
 var year     = document.dutyHoursList.elements["rliYear_c"].value;
 
 document.dutyHoursList.elements["-token.0"].value = name;
 document.dutyHoursList.elements["-token.1"].value = location;
 document.dutyHoursList.elements["-token.2"].value = month;
 document.dutyHoursList.elements["-token.3"].value = year;
 document.dutyHoursList.submit();
 
 // msg += location + "\n" + month + "\n" + year;
 // alert (msg);
}

 function setDutyHoursValues_exceeds(f)
{
 var msg = "";
 var location = document.dutyHoursList_exceeds.elements["rliActualLocation"].value;
 var month    = document.dutyHoursList_exceeds.elements["rliMonthName_c"].value;
 var year     = document.dutyHoursList_exceeds.elements["rliYear_c"].value;
 
 document.dutyHoursList_exceeds.elements["-token.1"].value = location;
 document.dutyHoursList_exceeds.elements["-token.2"].value = month;
 document.dutyHoursList_exceeds.elements["-token.3"].value = year;
 document.dutyHoursList_exceeds.submit();
 
 // msg += location + "\n" + month + "\n" + year;
 // alert (msg);
}

 function setEvalListValues(f)
{
 
 var location = document.evalList.elements["rliActualLocation"].value;
 var month    = document.evalList.elements["rliMonthName_c"].value;
 var year     = document.evalList.elements["rliYear_c"].value;
 
 document.evalList.elements["-token.1"].value = location;
 document.evalList.elements["-token.2"].value = month;
 document.evalList.elements["-token.3"].value = year;
 document.evalList.submit();
}


 function validateRotEval(f)
{
 var empty_fields = "";
 var msg="Please fill in ALL fields and pick a rating in EACH category... \n";
 var selections = 0;

 for (i = 0; i < f.length; i++) 
 {
	  var e = f.elements[i];
	  
      if ((e.type == "select-one") && (e.selectedIndex < 1))
      {
        empty_fields += "   " + e.name + " requires a value\n";
      } 
	  
	  if ( (e.type == "radio") && (e.checked) )
	  {
   	    selections++;	  
      }

	   // debug fields 
       //  empty_fields += "element#= " + i + ". e.name=" + e.name +"\n e.type=" + e.type + " \n e.value=" + e.value + " \ne.selectedIndex=" + e.selectedIndex + "\ne.checked=" + e.checked + " \n\n";
	     continue;
 } 
	  
 // empty_fields += " selections: " + selections;

if ( (empty_fields) || (selections < 16) ) 
 {
	 msg += empty_fields;
     alert(msg);
      return false;
 }
 else
 {
     document.eval_specific.submit();
 }
}

 function setTokensLogin()
 {
 var name = document.login.elements["full_name"].value;
 document.login.elements["-token.0"].value = name;
 document.login.submit();
 }
 
//  function validateFacSignIn(){
// var name = document.FacSignIn.elements["full_name"].value;
// var password = document.FacSignIn.elements["pw"].value;
 
// if (name == "admin") && (password == "da77as")
// {
// document.FacSignIn.elements["-token.0"].value = name;
// document.FacSignIn.submit();
// }
// else 
//  {
//  alert ("A valid administrator login and password are required to access this page. ");
//  return false;
//  }
// }

  function validateEval(f)
{
 var empty_fields = "";
 var msg="Please enter a rating in each category or select Not Applicable -AND- fill in Comments and Suggestions or put the word None... ";
 var choices = 0;
 var selections = 0;
 var empty_text = false;
 var skip = false;

 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if (e.type == "radio")
	  {
	     choices++;
		 if (e.checked)
		 {
			  selections++;	  
	     }
 		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
     }
	  
	 // if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	 // {
	////	     empty_text = true;
	//  }
     empty_fields += "   " + e.name + 
					 " e.type:"  + e.type + 
					 " val: " + e.value + 
					 " checked: " + e.checked + 
					 " \n" ;
  }
  empty_fields += " \nselections: " + selections + 
				  " choices: " + choices + " \nchoices/5" + (choices/5);

// if ( (empty_text) || (selections < (choices/5) ) )
 if (empty_text)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
    document.eval_j_specific.submit();
 }
}

 function validateRotation(f)
{
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
 for (i = 0; i < f.length; i++) 
 {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
      {
        empty_fields += "   " + e.name +" requires a value\n";
	    continue;
      } 
	   // debug fields 
       //  empty_fields += "element#= " + i + ". e.name=" + e.name +"\n e.type=" + e.type + " : id=" + e.id + " \n e.value=" + e.value +" \n\n";
	   //   continue;
  } 
  //empty_fields += " form elements= " + f.length;
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;
  }
}

 function validateRotedit(f)
 {
	
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;
  }
  else
  {
    var location = document.rotedit.elements["rLocation_t"].value;
    var month = document.rotedit.elements["rMonth_t"].value;
    var year = document.rotedit.elements["rAcademicYear_t"].value;
 
    document.rotedit.elements["-token.0"].value = location;
    document.rotedit.elements["-token.1"].value = month;
    document.rotedit.elements["-token.2"].value = year;
    document.rotedit.submit();
  }
}

 function validateRotadd(f)
{
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1 ))
        {
           empty_fields += "   " + e.name + " requires a value\n";
	       continue;
       }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
  else
  {
 var location = document.rotadd.elements["rLocation_t"].value;
 var month = document.rotadd.elements["rMonth_t"].value;
 var year = document.rotadd.elements["rAcademicYear_t"].value;
 
 document.rotadd.elements["-token.0"].value = location;
 document.rotadd.elements["-token.1"].value = month;
 document.rotadd.elements["-token.2"].value = year;
 document.rotadd.submit();
  }
}

 function validateCallSched(f){
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;

  }
  else
  {
 var location = document.callSched.elements["callLocation_L"].value;
 var month = document.callSched.elements["callStartMonth_c"].value;
 var year  = document.callSched.elements["callStartYear_c"].value;
 
 document.callSched.elements["-token.3"].value = location;
 document.callSched.elements["-token.1"].value = month;
 document.callSched.elements["-token.2"].value = year;
 
 document.callSched.submit();
  }
}

 function validateCallList(f){
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;

  }
  else
  {

 var location = document.callList.elements["callLocation_L"].value;
 var month = document.callList.elements["callStartMonth_c"].value;
 var year  = document.callList.elements["callStartYear_c"].value;
 
 document.callList.elements["-token.3"].value = location;
 document.callList.elements["-token.1"].value = month;
 document.callList.elements["-token.2"].value = year;
 
 document.callList.submit();
  }
}

 function validateAttCall(f){
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;

  }
  else
  {
 var location = document.attCall.elements["callFacLocation"].value;
 var month = document.attCall.elements["callFacStartMonth_c"].value;
 var year  = document.attCall.elements["callFacStartYear_c"].value;
 
 document.attCall.elements["-token.0"].value = location;
 document.attCall.elements["-token.1"].value = month;
 document.attCall.elements["-token.2"].value = year;
 
 document.attCall.submit();
  }
}

 function validateAttCallFac(f){
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;

  }
  else
  {
 var location = document.attCallFac.elements["callFacLocation"].value;
 var month = document.attCallFac.elements["callFacStartMonth_c"].value;
 var year  = document.attCallFac.elements["callFacStartYear_c"].value;
 
 document.attCallFac.elements["-token.0"].value = location;
 document.attCallFac.elements["-token.1"].value = month;
 document.attCallFac.elements["-token.2"].value = year;
 
 document.callCallFacSched.submit();
  }
}

 
  function validateCallSchedEdit(f){
 var empty_fields = "";
 var msg="Please fill in all fields: \n";
 
for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1))
        {
          empty_fields += "   " + e.name + " requires a value\n";
	      continue;
        }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	 return false;

  }
  else
  {
 var month = document.callSchedEdit.elements["callStartMonth_c"].value;
 var year  = document.callSchedEdit.elements["callStartYear_c"].value;
 var location  = document.callSchedEdit.elements["callLocation_L"].value;
 
 document.callSchedEdit.elements["-token.1"].value = month;
 document.callSchedEdit.elements["-token.2"].value = year;
 document.callSchedEdit.elements["-token.3"].value = location;
 
 document.callSchedEdit.submit();
  }
}

 function validateEvalSign2(f)
{
 var msg = "Resident Password AND Faculty Name and Password must be entered.";
 var empty = false;
 var passw = document.evalSign2.elements["pw::pw_t"].value;
  
 if ( (passw == null) || (passw == "") || isblank(passw) )
 {
     empty = true;
 }

  if (empty)
  {
    alert(msg);
	return false;
  }
}

   function validateResEval(f)
{
 var empty_fields = "";
 var msg="Please fill in all fields: \n";

 for (i = 0; i < f.length; i++) 
  {
  	  var e = f.elements[i];
      if ((e.type == "select-one") && (e.selectedIndex < 1 ))
        {
           empty_fields += "   " + e.name + " requires a value\n";
	       continue;
       }
  } 
  
  if (empty_fields) 
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
  else
  {
 var name     = document.resEval.elements["rliFullName_t"].value;
 var rotation = document.resEval.elements["rliActualLocation"].value;
// var month    = document.resEval.elements["rliMonthName_c"].value;
 var year     = document.resEval.elements["rliYear_c"].value;
 
 document.resEval.elements["-token.0"].value = name;
 document.resEval.elements["-token.1"].value = rotation;
// document.resEval.elements["-token.2"].value = month;
 document.resEval.elements["-token.3"].value = year;
 document.resEval.submit();
 
  // WARNING WARNING WARNING
  //temp code to handle monthly evals for specific resident. code
 // should go away as soon as realistically possible
 // ybr 10/31/05
// var pattern1 = /matevosyan/i;
// var pattern2 = /coag-bb/i;
// if (pattern1.test(name) && pattern2.test(rotation))
//   {
     //alert("name contains Karens AND location contains coag, change format, db, create new meta page");
	// document.resEval.elements["-Format"].value = "eval_b_meta_temp.html";
 //  }
 // end temp code
  // WARNING WARNING WARNING
  }
}

  
   function validateEval0(f)
{
 var empty_fields = "";
 var msg="Please enter a value in each field...\n";
 var choices = 0;
 var empty_text = false;
 var skip = false;
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
		   choices++;
			    	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	  if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	  {
		     empty_text = true;
	  }
	  
//     empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  } //end for
  


 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
else
 {
	if (skip)
	{
	   document.eval0.elements["-Format"].value = "eval_L_print.html";
	}
   //  document.eval0.submit();
 }
}

  
   function validateEval1(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }

      }
	  
	  //if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	  //{
	//	     empty_text = true;
	  //}
    // empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
// if (choices >0)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval1.elements["-Format"].value = "eval_L_print.html";
	}
 }
}

  
 function validateEval2(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }

      }
	  
	  //if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	 // {
	//	     empty_text = true;
	 // }
    // empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval2.elements["-Format"].value = "eval_L_print.html";
	}
 }
}

 function validateEval3(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;
 
 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	 // if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	 // {
	//	     empty_text = true;
	  //}
    // empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval3.elements["-Format"].value = "eval_L_print.html";
	}
 }
}

 function validateEval4(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;

 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	//  if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	//  {
	//	     empty_text = true;
	//  }
     //empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval4.elements["-Format"].value = "eval_L_print.html";
	}
 }
}


 function validateEval5(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;

 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	//  if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	//  {
	//	     empty_text = true;
	//  }
     //empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval5.elements["-Format"].value = "eval_L_print.html";
	}
 }
}


 function validateEval6(f)
{
 var empty_fields = "";
 var msg="Please enter a rating AND a Suggestion for Improvement or the word 'None'... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;

 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	 // if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	 // {
	////	     empty_text = true;
	//  }
     //empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if (choices < 1)
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval6.elements["-Format"].value = "eval_L_print.html";
	}
 }
}
 function validateEval7(f)
{
 var empty_fields = "";
 var msg="Please enter comments or Evaluation Acctepted, then select skip or sign... \n";
 var choices = 0;
 var empty_text = false;
 var skip = false;

 for (i = 0; i < f.length; i++) 
  {
	  var e = f.elements[i];
      if ((e.type == "radio") && (e.checked)) 
	  {
			  choices++;	  
		   if ((e.name == "evalNext_or_Sign_t") && (e.value == "Sign")) 
	       { 
			   skip = true;
	       }
      }
	  
	  if ( (e.type == "textarea") && ((e.value == null) || (e.value == "")  || isblank(e.value)) ) 
	  {
		     empty_text = true;
	  }
     //empty_fields += "   " + e.name + "  e.type:"  + e.type + " val: " + e.value + " checked: " + e.checked + " \n";
  }
  
 if ((choices < 1) || (empty_text))
 {
	 msg += empty_fields;
     alert(msg);
	    return false;
 }
 else
 {
	if (skip)
	{
	   document.eval7.elements["-Format"].value = "eval_L_print.html";
	}
 }
}

 function validateResEvalFac(f)
{
 var empty_fields = "";
 var msg="Please enter a value in each field...\n";
 var empty_text = false;
 
 var facName = document.resEvalFac.elements["TFaculty_full_c"].value;
 var facPas	= document.resEvalFac.elements["TFaculty_full_pass"].value;
 
 if ( isblank(facName) || isblank(facPas) ) 
  {
	     empty_text = true;
  }

 if (empty_text)
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
else
  {
    document.resEvalFac.elements["-token.5"].value = facName;
  }
}

 function validateFacultyRecord(f)
{
 var empty_fields = "";
 var msg="Please enter a value in each field...\n";
 var empty_text = false;
 
 var facName = document.FacChangePass.elements["TFaculty_full_c"].value;
 var facPas	= document.FacChangePass.elements["TFaculty_full_pass"].value;
 
 if ( isblank(facName) || isblank(facPas) ) 
  {
	     empty_text = true;
  }

 if (empty_text)
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
else
  {
    document.FacChangePass.elements["-token.0"].value = facName;
    document.FacChangePass.elements["-token.1"].value = facPass;
  }
}

 function validateFaculty_NewPass(f)
{
 var empty_fields = "";
 var msg="Please enter matching values...\n";
 var empty_text = false;
 
// var facName = document.FacNewPass.elements["TFaculty_full_c"].value;
 var  facPassNew	= document.FacNewPass.elements["tmpNewPass_t"].value;
 var facPassConfirm	= document.FacNewPass.elements["tmpConfirmPass_t"].value;
 
 if ( isblank(facPassNew) || isblank(facPassConfirm) ) 
  {
	     empty_text = true;
  }

 if (facPassNew != facPassConfirm)
 {
         empty_text = true;
  }
  
 if (empty_text)
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
//else
//  {
//    document.FacNewPass.elements["-script"].value = "changeFacultyPassword";
 // }
}

 function validateResidentRecord(f)
{
 var empty_fields = "";
 var msg="Please enter your current password...\n";
 var empty_text = false;

 var resName = document.resChangePass.elements["-token.0"].value;
 var resPas	= document.resChangePass.elements["pw::pw_t"].value;
 
 if (isblank(resPas) ) 
  {
	     empty_text = true;
  }

 if (empty_text)
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
else
  {

    document.resChangePass.elements["-token.0"].value = resName;
    document.resChangePass.elements["-token.1"].value = resPass;
  }
}

 function validateResident_NewPass(f)
{
 var empty_fields = "";
 var msg="Please enter matching values...\n";
 var empty_text = false;
 
// var facName = document.FacNewPass.elements["TFaculty_full_c"].value;
 var  resPassNew	= document.ResNewPass.elements["tmpNewPass_t"].value;
 var resPassConfirm	= document.ResNewPass.elements["tmpConfirmPass_t"].value;
 
 if ( isblank(resPassNew) || isblank(resPassConfirm) ) 
  {
	     empty_text = true;
  }

 if (resPassNew != resPassConfirm)
 {
         empty_text = true;
  }
  
 if (empty_text)
  {
	 msg += empty_fields;
     alert(msg);
	    return false;
  }
}


// functions  used by the template resEvalTemplate.html
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
