//	 <script type="text/javascript" src="/js/c360_lib.js"></script>

//current folder up to the /
function baseRef(){ return location.href.substring(0,location.href.lastIndexOf("/")+1)}
function e(obj){
	//3/23/07 you can pass in an object or the ele id name
	return (typeof obj == "string") ? document.getElementById(obj) : obj;
 }
function setStyle(obj,style,value){e(obj).style[style]= value;}
function showConsole(str) {	console.log(str)}
function fncDojoBindError(type, data, evt) {
 	alert("This page is still loading. Please wait until status bar clears");
	showConsole(evt.responseText)
 }

//Original:  Sandeep Tamhankar (stamhankar@hotmail.com) -->
//Web Site:  http://207.20.242.93 -->

//This script and many more are available free online at -->
//The JavaScript Source!! http://javascript.internet.com -->

//Begin
//Original:  Cyanide_7 (leo7278@hotmail.com) -->
//Web Site:  http://members.xoom.com/cyanide_7 -->

//This script and many more are available free online at -->
//The JavaScript Source!! http://javascript.internet.com -->
//<input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3">
//Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//End Auto Tab
//Original:  Cyanide_7 (leo7278@hotmail.com) -->
//Web Site:  http://www7.ewebcity.com/cyanide7 -->

//This script and many more are available free online at -->
//The JavaScript Source!! http://javascript.internet.com -->
//returns number in format 9,999.00
//Begin
function formatDec2(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-')  + num + '.' + cents);
//return (((sign)?'':'-') + '$' + num + '.' + cents);
}
//  End -->



function debug_showLoc () {alert(location.href)}

function extractCourses (myTerm) {
	var startDate = e("rangeStart").value
	var endDate = e("rangeEnd").value	
	winNew=window.open("extract_crsByTerm.cfm?t=myTerm&startDate=" + startDate + "&endDate=" + endDate, 
	"popupPTSAMembership", "width=425px,height=500px,top=50px,left=100px, scrollbars=1, menubar=1,location=0")	
	winNew.focus()
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
var yearPrefix = "20"
// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
function LZ(x) {return(x<0||x>9?"":"0")+x}
function formatDate(date,format) {
	var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');

	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isValidDateCheck(dtStr){
	//dtCh set at top of this file
	if (dtStr == "") {return true}
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)

	strYr=strYear
	if (strYr.length == 2) {strYr = yearPrefix + strYear}

	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy or m/d/yy or mmddyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYr.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date: Invalid characters")
		return false
	}
return true
}

function isValidDate(myField){
	//var dt=document.frmSample.txtDate
	//mpal 7/17/07 if date in format mmddyy, push in slashes, otherwise just pass through
	//skip if there is already formatting
	var strDate = myField.value
	var pos1=strDate.indexOf(dtCh)
	if (pos1 <0) {
	if (strDate.length == 6) {
		strDate = strDate.substr(0,2) + "/" + strDate.substr(2,2) + "/20" + strDate.substr(4,2)
		myField.value = strDate
	}
	}
	/*if (strDate.length == 8) {
		strDate = strDate.substr(0,6) + "20" + strDate.substr(6,2) 
		myField.value = strDate
	}*/
	
	
	if (isValidDateCheck(strDate)==false){
		myField.value = "";
		myField.focus(); myField.select()
		return false
	}
    return true
 }

//==================isValidDate end

function isValidTime(thisField) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.
// mpal 3/2/2007 allow 1 or 2 digit entries for hours with a/p or am/pm
var timeStr = thisField.value
var lastChar
var posOffset, justHours


if (timeStr.length <=4) {
	posOffset = 1
	lastChar = timeStr.substr(timeStr.length-posOffset,1)
	if (lastChar.toLowerCase() == "m"){
		posOffset = 2
		lastChar = timeStr.substr(timeStr.length-posOffset,1)
	}
	//figure out if this is a/p or am/pm, return a or p
	justHours = timeStr.substr(0,timeStr.length-posOffset)
	timeStr = justHours + ":00" + lastChar
	thisField.value = timeStr
}
if (timeStr == "") {return true}
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm|a|A|p|P))?$/;

var matchArray = timeStr.match(timePat);

if (matchArray == null) {
	alert("Time is not in a valid format (hh:mm a/p).");
	thisField.value = ""
	return false;
	}
	
hour = matchArray[1];
//Allow minutes to be blank
minute = (matchArray[2] == ""?00:matchArray[2]);
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
	alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
	return false;
}
if (hour <= 12 && ampm == null) {
	if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
	alert("You must specify AM or PM.");
	return false;
   }
}
if  (hour > 12 && ampm != null) {
	alert("You can't specify AM or PM for military time.");
	return false;
}
if (minute<0 || minute > 59) {
	alert ("Minute must be between 0 and 59.");
	return false;
}
if (second != null && (second < 0 || second > 59)) {
	alert ("Second must be between 0 and 59.");
	return false;
}
return false;
}



function hoursCalc( myStartTime, myEndTime, myHours) {
	//don't try to calc if no end time
	var oneHour = 3600000
	if (document.getElementById(myEndTime).value == "")
		{ return false;}
		
	var startTime = timeGetObj(myStartTime)
	var endTime = timeGetObj(myEndTime)
	
	var elapHours = (endTime - startTime)/oneHour
	//kludge mpal 10/5/2006 if noon to noon:59, produces negative number
	//so add 12 to get correct number
	//if end_time is noon, then subtract 12 hours
	
	if (elapHours < 0) {
		elapHours = 12 + elapHours
	}
	if (elapHours > 12) {
		elapHours = elapHours - 12
	}
	elapHours = elapHours.toFixed(2)
	document.getElementById(myHours).value = elapHours
	}
function timeGetObj(myStartTime) 
	{
	//var startTime = new Date(document.getElementById("startTime").value)
	//var endTime = new Date(document.getElementById("endTime").value)
	
	var startTime = document.getElementById(myStartTime).value
	
	startTime = startTime.toLowerCase()
	var startTimeNum
	var intStartHour = 0
	var intStartMin = 0
	var calcStartTime
	var calcEndTime
	var hoursOK = false
	var dt = new Date()
	var rtnDateTime
	var intOffset = 0
	
	//a or am or p or pm required
	if (startTime.indexOf("a") >= 0) {		
			intStartHour = parseInt(startTime.substring(0, startTime.indexOf("a")))
			hoursOK = true
			}
	if (startTime.indexOf("p") >= 0) {		
			intStartHour = parseInt(startTime.substring(0, startTime.indexOf("p"))) + 12
			hoursOK = true
	}
	
	if (hoursOK == false){alert("Requires AM or PM");return false;}
	//get minutes?	
	if (startTime.indexOf(":") >= 0) {
		intStartMin = parseInt(startTime.substr(startTime.indexOf(":") + 1, 2))		
	}
	
	rtnDateTime = new Date(dt.getYear(), dt.getMonth(), dt.getDate(), intStartHour, intStartMin, 00)
	
	return rtnDateTime
}

function getURLParam(strParamName){
	  var strReturn = "";
	  var strHref = window.location.href;
	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
	    {
	      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 )
	      {
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        break;
	      }
	    }
	  }
	  return strReturn;
	  
	} 

function popupEmailPreview(emailIDName) {
			
			newWin=window.open("popup_emailPreview.cfm?emailID=" + e(emailIDName).value,"popupEmailPreview", 	"width=740px,height=600px,top=25px,left=50px" )
			newWin.focus()
		
		}
		function emailCheckSubject () {
			//mpal 1/4/2006 check to make sure there is content in the subject field
			
			if (e("email_subject").value == "" || e("email_subject").value.length < 12) {
				return confirm("Subject value either blank or less than 12 characters.");
				//return false; 
			} else {
				return true;
			}
			
		}
function quickCity (thisFld) {		
		if (thisFld.value.toUpperCase() == "SF") {thisFld.value = "San Francisco"}	
		if (thisFld.value.toUpperCase() == "O") {thisFld.value = "Oakland"}
		if (thisFld.value.toUpperCase() == "B") {thisFld.value = "Berkeley"}
		if (thisFld.value.toUpperCase() == "DC") {thisFld.value = "Daly City"}
		if (thisFld.value.toUpperCase() == "SSF") {thisFld.value = "South San Francisco"}
		if (thisFld.value.toUpperCase() == "HMB") {thisFld.value = "Half Moon Bay"}
		if (thisFld.value.toUpperCase() == "P") {thisFld.value = "Pacifica"}
	}
	function defAreaCode (thisFld, areacodeFldID) {	
		
		if (
		document.getElementById(areacodeFldID).value == "" 
		&& thisFld.value != "")
		{
		document.getElementById(areacodeFldID).value = "415"
			
			
		}
		//format if phone entered without hyphen
		if (thisFld.value.length == 7 ) {
				thisFld.value = thisFld.value.substring(0,3) + "-" + thisFld.value.substring(3)
			}
			
	}
function refresh()
{
    window.location.reload( false );
}
 function popupBio(person_ID) {
		var myForm = document.forms["popup"]
		newWin=window.open("popup_InstructorBio.cfm?p=" + person_ID,"popupBio", 
		"width=575px,height=425px,top=50px,left=100px,resizable=1,scrollbars=1,location=0")
		newWin.focus()
	}
 function popup_purchAlloc(recID, masterID) {
 		//pass in recID = 0 for new item, if recID = 0, then masterID (disb_ID) is required
		var m = masterID == null?0:masterID
		/*if (m == 0 && recID == 0) {
			alert("Please Save master record before entering details")
		} else {*/
			var newWin=window.open("popup_purchAlloc.cfm?i="  + recID + "&m=" + m,"popupPurchAlloc", 
			"width=600px,height=600px,top=50px,left=100px,resizable=1,scrollbars=1,location=0")
			newWin.focus()
			
		//}
	}
function popup_schoolCode (bus_ID, schoolCode) {	
	
		var newWin=window.open("popup_schoolCode.cfm?b=" + bus_ID +  "&sc=" + schoolCode ,"popupDeleteName", 
		"width=300px,height=150px,top=50px,left=50px,scrollbars=1,resizable=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_crsSchedCopy (curTerm) {	
	
		var newWin=window.open("popup_crsSchedCopy.cfm?t=" + curTerm ,"popupcrsSchedCopy", 
		"width=300px,height=150px,top=100px,left=200px,scrollbars=1,resizable=1,menubar=0,location=0")		
		newWin.focus()
}
function popup_participationSelect (person_ID, participant_ID, event_type, event_nickname) {	
		//id ::= unique ID for participant record for editing
		 event_type = event_type == null?"":event_type
		 event_nickname = event_nickname == null?"":event_nickname
		var newWin=window.open("popup_participationSelect.cfm?p=" + person_ID + "&id=" + participant_ID 
			+ "&f=" + event_type + "&nn=" + event_nickname,"popupParticipationSelect", 
		"width=700px,height=500px,top=100px,left=100px,scrollbars=1,resizable=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_namesCopyPaste (person_ID) {	
	
		if (!person_ID) {
		alert("Please select a Person first")
		} else {
		var newWin=window.open("popup_namesCopyPaste.cfm?p=" + person_ID ,"popupNamesCopyPaste", 
		"width=350px,height=450px,top=100px,left=200px,scrollbars=1,resizable=1,menubar=0,location=0")		
		newWin.focus()
		}
}
function popupAddressBookDupeCheck(){
	// If this is called after Edit Name set for existing record, don't check dupes 9/22/2005
	
	if (document.getElementById("person_ID").value == 0) {

			// showStatusMsg01('checkName', 'Searching...')
			 	
			var ln = document.getElementById("last_name").value
			var fn = document.getElementById("first_name").value
			
			var winNames=window.open("popup_DupeNameCheck.cfm?f=checkName&ln=" + ln + "&fn=" + fn, "popup_NamesExist", 	
					"width=690px,height=350px,top=100px,left=50px,scrollbars=1,menubar=1")	
					if (winNames) {
					winNames.focus()}	
		} 
	}
function openNames(myPerson_ID, frm) {
	//pass in name of form to reload
		
		var frm = frm == null?"popup":frm
		var myPerson_ID = myPerson_ID==null?0:myPerson_ID
		if (myPerson_ID == "" && myPerson_ID== 0) {
		winAddressBook=
		window.open("popup_NamesDefault.cfm?frm="+ frm + "&fldPerson_ID=faculty_ID&popup=Y&refresh=Y", "popup_AddressBook"
		,"width=775px,height=575px,top=50px,left=25px,scrollable=1,location=0,menubar=1")	
		} else {
		winAddressBook=
		window.open("popup_NamesDefault.cfm?p=" + myPerson_ID + 
			"&frm=" + frm + "&fldPerson_ID=faculty_ID&popup=Y&refresh=Y", "popup_AddressBook"
			,"width=775,height=575,top=50px,left=25px,scrollable=1,location=0,menubar=1")	
		}
		winAddressBook.focus()
	} 
function openNamesFld(person_IDFld, frm) {
	//pass in name of form to reload
	//pass in Field Name for person_ID
		
		
		myPerson_ID = e(person_IDFld).value
		
		if (myPerson_ID == "" && myPerson_ID== 0) {
		winAddressBook=
		window.open("popup_NamesDefault.cfm?frm="+ frm + "&fldPerson_ID=" + person_IDFld + "&popup=Y", "popup_AddressBook"
		,"width=775px,height=575px,top=50px,left=25px,scrollable=1,location=0,menubar=1")	
		} else {
		winAddressBook=
		window.open("popup_NamesDefault.cfm?p=" + myPerson_ID + 
			"&frm=" + frm + "&fldPerson_ID=" + person_IDFld + "&popup=Y", "popup_AddressBook"
			,"width=775,height=575,top=50px,left=25px,scrollable=1,location=0,menubar=1")	
		}
		winAddressBook.focus()
	} 
function popup_deleteName (person_ID) {	
		var person_ID = person_ID == null?e("person_ID").value:person_ID
		//1/23/2007 clear address book before going to delete form
		ajaxAddressBookForm('person_ID', 0)
		newWin=window.open("popup_deleteName.cfm?p=" + person_ID ,"popupDeleteName", 
		"width=775px,height=625px,top=25px,left=25px,scrollbars=1,resizable=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_Donations (trans_ID, event_ID) {	
	
		newWin=window.open("popup_Donations.cfm?t=" + trans_ID +"&e=" + event_ID,"popupEmailConfirm", 
		"width=400px,height=525px,top=100px,left=200px,scrollbars=1,resizable=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_directionsDriving () {	
	
		newWin=window.open("popup_directionsDriving.cfm","popupDirectionsDriving", 
		"width=600px,height=500px,top=50px,left=50px,scrollbars=1,resizable=1,menubar=1,location=0")		
		newWin.focus()
}


function searchNameYouthReg(frmThis) {	
	checkDupe(frmThis.name);checkDupeMessage(frmThis)
}
function popupSecurity() {
			//mpal 11/22/05 include in onLoad for all popup forms
			//so if not called from a JS button, it won't open
			if(!self.opener) {window.location.href = "noAccess.htm"}
		}

function popup_busDir (action) {	
	
		newWin=window.open("popup_busDir.cfm?addBusiness=" + action ,"busDir", 
		"width=600px,height=615px,top=25px,left=25px,scrollbars=1,resizable=1,status=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_busDirGoTo (fieldName) {
	//fieldName of field that has parent_unitSite (bus__ID) for this person
	newWin=window.open("popup_busDir.cfm?x=" + e(fieldName).value ,"busDir", 
		"width=650px,height=600px,top=50px,left=100px,scrollbars=1,menubar=1,location=0")		
		newWin.focus()
}
function popup_edu_adultReg_emailReview (trans_ID) {	
	
		newWin=window.open("popup_edu_adultReg_EmailReview.cfm?t=" + trans_ID + "&action=p" ,"popupEmailConfirm", 
		"width=800px,height=525px,top=50px,left=25px,scrollbars=1,resizable=1,status=1,menubar=1")		
		newWin.focus()
}

function popup_CourseDesc () {	
		if (e("section_ID").value != "") {
			newWin=window.open("popup_coursedesc.cfm?section_ID=" + e("section_ID").value ,"popupCourseDesc", 
			"width=600px,height=400px,top=50px,left=25px,scrollbars=1,resizable=1,status=1")		
			newWin.focus()
		} else {
			alert("Select Course First")
					
		}
		
}
function popup_adminEvalFaculty (uniqueID) {	
	
		newWin=window.open("popup_adminEvalFaculty.cfm?i=" + uniqueID ,"popupAdminEvalFacultye", 
		"width=350px,height=200px,top=200px,left=200px,scrollbars=1,resizable=1,status=0,menubar=0,location=0")		
		newWin.focus()
}
function popup_Article (uniqueID) {	
	
		newWin=window.open("popup_Article.cfm?id=" + uniqueID ,"popupArticle", 
		"width=850px,height=650px,top=25px,left=25px,scrollbars=1,resizable=1,status=1,menubar=1")
		//, "width=650px,height=525px,top=50px,left=100px")
		newWin.focus()
}
function popup_article_edit (uniqueID, event_ID, menuCode, editType) {	
		//if event_ID push into item record event_ID_link
		//mpal 2/23/2007 editType:= quickLinkEdit, used to supress the Address book button for public edit
		//NOTE: Seems that when it's best to put the uniqueID parameter in quotes when passing in
		//menuCode::= 3/11/2007 mpal used when editing an article in the context of a menu, links to c360_menu_group
		var myEvent_ID = event_ID == null?0:event_ID
		var myEditType = editType == null?"":editType
		var myMenuCode = menuCode == null?"":menuCode
		var uniqueCode = ""

		//user can pass in a the unique nickname for an article instead of the numberic unique_ID. It's worked out below
		if (isNaN(uniqueID)) {
		
		uniqueCode = uniqueID
		uniqueID = "" }
		
	
		var str = "popup_Article_edit.cfm?unique_ID=" + uniqueID + "&uniqueCode=" + uniqueCode + "&event_ID=" + myEvent_ID + "&mc=" + myMenuCode + "&et=" + myEditType + "&popup=Y" 
		
		winArticleEdit=window.open(str ,
			"popupArticleEdit", "width=785px,height=650px,top=120px,left=120px,scrollbars=1,menubar=1,location=0")
			winArticleEdit.focus()
		
}
function popup_tasks (task_ID, sched_ID) {
	//task_ID == 0 if new task, sched ID could also be event ID if for master record
	
		newWin=window.open("popup_task.cfm?t=" + task_ID + "&s=" + sched_ID,"popupTasks",	"width=425px,height=400px,top=100px,left=100px")
		newWin.focus()
}
function popup_Zoom (fieldNameOnForm,  fieldNameInTable, tableName, keyFieldNameInTable, keyFieldElementName, formats, cssFileName, linkFieldNameInTable, linkFieldEleName) {
		//10/25/2006 mpal the popup_zoom form SAVES the text field on Exit and pushes the value back to the calling form
		//linkFieldNameInTable::= if this is a child record, name of the master key field in the table(like event_parent_ID)
		//linkFieldEleName::= name of the master element (event_ID) on the form
		//7/4/07 mpal this should be generalized for any table
		var f, eID, t, k, ft
		eID = e(keyFieldElementName).value
		k = keyFieldNameInTable
		t = tableName
		ft = fieldNameInTable
		var fItems = formats == null || formats==""?"All":formats
		var lField = linkFieldNameInTable == null?"":linkFieldNameInTable
		var lValue = linkFieldEleName == null?"":linkFieldEleName
		var css = cssFileName == null || cssFileName == ""?"":e("cssFileName").value
		var masterValue = 0
	
		if (lValue != "") {masterValue = e(lValue).value}
		//master record must be saved before calling Zoom
		if (eID == "" || eID ==0) {
			
			//if Events, create rec
			if (tableName == "events") {

				var bindArgs = {
					url: "ajaxForm.cfm",
					content: {action: "saveEvent", ajaxSubform: "_ajaxActivities.cfm", masterFieldName: lField, masterValue: masterValue},
					method: "post",
					mimetype: "text/json",
					error: function(type, data, evt){
						console.log(evt.responseText);				
     					alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    				},
					load: function(type, data, evt){	
						//alert(data.data.MAXID[0])
						e(keyFieldElementName).value = data.data.MAXID[0]
						eID = data.data.MAXID[0]
							newWin=window.open("popup_zoom.cfm?fld=" + fieldNameOnForm + "&e=" + eID + "&t=" + t + "&k=" + k + "&ft=" + ft + "&fItems=" + fItems + "&css=" + css,
								"popupZoom", "width=800px,height=600px,top=50px,left=120px,menubar=1,location=0")
							newWin.focus()
					
		    		}
				}
		
				dojo.io.bind(bindArgs);
			
			} else {			
				alert("Please save record before calling the Editor")
				return
			}
		} else {
			//record already saved
			var winAction = "popup_zoom.cfm?fld=" + fieldNameOnForm + "&e=" + eID + "&t=" + t + "&k=" + k + "&ft=" + ft  + "&fItems=" + fItems
			
			newWin=window.open(winAction, "popupZoom", "width=800px,height=600px,top=50px,left=120px,menubar=1,location=0")
			if (newWin) {
			newWin.focus()}
		}
		
}
function popup_Zoom_old (fieldNameOnForm) {
		//10/25/2006 mpal the popup_zoom form SAVES the text field on Exit and pushes the value back to the calling form
		
		
		newWin=window.open("popup_zoom_old.cfm?fld=" + fieldNameOnForm,"popupZoom",	"width=800px,height=600px,top=50px,left=120px,menubar=1")
		newWin.focus()
}
 function popup_crsRoster(section_ID) {
		//v=View  Coord(inator) or Ins(tructor)
		newWin=window.open("popup_crsRoster.cfm?s=" + section_ID + "&v=Coord","popupCrsRoster", 		"width=850px,height=600px,top=50px,left=50px, scrollbars=1,menubar=1")
		newWin.focus()
	}
 function popup_emailListSignup(listCode) {
		
		newWin=window.open("popup_emailListSignUp.cfm?l=" + listCode,"popupEmailListSignup", 		"width=475px,height=300px,top=200px,left=200px")
		newWin.focus()
	}
	 function popup_brochureRequests(listCode) {
		
		newWin=window.open("popup_brochureRequests.cfm?l=" + listCode,"popupEmailListSignup", 		"width=475px,height=300px,top=200px,left=200px")
		newWin.focus()
	}
 function popup_cs_stdRpt(advise_ID, term, course_ID, placement_ID) {		
 	//version: pass in zeros if no parameter
		
		newWin=window.open("popup_cs_stdRpt.cfm?i=" + advise_ID + "&t=" + term + "&c=" + course_ID + "&p=" + placement_ID,
		"popup_cs_site",
		"width=650px,height=575,top=50px,left=100px,location=0,scrollbars=1,menubar=1,resizable=1")
		newWin.focus()
	}
	 function popup_cs_hours(placement_ID, itemID) {		
 	//version: pass in zeros if no parameter
		
		newWin=window.open("popup_cs_hours.cfm?pid=" + placement_ID + "&itemID=" + itemID,
		"popup_cs_hours",
		"width=200px,height=200px,top=150px,left=200px,location=0,scrollbars=1,menubar=1,resizable=1")
		newWin.focus()
	}
	 function popup_cs_expItems(placement_ID, action) {		
 	//version: pass in zeros if no parameter
		
		newWin=window.open("popup_cs_expItems.cfm?p=" + placement_ID + "&a=" + action,
		"popup_cs_expItems",
		"width=650px,height=575,top=50px,left=100px,location=0,scrollbars=1,menubar=1,resizable=1")
		newWin.focus()
	}
 function popup_facRoster(meet_ID, term, sectionType) {		
 	//version: All, Std, Site, Prec
		
		newWin=window.open("popup_facRoster.cfm?m=" + meet_ID + "&st=" + sectionType ,
		"popup_cs_site",
		"width=650px,height=575,top=50px,left=100px,location=0,scrollbars=1,menubar=1,resizable=1")
		newWin.focus()
	}
 function popup_cs_site(site_ID, version, placement_ID) {		
 	//version: All, Std, Site, Prec
		var p = placement_ID == null?0:placement_ID
		newWin=window.open("popup_cs_site.cfm?s=" + site_ID + "&v=" + version + "&p=" + p,
		"popup_cs_site",
		"width=770px,height=575,top=75px,left=75px,location=0,scrollbars=1,menubar=1,resizable=1")
		newWin.focus()
	}
 function popup_cs_prec(preceptor_ID, version) {		
	newWin=window.open("popup_cs_prec.cfm?s=" + preceptor_ID + "&v=" + version,
	"popup_cs_prec",
	"width=650px,height=575,top=50px,left=100px,location=0,scrollbars=1,menubar=1,resizable=1")
	newWin.focus()
}
function clickPost(myGroup, myItem, myRoles, myE) {
	var newForm = baseRef() && "untitled1.cfm"
	//alert(myGroup + myItem + myRoles + myE)a
}
 function popup_Announcements(myID, frm) {	
		newWin=window.open("popup_announcements.cfm?i=" + myID + "&frm=" + frm,"popupAnnouncements", 
		"width=600px,height=400px,top=100px,left=100px,scrollbars=1")
		
		newWin.focus()
	}
	function popup_Announcements_view(myID) {	
		newWin=window.open("popup_announcements_view.cfm?i=" + myID,"popupAnnouncementsView", 
		"width=600px,height=400px,top=100px,left=100px,scrollbars=1")
		
		newWin.focus()
	}
 function popup_transDetail(myID) {
		
		newWin=window.open("popup_transDetailEdit.cfm?t=" + myID,"popupTransDetail", 
		"width=400px,height=300px,top=125px,left=200px")
		newWin.focus()
	}
	 function popup_transCredit(myID, myForm) {
		
		newWin=window.open("popup_transCredit.cfm?t=" + myID + "&frm=" + myForm,"popupTransDetail", 
		"width=400px,height=300px,top=125px,left=200px,resizable=1")
		newWin.focus()
	}
function calSetDateFmt(strURL) {
	//use with Calendar views. Create Select control called selectDate that shows months in format MMM YYYY, fieldname refDate
	//pass in the URL not including the v and d parameters. see _schedPublicList.cfm 9/23/2005
		var aryMonth = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
		var targetMonth = document.getElementById("selectDate").value		
		var targetYear = targetMonth.slice(4)
		var myNextCriteria
		if (e("calGroup")) {
			myNextCriteria = e("calGroup").value
		}
		targetMonth = targetMonth.slice(0,3)		
		
		for (var i=0; i<=11; i++) {			
			if (aryMonth[i] == targetMonth) {break}
		}
		
		document.getElementById("refDate").value = (i+1) + "/1/" + targetYear
		
		location.assign(strURL + "&v=Cal&d=" + targetYear + (i+1) + "&myNextCriteria=" + myNextCriteria)
	
	}
function popup_helpItem (itemCode) {
	var winHousehold
	
	winHousehold=window.open("popup_help_item.cfm?i=" + itemCode, "popupHelpItem", 
	"width=610px,height=640px,top=15px,left=50px")	
	winHousehold.focus()	
}
function popup_Activity (event_ID, sched_ID, event_type, flgQuickLink) {
	var winHousehold
	var e = sched_ID == null?0:sched_ID
	var event_type = event_type == null?"":event_type
	var flgQuickLink = flgQuickLink == null?"":flgQuickLink
	//flgQuickLink: quickLinkEdit
	//event_type: pass in default event_type when creating new recs
	winHousehold=
	window.open("popup_Activity.cfm?"
	+ "e=" + event_ID + "&s="+sched_ID + "&et=" + event_type + "&ql=" + flgQuickLink + "&isPopup=Y"
	 , "popupActivityEdit", "width=750px,height=660px,top=130px,left=120px,scrollbars=1,menubar=1,location=0")	
	winHousehold.focus()	
}

function popupBusDirDetail(field_ID) {
		var myBus_ID = document.getElementById(field_ID).value
		var winBusDir
		winBusDir=window.open("popup_busDir.cfm?x=" + myBus_ID + "&bus_id_fieldname=parent_unitSite&f=checkName", "popup_BusDir", "width=620px,height=625px,top=25px,left=100px,scrollbars=1, menubar=1")	
		winBusDir.focus()
	}
function popupBusDirSelect(myBus_ID) {		
		var winBusDir
		winBusDir=window.open("popup_busDir.cfm?x=" + myBus_ID, "popup_BusDir", "width=780px,height=600px,top=50px,left=100px,scrollbars=1, menubar=1")	
		winBusDir.focus()
	}
function popupZLK(listCode) {
	var winHousehold	
	
	winHousehold=window.open("popup_zlk.cfm?listCode=" + listCode , "popupZLK", "width=425px,height=450px,top=50px,left=50px")	
	winHousehold.focus()	
}

function popup_actSchedule (sched_ID, event_ID) {
	var winHousehold
	var e = event_ID == null?0:event_ID
	winHousehold=window.open("popup_actSchedule.cfm?s=" + sched_ID + "&e=" + event_ID
	 , "popupActSchedule", "width=725px,height=550px,top=50px,left=50px")	
	winHousehold.focus()	
}


function popup_flyer(doc_ID) {
	var winHousehold
	
	winHousehold=window.open("popup_flyer.cfm?i=" + doc_ID , "popupflyer", "menubar=1,scrollbars=1,location=0")	
	winHousehold.focus()	

}
function stripDoubleQuotes (thisField) {
	//mpal 9/5/2005 strip double quotes from entered data onChange
	
	var str = thisField.value

	if (str.indexOf('"') != 0) {
		alert( "Double-quotes cannot be used in the this field. Please replace with single-quotes.")
		return false }
		else {
		return true
		}
}
function popup_flyerEventDefGetEvent() {
	if (e("event_ID").value == 0) {alert("Please save record before Preview"); return}
	popup_flyerEventDef(e("event_ID").value, e("sched_ID").value)
}
function popup_flyerEventDef(event_ID, sched_ID) {
	var winHousehold	
	//10/10/2006 if event_ID value not passed in, look on form
	var e = event_ID == null?e("event_ID").value:event_ID
	var s = sched_ID == null?0:sched_ID
	
	winHousehold=window.open("popup_flyerEventDef.cfm?e=" + e +"&s="+ s, "popupflyer", "width=765px,height=750x,top=25px,left=25px,menubar=1,scrollbars=1,location=0,resizable=1")	
	winHousehold.focus()	

}
function delItemLink (link_ID) {
			if (confirm("Delete selected image?")) {
			var newWin=window.open("popup_delItemLink.cfm?i=" + link_ID ,"_new", 
			"width=1px,height=1px,top=1px,left=1px,scrollbars=0,resizable=0,menubar=0,location=0")	
			newWin.close()	
			alert("Image Link Deleted.")
			refresh()
			}
		}
	function delDocLink(id, catalog_ID, fileName) {
			if (confirm("Delete selected document from the web?") == false) {return}
			
			var bindArgs = {
				url: "ajaxForm.cfm",
				content: {action: "delDocLink", ajaxSubform: "_ajaxFileUpload.cfm", id: id, catalog_ID: catalog_ID, fileName: fileName},
				method: "post",
				mimetype: "text/plain",
				error: function(type, data, evt){	
				console.log(evt.responseText);		
				alert("error"); },
				load: function(type, data, evt){
					refresh()
				}
			}
			dojo.io.bind(bindArgs);
		}

function uploadFile(item_ID,  tableName, link_ID, item_file_type, item_shortname, events_item_ID, viewAction, fieldIDName, fieldFullFile) {
	//9/3/2005 mpal used to upload files to standard directories
	//item_id from item_catalog (optional, null if not known)
	
	//item_file_type::= type of file (pic, img, tmp, doc), optional
	//item_shortname::= optional. Can be used for standard documents (like Flyers in Performances)
	//tableName ::= table that the image is linked to (events, names, courses)
	//link_ID ::= values of foreign key for linked table (event_ID, person_ID, course_id)
	//fieldIDName ::= id of Span on form. Return uploaded file name
	//fieldFullFile::= id of input field, return full url and file name (use in link submission) 2/20/2007 mpal
	var winHousehold

	var i = item_ID == null?0:item_ID
	var e = link_ID==null?0:link_ID
	var ft = item_file_type==null?"":item_file_type
	var sn = item_shortname==null?"":item_shortname
	var ei = events_item_ID==null?0:events_item_ID
	var a = viewAction==null?"imgMulti":viewAction
	var fid = fieldIDName==null?"":fieldIDName
	var lnkFld = fieldFullFile==null?"":fieldFullFile
	var wHeight =  fid!=""?"200px":"450px"
	
	winHousehold=window.open("popup_fileUpload.cfm?" + 
	"i=" + i + "&e=" + e + "&ft=" + ft + "&sn=" + sn + "&ei=" + ei + "&t=" + tableName + "&a=" + a + "&fid=" + fid + "&lnkFld=" + lnkFld, 		
	"popupFileUpload", "width=700px,height=" + wHeight + ",top=100px,left=100px,resizable=1,scrollbars=1,menubar=1,location=0")	
	winHousehold.focus()	
}
function busDirPickMe () {
	
	busDir("Y")
}
function busDir (pickMe) {
		//7/18/2006 mpal If returnBus_ID is Y then show PickMe field to return parent_unitSite
		//alert(thisValue)
		var ynPickMe = pickMe == null?"N":pickMe
		var winBusDir
		
		var mySearch 
		if (e("busFinderField")) {
			mySearch = e("busFinderField").value
		} 
		
		if (mySearch=="") {alert("Please enter a value in the Search field"); return;}
		
		if (!winBusDir) {	
			winBusDir=window.open("popup_busDir.cfm?action=Select&b=" + mySearch + "&pickMe=" + ynPickMe, "busDir", 
			"width=650px,height=600px,top=100px,left=100px,location=0,menubar=1,scrollbars=1,resizable=1")	
		}
		
	winBusDir.focus()
}
function popupStaff (task_ID, event_ID) {			
	var winHousehold
	
	winHousehold=window.open("popup_Committee.cfm?t=" + task_ID + "&e=" + event_ID, "popupCommittee", "width=550px,height=500px,top=100px,left=100px")	
	winHousehold.focus()		
}
function popup_emailSetup (tableName, keyFieldName) {			
	var winHousehold
	winHousehold=window.open("popup_emailSetup.cfm?t=" + tableName + "&v=" + e(keyFieldName).value, 
		"popupEmailSetup", "width=800px,height=550px,top=50px,left=50px,scrollbars=1,location=0,menubar=1")	
	winHousehold.focus()		
}


function popupHelpView (menuItem, menuGroup, role) {			
	var winHousehold
	var g = menuGroup==null?"":menuGroup
	var r = role==null?"":role
	winHousehold=window.open("popup_HelpView.cfm?i=" + menuItem + "&g=" + g + "&r=" + r, "popupHelpView", "width=700px,height=575px,top=50px,left=100px")	
	winHousehold.focus()		
}
function popupStudentShort (student_ID) {			
	var winHousehold
	
	winHousehold=window.open("popup_studentShort.cfm?s=" + student_ID, "popupStudentShort", "width=700px,height=300px,top=50px,left=100px")	
	winHousehold.focus()		
}
function popupStudentFamily (student_ID, household_ID) {			
	var winHousehold
	
	winHousehold=window.open("popup_StudentFamily.cfm?s_id=" + student_ID + "&h_ID=" + household_ID, "popupStudentFamily", "width=750px,height=650px,top=10px,left=50px,scrollbars=1,resizable=1,menubar=1,location=0")	
	winHousehold.focus()		
}
function popupHelpViewFmt () {			
	var winHousehold
	
	winHousehold=window.open("popup_HelpViewFmt.cfm", "popupHelpViewFmt", "width=700px,height=575px,top=50px,left=100px")	
	winHousehold.focus()		
}
function popup_crsExpenseReport(section_ID) {			
	var winHousehold	
	winHousehold=window.open("popup_crsExpenseReport.cfm?s=" + section_ID, "popupcrsExpenseReport", "width=700px,height=575px,top=50px,left=100px,menubar=1,scrollbars=1")	
	winHousehold.focus()		
}

function popupNamesDefault (person_ID, frmName, action) {			
	var popupNamesDefault
	var a = action==null?"":action
	if (frmName) {
		popupNamesDefault=window.open("popup_NamesDefault.cfm?p=" + person_ID + "&frm=" + frmName + "&popup=Y&a=" + action, 
		"popupNamesDefault", "width=790px,height=550px,top=50px,left=50px,scrollbars=1,resizable=1,menubar=1")	
	} else {
		popupNamesDefault=window.open("popup_NamesDefault.cfm?p=" + person_ID + "&popup=Y", 
		"popupNamesDefault", "width=790px,height=550px,top=50px,left=50px,scrollbars=1,resizable=1,menubar=1")	
	}
	popupNamesDefault.focus()		
}

function popupVolForm01 (person_ID) {			
	var winHousehold
	if (person_ID == 0) {alert("Please save form first")} else {
	winHousehold=window.open("popup_volForm01.cfm?p=" + person_ID , "popupVolForm", "width=450px,height=550px,top=100px,left=100px")	
	winHousehold.focus()		
	}
}
var winNew


function popupPTSAMembershipLoad () {		
		
	winNew.document.getElementById("person_ID").value = e("student_ID").value
	winNew.document.getElementById("last_name").value = e("last_name").value + ", " + e("first_name").value
	
	if (e("p1_last_name").value != "") {
	winNew.document.getElementById("p1_person_ID").value = e("p1_person_ID").value
	winNew.document.getElementById("p1_last_name").value = e("p1_last_name").value + ", " + e("p1_first_name").value
	}
	if (e("p2_last_name").value != "") {
	winNew.document.getElementById("p2_person_ID").value = e("p2_person_ID").value
	winNew.document.getElementById("p2_last_name").value = e("p2_last_name").value + ", " + e("p2_first_name").value
	}
	winNew.focus()	
}


function popupNamesCampus (person_ID) {			
	var winHousehold
	winHousehold=window.open("popup_NamesCampus.cfm?p=" + person_ID , "popupNamesDefault", "width=550px,height=450px,top=100px,left=100px")			
}
function popupTransMaster (transID) {			
	var winHousehold
	
	winHousehold=window.open("popup_edu_adultReg.cfm?t=" + transID + "&isPopup=Y", "popupTransMaster", 
	"width=775px,height=575px,top=50px,left=100px,scrollbars=1,resizable=1,menubar=1,location=0")	
	winHousehold.focus()		
}
function popupDocentSchedItem (sched_ID, task_ID, frmName, action) {			
	var winHousehold
	//task_ID is participants.participant_ID
	//mpal 9/9/2005 frmName is name of form to clear (probably act_req) after scheduling
	//mpal 3/22/07 pass in Sched to force a schedule record to be create when opening form. passed in from Save/Schedule button
	var frm = frmName == null?"":frmName
	var action = action==null?"":action
	winHousehold=window.open("popup_DocentSchedItem.cfm?s=" + sched_ID+ "&p=" + task_ID + "&frm=" + frm + "&a=" + action, "popupSchedItem", "width=735px,height=550px,top=50px,left=50px,scrollbars=1,menubar=1,location=0")	
	winHousehold.focus()		
}

		function submitForm(formName) {
			document.forms[formName].submit()	
		}
		
	function checkDupeMessage(form){
		form.dupeMessage.value = "Checking for matches..."
	}
	
function showStatusMsg01(strForm, msg) {	
	if (document.forms[strForm].statusMsg01){		
	document.forms[strForm].statusMsg01.value = msg}
}

	
function home_Address1_focus(frmName) {
	//mpal 6/14/2005 should check if the form exists first
	
	if (document.forms[frmName])
	{
	var frmMain=document.forms[frmName]
	
	if (frmMain.last_name.value != "")
		{			
		frmMain.address1.select();
		frmMain.address1.focus();
		}
		else
		{
		frmMain.first_name.select();
		frmMain.first_name.focus();
		}
	}
}

function submitForm(frmName) {		
	document.forms[frmName].submit()	
}
function checkDupe(frmName) {
	document.forms[frmName].checkStatus.value="check"
	document.forms[frmName].submit()
}

function checkHomeAddress (frmName,thisField) {				
	var winHousehold
	winHousehold=window.open("popup_CheckAddress.cfm?f=" + frmName + "&h=0&a=" + thisField.value, 
		"popup_Household", "width=650px,height=325px,top=100px,left=100px,location=0")			
}

function popupCrsCat(action) {
	 	//action is rubric code or NewRec for new
		var myForm = document.forms["popup"]
		newWin=window.open("popup_crsCat.cfm?c="+action,"popupCrsCat", 
		"width=440px,height=130px,top=100px,left=100px")
		newWin.focus()
	}

function showHouseholdMembers (frmName, household_ID) {		
	var winHousehold
	winHousehold=window.open("popup_HouseholdDetail.cfm?frm=" + frmName + "&a=0&h=" + household_ID, "popup_Household",
	 "width=650px,height=375px,top=100px,left=100px")	
	//, 
}
function fieldROFmt (fieldIDName) {
	//assign CSS class fieldRO and make read-only
	if (!document.getElementById(fieldIDName)) {
		alert("ID not found in fieldROFmt: " + fieldIDName) }
		else {
	with (document.getElementById(fieldIDName)){
		
		 readonly = true
		className="fieldRO"
	}		
	}
	}
function msgDefaultFmt (fieldIDName) {
	//assign CSS class msgDefault and make read-only
	with (document.getElementById(fieldIDName)){
		 disabled = true
		className="msgDefault"
	}		
	}
	
function urlItem (refCode) {
		//mpal 6/27/2005
		//pass in url parameter reference, return value ucase
		
		myLocation = unescape(location.href)
		
		urlquery=myLocation.split("?")		
		
		if (urlquery[1]) {}
		
		else {
		//return empty if no parameters
		return ""
		}
		
		//get everything after the ?
		urlterms=urlquery[1].split("&")
		
		for (var i = 0; i < urlterms.length; i++) {
			myString = urlterms[i].toUpperCase()	
		
			if (myString.substr(0,myString.indexOf("=")) == refCode.toUpperCase()) {	
						
				return (myString.substr(myString.indexOf("=") + 1))
				}
		}
		return ""
	}
function pauseMs(millis)
{ //force pause in milliseconds
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
} 
function insertOptionFirst(elName, newText, newValue)
{
  var elSel = e(elName);
 
    var elOptNew = document.createElement('option');
    elOptNew.text = newText;
    elOptNew.value = newValue;
    try {
      elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      elSel.add(elOptNew); // IE only
    }
  	var elLen = elSel.length - 1
	elSel.selectedIndex = elLen
}

function frmElementsClear(frmName, spanArray) {
	//spanArray::= option array of Spane ID elements to clear
	
	var str = ''; var i
	var elem = document.getElementById(frmName).elements;
	for(i = 0; i < elem.length; i++) {
		elem[i].value = ""
	}
	if (spanArray) {
		for( i = 0; i < spanArray.length; i++) {
			if (e(spanArray[i])) {
			e(spanArray[i]).innerHTML = ""
			} else {
				//alert("Span element not found: " + spanArray[i])
			}
		}
	}
}
function frmElementsShow(frmName) {
	var str = '';
	var elem = document.getElementById(frmName).elements;		
	for(var i = 0; i < elem.length; i++)
	{str += elem[i].name + ", ";}
	alert(str);
}


function c360DateFmt (dateStr) {
	//dateStr as yyyy-mm-dd
	if (dateStr == "") {return ""}
	
	return dateStr.substr(5,2) + "/" + dateStr.substr(8,2) + "/" + dateStr.substr(0,4) 
}
function c360TimeFmt (timeStr) {
	//using timeStr from json return from cfquery
	if (timeStr == "") {return ""}
	var y = timeStr.substr(0,4)
	var m = timeStr.substr(5,2)
	var dy = timeStr.substr(8,2)
	var h = timeStr.substr(11,2)
	var n = timeStr.substr(14,2)
	
	var a_p = "";
var d = new Date(y,m,dy,h,n,0);

var curr_hour = d.getHours();
if (curr_hour < 12)
   {
   a_p = "AM";
   }
else
   {
   a_p = "PM";
   }
if (curr_hour == 0)
   {
   curr_hour = 12;
   }
if (curr_hour > 12)
   {
   curr_hour = curr_hour - 12;
   }

var curr_min = d.getMinutes();

curr_min = curr_min + "";

if (curr_min.length == 1)
   {
   curr_min = "0" + curr_min;
   }
	return curr_hour + ":" + curr_min +  a_p

}

function c360CarryOn(frmName, fldArray, spanArray) {
		//mpal 10/25/2006 pass in array with element names to carry over to next entry and Form ID
		//spanArray option list of Span ID elemements to clear
		//fldArray::= optional. If no field array, just clear
		var valArray = new Array();
		var i
		
		if (fldArray) {
			for (i=0;i<=fldArray.length-1;i++) {
				if (e(fldArray[i])){
				valArray[i] = e(fldArray[i]).value;		}	
			}
		}
		frmElementsClear(frmName, spanArray)
		if (fldArray) {
			for (i=0;i<=fldArray.length-1;i++) {
				if (e(fldArray[i])) {
				e(fldArray[i]).value = valArray[i];		}
			}
		}
	}
function logonGet() {
	/* 10/31/2006 trick or treat!! mpal
	in Client clientname_aboutUs.cfm, include next line
	if (urlItem("logon") == "Y") {logonShow()}
	in FormSetup() and dojo dlgNameLkup setup*/	

	//if NOT on index.cfm, load that
	
		logonShow("Y")
		

}
function logonCancel() {
	//close
	e("u10").value = ""
	e("u11").value = ""
	//dlgNameLkup.hide()
	window.location.href = "index.cfm?logout=Y"
}

function logonShow(loginAction) {
	//if login fails, url passed in X

	if (loginAction == "X" || loginAction == "Y") {
		//test if popup blocker is ON. Don't allow login until popup blocker OFF for this site. Mainly an ID problem
	 	var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 		if(mine) {
   		 	var popUpsBlocked = false
		  	mine.close()
		} else {
    		var popUpsBlocked = true
		}

 	if (popUpsBlocked) {alert("Please set your browser to allow Popups from this site"); return}
	
	if (e("u10")) {e("u10").focus() }

	var bindArgs = {
			url: "ajaxForm.cfm",
			content: {action: "logonShow", ajaxSubform: "_ajaxLogon.cfm", loginAction: loginAction},
			method: "post",
			mimetype: "text/plain",
			error: function(type, data, evt){
				console.log(evt.responseText);				
     			alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    			},
			load: function(type, data, evt){	
				
				if (e("include_page_narrow")) {
					e("include_page_narrow").innerHTML = data
					e("u10").focus()
				
				}
				
			}
		}
		
		//dojo.io.bind(bindArgs);
	} 

}

function compareEmail() {
	
	if (e("email1").value != e("email2").value) {
		alert( "Email addresses do not match. Please reenter.")
		return false
	} else {
		return true
	}

}
function logonUserResetPW() {
	if (e("u10").value == "") {
		alert("Please enter Login Name before continuing.")
		e("u10").focus()
		
	} else {
		e("logonForm").style.display = "none";
		e("logonResetPWFrm").style.display = "";
		e("loginNameShow").innerHTML = e("u10").value
	}
	
}
function logonNewUserSetup() {
	if (e("newUserEmail1").value != e("newUserEmail2").value ) { 
		alert("Your email addresses do not match. Please re-enter."); 
		e("newUserEmail2").select();
		return 
	}
	if (e("newUserEmail1").value =="" ) { 
		alert("Email is required."); 
		e("newUserEmail1").select();
		return
	}
	if (e("newUserLastName").value == "" || e("newUserFirstName").value == "") {
		alert("First and Last Names are required"); 
		e("newUserFirstName").select();
	}
	
	//see if email already in system
	var bindArgs = {
			url: "ajaxForm.cfm",
			content: {action: "logonNew", ajaxSubform: "_ajaxLogon.cfm"},
			method: "post",
			formNode: "frmLogonNew",
			mimetype: "text/json",
			error: function(type, data, evt){
				console.log(evt.responseText);				
     			alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    			},
			load: function(type, data, evt){	
				alert("Logon information has been sent to your email address.")
				refresh()
	    	}
		}
		
		dojo.io.bind(bindArgs);
	//if so, use that rec
	
	//else make new one

}
function logonNewUserClick() {
	e("logonForm").style.display = "none"
	e("logonNewUserMsg").style.display = ""
	e("newUserFirstName").focus()
}
function logonUserResetPWGo(calledFrom) {
	//if login fails, url passed in X
	var myLogin_name
	if (e("u10") && e("u10").value == "") {
		alert("Login name is required.")
		return false
	}

	var bindArgs = {
			url: "ajaxForm.cfm",
			content: {action: "logonReset", ajaxSubform: "_ajaxLogon.cfm", login_name: e("u10").value},
			method: "post",
			mimetype: "text/json",
			error: function(type, data, evt){
				console.log(evt.responseText);				
     			alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    			},
			load: function(type, data, evt){	
				if (e("logonMsg") ) {
					e("logonMsg").innerHTML = data
				}
				
				/*dlgNameLkup.setContent(data);    
				dlgNameLkup.show()
				e("u10").focus()*/
				return true
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
function ajaxLoadMenu(myHref, item_code) {
	//loads public menu choices
	var sideNavEleID = "navSide" + item_code
	
	var bindArgs = {
   		url: "ajaxForm.cfm",
		
		content: {nextView: item_code, ajaxSubform: "_nav_main_setup.cfm"},
		method: "get",
		mimetype: "text/plain",
		error: function(type, data, evt){	
			alert(evt.responseText); },
   		load: function(type, data, evt){
		
			location.href = myHref;
				
			//e(sideNavEleID).className = "navLevel2Highlight";
			
		}
   		
  		}
		
	dojo.io.bind(bindArgs);
		
}
function toProperCase(s)
{
  return s.toLowerCase().replace(/^(.)|\s(.)/g, 
          function($1) { return $1.toUpperCase(); });
}

function addNewRole (elRoleName, elRoleCode, elSelect, elRoleType) {
	//id of element that have meeting name
	if (e(elRoleName).value == "") {
		e("addRole").style.display = "none";
		if (e("start_date")) {
					e("start_date").focus();
				}
	} else {
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newRole", role_name: e(elRoleName).value, role_code: e(elRoleCode).value, role_group: e(elRoleType).value},		
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){
				
				insertOptionFirst(elSelect, e(elRoleName).value, e(elRoleCode).value);
				e("addRole").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				if (e("start_date")) {
					e("start_date").focus();
				}
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
}

function addNewWebSection (elRoleName, elRoleCode, elSelect, elRoleType) {
	//id of element that have meeting name
	if (e(elRoleName).value == "") {
		e("addWebSection").style.display = "none";
		if (e("event_location")) {e("event_location").focus();}
		if (e("event_ID_link")) {e("event_ID_link").focus();}
		
	} else {
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newWebSection", role_name: e(elRoleName).value, role_code: e(elRoleCode).value, role_group: e(elRoleType).value},		
			method: "post",
			mimetype: "text/json",
			error: function(type, data, evt){	
				
     			alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    		},
			load: function(type, data, evt){
				
				//3/10/2007 mpal if select element not used, skip next
				if (e(elSelect)) {
				insertOptionFirst(elSelect, e(elRoleName).value, e(elRoleCode).value);}
				e("addWebSection").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				if (e("event_location")) {e("event_location").focus();}
				if (e("event_ID_link")) {e("event_ID_link").focus();}
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
}
function makeWebSectionCode() {
	e("newSectionCode").value =  trimAllSpaces(e("newSectionName").value.toLowerCase())
}
function makeRoleCode() {
	e("newRoleCode").value =  trimAllSpaces(e("newRoleName").value.toLowerCase())
}
function makeCategoryCode() {
	e("newCategoryCode").value =  trimAllSpaces(e("newCategoryName").value.toLowerCase())
}
function addNewSchedCategory (elRoleName, elRoleCode, elSelect, role_type) {
	//id of element that have meeting name
	var newCode = trimAllSpaces(e(elRoleCode).value.toLowerCase())
	
	if (e(elRoleName).value == "") {
		e("addSchedCategory").style.display = "none";
		if (e("start_date")) {
					e("start_date").focus();
				}
	} else {
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newSchedCategory", role_name: e(elRoleName).value, role_code: newCode, role_group: e(role_type).value},		
			method: "post",
			mimetype: "text/json",
			error: function(type, data, evt){	
				
     			alert("An error occurred: Data: " + data + "Type: " + type + "Event: " +  evt);
    		},
			load: function(type, data, evt){
				
				insertOptionFirst(elSelect, e(elRoleName).value, newCode);
				addNewSchedCode(e(role_type).value, newCode, e(elRoleName).value)
				e("addSchedCategory").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				if (e("start_date")) {
					e("start_date").focus();
				}
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
}
function trimAllSpaces (str) {
  var regExp = / /g
  return str.replace(regExp,"");
}
function browserName() {
	var myAppName = navigator.appName
	
	var myReturn = "Other"
	if (myAppName == "Microsoft Internet Explorer") {myReturn = "Microsoft"}
	if (myAppName == "Netscape") {myReturn = "Netscape"}
	return myReturn
}


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str, msg) {
	//optional error message if email fails
	var msg = msg == null?"Invalid Email":msg
	
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert(msg)
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(msg)
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert(msg)
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(msg)
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(msg)
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(msg)
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(msg)
		    return false
		 }

 		 return true					
	}

function emailValidate(thisField, action){
	var emailID=thisField.value
	//action: Yes-required, No-Not required
	
	if (action=="yes") {
		if ((emailID==null)||(emailID=="")){
			alert("Please Enter your Email Address")
			thisField.focus()
			return false
		}
	}
	
	if (echeck(emailID)==false){
		thisField.value=""
		thisField.focus()
		return false
	}
	return true
 }

function articleEmailAlert(tableName, link_ID, actionFlag, email) {
	//used in Submission process
	//actionFlag: Approved, Draft
	var myActionFlag = (actionFlag == null || actionFlag == "")?"Unknown":actionFlag
	var myEmail = email == null?"":email
	var strEmail = ""
	var isCont = true
	var emailMsg
	//don't send email unless record is saved
	
	if (actionFlag != "Submit") {
	if (link_ID == 0 || link_ID == "") {return}
	//save status
	articleStatusSave(tableName, link_ID, actionFlag)
	
	if (myEmail == "") {
		emailMsg = "Current Item Status: " + myActionFlag + "\n\nSend QuickLink Notification Email?\n\nThere is no email in the Submitted By Email field.\n\nYou may enter an email in the field below."
	} else {
		emailMsg = "Current Item Status: " + myActionFlag + "\n\nSend QuickLink Notification Email to the Submitter?\n\nYou may also enter one additional email address below:"
	}	
	if (actionFlag != "xNo" ) {
		while (isCont == true) {
			//validate additional email
			strEmail = prompt(emailMsg, strEmail)
			if (strEmail == null || strEmail =="" || echeck(strEmail, "Additional Email Seems To Be Invalid.\n\nPlease reenter or clear field.")) {break}
		}
	}
	//cancelled
	if (strEmail == null) {return}
	if (myEmail == "" && strEmail == "") {alert("No emails entered. QuickLink Notification will not be sent");return}
	//if there is an additional email, concantenate and separate with comma
	if (strEmail != "") {
		if (myEmail != "") {
		myEmail += "," + strEmail
		} else {
		myEmail = strEmail
		}
	}
	} //don't prompt for email if user submitted (submit)
	//WE HAVE AN EMAIL, continue

	 var bindArgs = {
	   		url: "ajaxForm.cfm",
			content: {action: "emailAlert", ajaxSubform: "_ajaxActivities.cfm", tableName: tableName, link_id: link_ID, actionFlag:myActionFlag, email:myEmail},
			method: "post",
			//formNode: "mainForm",
			mimetype: "text/plain",
			error: function(type, data, evt){	
				console.log(evt.responseText);		
				//alert("emailAlert: error"  + evt.responseText); 
				alert("articleEmailAlert: error"  + evt.responseText); 
				},
	   		load: function(type, data, evt){
				//push rec ID back onto form for editing
				//don't show message for original submit
				if (actionFlag != "Submit"){
				alert("QuickLink Notification has been emailed to\n\n" + myEmail)}
				}
	  	}
			
		dojo.io.bind(bindArgs);
}

function articleStatusSave(tableName, id, itemStatus) {
	
	//only use this to save if item is being edited
	if (id==0 || id == "") {return}	
	if (tableName == "item_catalog") {
		var bindArgs = {
			url: "ajaxItem.cfm",
			content: {action: "quickSave", id: id, itemStatus: itemStatus},
			method: "post",
			mimetype: "text/plain",
			error: function(type, data, evt){	
				console.log(evt.responseText);		
				//alert("emailAlert: error"  + evt.responseText); 
				alert("articleEmailAlert: error"  + evt.responseText); 
				},
			load: function(type, data, evt) {}
		}
		dojo.io.bind(bindArgs);
	}
	if (tableName == "events") {
		var bindArgs = {
			url: "ajaxActivity.cfm",
			content: {action: "quickSave", id: id, itemStatus: itemStatus},
			method: "post",
			mimetype: "text/plain",
			error: fncDojoBindError,
			load: function(type, data, evt) {}
		}
		dojo.io.bind(bindArgs);
	}
}
function fieldHeightToggle(eleFieldName) {
	
	
	if (e(eleFieldName).style.height == "100px") {
	e(eleFieldName).style.height = "16px"
	} else {
	
	e(eleFieldName).style.height = "100px"
	}
}

function postCommunityGroup() {
		e("communityGroup").value += e("communityGroupSelect").value + ","
		e("communityGroupSelect").value = ""
		e("communityGroupShow").innerHTML = e("communityGroup").value
		if (e("communityGroup").value != "") {
			e("btnCommunityGroupClear").style.display = ""
		} else {
			e("btnCommunityGroupClear").style.display = "none"
		}
	}
	function communityGroupClear() {
		if (confirm("Clear current selections?")) {
		e("communityGroup").value = ""
		e("communityGroupShow").innerHTML = ""
		e("btnCommunityGroupClear").style.display = "none"
		}
	
	}
	
	function ajaxMeetingsDetail (meet_ID, sched_ID) {
	
	winHousehold=window.open("popup_def.cfm?t=_meetingDetail.cfm&m=" + meet_ID + "&s=" + sched_ID, "popupMeeting", "width=790px,height=615px,top=50px,left=50px,scrollbars=1,location=0,menubar=1")	
	winHousehold.focus()		
			return
			
		var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "detail", ajaxSubform: "_ajaxMeetings.cfm", sched_ID: sched_ID, meet_ID: meet_ID},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//dlgNameLkup.setContent(data);    
				//	dlgNameLkup.show();
				e("browseForm").style.display = "none"
				e("detailForm").innerHTML = data
					e("event_name").focus();
	    	}
		}
		dojo.io.bind(bindArgs);
	}
function webSectionMenu(webSections) {
		
		var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "webSectionMenu", ajaxSubform: "ajaxItem.cfm", keysSelect: e("communityGroup").value, webSections:webSections},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				e("communityGroupFrm").innerHTML = data
				e("communityGroupFrm").style.display=""
	    	}
			}
		
		dojo.io.bind(bindArgs);
	
	}
	function webSectionClose(formName) {
		
		//Save keys, push onto form
		
		//find all the keyCheck?? elements
		//frmElementsShow("frmKeys"); 
		var frmName = "frmKeys"
		var str = '';
		var strTitles = "";
		//if no items, skip loop (this would be unusual) mpal 3/30/2007
		//if (document.getElementById(frmName)) {
			var elem = document.getElementById(frmName).elements;		
			for(var i = 0; i < elem.length; i++)
			if (elem[i].checked) {
			str += elem[i].name.substr(7) + ",";
			strTitles += e(elem[i].name + "Title").value + ", ";
			}
		//}
		
		
			//clear and hide form, push string of values into fields
				e("communityGroupFrm").style.display="none"
				e("communityGroupFrm").innerHTML=""
				if (strTitles == "") {strTitles = "Click to Select"}
				e("communityGroupShow").innerHTML = "<b>" + strTitles + "</b>"
				e("communityGroup").value = str
			if (formName == "item_catalog") {
			ajaxSaveItem()}
	}
	
