//	 <script type="text/javascript" src="/js/c360_lib.js"></script>
var cfmInnerHtml

//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){try{e(obj).style[style]= value;} catch(ex) {;alert("setStyle: " + obj)}}
function showConsole(str) {	console.log(str)}
function fncDojoBindError(type, data, evt) {
 	
	//showConsole(evt.responseText)
	if (evt.responseText != "") {
	var str
		var newWin=window.open("popupErrorAlert.cfm" ,"popupErrorAlert", 
		"width=800px,height=500px,top=50px,left=50px,scrollbars=1,resizable=1,menubar=1,location=0")	
	str = "<html><head></head><body><div style='width:600px;padding:10px'>"
	str += evt.responseText
	str += "</div></body></html>"
		newWin.document.open()
		newWin.document.write(str)
		newWin.document.close()	
		alert("An error has occurred. Please check popup Error window")
		newWin.focus()
		
} else { alert("This page is still loading. Please wait until status bar clears");showConsole(evt.responseText);
 }
	//document.getElementById("errorShow").innerHTML += 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 = document.getElementById("rangeStart").value
	var endDate = document.getElementById("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) {
	
	//mpal 11/15/08 if not passed in as date object, convert here from mm/dd/yyyy or yyyymmdd
	//decrement month by 1 (javascript months zero based
	var dateType = typeof date
	if (dateType == "string" && date.substr(2,1)=="/") { //mm/dd/yyyy
		date = new Date(date.substr(6,4),date.substr(0,2) -1,date.substr(3,2))
	} else if (dateType == "string") { //yyyymmdd
		date = new Date(date.substr(0,4),date.substr(4,2) -1,date.substr(6,2))
	}
	//
	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
	//dtCh2 check for format 9999-99-99
	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) && (year != "9999")) {
		//mpal 12/16/09 allow 9999 to be used to indicate indefinite end
		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=" + document.getElementById(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 (document.getElementById("email_subject").value == "" || document.getElementById("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=785px,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=800,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 = document.getElementById(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=800px,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?document.getElementById("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=725px,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=825px,height=650px,top=50px,left=50px,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 or bus_ID value. test if Numberic 1/27/10 mpal
	var myID
	if (!isNaN(fieldName)){myID = fieldName} else {myID = document.getElementById(fieldName).value}
	
	
	var newWin = window.open("popup_namesDefault.cfm?popup=y&busDir=y&p=" + myID, "busDir",
		"width=850px,height=650px,top=50px,left=100px,scrollbars=1,menubar=1,location=0,resizable=1")	
		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 (document.getElementById("section_ID").value != "") {
			newWin=window.open("popup_coursedesc.cfm?section_ID=" + document.getElementById("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_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
		//1/10/2008 if no fieldNameInTable passed in, edit is not saved (used for adhoc changes)
 	
		var f, eID, t, k, ft
		var frmCssFileName = ""
		if (document.getElementById("cssFileName")) {frmCssFileName = document.getElementById("cssFileName").value}
		eID = keyFieldElementName == null?"":e(keyFieldElementName).value
		k = keyFieldNameInTable == null?"":keyFieldNameInTable
		t = tableName == null?"":tableName
		ft = fieldNameInTable == null?"":fieldNameInTable
		var fItems = formats == null || formats==""?"All":formats
		var lField = linkFieldNameInTable == null?"":linkFieldNameInTable
		var lValue = linkFieldEleName == null?"":linkFieldEleName
		var css = cssFileName == null || cssFileName == ""?frmCssFileName:cssFileName
		var masterValue = 0
 //alert("eid: " + eID)
		if (lValue != "") {masterValue = document.getElementById(lValue).value}
		//master record must be saved before calling Zoom
		if (eID == "" || eID ==0) {
			
			//if Events, create rec, if no tableName, this is an adhoc edit (not saved)
			
			if (t == "events" || t == "") {

				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){	
						//1/10/08 don't get returned element if this is adhoc edit (no save)
						if (k != "") {
						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 + "&css=" + css
			
			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_helpTicket(pre,template) {
		
		pre=pre==null?"":pre
		template=template==null?"":template
		newWin=window.open("popup_helpTicket.cfm?p=" + pre + "&t=" + template,"popupHelpTicket", "width=800px,height=600px,top=50px,left=50px, scrollbars=1,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=725x,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=625,top=50px,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 (document.getElementById("calGroup")) {
			myNextCriteria = document.getElementById("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 sched_ID = sched_ID == null?0:sched_ID
	//11/20/2009 mpal Never open on Schedule from Popup (schedule now on main view
	sched_ID = 0
	
	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=820px,height=715px,top=25px,left=50px,scrollbars=1,menubar=1,location=0")	
	winHousehold.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,location=1")
		//, "width=650px,height=525px,top=50px,left=100px")
		newWin.focus()
}
function popup_item (item_id, eventGroup) {	
		//mpal 2/9/09 eventGroup: pub or activity
		newWin=window.open("popup_item.cfm?i=" + item_id + "&g=" + eventGroup,"popupItem", 
		"width=820px,height=725px,top=15px,left=25px,scrollbars=1,resizable=1,status=1,menubar=1,location=1")
		//, "width=650px,height=525px,top=50px,left=100px")
		newWin.focus()
}
function popup_bio_edit (uniqueID,person_id) {	
		//3/30/09 specifically for editing bios, pass in event category and person_id
        if (document.getElementById("person_ID").value=="") {alert("Please save Address Book record before editing Bio");return}
		var str = "popup_article_edit.cfm?e=" + uniqueID  + "&ispopup=Y&ec=Bio&p=" + person_id
		var popupName = "popupBio" 
		winArticleEdit=window.open(str ,
			popupName, "width=810px,height=650px,top=50px,left=50px,scrollbars=1,menubar=1,location=1")
			winArticleEdit.focus()
		
}
function popup_article_edit (uniqueID, event_ID, menuCode, editType, wName) {	
		//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?e=" + uniqueID  + "&ispopup=Y" + "&uniqueCode=" + uniqueCode + "&elink=" + myEvent_ID
		var popupName = myEvent_ID == 0?"popupArticleEdit":"poupArticleLink"
		var popupName = wName==null?popupName:wName

		winArticleEdit=window.open(str ,
			popupName, "width=810px,height=650px,top=50px,left=50px,scrollbars=1,menubar=1,location=1")
			winArticleEdit.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=820px,height=650px,top=50px,left=50px,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 (document.getElementById("event_ID").value == 0) {alert("Please save record before Preview"); return}
	popup_flyerEventDef(document.getElementById("event_ID").value, document.getElementById("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?document.getElementById("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()
					alert("Click the Document tab to refresh view")
				}
			}
			dojo.io.bind(bindArgs);
		}

function uploadFile(item_ID,  tableName, link_ID, item_file_type, item_shortname, events_item_ID, viewAction, fieldIDName, fieldFullFile,sectionCode) {
	//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
	//sectionCode ::= code to link in event_section_link 2/6/09 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 sect = sectionCode==null?"":sectionCode
	var fid = fieldIDName==null?"":fieldIDName
	var lnkFld = fieldFullFile==null?"":fieldFullFile
	var wHeight =  fid!=""?"200px":"650px"
	
	winHousehold=window.open("popup_fileUpload.cfm?" + 
	"i=" + i + "&e=" + e + "&ft=" + ft + "&sn=" + sn + "&ei=" + ei + "&t=" + tableName + "&a=" + a + "&fid=" + fid + "&lnkFld=" + lnkFld + "&sc=" + sect, 		
	"popupFileUpload", "width=750px,height=" + wHeight + ",top=100px,left=100px,resizable=1,scrollbars=1,menubar=1,location=1")	
	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 (document.getElementById("busFinderField")) {
			mySearch = document.getElementById("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, sessionQuery) {			
	var winHousehold
	//if email not linked to an event or article, keyfieldVal is ""
	var keyFieldVal = keyFieldName==""?"":e(keyFieldName).value 
	sessionQuery = sessionQuery==null?"":sessionQuery
	winHousehold=window.open("popup_emailSetup.cfm?t=" + tableName + "&v=" + keyFieldVal + "&q=" + sessionQuery, 
		"popupEmailSetup", "width=800px,height=650px,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,paytoEntity) {			
	var popupNamesDefault
	var a = action==null?"":action
	//can pass in P for person or B for business (see disbursements) 1/27/09 mpal
	 var payToEntity = payToEntity==null?"P":payToEntity
	 var ynBusDir = paytoEntity=="B"?"y":"n"
	if (frmName) {
		popupNamesDefault=window.open("popup_NamesDefault.cfm?p=" + person_ID + "&frm=" + frmName + "&popup=Y&a=" + action + "&busdir=" + ynBusDir, 
		"popupNamesDefault", "width=900px,height=675px,top=25px,left=25px,scrollbars=1,resizable=1,menubar=1")	
	} else {
		popupNamesDefault=window.open("popup_NamesDefault.cfm?p=" + person_ID + "&popup=Y" + "&busdir=" + ynBusDir, 
		"popupNamesDefault", "width=900px,height=675px,top=25px,left=25px,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,scrollbars=1,resizable=1")	
	winHousehold.focus()		
	}
}
var winNew


function popupPTSAMembershipLoad () {		
		
	winNew.document.getElementById("person_ID").value = document.getElementById("student_ID").value
	winNew.document.getElementById("last_name").value = document.getElementById("last_name").value + ", " + document.getElementById("first_name").value
	
	if (document.getElementById("p1_last_name").value != "") {
	winNew.document.getElementById("p1_person_ID").value = document.getElementById("p1_person_ID").value
	winNew.document.getElementById("p1_last_name").value = document.getElementById("p1_last_name").value + ", " + document.getElementById("p1_first_name").value
	}
	if (document.getElementById("p2_last_name").value != "") {
	winNew.document.getElementById("p2_person_ID").value = document.getElementById("p2_person_ID").value
	winNew.document.getElementById("p2_last_name").value = document.getElementById("p2_last_name").value + ", " + document.getElementById("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=1")	
	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=800px,height=650px,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) {		
	
	//, 
}
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
	if (refCode==null) {return ""}
		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 = document.getElementById(elName);

  //check if value exists before adding, 11/22/08, return if exists  
  for (var i=0;i<elSel.options.length;i++) {if (newValue==elSel.options[i].value) {return}  }

    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
    }
	try {
  	var elLen = elSel.length - 1
	elSel.selectedIndex = elLen} catch(ex) {}
}

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++) {
		try {
		if (elem[i]) {elem[i].value = ""}} catch(ex) {alert(ex)}
	}
	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] = document.getElementById(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
	/*var divMain = <cfoutput>"#session.sec.divName#"</cfoutput>
	document.getElementById("u10").value = ""
	document.getElementById("u11").value = ""
	document.getElementById("logDiv").style.display="none"
	e(divMain).style.display=""*/
	//mpal 6/5/09 Not sure this should refer to index.cfm. Maybe current template instead?
	window.location.href = "index.cfm?logout=Y"
}

function logonShow(loginAction) {
	//if login fails, url passed in X
	if (loginAction == null) {alert("Null logonShow"); return}
	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 (document.getElementById("u10")) {document.getElementById("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 (document.getElementById("include_page_narrow")) {
					document.getElementById("include_page_narrow").innerHTML = data
					document.getElementById("u10").focus()
				
				}
				
			}
		}
		
		//dojo.io.bind(bindArgs);
	} 

}

function compareEmail() {
	
	if (document.getElementById("email1").value != document.getElementById("email2").value) {
		alert( "Email addresses do not match. Please reenter.")
		return false
	} else {
		return true
	}

}
function logonUserResetPW() {
	if (document.getElementById("u10").value == "") {
		alert("Please enter Login Name before continuing.")
		document.getElementById("u10").focus()
		
	} else {
		/*document.getElementById("logonForm").style.display = "none";
		document.getElementById("logonResetPWFrm").style.display = "";
		document.getElementById("loginNameShow").innerHTML = document.getElementById("u10").value*/
			document.getElementById("logonFail").style.display = "none"
					//document.getElementById("divForceReset").style.display=""
					document.getElementById("divResetPW").style.display=""
					document.getElementById("divNewPW").style.display=""
					document.getElementById("lblConfirm").style.display=""
					document.getElementById("logonButtons").style.display="none"
					//disble logOK because it fires even if hidden
					document.getElementById("logOK").disabled=true
					document.getElementById("logonForgotPW").style.display="none"
					document.getElementById("u11").value = ""
					document.getElementById("newPW").focus()
					
	}
	
}
function xxloginCheck(login,pw,resetDays,disableAfter) {
	alert(login + " " + pw + " " + resetDays + " " + disableAfter)
	if (resetDays==0 || resetDays=="") {return true}
	var bindArgs = {
				url: "ajaxForm.cfm",
				content: {action: "resetPWCheck", ajaxSubform: "_ajaxTest.cfm", login: login, resetDays:resetDays},
				method: "post",
				mimetype: "text/plain",
				error: fncDojoBindError,
				load: function(type, data, evt){
					//refresh()
					document.forms.logon.submit()
				}
			}
			dojo.io.bind(bindArgs);
		}	
function xloginCheck(login, pw, resetDays, disableAfter) {
	//if system has force reset days, check for this user, show message starting 1 wk, then force mpal 4/15/08
	
	 alert(resetDays)
	//alert(disableAfter)
	if (resetDays==0 || resetDays=="") {return true} //no forced reset
	
	var bindArgs = {
				url: "ajaxForm.cfm",
				content: {action: "resetPWCheck", ajaxSubform: "_ajaxTest.cfm", login: login, resetDays:resetDays},
				method: "post",
				mimetype: "text/plain",
				error: function(type, data, evt){	
				console.log(evt.responseText);		
				alert("error"); },
				load: function(type, data, evt){
					//refresh()
					alert("Click the Document tab to refresh view")
				}
			}
			dojo.io.bind(bindArgs);
	
	/*var thisdate = new Date();
	var salt = Math.round((Math.random()* thisdate.getTime())+1)
	//store 
	document.getElementById("xor").value = salt
	//encrypt before posting
	var strCheck = encryptStr(pw, salt)
	var bindArgs = {
			url: "ajaxForm.cfm",
			content: {action: "loginCheck", ajaxSubform: "_ajaxLogon.cfm", salt: salt,  strCheck: strCheck, },
			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);*/
	
}

// This script and many more are available free online at 
// The JavaScript Source!! http://javascript.internet.com -->

//Begin
/************************************************************************
* Copyright 2001 by Terry Yuen.
* Email: kaiser40@yahoo.com
* Last update: July 15, 2001.
* To implement this script onto your page, copy and paste the Javascript
* on this page and place it in the page that you want the encryption
* routine available on. Then use the func "encrypt()" to encrypt
* data. This function takes two parameters. The first parameter is the
* plain text string and the second parameter is the key. The returned
* string is the encrypted string. To decrypt the string, use the
* func "decrypt()" with the encrypted string as the first parameter
* and key as the second parameter. It returns the decrypted string.
*
* Examples:
* var secret = encrypt("My surprise will consist of ....", "password");
* document.writeln(secret);
*
* document.form[0].elements[1].value = decrypt(document.form[0].elements[0].value, "password");
*
*************************************************************************/

function encryptStr(str, pwd) {
  if(pwd == null || pwd.length <= 0) {
    alert("Please enter a password with which to encrypt the message.");
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.ceil(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  if(mult < 2) {
    alert("Algorithm cannot find a suitable hash. Please choose a different password. \nPossible considerations are to choose a more complex or longer password.");
    return null;
  }
  var salt = Math.round(Math.random() * 1000000000) % 100000000;
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i++) {
    enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
    if(enc_chr < 16) {
      enc_str += "0" + enc_chr.toString(16);
    } else enc_str += enc_chr.toString(16);
    prand = (mult * prand + incr) % modu;
  }
  salt = salt.toString(16);
  while(salt.length < 8)salt = "0" + salt;
  enc_str += salt;
  return enc_str;
}

function decryptStr(str, pwd) {
  if(str == null || str.length < 8) {
    alert("A salt value could not be extracted from the encrypted message because it's length is too short. The message cannot be decrypted.");
    return;
  }
  if(pwd == null || pwd.length <= 0) {
    alert("Please enter a password with which to decrypt the message.");
    return;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.round(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  var salt = parseInt(str.substring(str.length - 8, str.length), 16);
  str = str.substring(0, str.length - 8);
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i+=2) {
    enc_chr = parseInt(parseInt(str.substring(i, i+2), 16) ^ Math.floor((prand / modu) * 255));
    enc_str += String.fromCharCode(enc_chr);
    prand = (mult * prand + incr) % modu;
  }
  
  return enc_str;
}
function logonNewUserSetup() {
	if (document.getElementById("newUserEmail1").value != document.getElementById("newUserEmail2").value ) { 
		alert("Your email addresses do not match. Please re-enter."); 
		document.getElementById("newUserEmail2").select();
		return 
	}
	if (document.getElementById("newUserEmail1").value =="" ) { 
		alert("Email is required."); 
		document.getElementById("newUserEmail1").select();
		return
	}
	if (document.getElementById("newUserLastName").value == "" || document.getElementById("newUserFirstName").value == "") {
		alert("First and Last Names are required"); 
		document.getElementById("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() {
	document.getElementById("logonForm").style.display = "none"
	document.getElementById("logonNewUserMsg").style.display = ""
	document.getElementById("newUserFirstName").focus()
}
function checkLoginName(ele) {
	//mpal 12/10/08 since this is a closed system, alert user if login name is not available.
	var myName = ele.value
	if (myName=="") {return true} //nothing if empty
	var bindArgs = {
			url: "ajaxForm.cfm",
			content: {action: "checkLoginName", ajaxSubform: "_ajaxLogon.cfm", myName:myName},
			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){	
					//document.getElementById("divResetPW").style.display="none"
					//if (data.recordcount != 1) {alert("There is no record for this login name: " + ele.value);ele.value="";return false}
					//4/25/09 mpal disabled message if user not found
					return true
	    	}
		}
		
		dojo.io.bind(bindArgs);


}
function logonUserResetPWGo(myEnc, formName, pwHarden) {
	//if login fails, url passed in X
	 
	var myID = document.getElementById("u11").value
	 
	formName = formName==null?"":formName
	var myLogin_name
	if (document.getElementById("u10") && document.getElementById("u10").value == "") {
		alert("Login name is required.")
		return false
	}
	
	var myUser = document.getElementById("u10").value

	if (myUser == "" || myID == "") {
		alert("Please enter a Login Name and Password before continuing.");
		if (document.getElementById("u10").value == "") {
			document.getElementById("u10").focus();
			return false;
		}
		else {
			document.getElementById("u11").focus();
			return false
		}
	}
	//check for match and catch if submit before confirmation pw entered
	if (document.getElementById("divNewPW").style.display != "none") {
		if (document.getElementById("newPW").value != document.getElementById("u11").value || document.getElementById("newPW").value == "") {
			alert("Passwords do not match. Please reenter.");
			document.getElementById("u11").value = "";
			document.getElementById("u11").focus();
			return false
		}
		else {
			isNew = "Y"
		}
	}
	if (pwHarden != "") {
		//mpal 1/17/09 test for hardness
		var isSymbol = false
		var isCap = false
		var isNum = false
		var charSymbol = "!#$%&()*+-<=>?@^[]{}|~"
		var charNum = "0123456789"
		var charCap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		var charCapMsg = "A capital letter"
		var charNumMsg = "A number"
		var charSymbolMsg = "One of the following symbols: " + charSymbol
		for (var i = 0; i < myID.length; i++) {
			if (charSymbol.indexOf(myID.substr(i, 1)) >= 0) {
				isSymbol = true;
				charSymbolMsg = "";
			}
			else 
				if (charNum.indexOf(myID.substr(i, 1)) >= 0) {
					isNum = true;
					charNumMsg = "";
				}
				else 
					if (charCap.indexOf(myID.substr(i, 1)) >= 0) {
						isNum = true;
						charCapMsg = "";
					}
		}
		var hardenStr = ""
		if (charNumMsg != "") {
			hardenStr += charNumMsg + "\n\n"
		}
		if (charCapMsg != "") {
			hardenStr += charCapMsg + "\n\n"
		}
		if (charSymbolMsg != "") {
			hardenStr += charSymbolMsg + "\n\n"
		}
		
		
		if (hardenStr != "") {
			alert("For security purposes, you password needs to include: \n\n" + hardenStr);
			return false
		}
	}
	
	var hexhash = encStr(myID, myEnc)
 
	var bindArgs = {
		url: "ajaxForm.cfm",
		content: {
			action: "logonReset",
			ajaxSubform: "_ajaxLogon.cfm",
			login_name: document.getElementById("u10").value,
			hexhash: hexhash,
			formName: formName
		},
		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 (data != "") {
				document.getElementById("divResetPW").style.display = ""
				document.getElementById("divResetButtons").style.display = "none"
				document.getElementById("passwordInstructions").style.display = "none"
			}
			else {
				document.getElementById("divResetPW").style.display = "none"
			}
			
			
			//document.getElementById("divResetPW").style.display="none"
			document.getElementById("logonFail").style.display = "none"
			document.getElementById("divResetMsg").innerHTML = data
			document.getElementById("divResetMsg").style.display = ""
			
			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 == "") {
		document.getElementById("addRole").style.display = "none";
		if (document.getElementById("start_date")) {
					document.getElementById("start_date").focus();
				}
	} else {
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newRole", role_name: document.getElementById(elRoleName).value, role_code: document.getElementById(elRoleCode).value, role_group:document.getElementById(elRoleType).value},		
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){
				
				insertOptionFirst(elSelect,document.getElementById(elRoleName).value,document.getElementById(elRoleCode).value);
				document.getElementById("addRole").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				if (document.getElementById("start_date")) {
					document.getElementById("start_date").focus();
				}
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
}

function addNewWebSection (elRoleName, elRoleCode, elSelect, elRoleTypeVal) {
	//id of element that have meeting name

	var prefix = document.getElementById("codePrefixVal").value
	var code = trimAllSpaces(e(elRoleCode).value).toLowerCase()
	var newCode =  trimAllSpaces(prefix) + trimAllSpaces(code)
	var myType = elRoleTypeVal
	if (e(elRoleName).value == "") {
		//document.getElementById("addWebSection").style.display = "none";
		if (document.getElementById("event_location")) {document.getElementById("event_location").focus();}
		if (document.getElementById("event_ID_link")) {document.getElementById("event_ID_link").focus();}
		return true
	} else {

		if (newCode.length > 20) {e(elRoleCode).value = code.substr(0,20 - prefix.length); 
			alert("Code must be 20 characters or less, including prefix.\r\nCode has been shortened to 20 characters.");return false;}
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newWebSection", role_name:document.getElementById(elRoleName).value, role_code: newCode, role_group: myType },		
			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,document.getElementById(elRoleName).value, newCode);}
				//document.getElementById("addWebSection").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				document.getElementById("codePrefix").innerHTML = ""
				document.getElementById("codePrefixVal").value = ""
				if (document.getElementById("event_location")) {document.getElementById("event_location").focus();}
				if (document.getElementById("event_ID_link")) {document.getElementById("event_ID_link").focus();}
				return true
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
}
function webSectionCodeCheck(elThis) {
	if (elThis.value.length + document.getElementById("codePrefixVal").value > 20) {
		elThis.value = elThis.value.substr(0,20 - document.getElementById("codePrefixValue").length)
		alert("Code must be 20 characters or less, including code prefix.")
		elThis.focus()
	}
}
function makeWebSectionCode(elName) {

	var el =document.getElementById(elName)
	//var code = el.options[el.selectedIndex].value
	//document.getElementById("codePrefixVal").value = code
	//document.getElementById("codePrefix").innerHTML = code
	var code=document.getElementById("codePrefixVal").value
	document.getElementById("newSectionCode").value =  trimAllSpaces(document.getElementById("newSectionName").value.toLowerCase()).substr(0,20-code.length)
}
function loadWebCategory(el) {
	
	var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "getWebSectPrefix", code: el.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){
				document.getElementById("codePrefixVal").value = data.data.CODEPREFIX[0]
				document.getElementById("codePrefix").innerHTML =   data.data.CODEPREFIX[0]
	    	}
		}
		
		dojo.io.bind(bindArgs);
}
function makeRoleCode() {
	document.getElementById("newRoleCode").value =  trimAllSpaces(document.getElementById("newRoleName").value.toLowerCase())
}
function makeCategoryCode() {
	document.getElementById("newCategoryCode").value =  trimAllSpaces(document.getElementById("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 == "") {
		document.getElementById("addSchedCategory").style.display = "none";
		if (document.getElementById("start_date")) {
					document.getElementById("start_date").focus();
				}
	} else {
		var bindArgs = {
			url: "ajaxParticipationCrud.cfm",	
			content: {action: "newSchedCategory", role_name:document.getElementById(elRoleName).value, role_code: newCode, role_group:document.getElementById(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,document.getElementById(elRoleName).value, newCode);
				addNewSchedCode(e(role_type).value, newCode,document.getElementById(elRoleName).value)
				document.getElementById("addSchedCategory").style.display = "none";
				e(elRoleName).value = ""
				e(elRoleCode).value = ""
				if (document.getElementById("start_date")) {
					document.getElementById("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					
	}
/*<cfif REFindNocasdocument.getElementById("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$", Email)>
   Good address.
<cfelse>
   Very, very bad.
</cfif>*/
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 not required, blank IS OK
	if (emailID=="" || emailID==null) {return true}
	if (echeck(emailID)==false){
		thisField.value=""
		thisField.focus()
		return false
	}
	return true
 }

function articleEmailAlert(actionCode, tableName, link_ID, actionFlag, email) {
	//used in Submission process
	//actionFlag: Approved, Draft
	//actionCode: onClick, onChange

	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
	//mpal 9/4/2007 might want to sent when in Admin mode if submitter is external 
	if (actionFlag != "Submit") {
	if (link_ID == 0 || link_ID == "") {return}
	//save status
	articleStatusSave(tableName, link_ID, actionFlag)
	if (myEmail =="" && actionCode=="onChange") {return} //don't prompt onChange if no email in record mpal 8/3/07
	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() {
		document.getElementById("communityGroup").value += document.getElementById("communityGroupSelect").value + ","
		document.getElementById("communityGroupSelect").value = ""
		document.getElementById("communityGroupShow").innerHTML = document.getElementById("communityGroup").value
		if (document.getElementById("communityGroup").value != "") {
			document.getElementById("btnCommunityGroupClear").style.display = ""
		} else {
			document.getElementById("btnCommunityGroupClear").style.display = "none"
		}
	}
	function communityGroupClear() {
		if (confirm("Clear current selections?")) {
		document.getElementById("communityGroup").value = ""
		document.getElementById("communityGroupShow").innerHTML = ""
		document.getElementById("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();
				document.getElementById("browseForm").style.display = "none"
				document.getElementById("detailForm").innerHTML = data
					document.getElementById("event_name").focus();
	    	}
		}
		dojo.io.bind(bindArgs);
	}
function webSectionToggle(header) {
	//display each code row
	var setting
	for (var i=1; i<100; i++) {
		if (e(header + i)) {
			setting =document.getElementById(header + i).style.display=="none"?"":"none"
			e(header + i).style.display=setting
		} else {
			break
		}
	}
}
function webSectionMenu(webSections, tableName, ID, existingKeyField) {
	//flag: link, main, side (content)
	//existingKeyField ::= id of field with existing Keys

	if (ID=="" || ID==null) {alert("Please save record before adding Web Sections");return}
		var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "webSectionMenu", ajaxSubform: "ajaxItem.cfm", keysSelect:document.getElementById(existingKeyField).value, webSections:webSections, ID: ID, 
				tableName: tableName, flag: existingKeyField},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				 document.getElementById("communityGroupFrm").innerHTML = data
				 document.getElementById("communityGroupFrm").style.display=""
	    	}
			}
		
		dojo.io.bind(bindArgs);
	
	}
	function webSectionClose(formName, tableName, ID, flag) {
		
		
		//Save keys, push onto form
		
		//find all the keyCheck?? elements
		//frmElementsShow("frmKeys"); 
		var frmName = "frmKeys"
		var str = '';
		var strTitles = "";
		var strFmt = ""
		var showEle 
		var strStartDate="" //optional section start and end dates mpal 8/6/08
		var strEndDate=""
		var elemNameFmt
		var elemName
		
		//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++)
			//mpal 9/21/2007 if item checked more than once, ignore additional			
			if (elem[i].checked && str.indexOf(elem[i].name.substr(7))) {
	//alert(str); alert(elem[i].name.substr(7)); alert(str.indexOf(elem[i].name.substr(7)))
			str += trimAllSpaces(elem[i].name.substr(7)) + ",";
			strTitles +=document.getElementById(elem[i].name + "Title").value + ", ";
			strFmt +=document.getElementById(elem[i].name + "Title").value + "&nbsp;[" + elem[i].name.substr(7) + "], "
			elemNameFmt =  trimAllSpaces(elem[i].name)
	
			//when checked first time, date fields not showing. mpal 8/6/2008
			if (e(elemNameFmt + "StartDate")) {
				strStartDate +=   document.getElementById(elemNameFmt + "StartDate").value ==""?"NULL,":e(elemNameFmt + "StartDate").value + ","
				strEndDate += document.getElementById(elemNameFmt + "EndDate").value ==""?"NULL,":e(elemNameFmt + "EndDate").value + ","
			}
			} //end loop

			//clear and hide form, push string of values into fields
				document.getElementById("communityGroupFrm").style.display="none"
				document.getElementById("communityGroupFrm").innerHTML=""
	
			var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "webSectionPost", ajaxSubform: "ajaxItem.cfm", keysSelect: str, ID: ID, tableName: tableName, flag: flag,
			strStartDate: strStartDate, strEndDate: strEndDate},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				e(flag + "Show").innerHTML = strFmt 
				//push new comma delim string of codes into communityGroup for current reference
				e(flag).value = str
			if (formName == "item_catalog") {
			ajaxSaveItem()}
			return true
	    	}
			}
		
		dojo.io.bind(bindArgs);
			//item id; delete missing, add new
			
		//}
		
		
			
	}
	function loadPeople(pendingRecCnt,queryName) {
		//load records from session.getContacts into the Actions/People list. Person_ID only required field in getContacts
		//if there is already a pending list of names in session.lastNames, select replace or add
		queryName = queryName==null?"session.getContacts":queryName
		if (pendingRecCnt>0) {
		var str
		var str = "There are " + pendingRecCnt + " existing Names in Action:People\n\n" 
		
		str += "Click [OK] to Add the currently Selected Names to the existing Action:People names.\n\n"
		str += "Click [Cancel] to Replace the existing Action:People Names with the Selected Names."
		var action = confirm(str)
		actionSelect = action?"add":"replace"
		} else {
		actionSelect = "replace"
		if (!confirm("Add Selected Names to Action:People?")) {return false}
		}
		
		var bindArgs = {
			url: "ajaxForm.cfm",	
			content: {action: "selectActionNames", ajaxSubform: "_ajaxBus.cfm", actionSelect: actionSelect,queryName:queryName },		
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				alert("All selected Names have been added to the Action/People view\n\nTotal selected names: " + data.reccnt + "\n\nClick Actions from the left menu to continue.")
	    	}
		}
			dojo.io.bind(bindArgs);
	}
	
	function selectDateRangeFmt(thisField) {
		//used in _select_main_controls.cfm to hide date range if CURRENT
		var str = thisField.value
		if (str == "current") {document.getElementById("rowSelectDateRange").style.display="none"} else {document.getElementById("rowSelectDateRange").style.display=""}
	}
	function refreshRoleSelect() {
		var el = document.getElementById("PartRoleSelect")
		var startDate = document.getElementById("dateRangeStart").value
		var endDate = document.getElementById("dateRangeEnd").value
		var rangeType = document.getElementById("dateRangeType").value
		var bindArgs = {
			url: "ajaxForm.cfm",	
			content: {action: "roleSelect", ajaxSubform: "_ajaxSelect.cfm", startDate: startDate, endDate: endDate, rangeType: rangeType },		
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//refresh role
				var d = data.data
				var cnt = data.recordcount
	
				el.options.length = 0
			var myValue
			var myText
			for(var i = 0; i < cnt; i++) {
				myText = d.PARTICIPANT_ROLE_FMT[i] == ""?toProperCase(d.PARTICIPANT_ROLE[i]):d.PARTICIPANT_ROLE_FMT[i]
				
				myText += " [" + d.PARTICIPANT_ROLE[i] + "]: " 
				myText += d.COUNTOFPARTICIPANT_ROLE[i].toString()
				insertOptionFirst("PartRoleSelect", myText, d.PARTICIPANT_ROLE[i].toString())
			}
			
			//move to first element, nothing selected
			el.selectedIndex = ""
			
	    	}
		}
			dojo.io.bind(bindArgs);
	}
function quickShow (item_ID, instance_ID, ynForceSave) {
	var myInstance_ID = instance_ID==null?"":instance_ID
	var ynForceSave = ynForceSave==null?"N":"Y"
	var divName
	
	if (document.getElementById("mainViewHTML" + instance_ID).value == "" || ynForceSave == "Y") {
		document.getElementById("mainViewHTML" + instance_ID).value = document.getElementById("mainContent" + instance_ID).innerHTML
	}
	if (document.getElementById("rtnItemButtonSpan")) {document.getElementById("rtnItemButtonSpan").innerHTML = ""}
	cfmInnerHTML = document.getElementById("mainContent" + myInstance_ID).innerHTML
	//document.getElementById("mainContent" + myInstance_ID).innerHTML = "Loading..."
	//get template specs and load into specified div
	var bindArgs = {
			url: "ajaxForm.cfm",	
			content: {action: "quickShowGet", ajaxSubform: "_ajaxPub.cfm", item_ID: item_ID},		
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//quickShowGet(item_ID)
				var myDiv = data.data.DIVSELECT[0].substr(0,4)
				//if item_ID was for sched and no template, this will return the master event_ID
				item_ID = data.data.EVENT_ID[0]
		
				var myTemplate = data.data.ITEM_TEMPLATE[0]
				if (myDiv=="main") {
				 	divName = "mainContent"
				} else if (myDiv=="side") {
					divName = "sideContent"				
				} else if (myDiv=="both") {
					divName = "content"				
				} else if (myDiv=="full") {
					divName = "content"	
				} else if (myDiv=="cont") {
					divName = "contentContainer"	
				} else {
					divName = "UNKNOWN"			
				}
				/* If this is a menu item being called as a highlight item, the appropriate
					menu divName + myInstance_ID won't exist, so assign it to mainContent
					mpal 10/26/2007 */
				if (!e(divName + myInstance_ID)) {divName="mainContent"}
	
				if (myTemplate=="") {alert("This item does not have a selected Template");quickRestore(); return}
				quickShowGet(item_ID, divName, myTemplate, myInstance_ID)
				clickTrack(item_ID, 'quick', location.href)
				
	    	}
		}
			dojo.io.bind(bindArgs);

}
function quickShowGet (item_ID, divName, myTemplate, instance_ID) {
	
	
	//get template specs and load into specified div
	var bindArgs = {
			url: "ajaxForm.cfm",	
			content: {action: "quickShow", ajaxSubform: "_ajaxPub.cfm", item_ID: item_ID, myTemplate: myTemplate},		
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				/*var myHTML = '<div><span id="rtnItemButtonSpan"><input type="button" name="rtnItemButton" id="rtnItemButton" onClick="quickRestore(' + instance_ID + ')" value="Back" style="float:right" class="hideOnPrint"></span></div>' + data*/
var myHTML = '<div><form method="post"><span id="rtnItemButtonSpan"><input type="submit" name="rtnItemButton" id="rtnItemButton"  value="Back" style="float:right" class="hideOnPrint"></span></form></div>' + data
				e(divName + instance_ID).style.backgroundColor = "#fff"
				e(divName + instance_ID).innerHTML = myHTML
				
	    	}
		}
			dojo.io.bind(bindArgs);

}
function quickRestore(instance_ID) { alert(document.getElementById("mainContent" + instance_ID)); document.getElementById("mainContent" + instance_ID).innerHTML = document.getElementById("mainViewHTML" + instance_ID).value}
function quickLook(item_ID){alert("Needs to be implemented")}
function makeCFMItem(item_ID, item_template, event_status) {
	//if event_status Publish, create menu form, otherwise delete
	 //5/2/08 rem out for now, should store in application.views, no in file
		if (document.getElementById("statusMsg01")) {document.getElementById("statusMsg01").innerHTML="Updating item..."}
	  
		var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "makeCFMItem", ajaxSubform: "_ajaxPub.cfm", item_ID: item_ID, myItem_template: item_template, event_status: event_status},
			method: "post",			
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//no message for web link
				//if (data.msg != "") {alert(data.msg)}
	 			 
	    	}
		}
		
		dojo.io.bind(bindArgs);
	}
	
	function setSeq(sectionLinkID, myID, divName, newSeq) {
		
		var bindArgs = {
				url: "ajaxForm.cfm",
				content: { action: "seqSet", ajaxSubform: "ajaxItem.cfm", sectionLinkID: sectionLinkID, myID: myID, newSeq: newSeq, divName: divName},
				method: "post",			
				mimetype: "text/HTML",
				error: fncDojoBindError,
				load: function(type, data, evt){	
					e(divName).innerHTML = data;
					//9/8/2007 mpal SECURITY: by definition, if this is run, user has rights to set back on after refresh
					showAllATags("Y")
		    	}
			}
			
			dojo.io.bind(bindArgs);
	}
	function showAllATags(cfmYNEdit) {
	//show all hidden admin/edit tags, based on users security level
	 
	  if (cfmYNEdit == "Y") {
	  //1/12/2010 next line was altered at some point (during search and replace?)
	 // var editEl= document.getElementsByTagNamdocument.getElementById("a")
	    var editEl= document.getElementsByTagName("a")
	  for (var i=0; i < editEl.length; i++) {editEl[i].style.display=""}}
	 }
	function requiredSubmitFields (action) { 
		var isMsg = false

		if (action=="weblink") {
			aFields = new Array("submitName","submitEmail","event_name","item_link")
			aLabels = new Array("Submitter email","Submitter name","Weblink title","Weblink URL")
		} else if (action=="event") {
			aFields = new Array("submitName","submitEmail","event_name","start_date","start_time","producing_partners_desc","event_desc_long","event_location")
			aLabels = new Array("Submitter email","Submitter name","Weblink title","Event date","Start time","Sponsoring organization","Event description","Location")
		}

		var msg = "The following information is required:\n"
		var isMsg = false
		for (var i=0; i<aFields.length; i++) {

			if (e(aFields[i]).value == "") {msg += aLabels[i] + "\n"; isMsg=true;}
		}
		if (isMsg) {alert(msg); return false} else {return true}
		
	}
function limitText(limitField, limitCount, limitNum) {
	//limitField::= textarea/input field
	//limitCount::= span with count of chars left
	//limitNum::= max chars
	//onKeyDown and onKeyUp limitText(this.form.limitedtextarea,spanName,100)
	
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		e(limitCount).innerHTML = limitNum - limitField.value.length;
	}
}
function writetostatus(input){
    window.status=input
    return true
}
function clickTrack(item_ID, item_type, template) {

var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "clickTrack", ajaxSubform: "_ajaxLogon.cfm", item_ID:item_ID, item_name: template, item_type: item_type},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				
	    	}
			}
		
		dojo.io.bind(bindArgs);
}
function removeCommas(aNum) {
//remove any commas
//8/2008 mpal this was throwing errors that aNum.replace is not a function. Not sure why.
try {aNum=aNum.replace(/,/g,"");} catch(ex){}
//remove any spaces
try {aNum=aNum.replace(/\s/g,"");} catch(ex){}

return aNum;
}
function selectMenuShow(fieldName,curValue,idName, criteria, pxWidth) {
//replaces a <a></a> link with a select menu. The a link and hidden field reference are inside
//the span, so the select becomes the live field. On View, the value shows as a link
pxWidth = pxWidth==null?"100px":pxWidth
var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "selectMenuShow", ajaxSubform: "_ajaxSelectMenus.cfm", idName: idName, curValue:curValue, criteria:criteria, fieldName:fieldName,pxWidth:pxWidth},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				e(idName + "Show").innerHTML = data; //naming convention: idName plus "Show"
				e(idName).focus()
	    	}
			}
		dojo.io.bind(bindArgs);
}
function selectMenuQuick(category,idName,curValue) {
//replaces a <a></a> link with a select menu. The a link and hidden field reference are inside
//the span, so the select becomes the live field. On View, the value shows as a link
 var isOK = true
 curValue= curValue
 
if (category=="save") {
//return accountCode and value from save and push in
	if (curValue != "" ) { 
	
 
		if (curValue.substr(6,1) =="-") { //this is full account. get account id
			var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "getAccount", ajaxSubform: "_ajaxSelectMenus.cfm", account:curValue},
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				if (data.errcode =="") {
					document.getElementById("span_" + idName).innerHTML = data.accountcode
					e(idName).value = data.account_id
				} else {
					alert(data.errcode)
					isOK = false
				}
				 
	    	}
			}
			dojo.io.bind(bindArgs);
		
		} else { //short id seq entered, values already on popup form
			try {
			var rtnAccount_ID = document.getElementById("account" + curValue).value
			var rtnAccountCode = document.getElementById("accountCode" + curValue).value
			document.getElementById("span_" + idName).innerHTML = rtnAccountCode
			e(idName).value = rtnAccount_ID
			} catch(ex) {alert("No match for this sequence number");isOK=false;}
		}
		
		
	} else {
		//if no choice, current choice cleared
		var rtnAccount_ID = ""
		var rtnAccountCode = "==Click=="
	 
		e(idName).value = rtnAccount_ID
		document.getElementById("span_" + idName).innerHTML = rtnAccountCode
	}
}
if (category==null || category=="save") { //if accountcode not entered correctly, don't close popup
	if (isOK) {
		document.getElementById("div_popup").style.display="none";document.getElementById("div_popup").innerHTML="";document.getElementById("btn_" + idName).focus();
	}
	return
} //close box if function with no parameter
var bindArgs = {
			url: "ajaxForm.cfm",
			content: { action: "mainAccounts", ajaxSubform: "_ajaxSelectMenus.cfm", idName: idName, 
			myAccountCode:document.getElementById("span_" + idName).innerHTML, curValue:curValue,fieldName:category,dept:document.getElementById("appt_dept").value},
			method: "post",
			mimetype: "text/html",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//document.getElementById("cell_ " + idName.toLowerCase()).innerHTML = data; //naming convention: cell_idname (lowercase)
				//e(idName).focus()
				document.getElementById("div_popup").innerHTML = data
				document.getElementById("div_popup").style.display=""
				document.getElementById("accountSelect").focus()
	    	}
			}
		dojo.io.bind(bindArgs);
}

function checkDateRange(ele, startRange, endRange) {
	//pass in ele formatted mm/dd/yyyy and start and end Range (in format yyyymmdd); compare
			var myRtn
			var  dFmt
			var r
			
			
			if (isValidDate(ele)) {
				//ele.value will be in format mm/dd/yyyy
				v = ele.value
				dFmt =  v.substr(6,4) + v.substr(0,2) +   v.substr(3,2)  
				r = startRange.substr(4,2) + "/" + startRange.substr(6,2) + "/" + startRange.substr(0,4)
				r += "-" + endRange.substr(4,2) + "/" + endRange.substr(6,2) + "/" + endRange.substr(0,4)
				if (dFmt < startRange || dFmt > endRange) {alert("Pay Date outside of range of current Appointment: " + r);ele.value="";return false}
			
			}
		
		}
function calcFmt(val, fmt) {
			//take number or str value, remove embedded commas, convert to type. If blank, return 0 (not NaN) mpal 8/2008
 			var myRtn
			val = removeCommas(val)
			if (isNaN(val)) {myRtn = 0}
			else if (val=="") { myRtn =  0}
			else if (fmt.toLowerCase()=="int") {myRtn =  parseInt(val)}
			else if (fmt.toLowerCase()=="float") { myRtn =  parseFloat(val)}
			else if (fmt.charAt(0).toLowerCase()=="d"){val=parseFloat(val); myRtn = val.toFixed(fmt.charAt(1))}
			else {myRtn =  0}
		
			return myRtn
		}
function saveValue(tableName,keyFieldName,keyFieldValue,fieldType,fieldName,ele) {
	//fieldtype date,time,char,number
	//quicksave one field
	var rtn
	var newValue = ele.value
	if (fieldType.toLowerCase()=="date") {myRtn = isValidDate(ele); newValue = ele.value}
	else if (fieldType.toLowerCase=="time") {myRtn = isValueTime(ele);newValue=ele.value}
	if (myRtn==false) {return false}

	 var bindArgs = {
			url: "ajaxForm.cfm",
			content: { ajaxSubform: "_c360_crud.cfm", action: "saveValue",  tableName:tableName,keyFieldName:keyFieldName,keyFieldValue:keyFieldValue,
				fieldType:fieldType,fieldName:fieldName,newValue:newValue},
			method: "post",
			mimetype: "text/json",
			error: fncDojoBindError,
			load: function(type, data, evt){	
				//e(ele.name).style.color="green"
	    	}
		}
		dojo.io.bind(bindArgs); 

}

function makeCalendar(idName) {	

/*
<link rel="stylesheet" type="text/css" href="css\calendar-win2k-cold-2.css" media="screen">
<script type="text/javascript" src="js/dyn_calendar.js"></script>
<script type="text/javascript" src="js/dyn_calendar-en.js"></script>
<script type="text/javascript" src="js/dyn_calendar-setup.js"></script>
*/
	Calendar.setup(
	{
	inputField : idName, // ID of the input field
	ifFormat : "%m/%d/%Y", // the date format
	button : "calBtn_" + idName // ID of the button
	})
	}
function c360_makePopup(seq,str,w,t,l,z) { //can have more than one div defined, seq name
	//required div c360_popup_container to be on form, no styles required
	 
		seq = seq==null?"":seq
		seq = seq==0?"":seq //if zero, just clear it out (backward compatible)
		if (!document.getElementById("c360_popup_container" + seq)) {alert("Missing div: c360_popup_container" + seq);return}
		str = str==null?"":str
		if (str=="") 
		{document.getElementById("c360_popup_container" + seq).style.display="none";
		document.getElementById("c360_popup_container" + seq).innerHTML = "";return}
		t = t==null || t==""?"100px":t //defaults, only str required
		w = w==null|| w==""?"450px":w
		l= l==null|| l==""?"150px":l
		
	
	
		var btn = '<a href="javascript:void(0)" title="Exit" onClick="'
		if (seq=="") { //if more than one popup form, close correct seq number
		btn +='c360_makePopup()" style="padding-left:99%;font-size:12px">[x]</a>'
		} else {
		btn +='c360_makePopup(' + seq + ')" style="padding-left:99%;font-size:12px">[x]</a>'
		}
 
		var c = document.getElementById("c360_popup_container" + seq)
     //9/16/09 z param probably orphaned. derive next highest z-index of parentNode and use that
         z = getNextHighestZindex(c.parentNode)
        //z= z==null?2:z
        z = seq==""?z:z + 1 //seq z-index if multiple popup forms
		c.style.position="absolute"
		c.style.color = "000"
		c.style.backgroundColor = "#eee"
		c.style.top = t
		c.style.left = l
		c.style.width = w
		c.style.zIndex = z
		c.style.border = "5px solid darkred"
		c.style.MozBorderRadius = "5px"
		c.style.padding = "0 15px 15px 15px"
		c.style.fontFamily = "Arial,Sans-Serif"
		c.style.fontSize = "13px"
		c.innerHTML = btn + '<div id="c360_popup' + seq + '"></div>'
		//e(id).innerHTML = "Hello, World"
		c.style.display=""
		document.getElementById("c360_popup" + seq).innerHTML = str
		var p = document.getElementById("c360_popup" + seq)
		p.style.backgroundColor="#fff"
		p.style.marginTop = "1px"
		p.style.padding = "10px"
 
		
	}
function c360_makeLoading(divID, str, w, z) { //assumes one form open at a time;  
	//use the target div
	if (divID==null) {return}
	if (!e(divID)) {return}
	 
	 //9/16/09 z param probably orphaned. derive next highest z-index of parentNode and use that
	z = getNextHighestZindex(e(divID).parentNode)
	 
 try {
 	w = w == null ? "400px" : w
 	
 	z = z == null ? 2 : z
 
 	var c = document.getElementById(divID)
 	str = str == null ? "" : str
 	if (str == "") {
 		c.style.display = "none";
 		c.innerHTML = "";
 		c.style.width = "";
 		return
 	}
 	
 	
 	c.style.color = "#000"
 	c.style.backgroundColor = "#fff"
 	c.style.zIndex = z
 	//c.style.border = "10px solid #eee"
	c.style.border = "5px solid darkred"
 	c.style.MozBorderRadius = "5px"
 	c.style.padding = "10px"
 	c.style.fontFamily = "Arial,Sans-Serif"
 	c.style.fontSize = "13px"
 	
 	if (w != 0) {
 		c.style.width = w
 	}
 	else {
 		c.style.width = ""
 	}
 	c.style.height = ""
 	c.style.display = ""
 	c.innerHTML = str //'<p style="padding:10px 10px 7px 7px;background-color:#fff">' + str + '</p>'
		centerInView(c)
	//c.style.display=""
	} catch(ex) {alert(ex)}		
	}
	
function  c360_makeAlert(str,w,t,l) { //assumes one form open at a time; pass in no params to close
	//required div c360_popup_container to be on form, no styles required
		if (!document.getElementById("c360_popup_alert")) {alert("Missing div: c360_popup_alert");return}
		str = str==null?"":str
		if (str=="") {document.getElementById("c360_popup_alert").style.display="none";document.getElementById("c360_popup_alert").innerHTML = "";return}
		t = t==null?"275px":t //defaults, only str required
		w = w==null?"400px":w
		l= l==null?"250px":l
		var btn = '<a href="javascript:void(0)" title="Exit" onClick="'
		btn +='c360_makeAlert()" style="padding-left:99%;font-size:12px">[x]</a>'
		var c = document.getElementById("c360_popup_alert")
		
		c.style.display="none"
		 c.style.position="absolute"

		c.style.color = "#000"
		c.style.backgroundColor = "#fff"
		//c.style.top = t
		//c.style.left = l
		c.style.width = w
		
		c.style.zIndex = "200"
		
		 c.style.border = "1px solid #d3d3d3"
		 

		c.style.MozBorderRadius = "5px"
		c.style.padding = "0 15px 15px 15px"
		c.style.fontFamily = "Arial,Sans-Serif"
		c.style.fontSize = "13px"
	
		c.innerHTML = btn + '<div id="c360_alert_popup"></div>'
		
		c.style.display=""
		centerInView(c)
		var btn = '&nbsp;&nbsp;<a href="javascript:void(0)" title="Exit" onClick="'
		btn +='c360_makeAlert()" class="buttonDef">Close</a>'
		document.getElementById("c360_alert_popup").innerHTML = str + "<br />" + btn
		var p = document.getElementById("c360_alert_popup")
		p.style.backgroundColor="#fff"
		//p.style.border = "1px solid #d3d3d3"
		p.style.border = "1px solid red"
		p.style.marginTop = "1px"
		p.style.padding = "10px"
		
	}
	
	function centerInView(ele) {
//width and height of viewport
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //horizontal and vertical scroll
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  
  var eleH = ele.offsetHeight 
	var eleW = 	ele.offsetWidth 
	var parentW
	try { 
	 parentW = ele.offsetParent.offsetWidth //this works in IE and Firefox
	} catch(ex) {parentW = "800";}
	var tempHeight
	ele.style.position = "absolute"
	tempTop = myHeight-eleH<0?scrOfY:(myHeight - eleH)/2 + scrOfY
	ele.style.top = tempTop + "px"
	//ele.style.top = (myHeight - eleH)/2 + scrOfY + "px"
	ele.style.left = (parentW - eleW)/2 + scrOfX + "px" 
	if (myHeight-eleH<0) {
	 myHeight = myHeight - (myHeight*.2)
	 ele.style.height = myHeight + "px";ele.style.overflow="scroll" 
	
	}
	 ele.style.display=""
}
function validateForm(fldName) {
			//validate form name before file upload 
			//get name of file
			var fn=e(fldName).value.toLowerCase()
			var myReturn = true
			 
			if (fn == "") {
				alert("File name is required (Select file)")
				myReturn = false			
			}	
			if ( fn.charAt(fn.length-4) != "." && fn.charAt(fn.length-5) != "."){
				alert("File extension seems to be missing: " + fn)
				myReturn = false
				}
			var strTest = fn.slice(0,-5)
			if (strTest.indexOf(".") > -1) {
				alert("More than one period in a file name is not allowed: " + fn)
				myReturn = false
			}
			var ext = fn.substring(fn.indexOf("."))	
			var extOK = ".doc .jpg .pdf .xls .rtf .gif .htm .html .txt .csv .css .mp3 .ram .mpg .wmv .zip .rar .swf"
			if (extOK.indexOf(ext) == -1) {
				alert("File extensions must be one of the following: " + extOK)
				myReturn = false
				}
			 
			if (myReturn) {
				if (document.getElementById("fileName")){	postFileType()} //if called from old upload process 10/20/2008 mpal
			} else {
				e(fldName).value = ""
			}
			return myReturn
					
		}
function postFileType(myFile) { 
	//expects additional field called myFile + "_ext" to save extension mpal 10/20/08
	myFile=myFile==null?"fileName":myfile
	var fn =document.getElementById(myFile).value
	var ext = fn.substring(fn.indexOf(".")+1)	
	if (document.getElementById("item_file_type")) {	
			document.getElementById("item_file_type").value = ext
	} else {
		e(myFile + "_ext").value = ext
	} 	
}
function arrayFind(ary, value) {
	var rtn = false
	for (var i=0;i<ary.length;i++) {
		if (ary[i]==value) {rtn=true;break}
	}
	return rtn
}

 function helpSys(pre,status,template) {
 template = template==null?"":template

newWin=window.open("popup_helpsys.cfm?pre=" + pre + "&s=" + status + "&t=" + template,"popupHelp","width=750px,height=600px,top=50px,left=100px,scrollbars=1,resizable=1,status=0,menubar=0,location=1")		
		//newWin=window.open("popup_helpsys.cfm?pre=" + pre + "&s=" & status,"popupHelp", 
		//"width=400px,height=500px,top=50px,left=100px,scrollbars=1,resizable=1,status=0,menubar=0,location=1")		
		newWin.focus()
}
	  function unitTest(pre,template) {
        pre = pre==null?"":pre
        template= template==null?"":template
		var myTarget = template!=""?"_testParams":"_" + pre
       var win =window.open("popup_unitTest.cfm?p=" + pre + "&t=" + template, myTarget,"width=810px,height=650px,top=50px,left=50px,scrollbars=1,menubar=1,location=1")  
    win .focus()    
     }	
function reportMenu(groupList) {
 
		var bindArgs = {
			url: "c360_browse_reports.cfc?method=reportMenu",
				content: {groupList:groupList}, 
				method: "post",			
				mimetype: "text/html",
				error: fncDojoBindError,
				load: function(type, data, evt){	
		  
	 	  	c360_makePopup(0,data,"600px","","",3)
					//document.getElementById("rptpromptsForm").innerHTML = data
	
				}
			}
				dojo.io.bind(bindArgs);
	 
}
 function popup_listManagement(list_id) {
       var winList
    
    winList=window.open("popup_listManagement.cfm?l=" + list_id, "popupListManagement", "width=750px,height=650px,top=50px,left=50px,scrollbars=1,resizable=0")  
    winList.focus()    
    
    }
