
function AvailabilityTable(tableId){this.table=dojo.byId(tableId);this.allTds=this.table.getElementsByTagName('td');this.clickBoxes={};if(w.isRefineSearch)setDetailedScheduleCheckBoxes();for(var i=0;i<this.allTds.length;i++){if(this.allTds[i].className!='clickBox')continue;this.allTds[i].id="_"+i
this.clickBoxes[this.allTds[i].id]=new AvailabilityCell(this.allTds[i].id)}}
function AvailabilityCell(tableCellId,responseField){this.cell=document.getElementById(tableCellId);this.checkBox=this.cell.getElementsByTagName('input')[0];this.state=this.getState();dojo.connect(this.cell,'onclick',this,this.update);if(this.state=='on'){this.setState(this.state,true);}}
AvailabilityCell.prototype.update=function(type,data,evt){this.setState(this.getDesiredState());if(w.isRefineSearch)setDetailedScheduleHiddenField(this.parseInteger(this.checkBox.id));}
AvailabilityCell.prototype.getState=function(){if(this.checkBox){return(this.checkBox.checked)?'on':'off';}}
AvailabilityCell.prototype.getDesiredState=function(){return(this.state=='off')?'on':'off';}
AvailabilityCell.prototype.setState=function(state){switch(state){case'on':dojo.addClass(this.cell,'on');this.checkBox.checked=true;this.state='on';break;case'off':if(dojo.hasClass(this.cell,'on'))dojo.removeClass(this.cell,'on');this.checkBox.checked=false;this.state='off';break;default:break;}}
AvailabilityCell.prototype.parseInteger=function(fullString){var openB=fullString.indexOf('[')+1;var closeB=fullString.indexOf(']');return fullString.slice(openB,closeB);}
function setupSchedule(){try{var allTables=document.getElementsByTagName('table');for(var i=0;i<allTables.length;i++){if(allTables[i].className!='setAvail')continue;w[allTables[i].id]=new AvailabilityTable(allTables[i].id)}}catch(err){console.error(err);}}
dojo.addOnLoad(setupSchedule);dojo.addOnLoad(function(){window.allDatePickers=dojo.query('.datePicker').forEach(function(item,index,array){setUpDatePicker(item.id.replace('datePicker',''));});})