// prbrowser.js 

// based a lot on Ultimate client-side JavaScript client sniff. Version 3.02
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.

var prAgent	= navigator.userAgent.toLowerCase();
var prMajorAppVersion = parseInt(navigator.appVersion);
var prMinorAppVersion = parseFloat(navigator.appVersion);

// var IsIE = ((prAgent.indexOf("msie") != -1) && (prAgent.indexOf("opera") == -1));
// let's try letting Opera pretend to be MSIE
var IsIE = (prAgent.indexOf("msie") != -1);

// alert ("PRCOMMON.JS says IsIE = " + IsIE);
var IE4NUP = (IsIE && (prMajorAppVersion >= 4))?true:false;

// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
// If you want to allow spoofing, take out the tests for opera and webtv.
var IsNN = ((prAgent.indexOf('mozilla')!=-1) && (prAgent.indexOf('spoofer')==-1)
                && (prAgent.indexOf('compatible') == -1) && (prAgent.indexOf('opera')==-1)
                && (prAgent.indexOf('webtv')==-1) && (prAgent.indexOf('hotjava')==-1));

var NS4 = (IsNN && (prMajorAppVersion == 4))?true:false;
var NS6 = (IsNN && (prMajorAppVersion == 5))?true:false;

function OkToUseLayers()
{
	return (document.layers)?true:false;
}

function OkToUseClientWidth()
{
	return IE4NUP;
}

function OkToUseInnerWidth()
{
	return IsNN;
}

function OkToUseInnerHTML()
{
	return ((IsIE && (prMajorAppVersion >= 4)) || (IsNN && (document.getElementById)))?true:false;
}

function OkToUseILAYER()
{
	return NS4;
}

function BrowserOld ()
{
	return ((IsIE && (prMajorAppVersion < 4)) || (IsNN && (prMajorAppVersion < 4)))?true:false;
	
}

var helpwin = 0;

function ShowHelp(helpfile)
{
	var topmargin = 80;
	var w = (screen.width) ? (screen.width)/3 : 150;
	var h = (screen.height) ? (screen.height - (topmargin * 2)) : 400;
	
	// center the new window
	// var LeftPosition = (screen.width) ? (screen.width-w)/2 : 40;
	// var TopPosition = (screen.height) ? (screen.height-h)/2 : 40;
	
	// put new window on right edge of screen
	var LeftPosition = (screen.width) ? (screen.width-w-30 ) : 40;
	var TopPosition = (screen.height) ? (screen.height-h-topmargin) : 40;
	
	var settings = 'height=' + h + ',width='+ w +',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes, resizable=yes';

	helpwin = window.open(helpfile, "helpwin", settings).focus();
}

function ShowBigHelp(helpfile)
{
	var topmargin = 80;
	var w = (screen.width) ? ((screen.width)*7)/8 : 800;
	var h = (screen.height) ? (screen.height - (topmargin * 2)) : 600;
	
	// center the new window
	// var LeftPosition = (screen.width) ? (screen.width-w)/2 : 40;
	// var TopPosition = (screen.height) ? (screen.height-h)/2 : 40;
	
	// put new window on right edge of screen
	var LeftPosition = (screen.width) ? (screen.width-w-30 ) : 40;
	var TopPosition = (screen.height) ? (screen.height-h-topmargin) : 40;
	
	var settings = 'height=' + h + ',width='+ w +',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes, resizable=yes';

	helpwin = window.open(helpfile, "helpwin", settings).focus();
}

function GetEkDatePosition(dateString,dateType) 
{
    var now = new Date();
    
	// use getFullYear since after 2000 getYear works differently in IE & NN
	
	var today = new Date(now.getFullYear(),now.getMonth(),now.getDate());
        
	if (dateType == 5)
	{
	    var date = new Date(dateString.substring(6,10),
                            dateString.substring(0,2)-1,
                            dateString.substring(3,5));
	}						
    else
	{
    	alert("Unknown dataType");
		return false;
	}
	
	// alert( "DateString = " + dateString + "\n\nDate = " + date + "\n\nToday = " + today + "\n\nNow = " + now);
	
	if (date < today)
        return -1;
    else if (date > today)
        return 1;
    else
        return 0;
}

function Replace(aString,oldStr,newStr) 
{
// Replaces oldStr with newStr in aString
    var aStringLength = aString.length;
	var oldStrLength = oldStr.length;
    if ((aStringLength == 0) || (oldStrLength == 0)) return aString;

    var i = aString.indexOf(oldStr);
    if ((!i) && (text != aString.substring(0,oldStrLength))) return aString;
    if (i == -1) return aString;

    var newstr = aString.substring(0,i) + newStr;

    if (i+oldStrLength < aStringLength)
        newstr += replace(aString.substring(i+oldStrLength,aStringLength),oldStr,newStr);

    return newstr;
}

function CheckForDoubleQuotes (string) 
{
    if (string.search('"') == -1)
         return false;
     else
         return true;
}

function CheckForSingleQuotes (string) 
{
    if (string.search("'") == -1)
         return false;
     else
         return true;
}

function CheckColorListString (string) 
{
	// return false if find spacecomma or commaspace
    if ((string.search(', ') != -1) || (string.search(' ,') != -1))
    {
		// alert ("No spaces before or after the commas please.");
		return false;
	}	 
  	else
	{
		// alert("Looks good to me");	
  		return true;
	}	
}

function CheckForIllegalTags (string) 
{
	// check for HTML BODY SCRIPT tags	
	var RegExpStr ='\<html\>|\<\/html\>|\<script|\<\/script|\<body|\<\/body';
	var RegExpPat = new RegExp(RegExpStr);
	return RegExpPat.test(string);
}	

function CheckForScript (string) 
{
    if (string.search('<script') == -1)
         return false;
     else
         return true;
}

function PopMyClasses()
{
	var url = "../myclasses/index.cfm?" + jsAllArgs;
	window.open(url, "popmyclasseswin", "width=800,height=500,left=100,top=100, resizable=yes,scrollbars=yes").focus();
}

function ShowNote(cOrg, noteID)
{
	var url = "popnote.cfm?" + jsAllArgs + "&mID=" + noteID;
	window.open(url, "popnotewin", "width=400,height=400,left=100,top=100, resizable=yes,scrollbars=yes").focus();
}

function PopEvent(EventID)
{
	var url = "popevent.cfm?" + jsAllArgs + "&eID=" + EventID;
	window.open(url, "popeventwin", "width=480,height=480,left=100,top=100, resizable=yes,scrollbars=yes").focus();
}

function PopDfEdit(zMode,zID,zFormType)
{
	if (zMode == 'EDIT')
	{
		var url = "admin/dynaform_RecordEdit.cfm?" + jsAllArgs + "&RecordID=" + zID;
		window.open(url, "popdfedit", "width=900,height=700,left=40,top=40,resizable=yes,scrollbars=yes").focus();
	}
	else	
	if (zMode == 'CREATE')
	{
		var url = 'admin/dynaform_RecordEdit.cfm?' + jsAllArgs + '&FormType=' + zFormType + '&EvtID=' + zID;
		window.open(url, "popdfedit", "width=900,height=700,left=40,top=40, resizable=yes,scrollbars=yes").focus();
	}
	else
		alert("Unknown mode for DynaForm popup");
}

function ShowNoteEdit(cOrg, noteID)
{
	if (noteID == "") 
	{
		alert ("Gotta pick a Note");
		return;
	}	
	var url = "../popnote.cfm?" + jsAllArgs + "&mID=" + noteID;
	window.open(url, "popnotewin", "width=400,height=400,left=100,top=100, resizable=yes,scrollbars=yes").focus();
}

function ShowScripture(url)
{
window.open(url, "versewin", "width=500,height=500,left=50,top=50, resizable=yes,scrollbars=yes").focus()
}

function ShowFriendWindow(url)
{
	var topmargin = 80;
	var w = (screen.width) ? ((screen.width * 2)/3) : 500;
	var h = (screen.height) ? (screen.height - (topmargin * 2)) : 400;
	
	// center the new window
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 40;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 40;
	
	var settings = 'height=' + h + ',width='+ w +',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes, resizable=yes';

	window.open(url, "friendwin", settings).focus();
}

function UrlWindow(url,mode)
{
	var topmargin = 80;
	var w = (screen.width) ? ((screen.width * 2)/3) : 500;
	var h = (screen.height) ? (screen.height - (topmargin * 2)) : 400;
	
	// center the new window
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 40;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 40;
	
	if (mode==2)
	{
		TopPosition += 40;
		LeftPosition += 40;
	}
		
	var settings = 'height=' + h + ',width='+ w +',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable=yes,location';

	if (mode==1)
		window.open(url, "makeurlwin", settings).focus();
	else
		window.open(url, "testurlwin", settings).focus();
}

function ConfirmDelete()
{
	var answer=confirm("Are you sure you want to DELETE the selected item(s)?");
	if (answer)	return true ;
	else return false ;
}
	
<!--- Things from prcal.js --->

function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }

var today = new Date();
var day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear()), whichOne = 0;
var today2 = year + "-" + padout(month) + "-" + padout(day);

function RealMonth(codeMonth)
{
	var humanMonthNumber = Number(codeMonth) + 1;
	return humanMonthNumber;
}	
	
function bad_tfDayHasEvent (thisDay, evtDayList)
{
	var rMonth = RealMonth(document.SetDisplayCriteria.fMonth.value);
    var thisDate = "\'" + document.SetDisplayCriteria.fYear.value + "-" + padout(rMonth) + "-" + padout(thisDay);
	var testdate = new RegExp (thisDate);
	return !testdate.test(evtDayList);
}

function tfDayHasEvent (thisDay, evtDayList)
{
	var rMonth = RealMonth(document.SetDisplayCriteria.fMonth.value);
    var thisDate = "\'" + document.SetDisplayCriteria.fYear.value + "-" + padout(rMonth) + "-" + padout(thisDay);
	var testdate = new RegExp (thisDate);
	return testdate.test(evtDayList);
}

function newWindow(number) 
{
    whichOne = number;
    day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear());
    mywindow=open('cal.htm','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal.htm';
    if (mywindow.opener == null) mywindow.opener = self;
}

function tfToday (thisDay)
{
    return (today2 == document.SetDisplayCriteria.fYear.value + "-" + padout(document.SetDisplayCriteria.fMonth.value) + "-" + padout(thisDay));
}

function restart() 
{
    document.data.elements['date' + whichOne].value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
    mywindow.close();
}

function xMakeCalendarCode(Month,Year,tfEvtListPg1) 
{
    var output = '';
    
	// var output = '<form>in a form</form>';
    
    // output += '<form name="Cal"><table bgcolor="' + tbgColor1 + '" border="1">';
	output += '<table>';
	    
	output += '<tr><td>Opera MakeCalCode Test</td></tr>';
	
    output += '</table>';

	alert(output);
	
	return output;
}

function OkayToBookRoom(zMonth, zDay, zYear)
{
	if (jsTfRooms)
	{
		var curDate = new Date(zYear, zMonth, zDay);
		if (curDate <= jsMaxRoomDate)
			return true;
		else
			return false;
	}
	return true;
}

function MakeCalendarCode(Month,Year,tfEvtListPg1) 
{
	// alert("BEGIN -- Make Calendar Code"); 

	// <!--- build string of html code that we can stick somewhere --->
    var output = '';
    
    // <!--- start with form, main table, month & year header, select month and select year --->
    // opera fussing : remove form from here and put it on the page.
	output += '<table bgcolor="' + tbgColor1 + '" border=1>';
	// output += '<form name="Cal" style="margin-bottom: 0px;"><table bgcolor="' + tbgColor1 + '" border=1>';
	    
	// <!--- build the month and year select lists --->
    if (tfEvtListPg1)
	{
		output += '<tr><td align=center width=100%><font face="Arial" size="2"><select name="Month" STYLE="font-family : Arial; font-size : x-small" onChange="changeMonth(1);">';

		// <!--- build entries for the month selection list --->
    	for (month=0; month<12; month++) 
		{
        	if (month == Month) output += '<option value="' + month + '" selected>' + names[month] + '<\/option>';
        	else              
				output += '<option value="' + month + '">' + names[month] + '<\/option>';
    	}

    	output += '<\/select><\/font>&nbsp;<font face="Arial" size="2"><select name="Year" STYLE="font-family : Arial; font-size : x-small" onChange="changeYear(1);">';

    	// <!--- build entries for the year selection list --->
    	for (year=2006; year<2009; year++) 
		{
        	if (year == Year) output += '<option value="' + year + '" selected>' + year + '<\/option>';
        	else              output += '<option value="' + year + '">'          + year + '<\/option>';
    	}

    	output += '<\/select><\/font><\/td><\/tr>';
	}
	
	output += '<tr><td align=center colspan=2>';

 	// <!--- start the calendar math --->

    firstDay = new Date(Year,Month,1);
    startDay = firstDay.getDay();

    if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
         days[1] = 29; 
    else
         days[1] = 28;

	// <!--- the actual calendar table --->
    output += '<table cellspacing=1 cellpadding=' + cellpad + ' border=1 bgcolor="' + tbgColor2 + '"><tr>';

	// <!--- days of the week row --->
    for (i=0; i<7; i++)
	{
        output += '<td width="' + colwidth + '" align=center valign=middle>';
		
		if (tfBigMonth) 
			output += '<font size=2 color="#000000" face="Arial"><b>' + dow3[i]; 
		else 
			output += '<font size=-2 color="#000000" face="Arial"><b>' + dow[i]; 
		
		output += '<\/b><\/font><\/td>';
	}
		
    output += '<\/tr><tr align=center valign=middle>';

    var column = 0;
    var lastMonth = Month - 1;
    if (lastMonth == -1) lastMonth = 11;

	// <!--- last month's days --->
    for (i=0; i<startDay; i++, column++)
        output += '<td bgcolor=silver align=center width="' + colwidth + '" height="' + rowheight + '"><font size=-4 color="#808080" face="Arial ">' + (days[lastMonth]-startDay+i+1) + '<\/font><\/td>';

	// <!--- active days --->
	for (i=1; i<=days[Month]; i++, column++) 
	{
        if (tfBigMonth) 
		{	output += '<td align=left valign=top width="' + colwidth + '" height="' + rowheight + '"'; }
		else
		{	output += '<td align=center valign=middle width="' + colwidth + '" height="' + rowheight + '"'; }
			
		// <!--- woof: change the cell color if we've already picked today --->
		if 	((tfPickDates) && (IndexOfDayPicked(Month, i, Year) != -1))
		{ 
			output +=  ' bgcolor=red';
		}
		// <!--- woof: change the cell color if we're talking about today --->
		else if (tfToday(i)) 
		{ 
			output +=  ' bgcolor="' + todayColor + '"';
		}

		output += '>';
		
		// <!--- check to see if this day has any events --->
		// if (tfDayHasEvent(i,daylist) || (tfEvtEdit) || (tfPickDates))
		// add pick limits for Rooms
		if (tfDayHasEvent(i,daylist) || (tfPickDates) ||
			(tfEvtEdit && OkayToBookRoom(Month,i,Year)))
		{
			if (tfPickDates)
				output += '<a href="javascript:PickADay(' + Month + ',' + i + ',' + Year + ')">';
			else if (tfEvtEdit)
				output += '<a href="javascript:selectEditDay(' + Month + ',' + i + ',' + Year + ')">';
			else
				output += '<a href="javascript:selectDay(' + Month + ',' + i + ',' + Year + ')">';
			
			if (tfBigMonth) 
				output += '<font size=2 face="arial" color="red">' + i + '<\/font>';
			else
				output += '<font size=-4 face="arial" color="red">' + i + '<\/font>';
			output += '<\/a>';
			
			// <!--- get the event data for this day --->
			if (tfBigMonth) 
			{
				output += GetDayEvents(i);
			}
		}
		else
		{
			if (tfBigMonth) 
				output += '<font size=2 face="arial " color="black">&nbsp;' + i + '<\/font>';
			else
				output += '<font size=-4 face="arial " color="black">' + i + '<\/font>';
		}
		
        output += '<\/td>';
		
		if (column == 6) {
            output += '<\/tr><tr align=center valign=middle>';
            column = -1;
        }
    }

	// <!--- next month's days --->
    if (column > 0) {
        for (i=1; column<7; i++, column++)
            output +=  '<td bgcolor=silver width="' + colwidth + '" height="' + rowheight + '"><font size=-4 color="#808080" face="Arial ">' + i + '<\/font><\/td>';
    }

	// <!--- close the table, form and table --->
    
	// output += '<\/tr><\/table><\/td><\/tr><\/table><\/form>\n';
	
	// opera fussing remove close form tag
	output += '<\/tr><\/table><\/td><\/tr><\/table>\n';
	
	// alert("END -- Make Calendar Code"); 
	
    return output;
}

function MakeSimpleCalendarCode(Month,Year) 
{
	// alert("BEGIN -- Make Simple Calendar Code"); 

	// <!--- build string of html code that we can stick somewhere --->
    var output = '';
    
 	// <!--- start the calendar math --->

    firstDay = new Date(Year,Month,1);
    startDay = firstDay.getDay();

    if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
         days[1] = 29; 
    else
         days[1] = 28;

	// <!--- the actual calendar table --->
    output += '<table cellspacing=1 cellpadding=' + cellpad + ' border=1 bgcolor="' + tbgColor2 + '"><tr>';

	// <!--- days of the week row --->
    for (i=0; i<7; i++)
	{
        output += '<td width="' + colwidth + '" align=center valign=middle>';
		
		if (tfBigMonth) 
			output += '<font size=2 color="#000000" face="Arial"><b>' + dow3[i]; 
		else 
			output += '<font size=-2 color="#000000" face="Arial"><b>' + dow[i]; 
		
		output += '<\/b><\/font><\/td>';
	}
		
    output += '<\/tr><tr align=center valign=middle>';

    var column = 0;
    var lastMonth = Month - 1;
    if (lastMonth == -1) lastMonth = 11;

	// <!--- last month's days --->
    for (i=0; i<startDay; i++, column++)
        output += '<td bgcolor=silver align=center width="' + colwidth + '" height="' + rowheight + '"><font size=-4 color="#808080" face="Arial ">' + (days[lastMonth]-startDay+i+1) + '<\/font><\/td>';

	// <!--- active days --->
	for (i=1; i<=days[Month]; i++, column++) 
	{
		output += '<td align=left valign=top width="' + colwidth + '" height="' + rowheight + '"'; 		
		output += '>';
		
		// <!--- check to see if this day has any events --->
		if (tfDayHasEvent(i,daylist) || (tfEvtEdit) || (tfPickDates))
		{
			
			output += '<font size=2 face="arial" color="red">' + i + '<\/font>';
			output += GetDayEvents(i);
		}
		else
		{
			output += '<font size=2 face="arial " color="black">&nbsp;' + i + '<\/font>';
		}
		
        output += '<\/td>';
		
		if (column == 6) {
            output += '<\/tr><tr align=center valign=middle>';
            column = -1;
        }
    }

	// <!--- next month's days --->
    if (column > 0) {
        for (i=1; column<7; i++, column++)
            output +=  '<td bgcolor=silver width="' + colwidth + '" height="' + rowheight + '"><font size=-4 color="#808080" face="Arial ">' + i + '<\/font><\/td>';
    }

	// <!--- close the table, form and table --->
	output += '<\/tr><\/table>\n';
	// woof : moved form tags to within the table tags
	
	// alert("END -- Make Calendar Code"); 
	
    return output;
}

function GoToBigMonth (newMonth, newYear) 
{
 	var GoToURL = "";
	GoToURL += "bigmonth.cfm?" + jsAllArgs;
	GoToURL += "&reqMonth=" + RealMonth(newMonth);
	GoToURL += "&reqYear=" + newYear;
	
	// alert ("Go To Month URL = " + GoToURL);
	
	location.href = GoToURL;
}

function GoToBigYear (newYear) 
{
 	var GoToURL = "";
	GoToURL += "bigyear.cfm?" + jsAllArgs;
	GoToURL += "&reqYear=" + newYear;
	
	// alert ("GoTOYear URL = " + GoToURL);
	
	location.href = GoToURL;
}

function MonName (monNum) 
{
	var codeNum = Number(monNum) - 1;
 	document.write (names[codeNum]);
}

function selectDay( newMonth, newDay, newYear ) 
{
	// select day (for events)
	if (!jstfPassApp) 
	{
		document.SetDisplayCriteria.fDay.value = newDay;
		
		var GoToURL = "";
		GoToURL += "events.cfm?" + jsAllArgs + "&curMonth=" + RealMonth(newMonth);
		GoToURL += "&curYear=" + newYear;
		
		if (newDay!='0')
		{
		var GoToDate = "";
		GoToDate += RealMonth(newMonth) + "/";
		GoToDate += newDay + "/" + newYear;
		GoToURL += "#" + GoToDate;
		}
		
		location.href = GoToURL;
	}
	else // aka selectPassDay for passes
	{
		document.SetDisplayCriteria.fDay.value = newDay;
		// woof : may need to pad these dates for the anchor to work.
		
		var GoToURL = "";
		GoToURL += "events.cfm?" + jsAllArgs + "&curMonth=" + RealMonth(newMonth);
		GoToURL += "&curYear=" + newYear;
		GoToURL += "&tmpPassStartDate=";
		GoToURL += RealMonth(newMonth) + "/";
		GoToURL += newDay + "/" + newYear;
		
		// alert ("GoToURL = " + GoToURL);
		
		location.href = GoToURL;
	}
}
function ReturnToEditedDay( newMonth, newDay, newYear, PostStatus) 
{
	var GoToURL = "";
	GoToURL += "../events.cfm?" + jsAllArgs;
	if ((jsCurMonth != 'ALL') && (jsCurMonth != 'PASTTOO'))
	{
		GoToURL += "&curMonth=" + newMonth;
		GoToURL += "&curYear=" + newYear;
	}	

	if ((PostStatus == 'PENDING') || (PostStatus == 'PUBLICEDIT')|| (PostStatus == 'ROOMREQ'))
		GoToURL += "&curApp=eventsreview";
	else if (PostStatus == 'ROOMREQ')
		GoToURL += "&curApp=rooomreview";
	
	//else
	// 	GoToURL += "&curApp=events";

	// added to force display of events just edited.
	GoToURL += "&fRef=" + jsTimeID;
	
	if (newDay!='0')
	{
	var GoToDate = "";
	GoToDate += newMonth + "/";
	GoToDate += newDay + "/" + newYear;
	// alert ("GoToDate = " + GoToDate);
	GoToURL += "#" + GoToDate;
	}
	
	location.href = GoToURL;
}

function ReturnToEventList() 
{
	/*
	alert("ReturnToEventList in prcommon.js xx");
	alert("jstfEditMode = " + jstfEditMode);
	alert("jstfOrgHasCustomEK = " + jstfOrgHasCustomEK);
	*/
	
	var GoToURL = "";
	if (!jstfEditMode && jstfOrgHasCustomEK)
		GoToURL += "../../clients/" + jsCurOrg + "/ek_" + jsCurOrg + ".cfm?" + jsAllArgs;
	else
		GoToURL += "../events.cfm?" + jsAllArgs;
	
	if ((jsCurMonth != 'ALL') && (jsCurMonth != 'PASTTOO'))
	{
		GoToURL += "&curMonth=" + newMonth;
		GoToURL += "&curYear=" + newYear;
	}	
	GoToURL += "&curMode=LOGOUT";
	// alert("Going to " + GoToURL);
	location.href = GoToURL;
}

function selectEditDay( newMonth, newDay, newYear ) 
{
	tfEvtDateChanged = true;
	
	document.SetDisplayCriteria.fDay.value = newDay;
	// woof : may need to pad these dates for the anchor to work.
	
	<!--- do this twice, once to show editor and again to stuff	the date field.	 --->
	
	var newJsDate = new Date (newYear, newMonth, newDay);
	// alert ("New JsDate = " + newJsDate);
	
	xdayname = dow7[newJsDate.getDay()];
	xmonth   = names[newJsDate.getMonth()];
	xday 	= newJsDate.getDay();
	xyear = y2k(newJsDate.getYear());
	
	tStr = xdayname + ',   ' + xmonth + ' ' + newDay + ',  ' + xyear;

	var newDate = padout(RealMonth(newMonth)) + '/' + padout(newDay) + '/' + newYear;
	// alert ("New DB Date = " + newDate);

	// alert ("Show Date = " + tStr);
	// alert ("cbShowDate1 = " + document.EditEvent.cbShowDate1.checked);
	// alert ("cbShowDate2 = " + document.EditEvent.cbShowDate2.checked);
	
	if (document.EditEvent.cbShowDate1.checked)
	{
		document.EditEvent.showDate1.value = tStr;	

		document.EditEvent.EvtDateBegin.value = newDate;
		document.EditEvent.EvtMonth.value = RealMonth(newMonth);
		document.EditEvent.EvtDay.value = newDay;
		document.EditEvent.EvtYear.value = newYear;

		document.EditEvent.EvtDateTimeBegin.value = newDate;
	}
	
	if (document.EditEvent.cbShowDate2.checked)
	{
		document.EditEvent.showDate2.value = tStr;	
		document.EditEvent.EvtDateEnd.value = newDate;

		document.EditEvent.EvtDateTimeEnd.value = newDate;
	}	
}

function changeYear(tfEvtListPg3) 
{
	// woof : might need to use Layers to avoid layers even in NN on bigMonth
	// sniff
    if (OkToUseInnerHTML()) 
		newYear = document.Cal.Year.options[document.Cal.Year.selectedIndex].value + '';
	else
		newYear = document.layers['CL1'].document.Cal.Year.options[document.layers['CL1'].document.Cal.Year.selectedIndex].value + '';

	document.SetDisplayCriteria.fYear.value = newYear;
    ShowMonth (document.SetDisplayCriteria.fMonth.value,newYear,tfEvtListPg3,'JS-CY-186');
}

function changeMonth(tfEvtListPg2) 
{
	// alert("A: Change Month");
	// sniff
    if (OkToUseInnerHTML()) 
	{
		// alert ("A: change month, IE, layers");		
		newMonth = document.Cal.Month.options[document.Cal.Month.selectedIndex].value + '';
		// alert ("newMonth = " + newMonth);
	}
	else
	{
		// alert("A: Second option");
		newMonth = document.layers['CL1'].document.Cal.Month.options[document.layers['CL1'].document.Cal.Month.selectedIndex].value + '';
	}
			
	window.document.SetDisplayCriteria.fMonth.value = newMonth;
    ShowMonth (newMonth,document.SetDisplayCriteria.fYear.value,tfEvtListPg2,'JS-CM-178');    
}

function PickADay( newMonth, newDay, newYear ) 
{
	// alert("Pick a day");
	
	var pIndex = IndexOfDayPicked( newMonth, newDay, newYear );
	
	if ( pIndex == -1)
	{	

	<!--- do this twice, once to show editor and again to stuff	the date field.	 --->
	
	var newJsDate = new Date (newYear, newMonth, newDay);
	xdayname = dow7[newJsDate.getDay()];
	xmonth   = names[newJsDate.getMonth()];
	xday 	= newJsDate.getDay();
	xyear = y2k(newJsDate.getYear());
	
	tStr = xdayname + ',   ' + xmonth + ' ' + newDay + ',  ' + xyear;

	var newDate = padout(RealMonth(newMonth)) + '/' + padout(newDay) + '/' + newYear;

	{
		document.EditEvent.showDate1.value = tStr;	

		document.EditEvent.EvtDateBegin.value = newDate;
		document.EditEvent.EvtMonth.value = RealMonth(newMonth);
		document.EditEvent.EvtDay.value = newDay;
		document.EditEvent.EvtYear.value = newYear;

		document.EditEvent.EvtDateTimeBegin.value = newDate;
	}
	
	{
		document.EditEvent.showDate2.value = tStr;	
		document.EditEvent.EvtDateEnd.value = newDate;

		document.EditEvent.EvtDateTimeEnd.value = newDate;
	}	

		var pickedDateStr = RealMonth(newMonth) + '/' + newDay + '/' + newYear;
		// alert("you picked " + pickedDateStr);
		AddDayPicked (pickedDateStr);
	}
	else
	{
		PickedDayArray[pIndex] = 'DELETED';
	}			

	// alert ("array = " + PickedDayArray);

	ShowMonth(newMonth,newYear,1,'Internal')
}

function IndexOfDayPicked (thisMonth, thisDay, thisYear)
{
	var someDateStr = RealMonth(thisMonth) + '/' + thisDay + '/' + thisYear;
	// alert("checking day = " + someDateStr);
	// alert("PickedDayArray = " + PickedDayArray + "PickedDayArray.length = " + PickedDayArray.length);
	
	for (var i = 0; i < PickedDayArray.length; i++) 
   	{ 
   		if (someDateStr == PickedDayArray[i])
		{
			return i ; 
	 	}
	}	 
	return -1;
}

function AddDayPicked (thisDayStr)
{
	var plen = PickedDayArray.length;
	PickedDayArray[plen] = thisDayStr;
}

function RemindReindex()
{
	if (jsNeedReindex)
	{
		var answer=confirm("Are you sure that you want to LOGOUT without REINDEXING?");
		if (answer)	return true;
		else return false;	
	}
	return true;
}

function ShowInfo(cOrg, passID)
{
	var url = "popinfo.cfm?curOrg=" + cOrg + "&pID=" + passID;
	window.open(url, "popnotewin", "width=400,height=400,left=100,top=100, resizable=yes,scrollbars=yes").focus();
}


	