/* javascript compressor */
Ext.apply(Ext.Element.prototype,{getValue:function(){var el=this.dom;switch(el.tagName.toLowerCase()){case'select':var values=[];for(i=0;i<el.options.length;i++){var opt=el.options[i];if(opt.selected){values.push(opt.value!==null&&opt.value!=='undefined'?opt.value:opt.text);if(!el.multiple){return values[0]}}}return(el.multiple)?values:false;case'input':if(!(el.checked&&['checkbox','radio'].indexOf(el.type)!==-1)&&['hidden','text','password'].indexOf(el.type)==-1)break;case'textarea':return el.value}return false},setValue:function(value){var el=this.dom;switch(el.tagName.toLowerCase()){case'select':value=(typeof value!='array')?[value]:value;for(i=0;i<el.options.length;i++){var opt=el.options[i];opt.selected=opt.value&&value.indexOf(opt.value)!=-1}return;case'input':if(['checkbox','radio'].indexOf(el.type)!=-1){el.checked=el.value?(el.value==value):!(value===null||value===false);return}case'textarea':el.value=(!value||value=='undefined'||value===null)?'':value;return}return},getName:function(){return this.dom.name}});Ext.form.Field.prototype.getName=function(){return this.el.dom.name};Ext.form.Select=function(config){Ext.form.Select.superclass.constructor.call(this,config);this.addQueue=new Array();this.opts=new Array();this.addEvents({select:true,addoption:true,setoptions:true,clearoptions:true})};Ext.extend(Ext.form.Select,Ext.form.Field,{fieldClass:"x-form-field",textKey:'text',valueKey:'value',hideEmpty:'true',emptyText:'No Options',useValidation:false,preventMark:true,defaultAutoCreate:{tag:"select"},initEvents:function(){Ext.form.Select.superclass.initEvents.call(this);this.el.on("change",this.onSelect,this);this.el.on("keyup",this.onSelect,this)},validate:function(){if(!this.useValidation){return true}return Ext.form.Select.superclass.validate.call(this)},isValid:function(preventMark){if(this.useValidation){return true}return Ext.form.Select.superclass.validate.call(this,preventMark)},onSelect:function(){if(this.rendered){this.setValue()}},clearOptions:function(){this.opts=new Array();this.fireEvent('clearoptions',this);this.renderOptions()},setOptions:function(options,norender){var opts=options||this.options||[];this.options=opts;if(!this.rendered){return}this.clearOptions();if(this.options instanceof Array){for(var i=0;i<this.options.length;i++){this.addOption(this.options[i],true,true)}}else{for(var i in this.options){this.addOption(this.options[i],true,true)}}if(!norender){this.renderOptions()}this.fireEvent('setoptions',this,this.getValue())},addOption:function(option,pos,norender){if(!this.rendered){this.addQueue.push([option,pos]);return}if(!this.fireEvent('addoption',option,this)){return}var opt=new Option();if(option instanceof Array){opt.text=/^(\d)+$/.test(this.textKey)&&this.textKey<option.length?option[this.textKey]:option[option.length-1];opt.value=/^(\d)+$/.test(this.valueKey)&&this.valueKey<option.length?option[this.valueKey]:option[0]}else{opt.text=option[this.textKey];opt.value=option[this.valueKey]}if(opt.value==this.value){opt.selected=true}if(pos!==undefined&&pos!==false&&pos!==true){pos=parseInt(pos);if(pos<0){pos=0}else if(pos>this.opts.length){pos=this.opts.length}this.opts.splice(pos,0,opt)}else{this.opts.push(opt)}if(!norender){this.renderOptions()}},renderOptions:function(){while(this.el&&this.el.dom.options.length>0){this.el.dom.options[0]=null}if(this.opts.length==0){this.hide();return}this.show();for(i=0;this.el&&i<this.opts.length;i++){this.el.dom.options[i]=this.opts[i]}},hide:function(hidetext){if(!this.rendered){return}if(!this.emptyTextEl){var span=Ext.DomHelper.insertBefore(this.el.dom,{tag:'span'});this.emptyTextEl=Ext.get(span);this.emptyTextEl.setVisibilityMode(Ext.Element.DISPLAY);this.emptyTextEl.update(this.emptyText);this.emptyTextEl.hide();this.el.setVisibilityMode(Ext.Element.DISPLAY)}this.el.hide();if(!hidetext){this.emptyTextEl.show()}},show:function(){if(!this.rendered){return}if(this.emptyTextEl){this.emptyTextEl.hide()}this.el.show()},insertOption:function(option,pos){this.addOption(option,pos)},onRender:function(ct){Ext.form.Select.superclass.onRender.call(this,ct);if(this.options){this.setOptions(false,true);if(this.addQueue.length>0){for(i=0;i<this.addQueue.length;i++){var c=this.addQueue[i];this.addOption(c[0],c[1],true)}this.addQueue=new Array()}this.renderOptions();this.setValue(this.value)}},initValue:Ext.emptyFn,getValue:function(){if(this.rendered){var v=this.el.getValue();if(v!=this.value){this.value=v}return this.value}return this.value},setValue:function(v){if(this.el&&this.el.dom&&v){this.el.setValue(v)}this.value=this.el?this.el.getValue():v;this.fireEvent("select",this,this.value)},select:function(v){if(this.el&&this.el.dom&&v){this.el.setValue(v)}this.value=this.el?this.el.getValue():v}});Ext.namespace("MY","MY.joomla");Ext.BLANK_IMAGE_URL="http://www.threechefs.com.au/mambots/extjs1/ext/resources/images/default/s.gif";MY.joomla.Connector=function(){this.siteurl=this.cleanUrl('http://www.threechefs.com.au');this.ajaxurl=this.cleanUrl('http://www.threechefs.com.au/index2.php');this.option='com_tableboss';this.Itemid='58';this.readyStack=[];this.sections=null;this.user=null;this.events={'ready':true}};Ext.extend(MY.joomla.Connector,Ext.util.Observable,{cleanUrl:function(url){var regex=/^http\:\/\/www/;if(regex.test(window.location.href)&&!regex.test(url)){url=url.replace(/http\:\/\//,"http://www.")}else if(regex.test(url)&&!regex.test(window.location.href)){url=url.replace(/http\:\/\/www/,"http://")}return url},initialize:function(view,task){this.request({view:view,task:task,format:'raw',output:'json'},{callback:function(opts,success,xhr){if(success){this.data=Ext.util.JSON.decode(xhr.responseText);if(this.data.sections){this.sections=this.data.sections}if(this.data.user){this.user=this.data.user}}this.ready=true;this.fireEvent('ready')},scope:this})},getParams:function(view,task,output,format,config){var params={no_html:1,option:this.option,Itemid:this.Itemid,view:view,task:task,format:format||'raw',output:output||'json'};Ext.apply(params,config);return params},getConnection:function(params){var config={url:this.ajaxurl,method:'POST',extraParams:Ext.apply({no_html:1,option:this.option},params||{})};return new Ext.data.Connection(config)},request:function(params,options){options=(!options||typeof options=="boolean")?{}:options;var c=this.getConnection();options.params=params;c.request(options)},onReady:function(fn,scope){if(this.ready){var f=fn.createDelegate(scope);f();return}this.on('ready',fn,scope);return}});MY.IdGenerator=function(){var id=0;return{generate:function(){id++;return id}}}();MY.id=MY.IdGenerator.generate.createDelegate(MY.IdGenerator);MY.joomla.TextEditor=function(){this.id=MY.id();this.formDiv=false;this.editorView='editor';this.option=MY.Joomla.option;this.autoLoad=true;this.rendered=false;this.ready=false;MY.joomla.TextEditor.superclass.constructor.call(this);this.editorurl='';this.templates={input:new Ext.Template('<input type="hidden" name="{name}" id="{id}" />'),loading:new Ext.Template('<div class="my-circle-loading"><span>','Loading...','</span></div>'),iframe:new Ext.Template('<iframe style="display: block; z-index: 2;" scrolling="no" frameborder="0" ','src="{editorUrl}" id="{editorId}" name="{editorName}" class="mycontentEditFrame">','</iframe>')};this.inputs=[];var args=arguments;if(args.length==1&&args[0]instanceof Array){args=args[0]}this.map={};for(i=0;i<args.length;i++){var t=(typeof args[i]).toLowerCase();var input=false;switch(t){case'string':input={};input.name=args[i];input.value='';input.label='DESCRIPTION';break;case'object':input=args[i];break}if(input){this.map[input.name]=this.inputs.length;this.inputs.push(input)}}this.addEvents({'load':true,'hide':true,'show':true,'savecomplete':true});this.on('savecomplete',this.updateValues,this)};Ext.extend(MY.joomla.TextEditor,Ext.util.Observable,{render:function(el){if(this.rendered==true){return}this.templates.input.compile();this.templates.iframe.compile();this.templates.loading.compile();this.inputEls={};this.map={};for(var i=0;i<this.inputs.length;i++){this.map[this.inputs[i].name]=i;this.inputEls[this.inputs[i].name]=Ext.get(this.templates.input.append(el,{name:this.inputs[i].name,id:'my_joomla_input_'+this.inputs[i].name+'_id_'+this.id,value:this.inputs[i].value}))}this.loading=Ext.get(this.templates.loading.append(el));this.iframe=Ext.get(this.templates.iframe.append(el,{editorUrl:this.editorUrl,editorName:this.getIframeName(),editorId:this.getIframeId()}));this.loading.setVisibilityMode(Ext.Element.DISPLAY);this.iframe.setVisibilityMode(Ext.Element.DISPLAY);this.iframe.on('load',this.show,this);this.iframe.on('load',this.registerWithIframe,this);this.rendered=true;this.setupForm();if(this.autoLoad){this.setupform.submit()}},registerWithIframe:function(){var w=this.getIframeWindow();if(w&&w.Controller){this.ready=true;this.fireEvent('load');w.Controller.registerTextEditor(this)}},unloading:function(){this.ready=false;this.hide()},onReady:function(fn){console.log('onReady: ',this.ready);if(!this.ready){this.on('load',fn);return}fn()},hideEditor:function(n){this.onReady(function(name){var el=this.inputEls[name];var id=(el&&el.dom)?el.dom.id:'';var w=this.getIframeWindow();if(w&&w.Controller){w.Controller.hide(id)}}.createDelegate(this,[n]))},showEditor:function(n){this.onReady(function(name){var el=this.inputEls[name];var id=(el&&el.dom)?el.dom.id:'';var w=this.getIframeWindow();if(w&&w.Controller){w.Controller.show(id)}}.createDelegate(this,[n]))},changeLabel:function(name,l){var el=this.inputEls[name];var i=(el&&el.dom)?el.dom.id:'';this.onReady(function(id,label){console.log('changeLabel',id,label);var w=this.getIframeWindow();if(w&&w.Controller){w.Controller.changeLabel(id,label)}}.createDelegate(this,[i,l]))},show:function(){if(!this.rendered){return false}this.loading.hide();this.iframe.show();return true},hide:function(){if(!this.rendered){return}this.iframe.hide();this.loading.show()},apply:function(){this.doSave('apply')},save:function(){this.doSave('save')},doSave:function(saveType){this.saving=true;this.getIframeWindow().Controller[saveType](function(){this.saving=false;this.fireEvent('savecomplete')},this)},get:function(key){return this.inputEls[key].getValue()},updateValues:function(){for(var i=0;i<this.inputs.length;i++){this.inputs[i].value=this.inputEls[this.inputs[i].name].value}},update:function(values){this.updateValues();if(values){for(i in values){this.inputs[this.map[i]].value=values[i]}}this.setupForm();this.setupform.submit()},setupForm:function(){this.fireEvent('load');if(!this.setupform){this.setupform=Ext.DomHelper.append(document.body,{tag:'form',style:'display: none',target:this.getIframeName(),action:'http://www.threechefs.com.au/index2.php',method:'post'})}Ext.fly(this.setupform).update('');Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'no_html',value:'1'});Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'option',value:this.option});Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'view',value:this.editorView});Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'iframename',value:this.getIframeId()});for(var i=0;i<this.inputs.length;i++){Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'name'+i,value:this.inputEls[this.inputs[i].name].dom.id});Ext.DomHelper.append(this.setupform,{tag:'input',type:'hidden',name:'label'+i,value:this.inputs[i].label||'Editor '+i});Ext.DomHelper.append(this.setupform,{tag:'textarea',name:this.inputEls[this.inputs[i].name].dom.id,html:this.inputs[i].value||''})}},getIframeName:function(){return'my_joomla_iframe_name_'+this.id},getIframeId:function(){return'my_joomla_iframe_id_'+this.id},getIframeWindow:function(){return parent.frames[this.getIframeName()]}});MY.joomla.TextEditor.create=function(el,args){var te=new MY.joomla.TextEditor(args);te.render(el);return te};MY.Joomla=new MY.joomla.Connector();Ext.namespace('TB.pub');Ext.override(Ext.form.Field,{markInvalid:function(msg){if(!this.rendered||this.preventMark){return}this.el.addClass(this.invalidClass);msg=msg||this.invalidText;switch(this.msgTarget){case'qtip':this.el.dom.qtip=msg;this.el.dom.qclass='x-form-invalid-tip';if(Ext.QuickTips){Ext.QuickTips.enable()}break;case'title':this.el.dom.title=msg;break;case'under':if(!this.errorEl){var elp=this.el.findParent('.x-form-field-wrap',8,true);elp=Ext.fly(elp.dom.parentNode);this.errorEl=elp.createChild({cls:'x-form-invalid-msg',style:'text-align:left;'});this.errorEl.setWidth(elp.getWidth(true)-20)}this.errorEl.update(msg);Ext.form.Field.msgFx[this.msgFx].show(this.errorEl,this);break;case'side':if(!this.errorIcon){var elp=this.el.findParent('.x-form-element',5,true);this.errorIcon=elp.createChild({cls:'x-form-invalid-icon'})}this.alignErrorIcon();this.errorIcon.dom.qtip=msg;this.errorIcon.dom.qclass='x-form-invalid-tip';this.errorIcon.show();this.on('resize',this.alignErrorIcon,this);break;default:var t=Ext.getDom(this.msgTarget);t.innerHTML=msg;t.style.display=this.msgDisplay;break}this.fireEvent('invalid',this,msg)}});TB.pub.Reservation=function(){this.el=Ext.get('tb-reservation-form');this.prefix='tb-';this.user={'name':'','email':''};this.dayFieldType='dropdown';this.sizeFieldType='dropdown';this.map={};this.steps=[];this.addEvents({select:true});this.connection=MY.Joomla.getConnection({view:'public',format:'raw',output:'json'});this.init();var old=window.onunload;var fn=this.clearTemporary.createDelegate(this);window.onunload=function(){fn();if(old&&typeof(old).toLowerCase()!='undefined'){old()}}};Ext.extend(TB.pub.Reservation,Ext.util.Observable,{init:function(){var z=0;Ext.select('.step_content',true,this.el.dom).each(function(e){var s={};z++;s.wrap=e.findParent('.reservation_step',10,true);s.wrap.setStyle({'z-index':z});var c=e.child('.step_padding');s.container=c;s.orig=c.dom.innerHTML;c.update('');s.textWrap=c.createChild({tag:'div',cls:'text-wrap'});s.contentWrap=c.createChild({tag:'div',cls:'content-wrap'});s.textWrap.setVisibilityMode(Ext.Element.DISPLAY);s.contentWrap.setVisibilityMode(Ext.Element.DISPLAY);s.contentWrap.hide();s.textWrap.update(s.orig);s.id=e.dom.id.replace(new RegExp(this.prefix),'');this.map[s.id]=this.steps.length;this.steps[this.map[s.id]]=s},this);if(this.steps.length==0){return}this.load();Ext.QuickTips.init()},load:function(s){if(s){this.currentStep=s}if(!this.currentStep){this.currentStep=this.steps[0]}s=this.currentStep;this.reset(s);if(this['load_'+s.id]){return this['load_'+s.id]()}return this._default_load(s)},_default_load:function(s){if(!s.select){s.select=new Ext.form.Select({width:'80%',textKey:'display',valueKey:'value'});s.select.on('select',this.onSelect.createDelegate(this,[s]));s.select.render(s.contentWrap);s.loading=s.contentWrap.createChild({tag:'img',src:'http://www.threechefs.com.au/mambots/extjs1/ext/resources/images/default/grid/loading.gif',alt:'Loading...'});s.loading.setVisibilityMode(Ext.Element.DISPLAY);s.loading.hide()}if(s.errorMsgWrap){s.errorMsgWrap.hide()}s.select.hide(true);s.loading.show();this.connection.request({params:this.getParams({task:'dropdown'}),scope:this,success:function(res,options){res=Ext.decode(res.responseText);this.clearReservation(res.clearReservation);if(res.error){this.displayErrorMessage(s,res.error);return}s.select.setOptions(res.items);s.select.select(-1);s.loading.hide();s.select.show()}});return true},displayErrorMessage:function(s,msg){if(!s.errorMsgWrap){s.errorMsgWrap=s.contentWrap.createChild({tag:'div',style:'text-align:center'});s.errorMsgWrap.setVisibilityMode(Ext.Element.DISPLAY)}s.errorMsgWrap.update(msg);if(s.loading){s.loading.hide()}s.errorMsgWrap.show()},clearTemporary:function(e){if(this.reservation){this.connection.request({params:this.getParams({task:'clearTemporary'})})}},onSelect:function(s){if(s.select.getValue()==-1){this.reset(s);return}var next=this.steps[this.map[s.id]+1];this.load(next)},load_info:function(){var s=this.currentStep;if(!s.loading){s.loading=s.contentWrap.createChild({tag:'img',src:'http://www.threechefs.com.au/mambots/extjs1/ext/resources/images/default/grid/loading.gif',alt:'Loading...'});s.loading.setVisibilityMode(Ext.Element.DISPLAY)}s.loading.show();if(this.fc){this.fc.hide()}this.connection.request({params:this.getParams({task:'secureTable'}),scope:this,success:function(res,options){res=Ext.decode(res.responseText);this.clearReservation(res.clearReservation);if(res.success){this.reservation=res.reservation;s.loading.hide();var f=this.getForm(s);this.focusEmptyField(f);this.fc.show();f.clearInvalid()}else{this.error=res.error}}})},load_size:function(){var s=this.currentStep;if(this.sizeFieldType!='plusminus'){this._default_load(s);return}var next=this.steps[this.map[s.id]+1];if(!s.field){var w=s.contentWrap.getWidth()*.8;s.loading=s.contentWrap.createChild({tag:'img',src:'http://www.threechefs.com.au/mambots/extjs1/ext/resources/images/default/grid/loading.gif',alt:'Loading...'});s.loading.setVisibilityMode(Ext.Element.DISPLAY);s.fieldWrap=s.contentWrap.createChild({tag:'div',style:'text-align:left; margin: 0px auto; width: '+w+'px'});s.btnWrap=s.fieldWrap.createChild({tag:'div',style:'float: right'});var selectSize=function(){s.field.validate();if(s.field.isValid()){s.selectBtn.focus();this.load(next)}};s.selectBtn=new Ext.Button(s.btnWrap,{text:'Please Select Party Size',handler:selectSize,scope:this});var bw=s.selectBtn.getEl().getWidth();s.field=new Ext.ux.PlusMinusField({width:Math.ceil(w-bw-20),readOnly:false,msgTarget:'under',min:1,max:6});s.field.render(s.fieldWrap);var fw=s.field.getEl().up('.x-form-field-wrap');fw.setStyle({'margin':'0px auto 0px 0px'});var triggers=fw.select('.x-form-trigger');s.field.getEl().setWidth(s.field.getEl().getWidth()-2);s.loading.hide();s.field.on('change',this.reset.createDelegate(this,[s]));s.field.on('plus',this.reset.createDelegate(this,[s]));s.field.on('minus',this.reset.createDelegate(this,[s]));s.field.on('tabkey',selectSize,this);s.field.on('returnkey',selectSize,this);s.field.on('enterkey',selectSize,this)}},load_day:function(){var s=this.currentStep;if(this.dayFieldType!='calendar'){this._default_load(s);return}var next=this.steps[this.map[s.id]+1];if(!s.field){s.loading=s.contentWrap.createChild({tag:'img',src:'http://www.threechefs.com.au/mambots/extjs1/ext/resources/images/default/grid/loading.gif',alt:'Loading...'});s.loading.setVisibilityMode(Ext.Element.DISPLAY);var w=s.contentWrap.getWidth();w=.8*w;this.connection.request({params:this.getParams({task:'dateField'}),scope:this,success:function(res,options){res=Ext.decode(res.responseText);s.field=new Ext.form.DateField({width:parseInt(w),emptyText:'Choose Day',readOnly:true,format:res.format,minValue:res.min,maxValue:res.max,disabledDates:res.disabledDates,disabledDatesText:'This day is unavailable',menuListeners:{'select':function(m,d){s.field.setValue(d);this.onSelectDay(next)}.createDelegate(this)}});s.field.onTriggerClick=function(){if(this.disabled){return}if(this.menu==null){this.menu=new Ext.menu.DateMenu()}Ext.apply(this.menu.picker,{minDate:this.minValue,maxDate:this.maxValue,disabledDatesRE:this.ddMatch,disabledDatesText:this.disabledDatesText,disabledDays:this.disabledDays,disabledDaysText:this.disabledDaysText,format:this.format,minText:String.format(this.minText,this.formatDate(this.minValue)),maxText:String.format(this.maxText,this.formatDate(this.maxValue))});this.menu.on(Ext.apply({},this.menuListeners,{scope:this}));this.menu.picker.setValue(this.getValue()||new Date());this.menu.show(this.el,"c-c?")};s.field.render(s.contentWrap);s.field.getEl().on('click',s.field.onTriggerClick.createDelegate(s.field));var firstFocus=true;s.field.getEl().on('focus',function(){if(firstFocus){s.field.onTriggerClick();firstFocus=false}});s.loading.hide();s.field.getEl().setStyle({'text-align':'center'});var fw=s.field.getEl().up('.x-form-field-wrap');fw.setStyle({'position':'relative','left':'-8px'});s.field.show();s.field.focus()}})}if(s.field&&s.field.getValue()!=''){this.onSelectDay(next)}},onSelectDay:function(next){this.load(next)},focusEmptyField:function(form){form.items.each(function(field){if(field.getValue()==''){field.focus();return false}return true})},closeReservation:function(sendConfirmation,requireValidation,result){var delay=200;var i=0;var speed=.6;var t=this.steps.length-1;var opts={duration:.5};var s=this.steps[this.steps.length-1];var num=s.wrap.child('.step_number');num.setOpacity(0,opts);var cw=s.contentWrap;cw.setOpacity(0);cw.setStyle('text-align','left');if(!requireValidation){cw.update(this._confirmationHtml(sendConfirmation));cw.addClass('tb-reservation-success')}else if(result.paypalHTML){cw.update(result.paypalHTML);var form=cw.child('form');cw.child('input[type=image],input[type=submit]').on('click',function(){form.dom.submit()});cw.addClass('tb-reservation-validate')}else{cw.update('<p>You will receive an email with a validation code. Please enter the code in the following box, or click the link provided in the email, to confirm your reservation.</p>');cw.addClass('tb-reservation-validate');var bp=Ext.apply(MY.Joomla.getParams('public','validate'),{reservation:this.reservation.id});this.validateForm=new Ext.form.Form({method:'POST',url:MY.Joomla.ajaxurl,baseParams:bp});this.validateForm.add(new Ext.form.TextField({name:'code',fieldLabel:'Validation Code',labelWidth:220,width:100}));this.validateForm.addButton({text:'Validate',scope:this,handler:function(){this.validateForm.submit({scope:this,success:function(form,action){var result=action.result;cw.removeClass('tb-reservation-validate');cw.addClass('tb-reservation-success');cw.update(this._confirmationHtml(sendConfirmation))},failure:function(form,action){var result=action.result;Ext.MessageBox.alert('Email Validation',result.error)}})}});this.validateForm.render(cw)}for(i=0;i<this.steps.length-1;i++){var w=this.steps[i].wrap;var d=i/t*speed;if(Ext.isIE&&this.steps[i].field){this.steps[i].field.hide()}w.setStyle('overflow','hidden');var num=w.child('.step_number');num.setOpacity(0,opts);w.setHeight.defer(d,w,[0,opts])}var newopts={duration:3};cw.setOpacity.defer(d*i,cw,[100,newopts])},_confirmationHtml:function(sendConfirmation){var lastLine=sendConfirmation&&sendConfirmation!=0?'<p>You will receive an email with your reservation confirmation details.</p>':'';var time=Date.parseDate(this.reservation.start,'Y-m-d H:i:s');var html=['<p>Your Reservation has been confirmed!</p>',this.reservation.infoHtml,lastLine];return html.join(' ')},confirmReservation:function(){if(!this.form||this.currentStep.id!='info'||!this.reservation||this.confirming){return}this.confirming=true;this.form.submit({params:this.getParams({task:'confirmReservation'}),scope:this,success:function(form,action){this.confirming=false;this.reservation=action.result.reservation;this.closeReservation(action.result.sendConfirmation,action.result.requireValidation==1,action.result)},failure:function(form,action){this.confirming=false;Ext.MessageBox.alert('Problem Confirming Reservation','Please correct the errors noted on the form. <br /><br />Hover the field to see the error message.',function(){var r=action.result;if(action.result&&action.result.errors){var err=action.result.errors;for(var n in err){var f=this.form.findField(n);if(f){f.focus();if(f.selectText){f.selectText()}return}}}this.focusEmptyField(this.form)},this)}})},getForm:function(s){if(this.form){return this.form}var w=200;this.form=new Ext.form.Form({method:'POST',url:MY.Joomla.ajaxurl,baseParams:MY.Joomla.getParams('public','confirmReservation')});this.form.container({labelAlign:'right'},new Ext.form.TextField({name:'name',allowBlank:false,width:w,value:this.user.name,fieldLabel:'Name'}),new Ext.form.TextField({name:'email',allowBlank:false,width:w,value:this.user.email,fieldLabel:'Email'}),new Ext.form.TextField({name:'phone',allowBlank:false,width:w,fieldLabel:'Phone'}),new Ext.form.TextArea({name:'notes',allowBlank:true,width:w,fieldLabel:'Notes'}));this.form.addButton({text:'Make Reservation'},this.confirmReservation,this);var fc=Ext.DomHelper.append(s.contentWrap.dom,{tag:'div'});this.fc=Ext.get(fc);this.fc.setVisibilityMode(Ext.Element.DISPLAY);this.form.render(this.fc);var c=100;this.form.items.each(function(field){field.getEl().set({'tabindex':c++});if(field.getEl().dom.tagName.toLowerCase()=='input'){field.on('specialkey',function(field,e){if(e.getKey()==e.RETURN||e.getKey()==e.ENTER){this.confirmReservation()}},this)}},this);for(var i=0;i<this.form.buttons.length;i++){var btn=this.form.buttons[i];b=btn.getEl().child('button');b.set({'tabindex':c++})}return this.form},clearReservation:function(id){if(id&&this.reservation&&this.reservation.id==id){this.reservation=false}},getIndex:function(id){return this.map[id]},getParams:function(p){p=p||{};for(var i=0;i<this.map[this.currentStep.id];i++){var s=this.steps[i];if(s.select){p[s.id]=s.select.getValue()}else if(s.field){var v=s.field.getValue();if(v.getTimezone){v=v.format('Y-m-d')}p[s.id]=v}}if(this.reservation){p.reservation=this.reservation.id}p.step=this.currentStep.id;return p},reset:function(from){var seen=false;for(var i=0;i<this.steps.length;i++){var s=this.steps[i];if(seen){s.textWrap.show();s.contentWrap.hide();s.wrap.replaceClass('on','off');s.on=false}else{if(s.id==from.id){seen=true}s.textWrap.hide();s.contentWrap.show();s.wrap.replaceClass('off','on')}}}});Ext.onReady(function(){TB.ReservationForm=new TB.pub.Reservation()});