	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------- START FORM FIELD FUNCTION ------------------------------------- 	*/
	/*		------------------------------------------------------CREATED BY JASTLE   ----------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	

/*     ******************************** start  depentant  drop down redraw ********************************    */
		function redrawDropdownResults(retvar)
	{		
		dropdownArray = retvar.array;
		dropDown = $(retvar.fieldname);
		selectedValue = retvar.select;
		DWRUtil.removeAllOptions(retvar.fieldname);
		dropDown.disabled = false;
		
		
		for (i=0;i<dropdownArray.length;i++) {
		   if (dropdownArray[i] !='') {
		      //dropDown.options.length = (i+1); // make it one longer (ie prefers that)	
		      selLength = dropDown.options.length;
		      dropDown.options[selLength] = new Option(dropdownArray[i][1], dropdownArray[i][0]);
		      
		           if(selectedValue != ''){
		            	if(selectedValue == dropdownArray[i][0]){
					      	dropDown.options[selLength].selected = true;
		            }
		         }
		      }
		      
		   
		}
}

/*     ******************************** end depentant  drop down redraw ********************************    */



/*		THIS IS A BASIC FUNCTION TO HANDLE FIELD BY FIELD  */
/*     ******************************** start Form field save  for edit bpo ********************************    */
		function saveFormField(id, formfield, fieldname, qvalue, updatedin, method, obj, objmethod, miscname, miscvalue )
		{	
			//alert(miscvalue);
			//alert(miscname);
			//alert(formfield);
			ffield = $(fieldname);
			fvalue = ffield.value;
			ffield.disabled = true;
			url = '_code/_ajax/_gen_ajax.cfc';
			//alert(fieldname);
			CD(ffield);
			DWREngine._execute(url, null, method, {'id':id, 'field':fieldname, 'fieldval':fvalue, 'value':qvalue, 'obj':obj,  'objmethod':objmethod, 'updatedin':updatedin, 'miscname':miscname, 'miscvalue':miscvalue}, redrawFormField);
		}

/*     ******************************** end Form field save for edit bpo*******************************    */

//**********************************************************************************************************************************************************
//*****************************************************CHECK BOX AUDIT FUNCTIONS***************************************************************************
//**********************************************************************************************************************************************************


/*     ******************************** start  audit check box call ********************************    */
		function saveCheckBox(fk_id, type, sid, msginheader,dspdetail, savemsg, savedesc, msgdivid, detaildivid,  field)
	{		
			var qfield = $(field);
			var qdiv = $(msgdivid);
			qfield.disabled = true;
			if(detaildivid != ''){
				var qdtldiv = $(detaildivid);
				qdtldiv.innerHTML = '<img src="_images/_icons/indicator.white.gif" alt="" border="0">';
			}
			
			//display the saving msg
			if(msginheader == 1){
				qdiv.style.visibility='visible';
			}
			qdiv.innerHTML = savemsg;
			if(qfield.checked == true){
				checked = 1;
			}
			else{
				checked = 0;
			}
			DWREngine._execute('_code/_audits/_audits_AjaxWrapper.cfc', null, 'GENCKBOX', {'fk_id':fk_id, 'field':field, 'type':type, 'fk_sid':sid, 'dspdetail':dspdetail, 'savedesc':savedesc, 'msgdivid':msgdivid, 'detaildivid':detaildivid, 'savingmsg':savemsg, 'thecheck':checked}, redrawCheckBox);
}

/*     ******************************** end audit check box call ********************************    */



/*		THIS IS A BASIC FUNCTION TO HANDLE FIELD BY FIELD  */
/*     ********************************audit check box redraw ********************************    */
		function redrawCheckBox(r)
		{	
			var msgdiv = $(r.msgdivid);
			var dtldiv = $(r.detaildivid);
			var theck = $(r.thecheck);
			var field = $(r.field);
			var usrmsg = r.usrmsg;
			if(r.status != 2){
				if(r.dspdetail == 1){
				dtldiv.innerHTML = r.userid + ' ' + r.datecreated + ' ' + r.timecreated;
				}
				else{
					dtldiv.innerHTML  = '';					
				}
				msgdiv.innerHTML = 	usrmsg;
				field.disabled = false;
			}
			else
				alert(r.error);			
		}

/*     ******************************** redraw*******************************    */

//**********************************************************************************************************************************************************
//**********************************************************************************************************************************************************
//**********************************************************************************************************************************************************

/*     ******************************** Form field save  ******************************************    */
		function redrawFormField(retvar)
	{	
		field =  $(retvar.field);
		
		if(retvar.status != 2){
			//if the update worked then enable the cell and change the color
			field.disabled = false;
			CB(field);
			
		}
		else{
			// if the update fails leave the cell disabled
			// and alert the error			
			alert(retvar.error);
		}
}

/*     ******************************** end Form field save ***************************************    */


	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------- END FORM FIELD FUNCTION 		------------------------------------ 	*/
	/*		------------------------------------------------------CREATED BY JASTLE   ----------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	
	

	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		------------------------------------- START VALIDATION/LOOKUP FUNCTION ------------------------------------- 	*/
	/*		--------------------------------------				AUTHOR JASTLE   							-------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/

/*     ********************************  start  Zip code validation ********************************    */
	function checkZipCode(zipcode, fzip, fstate, fcounty)
	{
		zip = $(fzip);
		state = $(fstate);
		county = $(fcounty);
		
		var zipcode = DWRUtil.getValue(zipcode);
	 	url = '_code/_udc/_udc_zip_AjaxWrapper.cfc?field=';
	 	su = '&state=';
	 	cu = '&county=';
	 	state.disabled = true;
	 	county.disabled = true;
		zip	.disabled = true;
		path = url + fzip +su +fstate + cu +fcounty;
		
		DWREngine._execute(path, null, 'checkzip', zipcode, redrawvalidateZipCode);
		
	}
	
/*     ********************************  end Zip code validation ********************************    */


/*     ******************************** start  Zip code validation redraw ********************************    */
		function redrawvalidateZipCode(retvar)
	{		
		stat = retvar.stat;
		fzip = $(retvar.f_zip);
		fstate = $(retvar.f_state);
		fcount = $(retvar.f_county);
		fcounty = retvar.f_county;
		astate = retvar.s_array;
		//acounty = retvar.c_array;
		sstate = retvar.selected_state;
		scounty = retvar.selected_county;
		


		   if (stat != 1) {
		     CC(fzip);	
		     fzip.disabled = false;	      
		     fstate.disabled = false;
		     fcount.disabled = false;
		     fzip.focus();
		     alert( "Zip code was not found. \nPlease try again. " );
		   }
		   
		   else{
		   		CB(fzip);	
		   		fzip.disabled = false;
		   		
	   			for (i=0;i<astate.length;i++) {
		   if (astate[i] !='') {
		   		
		      fstate.options.length = (i+1); // make it one longer (ie prefers that)	
		      fstateLength = fstate.options.length;
		      fstate.options[fstate.options.length] = new Option(astate[i][1], astate[i][0]);
		      
		      if(sstate == astate[i][1]){
		      	fstate.disabled = false;
		      	fstate.options[fstateLength].selected = true;
		      	
		      }
		  
		   }
		}
		getCounty(retvar.f_state, fcounty, scounty);

		   		
		   }
		
}

/*     ******************************** end Zip code validation redraw ********************************    */

/*     ********************************  ajax county drop down ********************************    */
	function getCounty(state, county, selected)
	{
		var state = DWRUtil.getValue(state);
		countyDD = $(county);
	 	url = '_code/_udc/_udc_counties_AjaxWrapper.cfc?county=';
	 	select = selected;
	 	uselect = '&select=';
		path = url + county + uselect + select;
		DWRUtil.removeAllOptions(countyDD);
		countyDD.options[countyDD.options.length] = new Option('Loading ...');
		DWREngine._execute(path, null, 'countylookup', state, redrawDropdownResults);
		
	}
	

/*     ********************************  end ajax county drop down ********************************    */



/*     ********************************  dependant dropdown w/ repnames ********************************    */

	function getRepName(bank, rep, selected)
	{
		var number = DWRUtil.getValue(bank);
		url = '_code/_ab/_ab_ajaxWrapper.cfc?contact=';
		select = selected;
	 	uselect = '&select=';
		path = url + rep+ uselect + select;
		Frep = $(rep);
		DWRUtil.removeAllOptions(Frep);
		Frep.options[Frep.options.length] = new Option('Loading ...');
		DWREngine._execute(path, null, 'RepNameLookup', number, redrawDropdownResults);
	}
	
/*     ********************************  end dependant dropdown w/ repnames ********************************    */

/*     ********************************  ajax phone drop down ********************************    */
	function getPhone(bank, phone)
	{
		var number = DWRUtil.getValue(bank);
		url = '_code/_ab/_ab_ajaxWrapper.cfc?contact=';
		path = url + phone;
		Fphone = $(phone);
		DWRUtil.removeAllOptions(Fphone);
		Fphone.options[Fphone.options.length] = new Option('Loading ...');
		DWREngine._execute(path, null, 'contactLookup', number, redrawDropdownResults);
	}


/*     ********************************  ajax account subtype lookup ********************************    */
	function getAC_STYPE(catcode, field)
	{
		var catcode = DWRUtil.getValue(catcode);
		list = 'AC_SUBTYP' + catcode;
		ac_field = $(field);
	 	url = '_code/_udc/_udc_ajaxWrapper.cfc';
	 	select = '';
	 	DWRUtil.removeAllOptions(ac_field);
		ac_field.options[ac_field.options.length] = new Option('Loading ...');
		DWREngine._execute(url, null, 'getudc_list', {'list':list, 'field':field, 'select':select}, redrawDropdownResults);
		
	}
	
/*     ********************************  end account subtype lookup ********************************    */

/*     ********************************  ajax account subsubtype lookup ********************************    */
function getAC_SSUBTYPE(actype, acsubtype, field)
{
	var acsubtype = $(acsubtype).value;
	var actype =$(actype).value;
	//alert(acsubtype);
	list = 'AC_SUBSUBTYP' + actype + '_' + acsubtype;
	//alert(list);
	acsub_field = $(field);
 	url = '_code/_udc/_udc_ajaxWrapper.cfc';
 	select = '';
 	DWRUtil.removeAllOptions(acsub_field);
	acsub_field.options[acsub_field.options.length] = new Option('Loading ...');
	DWREngine._execute(url, null, 'getudc_list', {'list':list, 'field':field, 'select':select}, redrawDropdownResults);
	
}
/*     ********************************  end account subsubtype lookup ********************************    */


/*     ********************************  ajax account purch type lookup ********************************    */
	function getAC_PTYPE(catcode, field)
	{
		var catcode = DWRUtil.getValue(catcode);
		list = 'AC_PURTYP' + catcode;
		ac_field = $(field);
	 	url = '_code/_udc/_udc_ajaxWrapper.cfc';
	 	select = '';
	 	DWRUtil.removeAllOptions(ac_field);
		ac_field.options[ac_field.options.length] = new Option('Loading ...');
		DWREngine._execute(url, null, 'getudc_list', {'list':list, 'field':field, 'select':select}, redrawDropdownResults);
		
	}
	
/*     ********************************  end account purch type lookup ********************************    */


	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		------------------------------------- END VALIDATION/LOOKUP FUNCTIONS ------------------------------------- 	*/
	/*		--------------------------------------				AUTHOR JASTLE   							-------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/

	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		------------------------------------- START SAL EDIT  FUNCTIONS 				------------------------------------- 	*/
	/*		--------------------------------------				AUTHOR JASTLE   			-------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/

	function saveSAL(fk_id, fk_gid, type, mode, admin, view, edit, add, creatediv, updatediv, updatedin)
	{
		var qadminfield = $(admin);
		var qeditfield = $(edit);
		var qaddfield = $(add);
		var qviewfield = $(view);
		var adminvalue = 0;
		var editvalue = 0;
		var addvalue = 0;
		var viewvalue = 0;
		
		//first thing diable the checkboxes
		qadminfield.disabled = true;
		qeditfield.disabled = true;
		qaddfield.disabled = true;
		qviewfield.disabled = true;
		
		//find out what box is checked and act as needed
		if(mode == 3){
			//mode = 3 admin active
			if(qadminfield.checked == true){
				//admin is checked then check everything
				qviewfield.checked = true;		
				qeditfield.checked = true;
				qaddfield.checked = true;
				//adminvalue = 1; 
				//editvalue = 1;
				//addvalue = 1;
				//viewvalue = 1;
			}
			else {
				//adminvalue = 0;
			}
		}
		else if(mode == 2){
			//mode = 2 add active
			if(qaddfield.checked == true){
				//add is checked then check edit and view
				qviewfield.checked = true;
				qeditfield.checked = true;		
			}
			else {
				qadminfield.checked = false;		
			}			
		}
		else if(mode == 1){
			//mode = 1 edit active
			if(qeditfield.checked == true){
				//EDIT is checked then check VIEW
				qviewfield.checked = true;		
			}
			else {
				qadminfield.checked = false;
				qaddfield.checked = false;
			}			
		}
		else if(mode == 0){
			//mode = 0 view active
			if(qviewfield.checked == true){
				//VIEW is checked  doent check anything else 
			}
			else {
				qadminfield.checked = false;		
				qeditfield.checked = false;
				qaddfield.checked = false;
			}			
		}
		
		if(qviewfield.checked == true)viewvalue = 1;
		if(qeditfield.checked == true)editvalue = 1;
		if(qaddfield.checked == true)addvalue = 1;
		if(qadminfield.checked == true)adminvalue = 1;				
		
		
		
		toggleSAL(creatediv, '<img src="_images/_icons/progress_bar2.gif" alt="" border="0">');
		toggleSAL(updatediv, '');

		
		DWREngine._execute('_code/_security/_sal_ajaxWrapper.cfc', null, 'S_ACCESS_LIST_MGT', {'fk_id':fk_id, 'fk_gid':fk_gid, 'type':type, 'admin':adminvalue, 'edit': editvalue, 'view':viewvalue, 'add':addvalue, 'createddiv':creatediv, 'updateddiv':updatediv, 'updatedin':updatedin}, redrawSAL);
		
	}
	
		function toggleSAL(el, text)
	{
		myEl = $(el);
		myEl.style.display = (myEl.style.display == 'none') ? 'none' : 'block';
		myEl.innerHTML = text;
		
	}
	
	function redrawSAL(retvar)
	{	
		if(retvar.status != 2){
			var gid = retvar.fk_gid;
			var gidlen = (gid+'').length;
			var viewfield = 'VIEWALLOW' + gid;
			var adminfield = 'ADMINALLOW' +gid;
			var editfield = 'EDITALLOW' +gid;
			var addfield = 'ADDALLOW' +gid;
			var qadminfield = $(adminfield);
			var qviewfield = $(viewfield);
			var qeditfield = $(editfield);
			var qaddfield = $(addfield);			
			var updatedetail = retvar.updatedetail;
			var createdetail = retvar.createdetail;
			
				qviewfield.disabled = false;
				
			if(gidlen != 1){
				qadminfield.disabled = false;
				qeditfield.disabled = false;
				qaddfield.disabled = false;
			}
			toggleSAL(retvar.createddiv,  createdetail);
			toggleSAL(retvar.updateddiv,  updatedetail);
		}
		else{
			// if the update fails leave the cell disabled
			// and alert the error			
			alert(retvar.usrmsg);
		}
}	
	

	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		------------------------------------- START SAL EIDT  FUNCTIONS 				------------------------------------- 	*/
	/*		--------------------------------------				AUTHOR JASTLE   			-------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	
	
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		------------------------------------- START DELETE ROW FUNCTION 				------------------------------------- 	*/
	/*		--------------------------------------				AUTHOR SGUEST   			-------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/

function deleteRow(form, pattern, cfcPath, method, callback, displayPoint, button, fk_rbid, ownerID)
{
	//alert(method);
	//alert(ownerID);
	$(button).disabled = true;
	$(button).style.color = 'gray';
	
	$(displayPoint).style.visibility='visible';
	$(displayPoint).innerHTML = "Deleting . . . ";
	
	var formVals = getModuleFields(form, pattern);
/*
	var debug = '';
	
	for(key in formVals)
	{
		debug += key + ": " + formVals[key] + '\n';
	}
	
	alert(debug);
*/
	formVals['displayPoint'] = displayPoint;
	
	// defined in /_scripts/core/js/engine.js
	DWREngine._execute(cfcPath, null, method, {"formVals": formVals, "button":button, "ID":ownerID, "fk_rbid":fk_rbid}, callback);
	
}

	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	/*		----------------------------------------------- END DELETE ROW FUNCTION 		------------------------------------ 	*/
	/*		------------------------------------------------------CREATED BY SGUEST  	 ----------------------------------------	*/
	/*		----------------------------------------------------------------------------------------------------------------------	*/
	


///////////////////////////////////////////////////////////////////////////////////////////////
// AUTHOUR: BBUCK
// CREATED: 11 JUL 2006
// THIS IS A GENERIC METHOD TO CALL WHEN SAVING A MODULE VIA AJAXCFC
function saveMod(form, pattern, cfcPath, method, callback, displayPoint, button)
{
	$(button).disabled = true;
	$(button).style.color = 'gray';
	
	$(displayPoint).style.visibility='visible';
	$(displayPoint).innerHTML = "Saving Data . . . ";
	
	var formVals = getModuleFields(form, pattern);


/*
	var debug = '';
	
	for(key in formVals)
	{
		debug += key + ": " + formVals[key] + '\n';
	}
	
	alert(debug);
*/
	 
	formVals['displayPoint'] = displayPoint;
	
	// defined in /_scripts/core/js/engine.js
	DWREngine._execute(cfcPath, null, method, {"formVals": formVals, "button":button}, callback);
	
}

///////////////////////////////////////////////////////////////////////////////////////////////
// AUTHOUR: BBUCK
// CREATED: 11 JUL 2006
// THIS IS A GENERIC CALLBACK METHOD TO CALL WHEN SAVING A MODULE VIA AJAXCFC
// IT ALSO SETS THE FIELDS BACK TO THEIR INITIAL STATE AND DISPLAYS THE RESULT
function showModSaved(r)
{
	//alert(r);
	
	if(r != 'undefined' && r != null)
	{
		if (r.displaypoint != '' && r.displaypoint != null && r.displaypoint != 'undefined')
		{	
			$(r.button).disabled = false;
			$(r.button).style.color = '';
	
			$(r.displaypoint).style.visibility='visible';
			$(r.displaypoint).innerHTML = r.message;

			if(r.fields != '' && r.fields != null && r.fields != 'undefined')
			{
				var fieldsArr = r.fields.split(',');
		
				for (var i = 0; i < fieldsArr.length; i++)
				{
					CB(fieldsArr[i]);
				}
			}
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////
// AUTHOUR: BBUCK
// CREATED: 11 JUL 2006
// this will search through the entire form looking for
// form field names that match a regular expression. It 
// returns an associative array of the form fields found
// and their values. 
function getModuleFields(form, pattern)
{
	var matchedVal;
	var fieldsList = '';
	var formVals = new Object();
	
	// grab handles on all the form elements on the page.
	var inputEls = document.getElementsByTagName('input');
	var selectEls = document.getElementsByTagName('select');
	
	// loop over the entire form looking for only the fields that match the search pattern
	for (var i = 0; i < inputEls.length; i++)
	{
		matchedVal = inputEls[i].id.match(pattern);
		
		// save the matched values into a comma separated list
		if (matchedVal != null)
		{
			
			if(inputEls[i].type == 'checkbox')
			{
				formVals[matchedVal] = inputEls[i].checked;
			}
			else
			{
				formVals[matchedVal] = inputEls[i].value;
			}
			
			fieldsList = fieldsList + inputEls[i].id + ',';
		}
	}
	
	for (var j = 0; j < selectEls.length; j++)
	{	
		matchedVal = selectEls[j].id.match(pattern);
		
		// save the matched values into a comma separated list
		if (matchedVal != null)
		{
			//alert(matchedVal + '\n' + selectEls[j].id + '\n' + selectEls[j].value );
			
			formVals[matchedVal] = selectEls[j].value;
			fieldsList = fieldsList + selectEls[j].id + ',';
			//alert(formVals[matchedVal]  + '\n' + matchedVal);
			
		}
	}
	
	// strip off a trailing comma
	var regex = new RegExp(/,$/);
	fieldsList = fieldsList.replace(regex, '');
	
	formVals['fields'] = fieldsList;

/*
var debug = '';
	
	for(key in formVals)
	{
		debug += key + ": " + formVals[key] + '\n';
	}
	
	alert(debug);
*/
	
	return formVals
}

function altTblClrs(tableID, color1, color2)
{	// color1 and color2 are no longer being used. Substituted for the css colors
	var theTable = $(tableID);
	
	for(var i = 0; i < theTable.rows.length; i++)
	{
		if(i % 2 == 0)
		{
			theTable.rows[i].className= 'AR2';
		}
		else
		{
			theTable.rows[i].className= 'AR1';
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////
// AUTHOUR: jburnham
// CREATED: 2007-05-03
// THIS IS A BASIC FUNCTION TO HANDLE email
//		
		function sendEmail(method, emailTo, subject, body)
		{
			var url = '/_code/_email/_email.cfc';
			DWREngine._execute(url, null, method, {'EMAILTO':emailTo, 'EMAILSUBJECT':subject, 'EMAILBODY':body}, callBackSendEmail);
		}
//     ******************************** end Form sendEmail  *******************************    --->
	function callBackSendEmail(retvar)
	{   
		// do nothing
	}

