	function doQuery(id,m,cfc,two,three,tid, cb)	{
		
		// if callback not passed//
		if(cb == null)
			cb = 'doQueryCallback2';
		// send data to CF
		if(three!=null)
			var temp = three;
		else
			var temp = id;

		DWRUtil.removeAllRows("tableBody"+tid);
		DWRUtil.useLoadingMessage("","tableBody"+tid);
		///alert("callback.."+cb);
		var mycfc = (cfc!=null) ? cfc : _ajaxConfig._cfscriptLocation;
		///alert("load..."+id+"===cfc:"+mycfc+"===two:"+two+"===three:"+three+"===target:"+tid);
		if(three != null && two != null)
		{//alert("3");
			DWREngine._execute(mycfc, null, m, id, two, three, tid, window[cb]);
		}	
		else if(two != null)
		{//alert("2");
			
			DWREngine._execute(mycfc, null, m, id, two, tid, window[cb]);
		}
		else
		{//alert("1");
			DWREngine._execute(mycfc, null, m, id, tid, window[cb]);
		}
	}

	function doQueryNew(m,cfc,tpl,tid,cb)	{
		
		// if callback not passed//
		if(cb == null)
			cb = 'doQueryCallback3';
		// send data to CF

		DWRUtil.removeAllRows("tableBody"+tid);
		DWRUtil.useLoadingMessage("","tableBody"+tid);
		///alert("callback.."+cb);
		
		// Build params taken from page's document object
		ord = document.com_form.hid_sortby.value;
		sd = document.com_form.hid_seldate.value;
		ed = document.com_form.hid_seldate.value;
		inc = document.com_form.hid_include.value;
		var lis = '';
		var appendList = false;
		obj = document.getElementById('sel_lists')
		for (i=0;i<obj.length;i++){
			if (obj.item(i).selected){
				if (appendList == true){
					lis = lis + ',';
				}
				lis = lis + obj.item(i).value;
				appendList = true;
			}
		}
//		lis = document.com_form.sel_lists.value;
		com = document.com_form.sel_coms.value;
		
		var mycfc = (cfc!=null) ? cfc : _ajaxConfig._cfscriptLocation;

		DWREngine._execute(mycfc, null, m, ord, sd, ed, inc, lis, com, tpl, tid, window[cb]);
	}

	function clearRows(id) {
		DWRUtil.removeAllRows("tableBody"+id);

		var myid = id;
		if(id.search("addtotrack") != -1)
			myid = 'tableBody' + myid.replace("addtotrack","billdoc");
		window.location.hash=myid;
	}
	function doQueryCallback2 (r) { 
		var temph = r.myhtml[0].split(":")[0];
		if(r.id[0] == null)
		{
			alert("No records found.");
			
		}
		else if(temph == "javascript")
			{
				var myjs = r.myhtml[0].split(":")[1];
				//alert("type==="+myjs);
				//refreshPage(myjs);
				refreshPage();
			}
		else
		{
			var id = "";
			
			
			if(r.type[0] != null)
			{
				//alert("type=="+r.type[0]);
				id = "tableBody"+r.type[0];
			}
			
			else
				id = "tableBody"+r.id[0];
				
			DWRUtil.removeAllRows(id);
			var myhtml = function (thisRow) {
				
					var myhtml = unescape(thisRow.myhtml);
				return myhtml;
			}
			DWRUtil.addRows(id, r, [myhtml], null);
			
			var patt = new RegExp(location.pathname)
			if(typeof tinyMCE != "undefined"){
				if(patt.test("/sponsors.cfm") || patt.test("/histories.cfm") || patt.test("/summaries.cfm"))
					initTinyMCE_small();
				else {
					initTinyMCE();
					//tinyMCE.settings.content_editable = true;
				}
			}
		}
		
	}

	function commentsCallback (r) {

		if(r.id[0] != null)
		{
			tid = "tableBody"+r.id[0];
		}
		
		DWRUtil.removeAllRows(tid);

		var myhtml = function (thisRow) {
			
			var myhtml = unescape(thisRow.myhtml);
			return myhtml;
		}

		DWRUtil.addRows(tid, r, [myhtml], null);
		
		if (r.listid[0]==0){
			var txttid = "GeneralCommentsText"+r.billid[0];		// use billid
			var mydiv = "divGeneralComments"+r.billid[0];
		} else {
			var txttid = "SingleListCommentsText"+r.listid[0]+"_"+r.billid[0];	// use listid
			var mydiv = "divSingleListComments"+r.listid[0]+"_"+r.billid[0];
		}
		
		// Get the textarea value by name
		var foundit = false;
		var myc = '';
		var x = document[r.id[0]];
		for (var i=0;i<x.length;i++)
	  {
	  	if(x.elements[i].name == 'com');{
	  		myc = x.elements[i].value;
	  		foundit = true;
	  	}
	  	if(foundit)
	  		break;
	  }
		
		if(document.getElementById(txttid)){
			document.getElementById(txttid).innerHTML = myc;
			document.getElementById(mydiv).style.display = 'block';
			window.location.hash=eval('document.comments_form'+r.billid[0]+'.billnumber.value');
		}
				
		return false;
		
	}

	function doQueryCallback3 (r) { 
		//var temph = r.myhtml[0].split(":")[0];
		var tid;
		
		if(r.type[0] != null)
		{
			//alert("type=="+r.type[0]);
			tid = "tableBody"+r.type[0];
		}
		
		DWRUtil.removeAllRows(tid);

		var myhtml = function (thisRow) {
			
			var myhtml = unescape(thisRow.myhtml);
			return myhtml;
		}

		DWRUtil.addRows(tid, r, [myhtml], null);
		
	}

	function doTrackingListsQueryCallback (r) { 
		var temph = r.myhtml[0].split(":")[0];
		if(r.id[0] == null)
		{
			alert("No records found.");
			
		}
		else if(temph == "javascript")
			{
				var myjs = r.myhtml[0].split(":")[1];
				//alert("type==="+myjs);
				//refreshPage(myjs);
				refreshPage();
			}
		else
		{
			var id = "";
			
			if(r.type[0] != null)
			{
				//alert("type=="+r.type[0]);
				id = "tableBodyUpdateList"+r.type[0];
			}
			
			else
				id = "tableBodyUpdateList"+r.id[0];
				
			DWRUtil.removeAllRows(id);
			var myhtml = function (thisRow) {
				
					var myhtml = unescape(thisRow.myhtml);
				return myhtml;
			}
///			alert('id='+id);
///			alert('r='+r.name);
///			alert('[myhtml]='+[myhtml]);
			DWRUtil.addRows(id, r, [myhtml], null);
		}
		
	}

	function displayListCallBack(r) {
	
		///alert('call back');
		///special case to refresh list if any selected in tracking list manager page///
		var l = getSelectedLists();
		if(l!='')
			loadList();
		else
			doQueryCallback2(r);
	}
		
	// call back function
	function doQueryCallback (r) {
		if(r.id[0] == null)
		{
			alert("No records found.");
			
		}
		else
		{
			DWRUtil.removeAllRows("tableBody"+r.id[0]);
			//alert("back.."+r.mytype[0]+"==="+r.id[0]);
			var sponsors = function (thisRow) {
				
					var myhtml = "<a href='members.cfm?id="+thisRow.memberid+"'>"+thisRow.memberfirst + " " + thisRow.memberlast + " (" + thisRow.memberpartycode + ")</a><BR>";
				return myhtml;
			}
			var actions = function (thisRow) {
				
					var myhtml = "<b>" + thisRow.billactionshorttitle + "</b> " + thisRow.billactiondate + "<BR>" + thisRow.billactiondesc + "<BR><BR>";
				return myhtml;
			}
			var summary = function (thisRow) {
				
					var myhtml = thisRow.billsummarytext + "<BR><BR>";
				return myhtml;
			}
			var status = function (thisRow) {
				
					var myhtml = thisRow.statuscode + " " + thisRow.statusdesc + "<BR>";
				return myhtml;
			}
			var codes = function (thisRow) {
				
					var myhtml = "<a href='http://www.azleg.gov/ArizonaRevisedStatutes.asp?Title="+thisRow.codenumber+"' target='_blank'>" + thisRow.codenumber + "</a> ";
				return myhtml;
			}
			var sections = function (thisRow) {
				
					var myhtml = "<a href='http://www.azleg.gov/ArizonaRevisedStatutes.asp?Title="+thisRow.codenumber+"' target='_blank'>"+thisRow.codenumber+"-"+thisRow.sectionnumber+"</a> ";
				return myhtml;
			}
			DWRUtil.addRows("tableBody"+r.id[0], r, [eval(r.mytype[0])], null);
		}
	}

	function doViewPrintLink(c,s,q){
		// c = collate literal value (bill or meeting)
		// s = cgi script_name
		// q = cgi query_string
		if (typeof(document.cal_form.cal_collate) != 'undefined')
			document.cal_form.cal_collate.value = c;
		var myhref = s + '?print=true&show_alerts=true&pageview=all&coll=' + c;
//		if (q)
//			myhref = myhref + '&' + q;
		if (typeof(document.getElementById('a_viewprint')) != 'undefined' && document.getElementById('a_viewprint') != null)
			document.getElementById('a_viewprint').href = myhref;
		doQuery(document.cal_form.cal_select.value, 'includeTemplate', this.mycfcpath + 'main.cfc', 'home_Cal_alerts.html', c, 'Cal');
	}