var isResponses = false;URL = window.location.href;isResponses = (URL.indexOf('_comment?') > -1)var rowSelected = true;//global variablesvar whichUtils = new Array(2)whichUtils[0] = "editor"whichUtils[1] = "calendar"whichUtils[2] = "datatable";//view detailsvar currentView = 0;var viewnames;var viewsorters;var sortkey;var viewsif (isResponses == true) {views = ["vw_comments"];viewnames = ["Comments"];viewsorters = ["_by_date","_by_name"];sortkey = ["date","name"];} else {views = ["vw_observations","vw_applications","vw_prayers"];viewnames = ["Observations","Applications","Prayers"];viewsorters = ["_by_date","_by_name","_by_responses"];sortkey = ["date","name","responses"];}var sortdir = "desc";var sortcol = 0;var type = "";var isCalendarVisible = false;var isEditorVisible = false;var wasDateSelected = false;function makeArray() {    for (i = 0; i<makeArray.arguments.length; i++)        this[i + 1] = makeArray.arguments[i];}var months = new makeArray('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var days = new makeArray('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');//function to handle all custom initializationvar addCustomItems = function() {YAHOO.namespace("soaps");YAHOO.namespace("soaps.calendar");/* OVERRIDE  for account details, as calendar is visible*///capture rollover event for addcomment picture, and start animationYAHOO.util.Event.on('account', 'click', function() {if (isCalendarVisible == true) {showCalendar();}});/* TABLE ======================================*/if (document.getElementById('soapstable')) {//load tables if we have JSON availableYAHOO.soaps.onJsonLoad = function( ){  this.handleClick = function(e) {var origin = YAHOO.util.Event.getTarget(e);if (origin.nodeName.toUpperCase() == "A") {var whichPage =origin.id.substring(7);var oDataTable = YAHOO.soaps.myDataTable;var docCount = oDataTable.get("paginator").rowsPerPage;if (whichPage == 1) {whichDoc = Number(whichPage);} else {whichDoc = ((whichPage - 1) * docCount) + 1}nResults = YAHOO.soaps.myDataTable.get("paginator").rowsPerPage;var newRequest = views[currentView] + viewsorters[sortcol] + "_" + sortdir + "?openview&start=" + whichDoc + "&count=" + nResults + "&restricttocategory=" + category;thisds = oDataTable.getDataSource();thisds.sendRequest(newRequest, YAHOO.soaps.myDataTable.onDataReturnInitializeTable, YAHOO.soaps.myDataTable);}};YAHOO.util.Event.addListener('pageLinks','click',this.handleClick);this.myCommentFormatter = function(elCell, oRecord, oColumn, oData) { var thisName = oRecord.getData("name");var thisID = oRecord.getData("id");var thisComment = decodeURIComponent(oRecord.getData("comment"));elCell.innerHTML = '<span class="commentname">' + thisName + '</span><p><div style="width:280px">' + thisComment + '</div><p><a href="' + webdbname + 'fm_report?openform&id=' + thisID + '" class="offensive">Report as Offensive or Inappropriate</a>';var t = elCell.offsetHeight;};this.myDateFormatter = function(elCell, oRecord, oColumn, oData) {var thisDate = new Date(oRecord.getData("date"));var thisID = oRecord.getData("id");var day   = days[thisDate.getDay() + 1];var date  = thisDate.getDate();var month = months[thisDate.getMonth() + 1];var year  = thisDate.getFullYear();var a_p = "";var hours = thisDate.getHours();if (hours < 12)   {   a_p = "AM";   }else   {   a_p = "PM";   }if (hours == 0)   {   hours = 12;   }if (hours > 12)   {   hours = hours - 12;   }var min = thisDate.getMinutes();if (min< 10) {min = "0" + min;}elCell.innerHTML = "<div class='commentdate'>" + day + "<br>" + month + " " + date + " " + year + "<br>" + hours + ":" + min + " " + a_p + "</div>";};this.myResponsesFormatter = function(elCell, oRecord, oColumn, oData) {var thisResponses = oRecord.getData("responses");var thisID = oRecord.getData("id");elCell.innerHTML = "<span class=\"comments\" style=\"padding:5px;text-align:center;float: right;width:29px\">" +  thisResponses +"</span>";};var myColumnDefs;if(isResponses == false) {myColumnDefs= [{key:"date",label:"Date",width:"95px",sortable:true,parser:YAHOO.util.DataSource.parseDate,formatter:this.myDateFormatter},{key:"name",label:"Name",width:"340px",sortable:true,formatter:this.myCommentFormatter},{key:"responses",label:"Replies",sortable:true,parser:YAHOO.util.DataSource.parseNumber,formatter:this.myResponsesFormatter}];} else {myColumnDefs = [{key:"date",label:"Date",width:"95px",sortable:true,parser:YAHOO.util.DataSource.parseDate,formatter:this.myDateFormatter},{key:"name",label:"Name",width:"340px",sortable:true,formatter:this.myCommentFormatter}];}// DataSource instancethis.myDataSource = new YAHOO.util.DataSource(webdbname);this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;this.myDataSource.responseSchema = {resultsList: "records",fields: ["id","date","name","icon","comment","responses"]};// DataTable instancevar oConfigs = {initialRequest: views[currentView] + viewsorters[sortcol] + "_" + sortdir + "?openview&start=1&count=" +docsperpage + "&restricttocategory=" + category,sortedBy:{key:sortkey[sortcol], dir:"desc"}};YAHOO.soaps.myDataTable = new YAHOO.widget.DataTable("soapstable", myColumnDefs,this.myDataSource, oConfigs);// Custom code to parse the raw server data for Paginator values and page linksthis.myDataSource.doBeforeCallback = function(oRequest, oRawResponse, oParsedResponse, myDataTable) {//check for first row 'loader'var tbody = YAHOO.util.Dom.getElementsByClassName("yui-dt-body","tbody","soapstable")if (tbody) {var firstrow = tbody[0].firstChild;if (firstrow) {var firsttd =  firstrow.firstChild;if (firsttd) {if (firsttd.innerHTML.toLowerCase().indexOf("ajax-loader.gif") > 0) {firstrow.parentNode.removeChild(firstrow);}}}}var oDataTable = YAHOO.soaps.myDataTable;// Get Paginator valuesvar oRawResponse = oRawResponse.parseJSON(); //JSON.parse(oRawResponse); // Parse the JSON data//get rid of extra row added by Domino;var responseLength = oRawResponse.records.length;oRawResponse.records = oRawResponse.records.splice(0,responseLength - 1);oParsedResponse = this.parseJSONData("",oRawResponse);//get view location parametersvar docCount = oRawResponse.count; // How many records this pagevar recordsReturned = oRawResponse.recordsReturned; // How many records this pagevar startIndex = oRawResponse.startIndex; // Start record index this pagevar endIndex = startIndex + recordsReturned -1; // End record index this page;totalRecords = oRawResponse.totalRecords; // Total records all pagesif (totalRecords === 0) {document.getElementById('viewnavigatortitle').innerHTML = "No " + viewnames[currentView].toLowerCase() + " yet"} else if (totalRecords === 1) {document.getElementById('viewnavigatortitle').innerHTML = totalRecords + " " + viewnames[currentView].substring(0,viewnames[currentView].length - 1);} else {document.getElementById('viewnavigatortitle').innerHTML = totalRecords + " " + viewnames[currentView];}// Update the DataTable Paginator with new values   var newPag = {   recordsReturned: recordsReturned,   startRecordIndex: startIndex,   endIndex: endIndex,   totalResults: totalRecords,rowsPerPage:docCount}  oDataTable.updatePaginator(newPag);   // Do all our calculations to find out where we are in the viewnavRange = 3;partialPages = totalRecords / docCount;extraPage = (partialPages == Math.floor(partialPages)) ? 0 : 1;totalPages = Math.floor(partialPages) + extraPage;curPage = Math.floor(startIndex / docCount) + 1;// Figure out the number of the first and last pages to display on the navigatorstartLink = (curPage < (navRange + 1)) ? 1 : curPage - navRange;endLink = ((curPage + navRange) > totalPages) ? totalPages : curPage + navRange;var pageNav = "";for (i = startLink; i <= endLink; i++){	if (i == curPage) {		pageNav += "<span style=\"margin:6px 0\" class=\"yui-dt-selected\">" + i + "</span>";	} else {			pageNav += "<a style=\"margin-left:3px;margin-right:3px\" id=\"navpage" + i + "\" class=\"yui-dt-page\" href=\"#page" + i + "\" alt=\"Goto page " + i +  "\">" + i + "</a>"	}}if(totalRecords > docCount) {YAHOO.util.Dom.get("pageLinks").innerHTML = pageNav;YAHOO.util.Dom.get("firstLink").innerHTML = (startIndex === 1) ? "<<" : "<a href=\"#previous\" alt=\"Goto first page\"><<</a>" ;YAHOO.util.Dom.get("lastLink").innerHTML =  (endIndex >= totalRecords) ? ">>" :   "<a href=\"#next\" alt=\"Goto last page\">>></a>";} else {YAHOO.util.Dom.get("pageLinks").innerHTML =  "<span style=\"margin:6px 0\" class=\"yui-dt-selected\">1</span>";YAHOO.util.Dom.get("firstLink").innerHTML = "<<";YAHOO.util.Dom.get("lastLink").innerHTML = ">>";}// Update the config sortedBy with new valuesvar newSortedBy = {key: sortkey[sortcol],dir: sortdir}oDataTable.set("sortedBy", newSortedBy);// Let the DataSource parse the rest of the responsereturn oParsedResponse;};// Hook up custom paginationthis.getPage = function(nStartRecordIndex, nResults) {// If a new value is not passed in// use the old valueif(!YAHOO.lang.isValue(nResults)) {nResults = YAHOO.soaps.myDataTable.get("paginator").rowsPerPage;}// Invalid valueif(!YAHOO.lang.isValue(nStartRecordIndex)) {return;}var newRequest = views[sortcol] + viewsorters[sortcol] + "_" + sortdir + "?openview&start=" + nStartRecordIndex + "&count=" + nResults + "&restricttocategory=" + category;this.myDataSource.sendRequest(newRequest, YAHOO.soaps.myDataTable.onDataReturnInitializeTable, YAHOO.soaps.myDataTable);};this.getPreviousPage = function(e) {YAHOO.util.Event.stopEvent(e);// Already at first pageif(YAHOO.soaps.myDataTable.get("paginator").startRecordIndex === 0) {return;}var newStartRecordIndex = YAHOO.soaps.myDataTable.get("paginator").startRecordIndex - YAHOO.soaps.myDataTable.get("paginator").rowsPerPage;if (newStartRecordIndex < 1) {newStartRecordIndex = 1;}this.getPage(newStartRecordIndex);};this.getNextPage = function(e) {YAHOO.util.Event.stopEvent(e);// Already at last pageif(YAHOO.soaps.myDataTable.get("paginator").startRecordIndex +YAHOO.soaps.myDataTable.get("paginator").rowsThispage >=YAHOO.soaps.myDataTable.get("paginator").totalRecords) {return;}var newStartRecordIndex = (YAHOO.soaps.myDataTable.get("paginator").startRecordIndex + YAHOO.soaps.myDataTable.get("paginator").rowsThisPage);this.getPage(newStartRecordIndex);};this.getFirstPage = function(e) {YAHOO.util.Event.stopEvent(e);this.getPage(1);};this.getLastPage = function(e) {YAHOO.util.Event.stopEvent(e);var docCount = YAHOO.soaps.myDataTable.get("paginator").rowsPerPagevar partialPages = ((Math.floor(totalRecords / docCount)) * docCount) + 1;this.getPage(partialPages);}; // Override function for custom sortingYAHOO.soaps.myDataTable.sortColumn = function(oColumn) {if(oColumn.key === this.get("sortedBy").key) {sortdir = (this.get("sortedBy").dir === "asc") ?"desc" : "asc";} else {sortdir = "asc";}sortcol = oColumn.getKeyIndex();nResults =this.get("paginator").rowsPerPage;var newRequest = views[currentView] + viewsorters[sortcol] + "_" + sortdir + "?openview&start=1&count=" + nResults + "&restricttocategory=" + category;this.getDataSource().sendRequest(newRequest, this.onDataReturnInitializeTable, this);};YAHOO.util.Event.addListener(YAHOO.util.Dom.get("firstLink"), "click", this.getFirstPage, this, true); YAHOO.util.Event.addListener(YAHOO.util.Dom.get("lastLink"), "click", this.getLastPage, this, true); // Subscribe to events for row selection    YAHOO.soaps.myDataTable.subscribe("rowMouseoverEvent", YAHOO.soaps.myDataTable.onEventHighlightRow);   YAHOO.soaps.myDataTable.subscribe("rowMouseoutEvent", YAHOO.soaps.myDataTable.onEventUnhighlightRow);   YAHOO.soaps.myDataTable.subscribe("linkClickEvent", function(o){rowSelected = false;})YAHOO.soaps.myDataTable.subscribe("rowClickEvent", function(oArgs){//get row datavar elTarget = oArgs.target;   var elRecord = this.getRecord(elTarget);   var thisId = elRecord.getData("id");if (rowSelected == true) {var commentcontainer = document.getElementById('commentpanel');//if this is gecko, don't do popup, open page directlyvar cn = commentcontainer.parentNode.className;if(cn.indexOf("-scrollbars") > 0) {window.location = webdbname + "fm_comment?openform&parentunid=" +  thisId;} else {commentcontainer.style.display = "block";var maincomment = document.getElementById('maincomment');var footer = YAHOO.util.Dom.getElementsByClassName('ft', 'div','commentpanel');maincomment.innerHTML = '';maincomment.style.backgroundImage="url(ajax-loader.gif)";maincomment.style.backgroundRepeat="no-repeat";maincomment.style.backgroundPosition =  "center"; maincomment.className = "commentvisible";var responses = document.getElementById('commentresponses')if(responses){var thisResponses = elRecord.getData("responses");var thisID = elRecord.getData("id");if (thisResponses == "0") {responses.innerHTML = "<span class=\"comments\" style=\"padding:5px;text-align:center;float: left;width:29px\">" + thisResponses +"</span><span style=\"padding-left:10px;vertical-align: middle\"><a class=\"more\" href=\"" + webdbname + "fm_comment?openform&parentunid=" +  thisID + "\">No replies yet - be the first!</a></span>";} else {responses.innerHTML = "<span class=\"comments\" style=\"padding:5px;text-align:center;float:left;width:29px\"><a href=\"" + webdbname + "fm_comment?openform&parentunid=" +  thisID + "\">" + thisResponses +"</a></span><span style=\"padding-left:10px;vertical-align: middle\"><a class=\"more\" href=\"" + webdbname + "fm_comment?openform&parentunid=" +  thisID + "\">Read replies and add your own!</a></span>";}}}//format footervar thisName = elRecord.getData("name");var thisDate = new Date(elRecord.getData("date"));var day   = days[thisDate.getDay() + 1];var date  = thisDate.getDate();var month = months[thisDate.getMonth() + 1];var year  = thisDate.getFullYear();var a_p = "";var hours = thisDate.getHours();if (hours < 12)   {   a_p = "AM";   }else   {   a_p = "PM";   }if (hours == 0)   {   hours = 12;   }if (hours > 12)   {   hours = hours - 12;   }var min = thisDate.getMinutes();if (min< 10) {min = "0" + min;}footer = YAHOO.util.Dom.getElementsByClassName('ft', 'div','commentpanel');footer[0].innerHTML = '<span class="commentname">' + thisName + '</span><br><span class="commentdate">' + day + ', ' + month + ' ' + date + ' ' + year + '<br>' + hours + ':' + min + ' ' + a_p + '</div>';//get full comments/*FULL COMMENTS AJAX*/var handleFullCommentSuccess = function(o){	if(o.responseText !== undefined){	maincomment.style.backgroundImage = "none";	maincomment.innerHTML = o.responseText;	}	}var handleFullCommentFailure = function(o){	if(o.responseText !== undefined){		maincomment.style.backgroundImage = "none";		maincomment .innerHTML += "Whoops! There has been an error:<p>" + o.status + ": " + o.statusText;	}};var fullCommentCallback ={  success:handleFullCommentSuccess,  failure: handleFullCommentFailure,  argument: ['foo','bar']};var sUrl = "/youth/soap.nsf/vw_comments_full/" + thisId;var postData = "&1";YAHOO.soaps.fullcomment = YAHOO.util.Connect.asyncRequest('POST', sUrl, fullCommentCallback, postData);  xy = YAHOO.util.Dom.getXY( elTarget.id);xy[0] += 90;xy[1] += 40;var isVisible = YAHOO.soaps.container.commentdrag.cfg.getProperty("visible")if (isVisible == false) {YAHOO.soaps.container.commentdrag.cfg.setProperty("xy", xy); YAHOO.soaps.container.commentdrag.show();} else {var theseAttributes = {   points: { to: xy}   }; YAHOO.soaps.anim.duration= 0.25;YAHOO.soaps.anim.method= YAHOO.util.Easing.easeOut;YAHOO.soaps.anim.attributes = theseAttributes;YAHOO.soaps.anim.animate();}} else { //row wasn't clickedrowSelected = true} }); //end row clickYAHOO.util.Event.onAvailable("calendardate", function(){		if(null==this.well) dominoWellLoad(this, '/youth/common.nsf/button_calendar_roll.gif?OpenImageResource&amp;ImgIndex=0', 2);});if (isResponses == false) {function onMenuItemClick(p_sType, p_aArgs, p_oValue) {currentView = p_oValue;var menubar = this.parent;var allmenuitems= menubar.getItems();for(var x = 0;x <allmenuitems.length; x++){	if(x == currentView){		allmenuitems[x].element.className = allmenuitems[x].element.className.replace(" menuSelected","")		allmenuitems[x].element.className = allmenuitems[x].element.className + " menuSelected";	} else {		allmenuitems[x].element.className = allmenuitems[x].element.className.replace(" menuSelected","")	}}var oDataTable = YAHOO.soaps.myDataTable;thisds = oDataTable.getDataSource();nResults = oDataTable.get("paginator").rowsPerPage;var newRequest = views[currentView ] + viewsorters[0] + "_desc?openview&start=1&count=" + nResults + "&restricttocategory=" + category;thisds.sendRequest(newRequest, oDataTable.onDataReturnInitializeTable, oDataTable);}var oCommentsMenu = new YAHOO.widget.MenuBar("viewnavigator", {lazyload: true,visibile:true,context:['viewnavigatorholdermain','tl','tl']});oCommentsMenu.addItems(    [        { text: "Observations", onclick: { fn: onMenuItemClick, obj: 0} },        { text: "Applications", onclick: { fn: onMenuItemClick, obj: 1} },        { text: "Prayers", onclick: { fn: onMenuItemClick, obj: 2 } },    ]);oCommentsMenu.render("viewnavigatorholder");oCommentsMenu.getItems()[0].element.className = oCommentsMenu.getItems()[0].element.className + " menuSelected";document.getElementById('viewnavigator').style.visibility = "visible";}}; //end on JSON available//Begin by creating a new Loader instance:var loader = new YAHOO.util.YUILoader();	function checkJSON(name, loaderCallback) {	if (YAHOO.util.EventProvider) {		if (Object.prototype.toJSONString) {			loaderCallback();		} else {			setTimeout(function() {checkJSON(name, loaderCallback);}, 50);		}	} else {		setTimeout(function() {checkJSON(name, loaderCallback);}, 50);	}}//Add the module to YUILoaderloader.addModule({name: "json", //module name; must be uniquetype: "js", //can be "js" or "css"fullpath: "/build/json/json.js", //can use a path instead, extending base pathverifier: checkJSON //the verifier function we just defined});loader.require("json"); //include the new  module//Add the module to YUILoaderloader.addModule({name: "utils", //module name; must be uniquetype: "js", //can be "js" or "css"fullpath: "/build/utilities/utilities.js", //can use a path instead, extending base pathverifier: checkJSON //the verifier function we just defined});loader.require("utils"); //include the new  module//Set your skins member here:loader.skin = {defaultSkin: 'youth',base: '/build/assets/skins/'}            //Insert JSON utility on the page, passing in our callback:loader.insert(YAHOO.soaps.onJsonLoad);} //end if soapstable is available/* CALENDAR ======================================*/if (document.getElementById('jumptocalMainContainer')) {//create on overlay to fade calendar in and outYAHOO.soaps.container.calendarbox = new YAHOO.widget.Overlay("jumptocalMainContainer", { context:["jumptocalOutsideContainer","tl","bl"],visible:false,width:"200px",zIndex:1000,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } );//variable function handle jumping to different datesvar jumpToDate = function(type, args) {//hide calendarYAHOO.soaps.calendar.jumptocal.hide();//change calendar booleanisCalendarVisible = false;//check whether this was a date changeif (wasDateSelected == true) {//get chosen date arrayvar selected = YAHOO.soaps.calendar.jumptocal.getSelectedDates()[0];//create a formatted date from arrayvar newdate =  (selected.getMonth() + 1) + "/" + selected.getDate() + "/" + selected.getFullYear();//change the window locationwindow.location = webdbname + 'fm_soap?openform&date=' + newdate;}}//variable function to set calendar visible booleanvar setFlag = function(type, args) {//change calendar visibility booleanisCalendarVisible = true;}//subscribe to various container events//change calendar visibility flag when calendar is shownYAHOO.soaps.container.calendarbox.subscribe("show", setFlag);//change date when calendar is closedYAHOO.soaps.container.calendarbox.subscribe("hide", jumpToDate);//define function that runs when calendar is initializedYAHOO.soaps.calendar.loadcal = function() {//create a new calendarYAHOO.soaps.calendar.jumptocal = new YAHOO.widget.Calendar("jumptocal","jumptocalContainer",{selected:jumpto,pagedate:jumptomonth});if (!(window.datesinuse === undefined)) {	for (i=0; i<datesinuse.length; ++i) {		YAHOO.soaps.calendar.jumptocal.addRenderer(datesinuse[i], YAHOO.soaps.calendar.jumptocal.renderCellStyleHighlight1);  	}}//subscribe to select date eventYAHOO.soaps.calendar.jumptocal.selectEvent.subscribe(mySelectHandler,YAHOO.soaps.calendar.jumptocal, true);//add calendar to pageYAHOO.soaps.calendar.jumptocal.render();//add a rollover listener to calendar iconYAHOO.util.Event.addListener("calendarspan", "mouseover", showCalendar); YAHOO.util.Event.addListener("mainbackdrop", "click", hideCalendar); }//variable function to handle calendar date selectionvar mySelectHandler = function(type,args,obj) {// change date selected booleanwasDateSelected = true;//hide calendar containerYAHOO.soaps.container.calendarbox.hide();};//function to show or hide calendarfunction showCalendar(e, obj) {//if the calendar is hidden, show itif (isCalendarVisible == false) {wasDateSelected = false;//show the calendar in containerYAHOO.soaps.calendar.jumptocal.show();//fade the container inYAHOO.soaps.container.calendarbox.show();}}//function to  hide calendarfunction hideCalendar(e, obj) {YAHOO.soaps.container.calendarbox.hide();}//render calendarYAHOO.soaps.container.calendarbox.render(document.body);YAHOO.util.Event.onDOMReady(YAHOO.soaps.calendar.loadcal);}/*REPORT OFFENSIVE COMMENTS BUTTON*/if(document.getElementById('reportoffensive')) {YAHOO.soaps.reportOffensive = new YAHOO.widget.Button({label:"Submit", id:"reportoffensivebutton", container:"reportoffensive" });}/*ADD COMMENTS ======================================*///variable function to show editor box in correct positionvar showEditor = function(){if(typeof(myEditor)=="undefined"){ //variable function to add rich text features to add comment boxmyEditor = new YAHOO.widget.Editor('newComment', {height: '150px',width: '435px',dompath: false, //Turns on the bar at the bottomanimate: false, //Animates the opening, closing and moving of Editor windowstoolbar: { //defines toolbar        titlebar: 'My Editor',        buttons: [            { group: 'textstyle', label: 'Font Style',                buttons: [                    { type: 'push', label: 'Bold', value: 'bold' },                    { type: 'push', label: 'Italic', value: 'italic' },                    { type: 'push', label: 'Underline', value: 'underline' },                    { type: 'separator' },                    { type: 'color', label: 'Font Color', value: 'forecolor', disabled: true }                ]            },{ type: 'separator' },{ group: 'alignment', label: 'Alignment',                            buttons: [                                { type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },                                { type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },                                { type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' }                            ]                        },{ type: 'separator' },                        { group: 'indentlist', label: 'Lists',                            buttons: [                                { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },                                { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }                            ]                        },{ type: 'separator' },                        { group: 'insertitem', label: 'Insert Item',                            buttons: [                                { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true }                            ]                        }        ]    }});//Give the editor's window focus after the content is loaded..   myEditor.on('editorContentLoaded', function(){myEditor._focusWindow;});   //Render the editor   myEditor.render();   } else {var editorContainer = document.getElementById('editorMainContainer');editorContainer.style.display = 'inline';}var editorContainer = document.getElementById('editorMainContainer');editorContainer.style.display = 'inline';}//define editor fade in functionvar fadeEditorIn = new YAHOO.util.Anim('commentcontainer', {height: { to: 330 }}, 1, YAHOO.util.Easing.easeBoth);fadeEditorIn.onComplete.subscribe(showEditor);  //capture rollover event for add comment picture, and start animationYAHOO.util.Event.on('addcommentspan', 'mouseover', function() {fadeEditorIn.animate();});//define editor fade in functionvar fadeEditorOut = new YAHOO.util.Anim('commentcontainer', {height: { to: 0 }}, 1, YAHOO.util.Easing.easeBoth);//capture rollover event for add comment picture, and start animationYAHOO.util.Event.on('closeeditor', 'click', function() {var editorContainer = document.getElementById('editorMainContainer');editorContainer.style.display = "none";document.getElementById('newComment').blur();fadeEditorOut.animate();});//variable function to handle successfull ajax addition of commentvar handleSuccess = function(o){//update tablevar oDataTable = YAHOO.soaps.myDataTable;nResults =oDataTable.get("paginator").rowsPerPage;if(currentView === 0) {sortdir = "desc"} else {sortdir = "asc"}var newRequest = views[currentView] + viewsorters[0] + "_" + sortdir + "?openview&start=1&count=" + nResults + "&restricttocategory=" + category;oDataTable.getDataSource().sendRequest(newRequest, oDataTable.onDataReturnInitializeTable, oDataTable);//clear text from editordocument.getElementById('newComment').value = "";myEditor.clearEditorDoc();}//variable function to handle AJAX failurevar handleFailure = function(o){YAHOO.soaps.addingcomment.hide(); showError('Sorry - there has been an error adding your comment: ' + o.status +' -- ' + o.statusText)}//variable function that runs when AJAX sends a callback event, passing response to either success or failure handlervar callback ={  success:handleSuccess,  failure: handleFailure,  argument: ['foo','bar']};//function to add a new commentvar addComment = function() {var tbody = YAHOO.util.Dom.getElementsByClassName("yui-dt-body","tbody","soapstable")if (tbody) {var firstrow = tbody[0].firstChild;var tr = document.createElement("TR");var td = document.createElement("TD");td.setAttribute("colspan","3");td.setAttribute("align","center");td.style.textAlign = 'center';var thisimg = document.createElement("img");thisimg.setAttribute("src","/youth/common.nsf/ajax-loader.gif");td.appendChild(thisimg);tr.appendChild(td);tbody[0].insertBefore(tr,firstrow);}try {if (isResponses == true) {type = "comments";} else {type = "observations";//get typeswitch (currentView){case 0: {type = "observations";break }case 1: {type = "applications";break }case 2: {type = "prayers";break }default: {type = "observations";break}}}//get rich textmyEditor.saveHTML(); //Save the HTMLvar commentContent  = encodeURIComponent(myEditor.get('textarea').value);var nickname = document.getElementById('nickname').value;//check for empty contentvar testContent = remove(remove(remove(RemoveHTML(decodeURIComponent(commentContent)),"&nbsp;"),"\n"),"\r");if (testContent== "") {myEditor.clearEditorDoc();alert("Please add a comment before submitting");} else {var fbstring = "";if (document.getElementById('updatefacebook')) {if (document.getElementById('updatefacebook').checked == true) {		fbstring = "&fb=1"}}//send request to serverif (isResponses == true) {var postData = 'comment=' + commentContent + '&type=' + type + '&parentid=' + parentid + '&nn=' + nickname + fbstring;} else {var postData = 'comment=' + commentContent + '&type=' + type + '&day=' + dayoftheyear + '&nn=' + nickname + fbstring;}var request = YAHOO.util.Connect.asyncRequest('POST', webdbname + 'addcomment?openagent', callback, postData);}} catch(error) {errortext = "There has been an error:\n\n" + error;alert(errortext)}}/*RICH TEXT EDITOR ======================================*///do we have an add comment box?if (document.getElementById('newComment')) {/*ADD COMMENT BUTTON ======================================*///define button to add commentvar oaddcommentbutton = new YAHOO.widget.Button("addcommentbutton");oaddcommentbutton.on("click", addComment);}; //end of 'is new comment available test//rolloversYAHOO.util.Event.onAvailable("calendardate", function(){		if(null==this.well) dominoWellLoad(this, '/youth/common.nsf/button_calendar_roll.gif?OpenImageResource&amp;ImgIndex=0', 2);});YAHOO.util.Event.onAvailable("addcomment", function(){ 		if(null==this.well) dominoWellLoad(this, '/youth/common.nsf/button_addcomment_roll.gif?OpenImageResource&amp;ImgIndex=0', 2);});/*FULL COMMENTS BOX ======================================*/// Build popupYAHOO.soaps.container.commentdrag = new YAHOO.widget.Panel("commentpanel", {width:"341px",zIndex:"900",visible:false, constraintoviewport:true,effect:{effect: YAHOO.widget.ContainerEffect.FADE,duration:0.25}});YAHOO.soaps.container.commentdrag.beforeHideEvent.subscribe(function() {var maincomment = document.getElementById('maincomment');var footer = YAHOO.util.Dom.getElementsByClassName('ft', 'div','commentpanel');maincomment.className = "commenthidden";});//Create motion animation//YAHOO.soaps.anim = new YAHOO.util.Motion('commentpanel_c');//renderYAHOO.soaps.container.commentdrag.render();} //end custom add items stuff//function to remove characters from stringfunction remove(s, t) {  i = s.indexOf(t);  r = "";  if (i == -1) return s;  r += s.substring(0,i) + remove(s.substring(i + t.length), t);  return r; } //function to remove HTML from stringfunction RemoveHTML( strText ){	var regEx = /<[^>]*>/g;	return strText.replace(regEx, "");}