function ShowErrorMessage(n,t){var i=$$("#FormMessageContainer").first();i!=undefined&&(i.className="FormMessageContainer",n==""?i.hide():(i.addClassName(t),$$("#FormMessageContainer tr td.Message").first().innerHTML=n,i.visible()?(i.show(),i.setOpacity(1),Effect.Pulsate(i,{duration:.5,pulses:1})):Effect.Appear(i,{duration:.5}),Position.page(i)[1]<0&&window.scrollTo(0,0)))}function EditField(n){var t=$(n);t.focus(),window.scrollTo(0,Position.cumulativeOffset(t)[1]-20)}function ShowValidationErrors(n){var t="<ul>";$A(n).each(function(n){t+="<li>"+n.text,n.field!=null&&(t+=' <a href="javascript:void(0);" onclick="EditField(\''+n.field.id+"')\">(edit)<\/a>"),t+="<\/li>"}),t+="<\/ul>",ShowErrorMessage(t,"Failure")}function SeperateWords(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2")}function LoadPromoCode(){var i=new CookieJar({expires:""}),n=$("VPSDetailsDTO_PromotionalCode"),t=i.get("promotion");t!=null&&(n.value=t,ValidateField(n,n.form))}function wheel(n,t){var i=0;n||(n=window.event),n.wheelDelta?(i=n.wheelDelta/120,window.opera&&(i=-i)):n.detail&&(i=-n.detail/3),i&&t(i),n.preventDefault&&n.preventDefault(),n.returnValue=!1}function InitComboBox(n,t,i,r,u){$(n).onfocus=null,$(t).onmouseover=null,ComboBoxDataSource[$(n).name]&&(r=ComboBoxDataSource[$(n).name]),ComboBoxMap[$(n).name]=new ComboBox(n,t,i,r,u)}function CreateFormTemplateInstance(n,t,i){setTimeout(function(){var f=document.activeElement.id,r=$(n),e=r.getAttribute("counter"),o={"Form]Index":"["+e+"]",Form_Index:"_"+e},u;r.setAttribute("counter",new Number(e)+1);var s=FormTemplateMap[r.id],c=new Template(s),h=r.cloneNode(!1);return r.id="",r.removeClassName("FormTemplate"),r.parentNode.appendChild(h),h.update(s),r.update(c.evaluate(o)),t&&(u=new Template(t).evaluate(o),f=new Template(f).evaluate(o),$(u).value=i,setTimeout("$('"+f+"').focus()",1),ValidateField(u,$(u).up("form"))),FixTableRows(r.parentNode),u},1)}function DeleteFormSegment(n){var t=$(n).up(".FormRow"),i;t&&(i=t.up("table"),t.remove(),FixTableRows(i))}function FixTableRows(n){var t=0;n.getElementsBySelector("tr").each(function(n){n.hasClassName("Header")||(n.removeClassName("Row"),n.removeClassName("AlternateRow"),n.addClassName(t++%2==0?"Row":"AlternateRow"))})}function CreateStyleSheet(){var n=function(){var n=document.createElement("style");return n.appendChild(document.createTextNode("")),document.head.appendChild(n),n.sheet}();return n.Add=function(n,t,i){AddStyleSheetRule(this,n,t,i)},n}function AddStyleSheetRule(n,t,i,r){"insertRule"in n?n.insertRule(t+"{"+i+"}",r):"addRule"in n&&n.addRule(t,i,r)}function SetFormBusy(n,t){try{t?n.disable():n.enable(),$$("#"+n.id+" .BusyLoading").first()[t?"show":"hide"]()}catch(i){}}function ProcessForm(n,t,i,r){t===undefined&&(t=!0);var u=Form.serialize(n);return t?ValidateFormAsync(n,function(t){t?SubmitValidatedForm(n,u,i,r):SetFormBusy(n,!1)}):SubmitValidatedForm(n,u,i,r),!1}function SubmitValidatedForm(n,t,i,r){var u=new Ajax.Request(n.action,{parameters:t,onComplete:function(t){var o,u,f,e,s;SetFormBusy(n,!1),o="";try{u=t.responseText.evalJSON(),o=u.Data}catch(h){ShowErrorMessage("Unknown error: "+t.responseText,"Failure"),SetFormBusy(n,!1);return}if(f=!0,r!==undefined&&(f=r(u,n)),f)switch(u.ResponseType){case"SUCCESS":ShowErrorMessage(u.Data,"Success");break;case"WARNING":ShowErrorMessage(u.Data,"Warning");break;case"ERROR":ShowErrorMessage(u.Data,"Failure");break;case"VALIDATIONERROR":e=[],u.Data.evalJSON().each(function(n){e.push({field:null,text:n})}),ShowValidationErrors(e);break;case"REDIRECT":s=window.location.pathname+"#",window.location.href=u.Data,u.Data.indexOf(s)==0&&window.location.reload(!0);break;default:ShowErrorMessage("Unexpected Error: "+t.responseText,"Failure")}i!==undefined&&i(u.ResponseType)}});return!1}function FilterDataTable(n,t){var i,r;for(elements=$(n).getElementsBySelector("input"),i=0;i<elements.length;++i){var u=elements[i],f=u.up("tr"),e=!1;for(r=0;r<t.Data.length;++r)if(data=t.Data[r],u.value==data){e=!0;break}u.checked=!1,e?f.show():f.hide()}}function GetCsrfTokenValue(){return $$("meta[name='csrf_token']").first().getAttribute("content")}function IsTemplateField(n){return n.id.indexOf("#{")>=0}function ResetForm(n){for(var i=GetFields(n),r,t=0;t<i.length;t++)r=i[t],ResetField(r)}function ResetField(n){var t=$(n.id+"_Valid"),i=$(n.id+"_Invalid");validationStateByField[n.id]=undefined,n.type==="checkbox"?n.checked=!1:n.value="",t&&(t.style.display="none"),i&&(i.style.display="none")}function ValidationContext(n,t){this.Form=n,this.Callback=t,this.Fields=Array(),this.FieldById=Array(),this.Unvalidated=Array(),this.LeftToValidate=0;var i=this;this.AddField=function(n,t){this.FieldById[n.id]===undefined&&(this.FieldById[n.id]=n,this.Fields[this.Fields.length]=n,t||(this.Unvalidated[this.Unvalidated.length]=n))},this.Process=function(n){if(this.Unvalidated.length==0){this.OnAsyncValidationCompleted();return}this.LeftToValidate=this.Unvalidated.length;for(var t=0;t<this.Unvalidated.length;t++)ValidateField(this.Unvalidated[t],this.Form,n,function(n){i.OnFieldValidated(n)})},this.OnFieldValidated=function(){this.LeftToValidate--,this.LeftToValidate<=0&&this.OnAsyncValidationCompleted()},this.OnAsyncValidationCompleted=function(){for(var u=!0,f,t,r,n=0;n<this.Fields.length;n++)t=this.Fields[n],u&=validationStateByField[t.id].valid;if(f=[],!u){for(n=0;n<this.Fields.length;n++)(t=this.Fields[n],r=validationStateByField[t.id],r)&&(r.valid||f.push({field:t,text:r.title+": "+r.message}));ShowValidationErrors(f)}i.Callback!==undefined&&i.Callback(u==!0)}}function ValidateFormAsync(n,t){for(var f=GetFields(n),e=new ValidationContext(n,t),i,u,o,s,r=0;r<f.length;r++)if(i=f[r],!IsTemplateField(i)){if(u=i.readAttribute("validateonpost"),u!==undefined&&u=="false")continue;o=validationStateByField[i.id]!==undefined,e.AddField(i,o)}s=Form.serialize(n),SetFormBusy(n,!0),e.Process(s)}function ValidateField(n,t,i,r){var e,u,f,o,s,h;if(n=$(n),IsTemplateField(n)){n.getValue()!=null&&n.getValue()!=""&&n.up(".FormTemplate")&&CreateFormTemplateInstance(n.up(".FormTemplate"),n.id,n.getValue());return}(e=n.value,n.type=="select-one"&&(e=n.options.length>0?n.options[n.selectedIndex].value:null),u=escape(n.name),n.getAttribute("fieldToValidate")!==null&&(u=escape(n.getAttribute("fieldToValidate"))),f=n.readAttribute("validateonpost"),f===undefined||f!="false")&&(o=t.action.substr(0,t.action.lastIndexOf("/"))+"/validate"+t.id,i===undefined&&(i=Form.serialize(t)),s=!1,h=new Ajax.Request(o,{method:"POST",asynchronous:!0,parameters:i+"&fieldToValidate="+u,onSuccess:function(f){var h="",o=!1,e,c,a,v;try{if(e=f.responseText.evalJSON(),e.ResponseType=="NONE")return;h=e.ResponseType=="ERROR"?e.Data.escapeHTML():"",o=h==""}catch(w){return}c=u.substring(u.indexOf(".")+1),validationStateByField[n.id]={valid:o,name:c,message:e.Data?e.Data.escapeHTML():e.Data,title:n.getAttribute("validationTitle")!=null?n.getAttribute("validationTitle"):SeperateWords(c)};var s=$(n.id+"_Valid"),l=$(n.id+"_Invalid"),y=n.attributes.hidefeedback!==undefined&&n.attributes.hidefeedback,p=n.attributes.hideifmessageempty!==undefined&&n.attributes.hideifmessageempty;if(y||(l&&(l.style.display=o?"none":"",o||(l.innerHTML=h)),s&&(s.style.display=o?"":"none",s.innerHTML=e.Data?e.Data.escapeHTML():"",o&&e.Data==null&&p&&(s.style.display="none"))),n.attributes.alsovalidate){if(a=n.attributes.alsovalidate.value,v=$(a),v){ValidateField(v,t,i,r);return}console.error("Field "+n.id+" has an alsovalidate attribute that points to a missing input field: "+a)}r!==undefined&&r(n)}}))}function PostField(n,t,i){var r=new Ajax.Request(t,{method:"POST",asynchronous:!0,parameters:n.name+"="+escape(n.value),onSuccess:i,onFailure:function(){return}})}function GetFields(n){var t=$$("#"+n.id+" .AjaxField input[type!=hidden], #"+n.id+" .AjaxField select, #"+n.id+" .AjaxField textarea");return t.findAll(function(n){return n.visible()&&n.getDimensions().width!=0&&n.getDimensions().height!=0})}function StartRB(n,t,i,r,u){n.onload="";var f=n.parentNode;f.hoverImage=new Image,f.hoverImage.src=r,f.unselectedImage=new Image,f.unselectedImage.src=t,f.outImage=n.src,f.image=n,f.outClassName=f.className,f.overClassName="RB "+u+"HoverRB",f.unselectedClassName="RB "+i,f.className.indexOf("UnpaddedRB")!=-1&&(f.overClassName+=" UnpaddedRB"),f.onmouseover=MouseOverRB,f.onmouseout=MouseOutRB,f.SetSelected=SetSelected,f.MouseOverRB=MouseOverRB,f.SetUnselectedRB=SetUnselectedRB,f.forceSelected=!1,f.hasBeenForcedUnselected=!1}function SetSelected(n){n?this.MouseOverRB():(this.SetUnselectedRB(),this.hasBeenForcedUnselected=!0),this.forceSelected=n}function MouseOverRB(){this.image.onload=MouseOverLoadRB,this.image.src=this.hoverImage.src}function MouseOverLoadRB(){var n=this.parentNode;n&&(n.className=n.overClassName)}function SetUnselectedRB(){this.image.onload=UnselectedLoadRB,this.image.src=this.unselectedImage.src}function UnselectedLoadRB(){var n=this.parentNode;n&&(n.className=n.unselectedClassName)}function MouseOutRB(){if(!this.forceSelected){if(this.hasBeenForcedUnselected){this.SetUnselectedRB();return}this.image.onload=MouseOutLoadRB,this.image.src=this.outImage}}function MouseOutLoadRB(){var n=this.parentNode;n&&(n.className=n.outClassName)}function DropDownMenu(n){var t,i;Element.extend(n),t=n.down("ul"),i=n.down("a"),i.addClassName("DropDownSelected"),t.show();var r=t.down("li").getWidth(),u=i.getWidth(),f=$(n.parentNode).getHeight(),o=Position.cumulativeOffset(n),e=n.offsetLeft+u/2-r/2,s=f;t.setStyle({left:e+"px"})}function CloseUpMenu(n,t){var r,u;if(Element.extend(n),r=n.down("ul"),t){var i=!1,o=r.childElements(),f=Event.pointerX(t),e=Event.pointerY(t);for(i=i|Position.within(n,f,e)+0,i=i|Position.within(r,f,e)+0,u=0;u<o.length;u++)i=i|Position.within(o[u],f,e)+0;i||(n.down("a").removeClassName("DropDownSelected"),r.setStyle({left:"-999em"}))}else n.down("a").removeClassName("DropDownSelected"),r.setStyle({left:"-999em"})}function GraphController(n){this.updateIntervalSeconds=60,this.guestId=n,this.lastConfigByContainerId=[],this.Change=function(n,t,i){var o={containerId:n,type:t,window:i},f=this.lastConfigByContainerId[n],e,r,u,s;if(f==null||f.window!=i||f.type!=t){for(this.lastConfigByContainerId[n]=o,e=$$("#"+n+" .tab li"),r=0;r<e.length;r++)u=e[r],s=u.match("."+i),s?u.addClassName("active"):u.removeClassName("active");this.ChangeImage(o)}},this.ChangeImage=function(n,t){var i=$(n.containerId),r,u,f;t||(r=i.down(".GraphContainer .Graph"),u=i.down(".GraphContainer .Loading"),r.style.display="none",u.style.display=""),f=i.down(".GraphContainer .Graph img"),f.src=this.GetImageUrl(n),t||(f.onload=function(){u.style.display="none",r.style.display=""})},this.GetImageUrl=function(n){var t=new Date;return"/mpanel/graphs/view?guest="+this.guestId+"&window="+n.window+"&type="+n.type+"&cb="+t.getTime()},this.StartAutoUpdate=function(n){var t=this;window.setInterval(function(){var i=t.lastConfigByContainerId[n];i&&t.ChangeImage(i)},t.updateIntervalSeconds*1e3)}}var defaults,CookieJar,ComboBox,ComboBoxMap,ComboBoxDataSource,FormTemplateMap,validationStateByField,HostCommandMonitor,HostCommandForm,PingHostCommandForm,UptimeHostCommandForm,IsGuestRuningHostCommandForm,ResetGuestPasswordCommandForm,CpanelAccountSummaryCommandForm,HostCommandStatusPage,SignupManager,OperatingSystemManager,PhoneVerifiedForm,CancelManager,Konami;Event.observe(window,"scroll",function(){var n=$("Header"),t;n.touchDevice||n.style.display!="fixed"||(t=$("HeaderSpace").viewportOffset()[1],n.style.top=Math.max(t,-60)+"px")}),Event.observe(window,"touchmove",function(){var n=$("Header"),t=$("FixedHeader");n.touchDevice=!0,n.style.top="0px",t.style.position=n.style.position="absolute"}),defaults={delay:100,batch:1,queue:[]},jqmq=function(n){function c(){e&&clearTimeout(e),e=undefined}var t={},u=Object.extend(Object.extend({},defaults),n),i=u.queue,f=u.paused,r=[],e,o,l,s,h;return t.add=function(n,t){return l([n],t)},t.addEach=l=function(n,t){return n&&(o=!1,i=t?n.concat(i):i.concat(n),f||h()),s()},t.start=h=function(){f=!1,!s()||e||r.length||function n(){var f=u.delay,h=u.batch,l=u.complete,a=u.callback;if(c(),!s()){o=!0,l&&l.call(t);return}r=i.splice(0,h),a&&a.call(t,h===1?r[0]:r)===!0&&(i=r.concat(i),r=[]),typeof f=="number"&&f>=0&&(r=[],e=setTimeout(n,f))}()},t.next=function(n){var e=u.complete;n&&(i=r.concat(i)),r=[],s()?f||h():o||(o=!0,e&&e.call(t))},t.clear=function(){var n=i;return c(),i=[],o=!0,r=[],n},t.pause=function(){c(),f=!0},t.update=function(n){Object.extend(u,n)},t.size=s=function(){return i.length},t.indexOf=function(n){return i.indexOf(n)},f||h(),t},CookieJar=Class.create(),CookieJar.prototype={appendString:"__CJ_",initialize:function(n){if(this.options={expires:3600,path:"",domain:"",secure:""},Object.extend(this.options,n||{}),this.options.expires!=""){var t=new Date;t=new Date(t.getTime()+this.options.expires*1e3),this.options.expires="; expires="+t.toGMTString()}this.options.path!=""&&(this.options.path="; path="+escape(this.options.path)),this.options.domain!=""&&(this.options.domain="; domain="+escape(this.options.domain)),this.options.secure=this.options.secure=="secure"?"; secure":""},put:function(n,t){var i,r;n=this.appendString+n,cookie=this.options,i=typeof t;switch(i){case"undefined":case"function":case"unknown":return!1;case"boolean":case"string":case"number":t=String(t.toString())}r=n+"="+escape(Object.toJSON(t));try{document.cookie=r+cookie.expires+cookie.path+cookie.domain+cookie.secure}catch(u){return!1}return!0},remove:function(n){var t,i;n=this.appendString+n,cookie=this.options;try{t=new Date,t.setTime(t.getTime()-36e5),i="; expires="+t.toGMTString(),document.cookie=n+"="+i+cookie.path+cookie.domain+cookie.secure}catch(r){return!1}return!0},get:function(n){n=this.appendString+n;var t=document.cookie.match(n+"=(.*?)(;|$)");return t?unescape(t[1]).evalJSON():null},empty:function(){for(keys=this.getKeys(),size=keys.size(),i=0;i<size;i++)this.remove(keys[i])},getPack:function(){for(pack={},keys=this.getKeys(),size=keys.size(),i=0;i<size;i++)pack[keys[i]]=this.get(keys[i]);return pack},getKeys:function(){for(keys=$A(),keyRe=/[^=; ]+(?=\=)/g,str=document.cookie,CJRe=new RegExp("^"+this.appendString);(match=keyRe.exec(str))!=undefined;)CJRe.test(match[0].strip())&&keys.push(match[0].strip().gsub("^"+this.appendString,""));return keys}},function(){var n=window.location.search.toQueryParams(),t;n.promotion!==undefined&&(t=new CookieJar({expires:""}),t.put("promotion",n.promotion))}(),Control.AnimatedSlider=Class.create(),Object.extend(Object.extend(Control.AnimatedSlider.prototype,Control.Slider.prototype),{setValueAnimated:function(n,t){t=t||this.activeHandleIdx||0,n=this.getNearestValue(n),this.values[t]=n,this.value=this.values[0],typeof this.moveAnim!="undefined"&&this.moveAnim.cancel&&this.moveAnim.cancel();var i=this,r={};r[this.isVertical()?"top":"left"]=this.translateToPx(n),this.moveAnim=new Effect.Morph(this.handles[t],{style:r,duration:.6,transition:Effect.Transitions.sinoidal,afterUpdate:function(n){var t=n.element.style.left,r;if(t=t.slice(0,t.length-2),r=i.translateToValue(t),i.initialized&&i.options.onAnimate)i.options.onAnimate(r)}}),this.drawSpans(),this.dragging&&this.event||this.updateFinished()},startDrag:function(n){var t;if(n.button==0){if(!this.disabled){this.active=!0;var i=this.activeHandle.parentElement,r=[Event.pointerX(n),Event.pointerY(n)],u=i;if(u==this.track)t=Position.cumulativeOffset(this.track),this.event=n,this.setValueAnimated(this.translateToValue((this.isVertical()?r[1]-t[1]:r[0]-t[0])-this.handleLength/2)),t=Position.cumulativeOffset(this.activeHandle),this.offsetX=r[0]-t[0],this.offsetY=r[1]-t[1];else{while(this.handles.indexOf(i)==-1&&i.parentNode)i=i.parentNode;this.handles.indexOf(i)!=-1&&(this.activeHandle=i,this.activeHandleIdx=this.handles.indexOf(this.activeHandle),this.updateStyles(),t=Position.cumulativeOffset(this.activeHandle),this.offsetX=r[0]-t[0],this.offsetY=r[1]-t[1])}}Event.stop(n)}},draw:function(n){var t=[Event.pointerX(n),Event.pointerY(n)],i=Position.cumulativeOffset(this.track);if(typeof this.moveAnim!="undefined"&&this.moveAnim.cancel&&this.moveAnim.state!="finished"){this.moveAnim.cancel();var r=this.activeHandle.parentElement,t=[Event.pointerX(n),Event.pointerY(n)],u=r,i=Position.cumulativeOffset(this.track);this.event=n,this.setValue(this.translateToValue((this.isVertical()?t[1]-i[1]:t[0]-i[0])-this.handleLength/2)),i=Position.cumulativeOffset(this.activeHandle),this.offsetX=t[0]-i[0],this.offsetY=t[1]-i[1]}else t[0]-=this.offsetX+i[0],t[1]-=this.offsetY+i[1],this.event=n,this.setValue(this.translateToValue(this.isVertical()?t[1]:t[0]));if(this.initialized&&this.options.onSlide)this.options.onSlide(this.values.length>1?this.values:this.value,this)},updateTrackLength:function(){this.trackLength=this.maximumOffset()-this.minimumOffset()}}),Control.Slider.prototype.scrollVerticalElement=function(n,t){t.scrollTop=Math.round(n/this.maximum*(t.scrollHeight-t.offsetHeight))},Autocompleter.Combo=Class.create(),Object.extend(Object.extend(Autocompleter.Combo.prototype,Autocompleter.Local.prototype),{baseInitialize:function(n,t,i){n=$(n),this.element=n,this.update=$(t),this.hasFocus=!1,this.changed=!1,this.active=!1,this.index=0,this.entryCount=0,this.setOptions?this.setOptions(i):this.options=i||{},this.options.paramName=this.options.paramName||this.element.name,this.options.tokens=this.options.tokens||[],this.options.frequency=this.options.frequency||.4,this.options.minChars=this.options.minChars||1,this.options.onShow=this.options.onShow||function(n,t){t.style.position&&t.style.position!="absolute"||(t.style.position="absolute"),Effect.Appear(t,{duration:.15})},this.options.onHide=this.options.onHide||function(n,t){new Effect.Fade(t,{duration:.15})},typeof this.options.tokens=="string"&&(this.options.tokens=new Array(this.options.tokens)),this.observer=null,this.element.setAttribute("autocomplete","off"),Element.hide(this.update),Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this)),Event.observe(this.element,"keypress",this.onKeyPress.bindAsEventListener(this)),Event.observe(window,"beforeunload",function(){n.setAttribute("autocomplete","on")})},markPrevious:function(){this.index>0?this.index--:this.index=this.entryCount-1,this.safeScrollIntoView(this.getEntry(this.index))},markNext:function(){this.index<this.entryCount-1?this.index++:this.index=0,this.safeScrollIntoView(this.getEntry(this.index))},onObserverEvent:function(){this.changed=!1},safeScrollIntoView:function(){var n=this.update.getElementsByTagName("UL")[0],t=this.getEntry(this.index).offsetTop+this.getEntry(this.index).offsetHeight,i=n.scrollTop+n.offsetHeight;if(i<t&&(n.scrollTop+=t-i),n.scrollTop>this.getEntry(this.index).offsetTop&&(n.scrollTop=this.getEntry(this.index).offsetTop),this.options.Slider&&this.options.onScroll)this.options.onScroll(n.scrollTop/(n.scrollHeight-n.offsetHeight))},getCurrentEntry:function(){var n=this.options.array[this.index];return typeof n=="object"?n.value:n},updateElement:function(n){this.element.value=n,this.element.onblur&&this.element.onblur(),this.element.focus()}}),ComboBox=Class.create(),ComboBox.Autocompleter=Autocompleter.Combo,ComboBox.Autocompleter.prototype.onBlur=function(){Element.getStyle(this.update,"display")!="none"&&(setTimeout(this.hide.bind(this),250),this.hasFocus=!1,this.active=!1)},ComboBox.prototype={initialize:function(n,t,i,r,u){this.textBox=$(n),this.arrow=$(t),this.results=$(i),this.array=r,this.resultsWidth=this.textBox.getWidth(),this.results.style.display="none",this.events={showChoices:this.showChoices.bindAsEventListener(this),hideChoices:this.hideChoices.bindAsEventListener(this),click:this.click.bindAsEventListener(this),keyDown:this.keyDown.bindAsEventListener(this)},this.autocompleter=new ComboBox.Autocompleter(this.textBox,this.results,this.array,Object.extend(u,{onShow:function(n,t){t.style.position&&t.style.position!="absolute"||(t.style.position="absolute"),t.show(),t.style.display="block"},onHide:function(n,t){t.update(),t.hide()},onScroll:this.onSliderScroll})),Event.observe(this.arrow,"click",this.events.click),Event.observe(this.textBox,"keydown",this.events.keyDown)},onSliderScroll:function(n){this.Slider&&this.Slider.setValue(n)},getAllChoices:function(n){var r=this.array.collect(function(n){var t="";return t=typeof n=="object"?n.name:n,"<li>"+t+"<\/li>"}),t='<ul id="CBPanel" style="float:left;width:'+n+'px;overflow:hidden;height:180px;">'+r.join("")+"<\/ul>";if(this.array.length>10&&(t=t+'<div id="CBTrack"><div id="CBHandle"><\/div><\/div>'),this.autocompleter.updateChoices(t),this.array.length>10){var u=$("CBTrack"),f=$("CBHandle"),i=$("CBPanel");u.style.height=this.autocompleter.update.getHeight()+"px",f.style.height=Math.max(i.offsetHeight*(i.offsetHeight/i.scrollHeight),15)+"px",slider1=new Control.Slider("CBHandle","CBTrack",{axis:"vertical",onSlide:function(n){slider1.scrollVerticalElement(n,$("CBPanel"))},onChange:function(n){slider1.scrollVerticalElement(n,$("CBPanel"))}}),Event.observe(this.autocompleter.update,"DOMMouseScroll",function(n){wheel(n,function(n){slider1.setValueBy(-(n/10))})}),Event.observe(this.autocompleter.update,"mousewheel",function(n){wheel(n,function(n){slider1.setValueBy(-(n/10))})}),this.autocompleter.options.Slider=slider1}},keyDown:function(n){n.keyCode==Event.KEY_DOWN&&this.choicesVisible()&&this.showChoices()},choicesVisible:function(){return Element.getStyle(this.autocompleter.update,"display")=="none"},click:function(){this.choicesVisible()?this.showChoices():this.hideChoices()},showChoices:function(){this.textBox.focus(),this.autocompleter.changed=!1,this.autocompleter.hasFocus=!0,this.getAllChoices(this.textBox.getWidth())},hideChoices:function(){this.autocompleter.hide()},updateArray:function(n){this.array=n,this.autocompleter.options.array=n}},ComboBoxMap={},ComboBoxDataSource={},FormTemplateMap={},Event.observe(window,"dom:loaded",function(){$$(".bg-img").each(function(n){console.log($(n));var t=$(n).getAttribute("src");t="url("+t+")",$(n).parentNode.style["background-image"]=t})}),Ajax.Responders.register({onCreate:function(n){var t=GetCsrfTokenValue();t&&(n.options.requestHeaders||(n.options.requestHeaders={}),n.options.requestHeaders["X-CSRF-TOKEN"]=t)}}),validationStateByField={},HostCommandMonitor=Class.create(),HostCommandMonitor.prototype={initialize:function(n,t,i,r){this.CommandId=n,this.OnMonitor=t.onMonitor,this.OnComplete=t.onComplete,this.OnFailure=t.onFailure,this.RequestUrl=i||"/hostcommand/gethostcommand",this.MonitorCommand(),this.FailureLimit=3,this.FailureCount=0,this.RetryOnFail=r!=undefined?r:!0},MonitorCommand:function(){var n=this;new Ajax.Request(this.RequestUrl,{method:"post",parameters:{commandId:this.CommandId},onComplete:function(t){var r,i;if(t.status==401){window.onbeforeunload=null,window.location.reload();return}try{r=t.responseText.evalJSON()}catch(u){n.HandleFailure("Could not decode: "+(t?t.responseText:"response not defined"))}switch(r.ResponseType){case"SUCCESS":i=r.Data,n.OnMonitor&&n.OnMonitor(i),i.IsRunning?setTimeout(function(){n.MonitorCommand()},2e3):n.OnComplete(i);break;case"ERROR":n.OnFailure("responsetype was error: "+t.responseText)}},onFailure:function(){n.HandleFailure("AJAX failure")}})},HandleFailure:function(n){var t=this;t.RetryOnFail&&t.FailureCount!=t.FailureLimit?(t.FailureCount++,setTimeout(function(){t.MonitorCommand()},2e3)):(t.OnFailure("failure count reached: "+n),t.FailureCount=0)}},HostCommandForm=Class.create(),HostCommandForm.prototype={initialize:function(n,t,i,r,u,f){this.Id=n,this.Form=document.forms[n],this.Form&&(this.Form.HostCommandForm=this),this.ButtonId=this.Id+"_button",this.StatusLoaderId=this.Id+"_statusloader",this.StatusTextId=this.Id+"_statustext",this.CommandRunning=!1,this.CommandCreateURL=i,this.CommandType=t,this.CommandId="",this.OnValidate=r,this.OnCommandSubmitted=u,this.OnCommandComplete=f},UpdateForm:function(n){this.CommandRunning=n,this.ShowStatusLoader(n)},ShowStatusLoader:function(n){$(this.StatusLoaderId).style.display=n?"inline":"none"},ClearCommandStatusText:function(){this.SetCommandStatusText("")},SetCommandStatusText:function(n){$(this.StatusTextId).innerHTML=n},Submit:function(){var n=this;if(n.CommandRunning)return!1;(n.OnValidate==null||n.OnValidate(n.Form))&&(n.UpdateForm(!0),n.ClearCommandStatusText(),new Ajax.Request(n.CommandCreateURL,{method:"post",parameters:Form.serialize(n.Form),onSuccess:function(t){var i=t.responseText.evalJSON();switch(i.ResponseType){case"SUCCESS":n.CommandCreationSuccess(i.Data.CommandId);break;case"ERROR":n.CommandCreationFailed(i)}},onFailure:function(){n.HandleFailed()}}))},CommandCreationSuccess:function(n){this.OnCommandSubmitted!=null&&this.OnCommandSubmitted(n),this.CommandId=n,this.MonitorCommand()},CommandCreationFailed:function(n){n.Data.Blocked?(this.UpdateForm(!1),this.ClearCommandStatusText(),alert("A currently active "+n.Data.BlockedBy+" is blocking you from being able to perform this action.")):this.HandleFailed()},MonitorCommand:function(){var n=this;n.UpdateForm(!0),n.ClearCommandStatusText(),new HostCommandMonitor(n.CommandId,{onMonitor:function(t){n.SetCommandStatusText(t.CurrentStepText)},onComplete:function(t){n.UpdateForm(!1),t.Succeeded?(n.CommandComplete(t),n.OnCommandComplete!=null&&n.OnCommandComplete(n.Form)):n.CommandFailed(t)},onFailure:function(){n.HandleFailed()}})},CommandComplete:function(){this.SetCommandStatusText("<span class='Yes'><img src='/res/images/icons/tick.png' alt='' />Complete<\/span>")},CommandFailed:function(){this.SetCommandStatusText("<span class='No'><img src='/res/images/icons/cross.png' alt='' />Failed<\/span>")},HandleFailed:function(){this.UpdateForm(!1),this.SetCommandStatusText("<span class='No'><img src='/res/images/icons/cross.png' alt='' />Failed<\/span>")}},PingHostCommandForm=Class.create(),PingHostCommandForm.prototype=Object.extend(new HostCommandForm,{retries:0,CommandComplete:function(){this.SetCommandStatusText("<span class='Yes'><img src='/res/images/icons/tick.png' alt='' />Yes<\/span>")},CommandFailed:function(){if(this.SetCommandStatusText("<span class='No'><img src='/res/images/icons/cross.png' alt='' />No<\/span>"),this.retries++!=2){var n=this;setTimeout(function(){n.Submit()},5e3)}}}),UptimeHostCommandForm=Class.create(),UptimeHostCommandForm.prototype=Object.extend(new PingHostCommandForm,{CommandComplete:function(n){this.SetCommandStatusText("<span class='Yes'><img src='/res/images/icons/tick.png' alt='' />Yes<\/span> up for "+n.ResultData+"<\/span>")}}),IsGuestRuningHostCommandForm=Class.create(),IsGuestRuningHostCommandForm.prototype=Object.extend(new PingHostCommandForm),ResetGuestPasswordCommandForm=Class.create(),ResetGuestPasswordCommandForm.prototype=Object.extend(new HostCommandForm,{CommandComplete:function(n){this.SetCommandStatusText("<span class='Yes'><img src='/res/images/icons/tick.png' alt='' />Complete, your new password is <\/span> <b>"+n.ResultData+"<\/b>")}}),CpanelAccountSummaryCommandForm=Class.create(),CpanelAccountSummaryCommandForm.prototype=Object.extend(new HostCommandForm,{initialize:function(n,t,i,r,u,f){this.Id=n,this.Form=document.forms[n],this.ButtonId=this.Id+"_button",this.StatusLoaderId=this.Id+"_statusloader",this.StatusTextId=this.Id+"_statustext",this.GuestDomain=i.split("/")[0],this.CommandRunning=!1,this.CommandCreateURL=i,this.CommandType=t,this.CommandId="",this.OnValidate=r,this.OnCommandSubmitted=u,this.OnCommandComplete=f},retries:0,UpdateForm:function(n){this.CommandRunning=n,this.ShowStatusLoader(!1)},CommandComplete:function(n){this.SetCommandStatusText(""),new Ajax.Updater("ManageWrapper","/mpanel/manage-web/"+this.GuestDomain+"/update",{method:"post",parameters:{resultData:n.ResultData}})},CommandFailed:function(){this.SetCommandStatusText("")}}),HostCommandStatusPage=Class.create(),HostCommandStatusPage.prototype={initialize:function(n,t,i,r,u){this.CommandId=n,this.ReturnUrl=t,this.ErrorUrl=i,this.Title=r,this.OpenVncStep=u,this.ErrorUrl&&this.ErrorUrl.indexOf("?")==-1&&(this.ErrorUrl+="?"),this.SetHostCommandProceedUrl="/hostcommand/sethostcommandproceed",window.onbeforeunload=function(){return"Are you sure you would like to leave the command status page, if you leave the page you will not be able to view the status of your command."},this.MonitorCommand()},MonitorCommand:function(){var n=this;n.VncLoaded=!1,n.InputShown=!1,$("StatusHeading").innerHTML=n.Title,new HostCommandMonitor(n.CommandId,{onMonitor:function(t){n.SetProgress(t),n.ShowTechnicalDetails(t),t.InputRequired&&!n.InputShown&&(n.InputShown=!0,n.ShowInputRequired(t)),t.PowercycleRequest&&!n.InputShown&&(n.InputShown=!0,n.ShowPowercycleRequest(t)),!n.VncLoaded&&t.CurrentStep>=n.OpenVncStep&&t.GuestBooting&&(n.ShowVncWindow(t),n.VncLoaded=!0)},onComplete:function(t){window.onbeforeunload=null,t.Succeeded?setTimeout(function(){window.location=n.ReturnUrl},3e3):window.location=n.ErrorUrl+"&cause="+encodeURIComponent("Completed but not succeeded")},onFailure:function(t){window.onbeforeunload=null,window.location=n.ErrorUrl+"&cause="+encodeURIComponent(t)}})},SetProgress:function(n){var i=n.ProgressComplete,r=$("ProgressLevel"),t=$("ResultData");n.ProgressStatus?(t.show(),t.innerHTML=n.ProgressStatus):t.hide(),new Effect.Morph(r,{style:{width:i<0?0:i+"%"}})},ShowTechnicalDetails:function(n){var i=$("TechnicalDetails"),t,u,r;for(i.innerHTML="",t=0;t<n.CompletedSteps.length;t++)u=n.CompletedSteps[t],i.innerHTML+="<div class='TechnicalDetail'>"+u+"... <span class='Done'>Done<\/span><\/div>";r=n.CurrentStepText,r!=""&&(i.innerHTML+="<div class='TechnicalDetail'>"+r+"...<\/div>")},ShowVncWindow:function(n){var t=$("VncWindow"),i;t.style.display="block",i=document.createElement("canvas").getContext?'<iframe frameBorder="0" src="/res/novnc/vnc_auto.html?host='+n.RescueServer.replace("rescue","ws-rescue")+"&port="+n.RescuePort+"&password="+n.RescuePassword+'&view_only=1&shared=0&nobeforeunload=1&connectTimeout=5" width="800" height="600" scrolling="no">':'<applet code="VncViewer.class" archive="/res/java/VncViewer.jar" width="800" height="624"><param name="PORT" value="'+n.RescuePort+'" /><param name="HOST" value="'+n.RescueServer+'" /><param name="PASSWORD" value="'+n.RescuePassword+'" /><param name="Open New Window" value="no" /><param name="trustAllVncCerts" value="yes" /><param name="View only" value="yes" /><\/applet>',t.innerHTML=i,window.onbeforeunload=null},ShowPowercycleRequest:function(){ShowErrorMessage('<p>A shutdown request has been sent to your server, but the server has not responded.<\/p><p><input class="button primary" type="submit" value="Force Shutdown" OnClick="ProceedWithProcess(\'true\');" />&nbsp;<input class="button" type="submit" value="Abort Request" OnClick="ProceedWithProcess(\'false\');" />&nbsp;<input class="button" type="submit" value="Keep Waiting" OnClick="ShowErrorMessage(\'\',\'\');" /><\/p>',"Warning")},ShowInputRequired:function(){ShowErrorMessage('<p>Your VPS should have finished setup but has not responded to ping. What would you like to do?<\/p><div class="Buttons"><input class="button primary" type="submit" value="Continue" OnClick="ProceedWithProcess(\'true\');" />&nbsp;<input class="button" type="submit" value="Cancel" OnClick="ProceedWithProcess(\'false\');" /><\/div>',"Warning")},ProceedWithProcess:function(n){var t=this;n=="true"?ShowErrorMessage("Proceeding...","Success"):ShowErrorMessage("Cancelling...","Failure"),setTimeout(function(){ShowErrorMessage("","")},5e3),new Ajax.Request(t.SetHostCommandProceedUrl,{method:"post",parameters:{commandId:this.CommandId,proceed:n},onComplete:function(){t.InputShown=!1},onFailure:function(){window.onbeforeunload=null,window.location=t.ErrorUrl+"&cause="+encodeURIComponent("proceed failed")}})}},SignupManager={FirstPlanSelected:!0,SliderMode:!1,OsBitSupport:null,SelectedPlan:"",SelectedWebPlan:"",SelectedOs:null,SelectedBitType:undefined,DurationInMonths:1,SelectedInterfaces:0,SelectedBackups:{daily:0,weekly:0,monthly:0,offsite:!1},SelectedUpgrades:{memory:0,storage:0,data:0},RequestQueue:jqmq({delay:-1,batch:1,callback:function(n){var t=n.getParams();if(!t){SignupManager.RequestQueue.next();return}t.onComplete=function(){SignupManager.RequestQueue.next()},n.htmlId?new Ajax.Updater(n.htmlId,n.url,t):new Ajax.Request(n.url,t)}}),Initialize:function(n){Object.extend(this,n),this.SpecifiedPlan=this.SelectedPlan,this.SliderMode&&(this.planSelector=window.planSelectorWithCallback(this.SliderPlanChanged.bind(this)),this.planSelector.PlanSettings=this.PlanSettings),this.Defaults={Os:this.SelectedOs,BitType:this.SelectedBitType},this.SelectedWebPlan!=""?this.SelectWebPlan(this.SelectedWebPlan):this.SelectDefaults(),this.PopulateDurationInMonths();var t=this;$("VPSDetailsDTO_OffsiteBackups")&&($("VPSDetailsDTO_OffsiteBackups").onclick=function(){t.OffsiteBackupChanged()})},SliderPlanChanged:function(n,t,i,r){function f(n,t){var i=null;return function(){var u=this,f=arguments,r=t;i||(r=1),clearTimeout(i),i=setTimeout(function(){n.apply(u,f)},r)}}this.planSelector&&this.planSelector.UpdateSelectedPlan(n,t,i,r);var u=this;this.onSliderChanged||(this.onSliderChanged=f(function(n,t,i,r){u.SelectedUpgrades.storage=t,u.SelectedUpgrades.memory=i,u.SelectedUpgrades.transfer=r,u.SelectedPlan=n.plan.id;var f=n.plan.id;u.PopulateExtrasOptions(f),u.PopulateBackupOptions(f),u.PopulateInterfaceOptions(f),u.CalculateTotals()},500));this.onSliderChanged(n,i,t,r)},SelectDefaults:function(){!this.SelectedPlacement&&$$(".OperatingSystemPlacement").length&&(this.SelectedPlacement=$$(".OperatingSystemPlacement").first().value),$$(".OperatingSystemPlacement").each(function(n){n.checked=n.value==SignupManager.SelectedPlacement}),this.Defaults.Os!==undefined&&this.Defaults.BitType!==undefined?this.SelectOs(this.Defaults.Os,this.Defaults.BitType):this.OsTypeClicked("Linux")},OsTypeClicked:function(n){var t=$$("#OperatingSystems"+n).first();typeof t!="undefined"&&($("OperatingSystems"+n).selectedIndex=1,this.OsSelected(n,$("OperatingSystems"+n).value))},OsSelected:function(n,t,i){var r,u;if(t=="0")return this.OsTypeClicked(n);this.SelectOsType(n),this.SelectedOs=t,$("OperatingSystemName").value=t,r=SignupManager.OsSetupWarnings[t],r!=null&&r!=""?($("SignupWarningDiv").style.display="block",$("SignupWarningDiv").innerHTML=r):$("SignupWarningDiv").style.display="none",u=!0,$$(".OperatingSystemBitsType").each(function(n){var f=SignupManager.OsBitSupport[t].indexOf(n.value)>-1,e=i||(f?n.value:null),r;n[f?"enable":"disable"](),r=n.next(".BitRecommendation"),r&&(f?r.show():r.hide()),u&&n.value==e&&(u=!1,n.checked=!0,SignupManager.BitTypeSelected(n.value))})},SelectOs:function(n,t){$$("#OperatingSystemsWindows, #OperatingSystemsLinux, #OperatingSystemsMetaTrader").each(function(i){$A(i.options).each(function(r){if(r.value==n){var u=i.getAttribute("type");i.selectedIndex=r.index,SignupManager.OsSelected(u,r.value,t)}})})},SelectOsType:function(n){$$("input[id=OperatingSystemType][value='"+n+"']").first().checked=!0,["Windows","Linux","MetaTrader"].each(function(t){if(t!=n){var i=$("OperatingSystems"+t);i!=null&&(i.selectedIndex=0)}}),this.SliderMode&&this.planSelector.setWindows(n=="Windows")},PlacementSelected:function(n){this.SelectedPlacement=n,this.LoadPlans()},BitTypeSelected:function(n){this.SelectedBits=n,this.LoadPlans(),window.sshManager&&sshManager.sshKeyChangeOSName&&sshManager.sshKeyChangeOSName(this.SelectedOs,this.SelectedBits)},PlanTypeSelected:function(n){this.SelectedPlanType=n,this.LoadPlans()},SelectPlan:function(n){var t,i;SignupManager.ShowPlanSpinner(!0),this.SelectedPlan=n,t=$$("input[id=VPSDetailsDTO_PlanId][value='"+n+"']").first(),t.checked=!0,$$(".PlanList tr").each(function(n){n.removeClassName("highlight")}),i=t.up(2),i.addClassName("highlight"),this.PopulateExtrasOptions(n),this.PopulateBackupOptions(n),this.PopulateInterfaceOptions(n),this.CalculateTotals()},SelectWebPlan:function(n){var t,i;SignupManager.ShowPlanSpinner(!0),this.SelectedWebPlan=n,t=$$("input[id=WebGuestDetailsDTO_WebPlanId][value='"+n+"']").first(),t.checked=!0,$$(".PlanList tr").each(function(n){n.removeClassName("highlight")}),i=t.up(4),i.addClassName("highlight"),this.PopulateExtrasOptions(n),this.CalculateTotals()},SelectDomainName:function(){this.CalculateTotals()},OffsiteBackupChanged:function(){this.CalculateTotals()},BackupOptionSelected:function(n){var t=$(n).getAttribute("type"),i=$(n).value;this.SelectedBackups[t]=i,this.CalculateTotals(),this.UpdateOffsiteBackupCost()},InterfaceOptionSelected:function(n){var i=$(n).getAttribute("type"),t=$(n).value;this.SelectedInterfaces=t,this.CalculateTotals()},DurationInMonthsSelected:function(n,t){var i=$(n).value,r="month",u="";i>1&&(r=i+" months",u="none"),$$(".SelectedDuration").each(function(n){n.innerHTML=r}),$$(".SelectedDurationInfo").each(function(n){n.style.display=i>0?"":"none"}),$$(".HourlyOnly").each(function(n){n.style.display=i==0?"":"none"}),$$(".Contract").each(function(n){n.style.display=u}),t||this.CalculateTotals()},UpgradesOptionSelected:function(n){var t=$(n).getAttribute("type"),i=$(n).value;this.SelectedUpgrades[t]=i,this.SelectedPlan&&t=="storage"&&this.PopulateBackupOptions(this.SelectedPlan),this.CalculateTotals()},Wait:function(n){var i=new Date,t=null;do t=new Date;while(t-i<n)},UpdateOffsiteBackupCost:function(){var n=this,t={url:"/Signup/GetOffsiteCost",getParams:function(){return{method:"post",parameters:{planId:n.SelectedPlan,totalStorageInGigabytes:n.SelectedUpgrades.storage,daily:n.SelectedBackups.daily,weekly:n.SelectedBackups.weekly,monthly:n.SelectedBackups.monthly},onSuccess:function(n){var n=n.responseText.evalJSON();$("OffsiteBackupCost").innerHTML="(+"+n.offsitecost+" per month)"}}}};this.RequestQueue.add(t)},LicenseSelected:function(){this.CalculateTotals()},PopulateBackupOptions:function(n){var t=this,i={url:"/Signup/GetBackupOptions",getParams:function(){return{method:"post",parameters:{planId:n,totalStorageInGigabytes:t.SelectedUpgrades.storage},onSuccess:function(n){var n=n.responseText.evalJSON();$$(".BackupSelection").each(function(t){var i=t.getAttribute("type"),r=SignupManager.SelectedBackups[i];r===undefined&&n[i][1].Value.indexOf("Free")!=-1&&(SignupManager.SelectedBackups[i]=r=n[i][1].Key),SignupManager.PopulateDropDown(t,n[i],r)})}}}};this.RequestQueue.add(i),this.UpdateOffsiteBackupCost(),this.PopulateBackupStrategyOptions(n)},PopulateBackupStrategyOptions:function(n){if($("BackupStrategySettings")){var t=this,i={url:"/Signup/GetBackupStrategyOptions",getParams:function(){return{method:"post",parameters:{planId:n,totalStorageInGigabytes:t.SelectedUpgrades.storage},onSuccess:function(n){for(var n=n.responseText.evalJSON(),i,t=0;t<n.length;t++)i=$$("[name=VPSDetailsDTO.BackupStrategy][value="+(t+1)+"]")[0],i.siblings()[0].innerHTML=n[t].Description,i.dataset.daily=n[t].Daily,i.dataset.weekly=n[t].Weekly,i.dataset.monthly=n[t].Monthly,i.dataset.offsite=n[t].Offsite?"true":""}}}};this.RequestQueue.add(i)}},PopulateInterfaceOptions:function(n){var t=this,i={url:"/Signup/GetInterfaceOptions",getParams:function(){return{method:"post",parameters:{guestId:t.GuestId,planId:n},onSuccess:function(n){var t=n.responseText.evalJSON(),i=$$(".AdditionalInterfaces").first();SignupManager.PopulateDropDown(i,t,SignupManager.SelectedInterfaces)}}}};this.RequestQueue.add(i)},PopulateLicensesFor:function(n,t,i){var r={osId:n};t&&(r={osName:n,osBitType:t}),i&&(r.guestId=i),new Ajax.Updater("LicenseSelectionContainer","/licenses/GetAvailable",{method:"post",parameters:r})},PopulateDurationInMonths:function(){var n=this,t={url:"/Signup/GetDurationInMonths",getParams:function(){return{method:"post",parameters:{includePrepaid:!!n.SelectedBitType},onSuccess:function(n){var i=n.responseText.evalJSON(),t=$$(".DurationInMonths").first();t!=null&&(SignupManager.PopulateDropDown(t,i,SignupManager.DurationInMonths),SignupManager.DurationInMonthsSelected(t,!0))}}}};this.RequestQueue.add(t)},PopulateAdditionalUpgrades:function(n){if(!this.SliderMode){$$("div[name=upgrade]").each(function(n){n.innerHTML=""}),$$("div[name=plan]").each(function(n){n.style.display=""});var r=$("VPSDetailsDTO_AdditionalMemory"),u=$("VPSDetailsDTO_AdditionalStorage"),f=$("VPSDetailsDTO_AdditionalDataTransfer"),e=$(n+"_Memory"),t=$(n+"_AdditionalMemory"),o=$(n+"_Storage"),s=$(n+"_AdditionalStorage"),h=$(n+"_DataTransfer"),c=$(n+"_AdditionalDataTransfer"),i=document.getElementById(n+"_CostPerMonth"),l=document.getElementById(n+"_AdditionalCostPerMonth");t&&(t.appendChild(r),e.style.display="none"),s.appendChild(u),o.style.display="none",c.appendChild(f),h.style.display="none",l.innerHTML=i.innerHTML,i.style.display="none"}},PopulateExtrasOptions:function(n){var t=this,i={url:"/Signup/GetExtrasOptions",getParams:function(){var i=$("customersignupform");return i==null&&(i=$("createserverform")),i==null&&(i=$("changeplanform")),{method:"post",parameters:{planId:n,guestId:t.GuestId,signupType:i.SignupType.value},onSuccess:function(i){var r=i.responseText.evalJSON();["memory","storage","data"].each(function(n){var f="",i=$$(".UpgradeSelection[type='"+n+"']").first(),u;i&&(i.update(),$A(r[n]).each(function(n){var t=document.createElement("option");t.text=n.Value,t.value=n.Key,n.Key==f&&t.setAttribute("selected","true"),n.Value=="SelectedValue"?f=n.Key:i.options.add(t),t.value==-1&&(t.disabled=!0)}),u=!1,$A(i.options).each(function(r){r.value==t.SelectedUpgrades[n]&&t.FirstPlanSelected&&(i.selectedIndex=r.index,u=!0)}),u||(t.SelectedUpgrades[n]=i.options[i.selectedIndex>=0?i.selectedIndex:0].value))}),t.FirstPlanSelected=!1,t.PopulateAdditionalUpgrades(n)}}}};this.RequestQueue.add(i)},PopulateDropDown:function(n,t,i){n.update(),$A(t).each(function(t){var i=document.createElement("option");i.text=t.Value,i.value=t.Key,n.options.add(i)}),$A(n.options).each(function(t){t.value==i&&(n.selectedIndex=t.index)})},SetTotals:function(n){var t=0;$$(".MonthlyCostValue").each(function(t){t.innerHTML=n.MonthlyCost}),n.MonthlyCost!=n.TotalCost&&parseFloat(n.TotalCost.replace(/[A-Z\$,]/g,""))>.01?($$(".TotalCostRow").each(function(n){n.show()}),$$(".TotalCostValue").each(function(t){t.innerHTML=n.TotalCost})):$$(".TotalCostRow").each(function(n){n.hide()}),n.Discount!==undefined&&(t=parseFloat(n.Discount.replace(/[A-Z\$,]/g,""))),t>0?($$(".DiscountValueRow").each(function(n){n.show()}),$$(".DiscountValue").each(function(t){t.innerHTML=n.Discount})):$$(".DiscountValueRow").each(function(n){n.hide()}),$$(".TotalDueValue").each(function(t){t.innerHTML=n.TotalDue})},SetPlanTotalText:function(n){var t=$(this.SelectedPlan+"_AdditionalCostPerMonth")||$(this.SelectedWebPlan+"_AdditionalCostPerMonth");t!=null&&(t.innerHTML=n)},ShowPlanSpinner:function(n){this.SliderMode||(n?($("PlanListLoading").setStyle({background:"url(/res/images/plans-loading-background.png)"}),$("PlanListLoading").show()):($("PlanListLoading").setStyle({background:"none"}),$("PlanListLoading").hide()))},LoadPlans:function(){this.SliderMode||SignupManager.ShowPlanSpinner(!0),LoadAvailableDeploymentScriptsFor(SignupManager.SelectedOs,SignupManager.SelectedBits),this.PopulateLicensesFor(SignupManager.SelectedOs,SignupManager.SelectedBits,SignupManager.GuestId);var n={json:this.SliderMode,placement:SignupManager.SelectedPlacement,osName:SignupManager.SelectedOs,osBitType:SignupManager.SelectedBits,specifiedPlan:SignupManager.SpecifiedPlan,planType:SignupManager.SelectedPlanType,guestId:SignupManager.GuestId};this.SliderMode?new Ajax.Request("/Plans/GetPlans",{method:"post",parameters:n,onSuccess:function(n){var n=n.responseText.evalJSON();SignupManager.planSelector.LoadPlans(n.plans)}}):new Ajax.Updater("PlansList","/Plans/GetPlans",{method:"post",parameters:n,onComplete:function(){var n=$$("input[id=VPSDetailsDTO_PlanId][safename='"+SignupManager.SpecifiedPlan+"']").first();typeof n!="undefined"&&(SignupManager.SelectedPlan=n.value),SignupManager.SelectedPlanType&&(n=$$("input[name=PlanType][value='"+SignupManager.SelectedPlanType+"']").first(),n.checked=!0),SignupManager.SelectedPlan!=""?(n=$$("input[id=VPSDetailsDTO_PlanId][value='"+SignupManager.SelectedPlan+"']").first(),typeof n!="undefined"?SignupManager.SelectPlan(SignupManager.SelectedPlan):(n=$$("input[id=VPSDetailsDTO_PlanId]").first(),typeof n!="undefined"&&SignupManager.SelectPlan(n.value))):(n=$$("input[id=VPSDetailsDTO_PlanId]").first(),typeof n!="undefined"&&SignupManager.SelectPlan(n.value)),SignupManager.ShowPlanSpinner(!1)}})},DisplayPhoneVerificationFields:function(n,t,i){n&&ShowErrorMessage("Please enter your account validation code to continue.","Error"),$("FraudEvaluationPinRequired").value=n,$("PhoneVerificationDiv").style.display=n?"block":"none",$("PhoneVerificationPhoneNumber")&&$("PhoneVerificationPhoneNumber").value==""&&($("PhoneVerificationPhoneNumber").value=i),$("PhoneVerificationPinError").style.display=t?"block":"none",t&&($("PhoneVerificationPinError").innerHTML="Invalid PIN")},ProcessFormHook:function(n,t){if(n.ResponseType=="FRAUDEVALUATION"||n.ResponseType=="INCORRECTPIN"){switch(n.FraudAdvice){case"flag":SignupManager.DisplayPhoneVerificationFields(!0,n.ResponseType=="INCORRECTPIN",n.PhoneNumber);break;case"block":SignupManager.BlockSignup(t)}return!1}return!0},BlockSignup:function(n){this.DisplayPhoneVerificationFields(!1,!1,""),$("BlockedSignupDiv").style.display="block",n.disable()},SetupPhoneVerification:function(){if($("FraudEvaluationPinRequired").value){$("PhoneVerificationPinError").style.display="none",$("PhoneVerificationPhoneError").style.display="none";var n=$("customersignupform"),t=Form.serialize(n),i=parseInt($("PhoneCallAttempts").value);if(i>=3){$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML="We cannot process this order",n.disable();return}$("BusyCalling").style.display="block",n.disable(),new Ajax.Request("/SignUp/SetupPhoneVerification",{method:"post",parameters:t+"&phoneNumber="+$("PhoneVerificationPhoneNumber").value,onSuccess:function(t){try{var i=t.responseText.evalJSON()}catch(r){n.enable(),$("BusyCalling").style.display="none",$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML='Error sending code. Try again or <a href="/contact-us">contact support<\/a> for further help.';return}$("BusyCalling").style.display="none",n.enable();switch(i.Status){case"SUCCESS":$("HashedFraudEvaluationPin").value=i.HashedPin,$("PhoneCallAttempts").value=parseInt($("PhoneCallAttempts").value)+1;break;case"INVALIDNUMBER":$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML="The code cannot be sent to this phone number";break;case"FAILURE":$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML="Error sending code, please check your number and try again";break;case"INSUFFICIENTFUNDS":$("HashedFraudEvaluationPin").value=i.HashedPin,SignupManager.ProcessSignupForm(n);break;default:$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML='Error sending code. Try again or <a href="/contact-us">contact support<\/a> for further help.'}},onFailure:function(t){$("BusyCalling").style.display="none",n.enable(),ShowErrorMessage("Unknown error: "+t.responseText,"Failure")}})}},CalculateTotals:function(){if(!this.SelectedPlan&&!this.SelectedWebPlan){SignupManager.ShowPlanSpinner(!1);return}var n=this,t={url:"/signup/calculatetotals",getParams:function(){var t=$("customersignupform"),i;return t==null&&(t=$("createserverform")),t==null&&(t=$("createdomainform")),t==null&&(t=$("changeplanform")),i=Form.serialize(t),SignupManager.ShowPlanSpinner(!1),{method:"post",parameters:i,onSuccess:function(t){var i="",r=t.responseText.evalJSON();r.ResponseType=="SUCCESS"&&(i=r.Data,n.SetTotals(i),n.SetPlanTotalText(i.PlanCost))}}}};this.RequestQueue.add(t)},BackupStrategySelected:function(n){var t=n.value,i=parseInt(n.dataset.daily)||0,r=parseInt(n.dataset.weekly)||0,u=parseInt(n.dataset.monthly)||0,f=!!n.dataset.offsite;if(t==-1){this.HideBackupStrategy(),$("OptionalServerSettings").show();return}$("VPSDetailsDTO_DailyBackups").value=i,$("VPSDetailsDTO_WeeklyBackups").value=r,$("VPSDetailsDTO_MonthlyBackups").value=u,$("VPSDetailsDTO_OffsiteBackups").checked=f,this.BackupOptionSelected($("VPSDetailsDTO_DailyBackups")),this.BackupOptionSelected($("VPSDetailsDTO_WeeklyBackups")),this.BackupOptionSelected($("VPSDetailsDTO_MonthlyBackups"))},HideBackupStrategy:function(){$("BackupStrategySettings").hide(),$$("#BackupStrategySettings input[value=-1]")[0].checked=!0}},OperatingSystemManager=function(){this.$buttons=$("OperatingSystemButtons"),this.$versions=$("OperatingSystemVersions"),this.$buttons.observe("click",this.onChangeOS.bind(this)),this.$versions.observe("click",this.onChangeVersion.bind(this)),this.updateSelected()},OperatingSystemManager.prototype.onChangeVersion=function(n){var i=$(n.findElement("li")),t;i&&(t=i.readAttribute("data-name"),t&&this.setSelectedVersion(t))},OperatingSystemManager.prototype.onChangeOS=function(n){var i=$(n.findElement("li")),t;i&&(t=i.readAttribute("data-os"),t&&this.setSelectedOS(t))},OperatingSystemManager.prototype.getSelectedOS=function(){var n=this.$buttons.select("li.active")[0];return $(n).readAttribute("data-os")},OperatingSystemManager.prototype.setSelectedOS=function(n){this.$buttons.childElements().each(function(n){$(n).removeClassName("active")});var t=this.$buttons.select('li[data-os="'+n+'"]')[0];$(t).addClassName("active"),this.updateVersionGroups(),this.updateSelected()},OperatingSystemManager.prototype.setSelectedVersion=function(n){this.$versions.select("ul.active li.active").each(function(n){$(n).removeClassName("active")});var t=this.$versions.select('ul.active li[data-name="'+n+'"]')[0];$(t).addClassName("active"),this.updateSelected()},OperatingSystemManager.prototype.getSelectedVersion=function(){var n=this.$versions.select("ul.active li.active")[0];return $(n).readAttribute("data-name")},OperatingSystemManager.prototype.updateVersionGroups=function(){var i=this.$versions.select("ul.active"),n,t;i.each(function(n){$(n).removeClassName("active")}),n=this.getSelectedOS(),t=this.$versions.select("#"+n+"-versions")[0],$(t).addClassName("active")},OperatingSystemManager.prototype.updateSelected=function(){$("VPSDetailsDTO.OperatingSystemName").value=this.getSelectedVersion()},OperatingSystemManager.prototype.getSelectedType=function(){var n=this.$versions.select("ul.active li.active")[0];return $(n).readAttribute("data-type")},OperatingSystemManager.prototype.updateSelected=function(){SignupManager.SelectOs(this.getSelectedVersion())},PhoneVerifiedForm=function(n,t){this.form=n,this.formattedNumberField=t},PhoneVerifiedForm.prototype.DisplayPhoneVerificationFields=function(n,t){n&&ShowErrorMessage(""),$("ValidationNeededMsg").style.display=n?"block":"none",$("FraudEvaluationPinRequired").value=n,$("PhoneVerificationDiv").style.display=n?"block":"none",$("PhoneDetailsDiv").style.display=n?"block":"none",$("PhoneVerificationPinError").style.display=t?"block":"none",t&&($("PhoneVerificationPinError").innerHTML="Invalid PIN")},PhoneVerifiedForm.prototype.ProcessFormHook=function(n,t){if(n.ResponseType=="FRAUDEVALUATION"||n.ResponseType=="INCORRECTPIN"){switch(n.FraudAdvice){case"flag":this.DisplayPhoneVerificationFields(!0,n.ResponseType=="INCORRECTPIN");break;case"block":this.BlockSignup(t)}return!1}return!0},PhoneVerifiedForm.prototype.BlockSignup=function(n){this.DisplayPhoneVerificationFields(!1,!1),$("BlockedSignupDiv").style.display="block",n.disable()},PhoneVerifiedForm.prototype.SetupPhoneVerification=function(){var r;if($("FraudEvaluationPinRequired").value){$("PhoneVerificationPinError").style.display="none",$("PhoneVerificationPhoneError").style.display="none";var n=this.form,t=Form.serialize(n),i=parseInt($("PhoneCallAttempts").value);if(i>=3){$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML="We cannot process this order",n.disable();return}$("BusyCalling").style.display="block",n.disable(),$("CallSuccess").style.display="none",r=new Ajax.Request("/signup/SetupPhoneVerification",{method:"post",parameters:t+"&phoneNumber="+this.formattedNumberField.value,onSuccess:function(t){try{var i=t.responseText.evalJSON()}catch(r){n.enable(),$("BusyCalling").style.display="none",$("PhoneVerificationPhoneError").style.display="block",$("PhoneVerificationPhoneError").innerHTML='Error sending code. Try again or <a href="/contact-us">contact support<\/a> for further help.';return}$("BusyCalling").style.display="none",n.enable(),$("PhoneVerificationPhoneError").style.display="block";switch(i.Status){case"SUCCESS":$("PhoneVerificationPhoneError").style.display="none",$("HashedFraudEvaluationPin").value=i.HashedPin,$("PhoneCallAttempts").value=parseInt($("PhoneCallAttempts").value)+1,$("CallSuccess").style.display="block";break;case"INVALIDNUMBER":$("PhoneVerificationPhoneError").innerHTML="The code cannot be sent to this phone number.";break;case"NOSMS":$("PhoneVerificationPhoneError").innerHTML="Sorry, SMS delivery is not available.";break;case"BLOCKED":$("PhoneVerificationPhoneError").innerHTML=i.Reason||"The code cannot be sent to this phone number.";break;case"INUSE":$("PhoneVerificationPhoneError").innerHTML="Sorry, this phone number is already in use.";break;case"FAILURE":$("PhoneVerificationPhoneError").innerHTML="Error sending code, please check your number and try again.";break;default:$("PhoneVerificationPhoneError").innerHTML='Error sending code. Try again or <a href="/contact-us">contact support<\/a> for further help.'}},onFailure:function(t){$("BusyCalling").style.display="none",n.enable(),ShowErrorMessage("Unknown error: "+t.responseText,"Failure")}})}};var DomainNameManager={TableId:"FoundDomainNameDetailsTable",ShowPlanSpinner:function(n){n?($("PlanListLoading").setStyle({background:"url(/res/images/plans-loading-background.png)"}),$("PlanListLoading").show()):($("PlanListLoading").setStyle({background:"none"}),$("PlanListLoading").hide())},SearchDomainName:function(){var n=this,t;return $("SearchDomainName").value==""?!1:(t=encodeURIComponent($("SearchDomainName").value+$("SearchDomainExtension").value),this.ShowPlanSpinner(!0),new Ajax.Updater("AvailableDomainNamesContainer","/domainnameplans/search",{method:"post",parameters:"domainName="+t,onComplete:function(){n.ShowPlanSpinner(!1),n.CalculateTotals()}}),!1)},OnTransferChanged:function(){for(var e=this,f=$("TransferDomainName"),i=f.value,r=$("TransferDomainExtension"),u=r.options,t,n=0;n<u.length;n++)if(t=u[n].value,i.endsWith(t)){r.value=t,$("TransferDomainName").value=i.substring(0,i.length-t.length);return}},CheckDomainNameTransfer:function(){var n=this,t,i;return $("TransferDomainName").value==""?!1:(t=encodeURIComponent($("TransferDomainName").value+$("TransferDomainExtension").value),i=encodeURIComponent($("TransferDomainPassword").value),this.ShowPlanSpinner(!0),new Ajax.Updater("AvailableDomainNamesContainer","/domainnameplans/checktransfer",{method:"post",parameters:"domainName="+t+"&domainPassword="+i,onComplete:function(){n.ShowPlanSpinner(!1),n.CalculateTotals()}}),!1)},OnPurchaseClicked:function(){for(var i=$$("#FoundDomainNameDetails .PurchaseCheckbox"),r,t,n=0;n<i.length;n++)(r=i[n],t=$("RegistrantDetails_"+n),t)&&t.setStyle({display:r.checked?"":"none"});this.CalculateTotals()},OnRenewalChanged:function(){this.CalculateTotals()},CalculateTotals:function(){var t=this,n={url:"/domainnameplans/calculatetotals",getParams:function(){var n=$("createdomainform")||$("customersignupform")||$("renewalform"),t=Form.serialize(n);return{method:"post",parameters:t,onSuccess:function(n){var i=n.responseText.evalJSON(),t=i.Data;SignupManager.SetTotals(t),SignupManager.SetPlanTotalText(t.PlanCost)}}}};SignupManager.RequestQueue.add(n)},NameserverTypeChanged:function(n){var t=n.value,i=$("CustomNameserversContainer");i.style.display=t=="Custom"?"block":"none"}},IpFailover={GuestList:{},RestartGuests:!0,ToggleGuest:function(n,t,i){this.GuestList==undefined&&(this.GuestList={}),this.GuestList[n]==undefined&&(this.GuestList[n]={}),this.GuestList[n][t]=i},Submit:function(){return new Ajax.Request("/mpanel/ipfailover/update",{method:"post",parameters:{encodedData:JSON.encode(this.GuestList),restartGuests:this.RestartGuests},onComplete:function(n){var r=JSON.decode(n.responseText),t=r.ResponseType,i=r.Data;t=="SUCCESS"&&ShowErrorMessage(i,"Success"),t=="WARNING"&&ShowErrorMessage(i,"Warning"),t=="FAILURE"&&ShowErrorMessage(i,"Failure")}}),!1}},Backups={SetHiddenField:function(n){var t=document.getElementById("performAction");return t.value=n,n=="attach"?confirm("Attaching a backup will require a reboot of your VPS, are you sure?"):!0}},Reschedule={ScheduleList:{},Submit:function(n){return new Ajax.Request("/mpanel/change-host/update",{method:"post",parameters:{commandId:n,scheduledTime:this.ScheduleList[n]},onComplete:function(n){var r=JSON.decode(n.responseText),t=r.ResponseType,i=r.Data;t=="SUCCESS"&&ShowErrorMessage(i,"Success"),t=="WARNING"&&ShowErrorMessage(i,"Warning"),t=="FAILURE"&&ShowErrorMessage(i,"Failure"),t=="ERROR"&&ShowErrorMessage(i,"Error")}}),!1},UpdateSchedule:function(n,t){var i=t.options[t.selectedIndex].value;this.ScheduleList[n]=i}};JSON=new function(){this.decode=function(){var f,t,n,e;if(y("toString")){switch(arguments.length){case 2:n=arguments[0],f=arguments[1];break;case 1:i[typeof arguments[0]](arguments[0])===Function?(n=this,f=arguments[0]):n=arguments[0];break;default:n=this}if(r.test(n))try{if(t=u("(".concat(n,")")),f&&t!==null&&(e=i[typeof t](t))&&(e===Array||e===Object))for(n in t)t[n]=v(n,t)?f(n,t[n]):t[n]}catch(o){}else throw new JSONError("bad data");}return t},this.encode=function(){var n=arguments.length?arguments[0]:this,r,u,h,l;if(n===null)r="null";else if(n!==undefined&&(u=i[typeof n](n)))switch(u){case Array:r=[];for(var h=0,c=0,a=n.length;c<a;c++)n[c]!==undefined&&(u=JSON.encode(n[c]))&&(r[h++]=u);r="[".concat(r.join(","),"]");break;case Boolean:r=String(n);break;case Date:r='"'.concat(n.getFullYear(),"-",t(n.getMonth()+1),"-",t(n.getDate()),"T",t(n.getHours()),":",t(n.getMinutes()),":",t(n.getSeconds()),'"');break;case Function:break;case Number:r=isFinite(n)?String(n):"null";break;case String:r='"'.concat(n.replace(f,o).replace(e,s),'"');break;default:h=0,r=[];for(l in n)n[l]!==undefined&&(u=JSON.encode(n[l]))&&(r[h++]='"'.concat(l.replace(f,o).replace(e,s),'":',u));r="{".concat(r.join(","),"}")}return r},this.toDate=function(){var t=arguments.length?arguments[0]:this,i;return l.test(t)?(i=new Date,i.setHours(n(t,11,2)),i.setMinutes(n(t,14,2)),i.setSeconds(n(t,17,2)),i.setMonth(n(t,5,2)-1),i.setDate(n(t,8,2)),i.setFullYear(n(t,0,4))):a.test(t)&&(i=new Date(t*1e3)),i};var h={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\","/":"/"},t=function(n){return n<10?"0".concat(n):n},u=function(n,t,i){return i=eval,delete eval,typeof eval=="undefined"&&(eval=i),t=eval(""+n),eval=i,t},n=function(n,t,i){return 1*n.substr(t,i)},c=["","000","00","0",""],r=null,l=/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/,f=/(\x5c|\x2F|\x22|[\x0c-\x0d]|[\x08-\x0a])/g,a=/^([0-9]+|[0-9]+[,\.][0-9]{1,3})$/,e=/([\x00-\x07]|\x0b|[\x0e-\x1f])/g,o=function(n,t){return"\\".concat(h[t])},s=function(n,t){var i=t.charCodeAt(0).toString(16);return"\\u".concat(c[i.length],i)},v=function(n,t){return i[typeof result](result)!==Function&&(t.hasOwnProperty?t.hasOwnProperty(n):t.constructor.prototype[n]!==t[n])},i={boolean:function(){return Boolean},"function":function(){return Function},number:function(){return Number},object:function(n){return n instanceof n.constructor?n.constructor:null},string:function(){return String},undefined:function(){return null}},y=function(n){function t(t,i){i=t[n],delete t[n];try{u(t)}catch(r){return t[n]=i,1}}return t(Array)&&t(Object)};try{r=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')}catch(p){r=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/}},CancelManager={CancelReasonSelected:function(n){var i=$(n).value,t=$("CancelOther");t&&(t.style.display=i=="other"?"block":"none")},CancelVpsSelected:function(n){var i=$(n).checked,t=$("ReasonWrapper");t&&(t.style.display=i?"block":"none")}},multistep=function(){function n(n){n.siblings().each(function(n){n.removeClassName("active"),n.getAttribute("data-content")&&$(n.getAttribute("data-content")).hide()}),n.addClassName("active"),$(n.getAttribute("data-content")).show()}return Event.observe(window,"load",function(){$$(".autotab").each(function(t){for(var r=t.getElementsBySelector("li"),u,i=0;i<r.length;i++)(u=r[i].getElementsBySelector("a")[0].getAttribute("href").split("#")[1],u)&&(r[i].setAttribute("data-content",u),i==0?(r[i].addClassName("active"),$(u).show()):$(u).hide(),Event.observe(r[i],"click",function(t){Event.stop(t);var i=Event.findElement(t,"LI");n(i)}))}),location.hash&&(href=location.hash.split("#")[1],$$(".autotab li[data-content="+href+"]").each(function(t){n(t),location.hash=""}))}),{selectTab:function(t){t=t.split("#")[1],$$(".autotab li[data-content="+t+"]").each(function(t){n(t),window.scrollTo(0,0)})}}}(),Carousel=Class.create(Abstract,{initialize:function(n,t,i,r){if(this.scrolling=!1,this.scroller=$(n),this.slides=t,this.controls=i,this.options=Object.extend({duration:1,auto:!1,frequency:3,visibleSlides:1,controlClassName:"carousel-control",jumperClassName:"carousel-jumper",disabledClassName:"carousel-disabled",selectedClassName:"carousel-selected",circular:!1,wheel:!0,effect:"scroll",transition:"sinoidal"},r||{}),this.options.effect=="fade"&&(this.options.circular=!0),this.slides.each(function(n,t){n._index=t}),this.controls&&this.controls.invoke("observe","click",this.click.bind(this)),this.options.wheel&&this.scroller.observe("mousewheel",this.wheel.bindAsEventListener(this)).observe("DOMMouseScroll",this.wheel.bindAsEventListener(this)),this.options.auto&&this.start(),this.options.initial){var u=this.slides.indexOf($(this.options.initial));u>this.options.visibleSlides-1&&this.options.visibleSlides>1&&u>this.slides.length-(this.options.visibleSlides+1)&&(u=this.slides.length-this.options.visibleSlides),this.moveTo(this.slides[u])}},click:function(n){this.stop();var t=n.findElement("a");t.hasClassName(this.options.disabledClassName)||(t.hasClassName(this.options.controlClassName)?eval("this."+t.rel+"()"):t.hasClassName(this.options.jumperClassName)&&(this.moveTo(t.rel),this.options.selectedClassName&&(this.controls.invoke("removeClassName",this.options.selectedClassName),t.addClassName(this.options.selectedClassName)))),this.deactivateControls(),n.stop()},moveTo:function(n){var t,i,r;this.options.beforeMove&&typeof this.options.beforeMove=="function"&&this.options.beforeMove(),this.previous=this.current?this.current:this.slides[0],this.current=$(n),t=this.scroller.cumulativeOffset(),i=this.current.cumulativeOffset(),this.scrolling&&this.scrolling.cancel();switch(this.options.effect){case"fade":this.scrolling=new Effect.Opacity(this.scroller,{from:1,to:0,duration:this.options.duration,afterFinish:function(){this.scroller.scrollLeft=i[0]-t[0],this.scroller.scrollTop=i[1]-t[1],new Effect.Opacity(this.scroller,{from:0,to:1,duration:this.options.duration,afterFinish:function(){this.controls&&this.activateControls(),this.options.afterMove&&typeof this.options.afterMove=="function"&&this.options.afterMove()}.bind(this)})}.bind(this)});break;case"scroll":default:switch(this.options.transition){case"spring":r=Effect.Transitions.spring;break;case"sinoidal":default:r=Effect.Transitions.sinoidal}this.scrolling=new Effect.SmoothScroll(this.scroller,{duration:this.options.duration,x:i[0]-t[0],y:i[1]-t[1],transition:r,afterFinish:function(){this.controls&&this.activateControls(),this.options.afterMove&&typeof this.options.afterMove=="function"&&this.options.afterMove(),this.scrolling=!1}.bind(this)})}return!1},prev:function(){var t,n;this.current?(t=this.current._index,n=t==0?this.options.circular?this.slides.length-1:0:t-1):n=this.options.circular?this.slides.length-1:0,n==this.slides.length-1&&this.options.circular&&this.options.effect!="fade"&&(this.scroller.scrollLeft=(this.slides.length-1)*this.slides.first().getWidth(),this.scroller.scrollTop=(this.slides.length-1)*this.slides.first().getHeight(),n=this.slides.length-2),this.moveTo(this.slides[n])},next:function(){var t,n;this.current?(t=this.current._index,n=this.slides.length-1==t?this.options.circular?0:t:t+1):n=1,n==0&&this.options.circular&&this.options.effect!="fade"&&(this.scroller.scrollLeft=0,this.scroller.scrollTop=0,n=1),n>this.slides.length-(this.options.visibleSlides+1)&&(n=this.slides.length-this.options.visibleSlides),this.moveTo(this.slides[n])},first:function(){this.moveTo(this.slides[0])},last:function(){this.moveTo(this.slides[this.slides.length-1])},toggle:function(){if(this.previous)this.moveTo(this.slides[this.previous._index]);else return!1},stop:function(){this.timer&&clearTimeout(this.timer)},start:function(){this.periodicallyUpdate()},pause:function(){this.stop(),this.activateControls()},resume:function(n){if(n){var t=n.relatedTarget||n.toElement;t&&(this.slides.include(t)||this.slides.any(function(n){return t.descendantOf(n)}))||this.start()}else this.start()},periodicallyUpdate:function(){this.timer!=null&&(clearTimeout(this.timer),this.next()),this.timer=setTimeout(this.periodicallyUpdate.bind(this),this.options.frequency*1e3)},wheel:function(n){n.cancelBubble=!0,n.stop();var t=0;return n||(n=window.event),n.wheelDelta?t=n.wheelDelta/120:n.detail&&(t=-n.detail/3),this.scrolling||(this.deactivateControls(),t>0?this.prev():this.next()),Math.round(t)},deactivateControls:function(){this.controls.invoke("addClassName",this.options.disabledClassName)},activateControls:function(){this.controls.invoke("removeClassName",this.options.disabledClassName)}}),Effect.SmoothScroll=Class.create(),Object.extend(Object.extend(Effect.SmoothScroll.prototype,Effect.Base.prototype),{initialize:function(n){this.element=$(n);var t=Object.extend({x:0,y:0,mode:"absolute"},arguments[1]||{});this.start(t)},setup:function(){this.options.continuous&&!this.element._ext&&(this.element.cleanWhitespace(),this.element._ext=!0,this.element.appendChild(this.element.firstChild)),this.originalLeft=this.element.scrollLeft,this.originalTop=this.element.scrollTop,this.options.mode=="absolute"&&(this.options.x-=this.originalLeft,this.options.y-=this.originalTop)},update:function(n){this.element.scrollLeft=this.options.x*n+this.originalLeft,this.element.scrollTop=this.options.y*n+this.originalTop}}),Event.observe(window,"load",function(){$$("#carousel-content img").each(function(n){var t=n.src.split("#");t.length==2&&(n.src=t[1])})}),TINY={},TINY.box=function(){var i,f,r,u,n,t=0;return{show:function(e){n={opacity:50,close:1,animate:0,fixed:1,mask:1,maskid:"",boxid:"",topsplit:2,url:0,post:0,height:0,width:0,html:0,iframe:0};for(s in e)n[s]=e[s];t?(i.style.display="none",clearTimeout(t.ah),u.v&&(t.removeChild(u),u.v=0)):(i=document.createElement("div"),i.className="tbox",t=document.createElement("div"),t.className="tinner",r=document.createElement("div"),r.className="tcontent",f=document.createElement("div"),f.className="tmask",u=document.createElement("div"),u.className="tclose",u.v=0,document.body.appendChild(f),document.body.appendChild(i),i.appendChild(t),t.appendChild(r),f.onclick=u.onclick=TINY.box.hide,window.onresize=TINY.box.resize),t.id=n.boxid,f.id=n.maskid,i.style.position=n.fixed?"fixed":"absolute",n.html&&!n.animate?(t.style.backgroundImage="none",r.innerHTML=n.html,r.style.display="",t.style.width=n.width?n.width+"px":"auto",t.style.height=n.height?n.height+"px":"auto"):(r.style.display="none",!n.animate&&n.width&&n.height?(t.style.width=n.width+"px",t.style.height=n.height+"px"):t.style.width=t.style.height="100px"),n.mask?(this.mask(),this.alpha(f,1,n.opacity)):this.alpha(i,1,100),n.autohide?t.ah=setTimeout(TINY.box.hide,1e3*n.autohide):document.onkeyup=TINY.box.esc},fill:function(i,r,u,f,e,o){var h,s;r?n.image?(h=new Image,h.onload=function(){e=e||h.width,o=o||h.height,TINY.box.psh(h,f,e,o)},h.src=n.image):n.iframe?this.psh('<iframe src="'+n.iframe+'" width="'+n.width+'" frameborder="0" height="'+n.height+'"><\/iframe>',f,e,o):(s=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),s.onreadystatechange=function(){s.readyState==4&&s.status==200&&(t.style.backgroundImage="",TINY.box.psh(s.responseText,f,e,o))},u?(s.open("POST",i,!0),s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),s.send(u)):(s.open("GET",i,!0),s.send(null))):this.psh(i,f,e,o)},psh:function(n,i,u,f){typeof n=="object"?r.appendChild(n):r.innerHTML=n;var e=t.style.width,o=t.style.height;u&&f||(t.style.width=u?u+"px":"",t.style.height=f?f+"px":"",r.style.display="",f||(f=parseInt(r.offsetHeight)),u||(u=parseInt(r.offsetWidth)),r.style.display="none"),t.style.width=e,t.style.height=o,this.size(u,f,i)},esc:function(n){n=n||window.event,n.keyCode==27&&TINY.box.hide()},hide:function(){TINY.box.alpha(i,-1,0,3),document.onkeypress=null,n.closejs&&n.closejs()},resize:function(){TINY.box.pos(),TINY.box.mask()},mask:function(){f.style.height=this.total(1)+"px",f.style.width=this.total(0)+"px"},pos:function(){var t;typeof n.top!="undefined"?t=n.top:(t=this.height()/n.topsplit-i.offsetHeight/2,t=t<20?20:t),n.fixed||n.top||(t+=this.top()),i.style.top=t+"px",i.style.left=typeof n.left!="undefined"?n.left+"px":this.width()/2-i.offsetWidth/2+"px"},alpha:function(n,t,i){clearInterval(n.ai),t&&(n.style.opacity=0,n.style.filter="alpha(opacity=0)",n.style.display="block",TINY.box.pos()),n.ai=setInterval(function(){TINY.box.ta(n,i,t)},20)},ta:function(u,e,o){var h=Math.round(u.style.opacity*100),s;h==e?(clearInterval(u.ai),o==-1?(u.style.display="none",u==i?TINY.box.alpha(f,-1,0,2):r.innerHTML=t.style.backgroundImage=""):u==f?this.alpha(i,1,100):(i.style.filter="",TINY.box.fill(n.html||n.url,n.url||n.iframe||n.image,n.post,n.animate,n.width,n.height))):(s=e-Math.floor(Math.abs(e-h)*.5)*o,u.style.opacity=s/100,u.style.filter="alpha(opacity="+s+")")},size:function(i,f,e){if(e){clearInterval(t.si);var o=parseInt(t.style.width)>i?-1:1,s=parseInt(t.style.height)>f?-1:1;t.si=setInterval(function(){TINY.box.ts(i,o,f,s)},20)}else t.style.backgroundImage="none",n.close&&(t.appendChild(u),u.v=1),t.style.width=i+"px",t.style.height=f+"px",r.style.display="",this.pos(),n.openjs&&n.openjs()},ts:function(i,f,e,o){var s=parseInt(t.style.width),h=parseInt(t.style.height);s==i&&h==e?(clearInterval(t.si),t.style.backgroundImage="none",r.style.display="block",n.close&&(t.appendChild(u),u.v=1),n.openjs&&n.openjs()):(s!=i&&(t.style.width=i-Math.floor(Math.abs(i-s)*.6)*f+"px"),h!=e&&(t.style.height=e-Math.floor(Math.abs(e-h)*.6)*o+"px"),this.pos())},top:function(){return document.documentElement.scrollTop||document.body.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},total:function(n){var t=document.body,i=document.documentElement;return n?Math.max(Math.max(t.scrollHeight,i.scrollHeight),Math.max(t.clientHeight,i.clientHeight)):Math.max(Math.max(t.scrollWidth,i.scrollWidth),Math.max(t.clientWidth,i.clientWidth))}}}(),Event.observe(window,"load",function(){$$(".tinybox").each(function(n){Event.observe(n,"click",function(t){(Event.stop(t),window.innerWidth<1024)||TINY.box.show({image:n.src})})})}),function(n){"use strict";function t(n,t,i){return n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent?n.attachEvent("on"+t,i):void 0}function i(n,t){for(var i=0,r=n.length;r>i;i++)if(n[i]===t)return!0;return!1}function r(n,t){var i;n.createTextRange?(i=n.createTextRange(),i.move("character",t),i.select()):n.selectionStart&&(n.focus(),n.setSelectionRange(t,t))}function u(n,t){try{return n.type=t,!0}catch(i){return!1}}n.Placeholders={Utils:{addEventListener:t,inArray:i,moveCaret:r,changeType:u}}}(this),function(n){"use strict";function nt(){}function tt(){try{return document.activeElement}catch(n){}}function v(n,t){var i,r,u=!!t&&n.value!==t,e=n.value===n.getAttribute(f);return(u||e)&&"true"===n.getAttribute(h)?(n.removeAttribute(h),n.value=n.value.replace(n.getAttribute(f),""),n.className=n.className.replace(gt,""),r=n.getAttribute(w),parseInt(r,10)>=0&&(n.setAttribute("maxLength",r),n.removeAttribute(w)),i=n.getAttribute(a),i&&(n.type=i),!0):!1}function b(n){var t,r,u=n.getAttribute(f);return""===n.value&&u?(n.setAttribute(h,"true"),n.value=u,n.className+=" "+g,r=n.getAttribute(w),r||(n.setAttribute(w,n.maxLength),n.removeAttribute("maxLength")),t=n.getAttribute(a),t?n.type="text":"password"===n.type&&i.changeType(n,"text")&&n.setAttribute(a,"password"),!0):!1}function it(n,t){var r,s,u,o,h,l,i;if(n&&n.getAttribute(f))t(n);else for(u=n?n.getElementsByTagName("input"):e,o=n?n.getElementsByTagName("textarea"):c,r=u?u.length:0,s=o?o.length:0,i=0,l=r+s;l>i;i++)h=r>i?u[i]:o[i-r],t(h)}function rt(n){it(n,v)}function at(n){it(n,b)}function vt(n){return function(){y&&n.value===n.getAttribute(f)&&"true"===n.getAttribute(h)?i.moveCaret(n,0):v(n)}}function yt(n){return function(){b(n)}}function pt(n){return function(t){return k=n.value,"true"===n.getAttribute(h)&&k===n.getAttribute(f)&&i.inArray(dt,t.keyCode)?(t.preventDefault&&t.preventDefault(),!1):void 0}}function wt(n){return function(){v(n,k),""===n.value&&(n.blur(),i.moveCaret(n,0))}}function bt(n){return function(){n===tt()&&n.value===n.getAttribute(f)&&"true"===n.getAttribute(h)&&i.moveCaret(n,0)}}function kt(n){return function(){rt(n)}}function ut(n){n.form&&(o=n.form,"string"==typeof o&&(o=document.getElementById(o)),o.getAttribute(st)||(i.addEventListener(o,"submit",kt(o)),o.setAttribute(st,"true"))),i.addEventListener(n,"focus",vt(n)),i.addEventListener(n,"blur",yt(n)),y&&(i.addEventListener(n,"keydown",pt(n)),i.addEventListener(n,"keyup",wt(n)),i.addEventListener(n,"click",bt(n))),n.setAttribute(ht,"true"),n.setAttribute(f,r),(y||n!==tt())&&b(n)}var e,c,y,ft,k,l,d,r,et,o,t,p,u,ot=["text","search","url","tel","email","password","number","textarea"],dt=[27,33,34,35,36,37,38,39,40,8,46],g="placeholdersjs",gt=RegExp("(?:^|\\s)"+g+"(?!\\S)"),f="data-placeholder-value",h="data-placeholder-active",a="data-placeholder-type",st="data-placeholder-submit",ht="data-placeholder-bound",w="data-placeholder-maxlength",ni=document.createElement("input"),ct=document.getElementsByTagName("head")[0],lt=document.documentElement,s=n.Placeholders,i=s.Utils;if(s.nativeSupport=void 0!==ni.placeholder,!s.nativeSupport){for(e=document.getElementsByTagName("input"),c=document.getElementsByTagName("textarea"),y="false"===lt.getAttribute("data-placeholder-focus"),ft="false"!==lt.getAttribute("data-placeholder-live"),l=document.createElement("style"),l.type="text/css",d=document.createTextNode("."+g+" { color:#ccc; }"),l.styleSheet?l.styleSheet.cssText=d.nodeValue:l.appendChild(d),ct.insertBefore(l,ct.firstChild),u=0,p=e.length+c.length;p>u;u++)t=e.length>u?e[u]:c[u-e.length],r=t.attributes.placeholder,r&&(r=r.nodeValue,r&&i.inArray(ot,t.type)&&ut(t));et=setInterval(function(){for(u=0,p=e.length+c.length;p>u;u++)t=e.length>u?e[u]:c[u-e.length],r=t.attributes.placeholder,r?(r=r.nodeValue,r&&i.inArray(ot,t.type)&&(t.getAttribute(ht)||ut(t),(r!==t.getAttribute(f)||"password"===t.type&&!t.getAttribute(a))&&("password"===t.type&&!t.getAttribute(a)&&i.changeType(t,"text")&&t.setAttribute(a,"password"),t.value===t.getAttribute(f)&&(t.value=r),t.setAttribute(f,r)))):t.getAttribute(h)&&(v(t),t.removeAttribute(f));ft||clearInterval(et)},100)}i.addEventListener(n,"beforeunload",function(){s.disable()}),s.disable=s.nativeSupport?nt:rt,s.enable=s.nativeSupport?nt:at}(this),function(n){"use strict";function t(n,t){return t.getAttribute("data-placeholder-active")?"":n.call(this,t)}var i=n.Element.Methods.getValue,r=n.Element.getValue,u=$F;Placeholders.nativeSupport||($F=function(n){return t.call(this,u,n)},n.Element.getValue=function(n){return t.call(this,r,n)},Element.addMethods(["INPUT","TEXTAREA"],{getValue:function(n){return t.call(this,i,n)}}))}(Form),typeof Prototype=="undefined"&&alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>)."),Prototype.Version<"1.6"&&alert("Prototype 1.6.0 is required.  If using earlier version of prototype, please use calendar_date_select version 1.8.3"),Element.addMethods({purgeChildren:function(n){$A(n.childNodes).each(function(n){$(n).remove()})},build:function(n,t,i,r){var u=Element.buildAndAppend(t,i,r);return n.appendChild(u),u}}),Element.buildAndAppend=function(n,t,i){var r=$(document.createElement(n));return $H(t).each(function(n){r[n.key]=n.value}),i&&r.setStyle(i),r},nil=null,Date.one_day=864e5,Date.weekdays=$w("S M T W T F S"),Date.first_day_of_week=0,Date.months=$w("January February March April May June July August September October November December"),Date.padded2=function(n){var t=parseInt(n,10);return n<10&&(t="0"+t),t},Date.prototype.getPaddedMinutes=function(){return Date.padded2(this.getMinutes())},Date.prototype.getAMPMHour=function(){var n=this.getHours();return n==0?12:n>12?n-12:n},Date.prototype.getAMPM=function(){return this.getHours()<12?"AM":"PM"},Date.prototype.stripTime=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate())},Date.prototype.daysDistance=function(n){return Math.round((n-this)/Date.one_day)},Date.prototype.toFormattedString=function(n){var i,t;return t=Date.months[this.getMonth()]+" "+this.getDate()+", "+this.getFullYear(),n&&(i=this.getHours(),t+=" "+this.getAMPMHour()+":"+this.getPaddedMinutes()+" "+this.getAMPM()),t},Date.parseFormattedString=function(n){return new Date(n)},Math.floor_to_interval=function(n,t){return Math.floor(n/t)*t},window.f_height=function(){return[window.innerHeight?window.innerHeight:null,document.documentElement?document.documentElement.clientHeight:null,document.body?document.body.clientHeight:null].select(function(n){return n>0}).first()||0},window.f_scrollTop=function(){return[window.pageYOffset?window.pageYOffset:null,document.documentElement?document.documentElement.scrollTop:null,document.body?document.body.scrollTop:null].select(function(n){return n>0}).first()||0},_translations={OK:"OK",Now:"Now",Today:"Today",Clear:"Clear"},SelectBox=Class.create(),SelectBox.prototype={initialize:function(n,t,i,r){this.element=$(n).build("select",i,r),this.populate(t)},populate:function(n){this.element.purgeChildren();var t=this;$A(n).each(function(n){typeof n!="object"&&(n=[n,n]),t.element.build("option",{value:n[1],innerHTML:n[0]})})},setValue:function(n){var t=this.element,i=!1;return $R(0,t.options.length-1).each(function(r){t.options[r].value==n.toString()&&(t.selectedIndex=r,i=!0)}),i},getValue:function(){return $F(this.element)}},CalendarDateSelect=Class.create(),CalendarDateSelect.prototype={initialize:function(n,t){if(this.target_element=$(n),!this.target_element)return alert("Target element "+n+" not found!"),!1;this.target_element.tagName!="INPUT"&&(this.target_element=this.target_element.down("INPUT")),this.target_element.calendar_date_select=this,this.last_click_at=0,this.options=$H({embedded:!1,popup:nil,time:!1,buttons:!0,clear_button:!0,year_range:10,close_on_click:nil,minute_interval:5,popup_by:this.target_element,month_year:"dropdowns",onchange:function(n){return function(){var t;n.dispatchEvent?(t=document.createEvent("HTMLEvents"),t.initEvent("change",!0,!0),n.dispatchEvent(t)):(t=document.createEventObject(),t.type="onChange",n.fireEvent("onChange",t))}}(this.target_element),valid_date_check:nil}).merge(t||{}),this.use_time=this.options.get("time"),this.parseDate(),this.callback("before_show"),this.initCalendarDiv(),this.options.get("embedded")||(this.positionCalendarDiv(),Event.observe(document,"mousedown",this.closeIfClickedOut_handler=this.closeIfClickedOut.bindAsEventListener(this)),Event.observe(document,"keypress",this.keyPress_handler=this.keyPress.bindAsEventListener(this))),this.callback("after_show")},positionCalendarDiv:function(){var u=!1,f=this.calendar_div.cumulativeOffset(),y=f[0],p=f[1],e=this.calendar_div.getDimensions(),n=e.height,l=e.width,o=window.f_scrollTop(),a=window.f_height(),s=$(this.options.get("popup_by")).cumulativeOffset(),t=s[1],v=s[0],h=$(this.options.get("popup_by")).getDimensions().height,c=t+h,i,r;c+n>o+a&&c-n>o&&(u=!0),i=v.toString()+"px",r=(u?t-n:t+h).toString()+"px",this.calendar_div.style.left=i,this.calendar_div.style.top=r,this.calendar_div.setStyle({visibility:""}),navigator.appName=="Microsoft Internet Explorer"&&(this.iframe=$(document.body).build("iframe",{src:"javascript:false",className:"ie6_blocker"},{left:i,top:r,height:n.toString()+"px",width:l.toString()+"px",border:"0px"}))},initCalendarDiv:function(){var n,t,i;this.options.get("embedded")?(n=this.target_element.parentNode,t={}):(n=document.body,t={position:"absolute",visibility:"hidden",left:0,top:0}),this.calendar_div=$(n).build("div",{className:"calendar_date_select"},t),i=this,$w("top header body buttons footer bottom").each(function(n){i[n+"_div"]=i.calendar_div.build("div",{className:"cds_"+n},{clear:"left"})}),this.initHeaderDiv(),this.initButtonsDiv(),this.initCalendarGrid(),this.updateFooter("&#160;"),this.refresh(),this.setUseTime(this.use_time)},initHeaderDiv:function(){var n=this.header_div;this.close_button=n.build("a",{innerHTML:"x",href:"#",onclick:function(){return this.close(),!1}.bindAsEventListener(this),className:"close"}),this.next_month_button=n.build("a",{innerHTML:"&gt;",href:"#",onclick:function(){return this.navMonth(this.date.getMonth()+1),!1}.bindAsEventListener(this),className:"next"}),this.prev_month_button=n.build("a",{innerHTML:"&lt;",href:"#",onclick:function(){return this.navMonth(this.date.getMonth()-1),!1}.bindAsEventListener(this),className:"prev"}),this.options.get("month_year")=="dropdowns"?(this.month_select=new SelectBox(n,$R(0,11).map(function(n){return[Date.months[n],n]}),{className:"month",onchange:function(){this.navMonth(this.month_select.getValue())}.bindAsEventListener(this)}),this.year_select=new SelectBox(n,[],{className:"year",onchange:function(){this.navYear(this.year_select.getValue())}.bindAsEventListener(this)}),this.populateYearRange()):this.month_year_label=n.build("span")},initCalendarGrid:function(){var e=this.body_div,t,r,u,f,i,n;for(this.calendar_day_grid=[],t=e.build("table",{cellPadding:"0px",cellSpacing:"0px",width:"100%"}),r=t.build("thead").build("tr"),Date.weekdays.each(function(n){r.build("th",{innerHTML:n})}),u=t.build("tbody"),f=0,n=0;n<42;n++)i=(n+Date.first_day_of_week)%7,n%7==0&&(days_row=u.build("tr",{className:"row_"+f++})),(this.calendar_day_grid[n]=days_row.build("td",{calendar_date_select:this,onmouseover:function(){this.calendar_date_select.dayHover(this)},onmouseout:function(){this.calendar_date_select.dayHoverOut(this)},onclick:function(){this.calendar_date_select.updateSelectedDate(this,!0)},className:i==0||i==6?" weekend":""},{cursor:"pointer"})).build("div"),this.calendar_day_grid[n]},initButtonsDiv:function(){var n=this.buttons_div,i,t,r;this.options.get("time")?(i=$A(this.options.get("time")=="mixed"?[[" - ",""]]:[]),n.build("span",{innerHTML:"@",className:"at_sign"}),t=new Date,this.hour_select=new SelectBox(n,i.concat($R(0,23).map(function(n){return t.setHours(n),$A([t.getAMPMHour()+" "+t.getAMPM(),n])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({hour:this.value})},className:"hour"}),n.build("span",{innerHTML:":",className:"seperator"}),r=this,this.minute_select=new SelectBox(n,i.concat($R(0,59).select(function(n){return n%r.options.get("minute_interval")==0}).map(function(n){return $A([Date.padded2(n),n])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({minute:this.value})},className:"minute"})):this.options.get("buttons")||n.remove(),this.options.get("buttons")&&(n.build("span",{innerHTML:"&#160;"}),this.options.get("time")!="mixed"&&this.options.get("time")||(b=n.build("a",{innerHTML:_translations.Today,href:"#",onclick:function(){return this.today(!1),!1}.bindAsEventListener(this)})),this.options.get("time")=="mixed"&&n.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"}),this.options.get("time")&&(b=n.build("a",{innerHTML:_translations.Now,href:"#",onclick:function(){return this.today(!0),!1}.bindAsEventListener(this)})),this.options.get("embedded")||this.closeOnClick()||(n.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"}),n.build("a",{innerHTML:_translations.OK,href:"#",onclick:function(){return this.close(),!1}.bindAsEventListener(this)})),this.options.get("clear_button")&&(n.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"}),n.build("a",{innerHTML:_translations.Clear,href:"#",onclick:function(){return this.clearDate(),this.options.get("embedded")||this.close(),!1}.bindAsEventListener(this)})))},refresh:function(){this.refreshMonthYear(),this.refreshCalendarGrid(),this.setSelectedClass(),this.updateFooter()},refreshCalendarGrid:function(){var t,i;this.beginning_date=new Date(this.date).stripTime(),this.beginning_date.setDate(1),this.beginning_date.setHours(12),t=this.beginning_date.getDay(),t<3&&(t+=7),this.beginning_date.setDate(1-t+Date.first_day_of_week);var n=new Date(this.beginning_date),r=(new Date).stripTime(),u=this.date.getMonth();for(vdc=this.options.get("valid_date_check"),i=0;i<42;i++)day=n.getDate(),month=n.getMonth(),cell=this.calendar_day_grid[i],Element.remove(cell.childNodes[0]),div=cell.build("div",{innerHTML:day}),month!=u&&(div.className="other"),cell.day=day,cell.month=month,cell.year=n.getFullYear(),vdc&&(vdc(n.stripTime())?cell.removeClassName("disabled"):cell.addClassName("disabled")),n.setDate(day+1);this.today_cell&&this.today_cell.removeClassName("today"),$R(0,41).include(days_until=this.beginning_date.stripTime().daysDistance(r))&&(this.today_cell=this.calendar_day_grid[days_until],this.today_cell.addClassName("today"))},refreshMonthYear:function(){var i=this.date.getMonth(),t=this.date.getFullYear(),n;this.options.get("month_year")=="dropdowns"?(this.month_select.setValue(i,!1),n=this.year_select.element,this.flexibleYearRange()&&(!this.year_select.setValue(t,!1)||n.selectedIndex<=1||n.selectedIndex>=n.options.length-2)&&this.populateYearRange(),this.year_select.setValue(t)):this.month_year_label.update().insert(Date.months[i]+" "+t.toString())},populateYearRange:function(){this.year_select.populate(this.yearRange().toArray())},yearRange:function(){if(!this.flexibleYearRange())return $R(this.options.get("year_range")[0],this.options.get("year_range")[1]);var n=this.date.getFullYear();return $R(n-this.options.get("year_range"),n+this.options.get("year_range"))},flexibleYearRange:function(){return typeof this.options.get("year_range")=="number"},validYear:function(n){return this.flexibleYearRange()?!0:this.yearRange().include(n)},dayHover:function(n){var t=new Date(this.selected_date);t.setFullYear(n.year,n.month,n.day),this.updateFooter(t.toFormattedString(this.use_time))},dayHoverOut:function(){this.updateFooter()},clearSelectedClass:function(){this.selected_cell&&this.selected_cell.removeClassName("selected")},setSelectedClass:function(){this.selection_made&&(this.clearSelectedClass(),$R(0,42).include(days_until=this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()))&&(this.selected_cell=this.calendar_day_grid[days_until],this.selected_cell.addClassName("selected")))},reparse:function(){this.parseDate(),this.refresh()},dateString:function(){return this.selection_made?this.selected_date.toFormattedString(this.use_time):"&#160;"},parseDate:function(){var t=$F(this.target_element).strip(),n=this.options.get("default_time");this.selection_made=t!=""||n,this.date=t==""?NaN:Date.parseFormattedString(this.options.get("date")||t),isNaN(this.date)&&!n?this.date=new Date:isNaN(this.date)&&n&&(this.date=Object.prototype.toString.apply(n)==="[object Function]"?n():n),this.validYear(this.date.getFullYear())||this.date.setYear(this.date.getFullYear()<this.yearRange().start?this.yearRange().start:this.yearRange().end),this.selected_date=new Date(this.date),this.use_time=/[0-9]:[0-9]{2}/.exec(t)?!0:!1,this.date.setDate(1)},updateFooter:function(n){n||(n=this.dateString()),this.footer_div.purgeChildren(),this.footer_div.build("span",{innerHTML:n})},clearDate:function(){if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return!1;var n=this.target_element.value;this.target_element.value="",this.clearSelectedClass(),this.updateFooter("&#160;"),n!=this.target_element.value&&this.callback("onchange")},updateSelectedDate:function(n,t){var i=$H(n),r,u;if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return!1;if(i.get("day")){if(r=this.selected_date,u=this.options.get("valid_date_check"),r.setFullYear(i.get("year"),i.get("month"),i.get("day")),u&&!u(r.stripTime()))return!1;this.selected_date=r,this.selection_made=!0}isNaN(i.get("hour"))||this.selected_date.setHours(i.get("hour")),isNaN(i.get("minute"))||this.selected_date.setMinutes(Math.floor_to_interval(i.get("minute"),this.options.get("minute_interval"))),i.get("hour")===""||i.get("minute")===""?this.setUseTime(!1):isNaN(i.get("hour"))&&isNaN(i.get("minute"))||this.setUseTime(!0),this.updateFooter(),this.setSelectedClass(),this.selection_made&&this.updateValue(),this.closeOnClick()&&this.close(),t&&!this.options.get("embedded")&&(new Date-this.last_click_at<333&&this.close(),this.last_click_at=new Date)},closeOnClick:function(){return this.options.get("embedded")?!1:this.options.get("close_on_click")===nil?this.options.get("time")?!1:!0:this.options.get("close_on_click")},navMonth:function(n){return(target_date=new Date(this.date)).setMonth(n),this.navTo(target_date)},navYear:function(n){return(target_date=new Date(this.date)).setYear(n),this.navTo(target_date)},navTo:function(n){return this.validYear(n.getFullYear())?(this.date=n,this.date.setDate(1),this.refresh(),this.callback("after_navigate",this.date),!0):!1},setUseTime:function(n){if(this.use_time=this.options.get("time")&&(this.options.get("time")=="mixed"?n:!0),this.use_time&&this.selected_date){var t=Math.floor_to_interval(this.selected_date.getMinutes(),this.options.get("minute_interval")),i=this.selected_date.getHours();this.hour_select.setValue(i),this.minute_select.setValue(t)}else this.options.get("time")=="mixed"&&(this.hour_select.setValue(""),this.minute_select.setValue(""))},updateValue:function(){var n=this.target_element.value;this.target_element.value=this.dateString(),n!=this.target_element.value&&this.callback("onchange")},today:function(n){var t=new Date,i;this.date=new Date,i=$H({day:t.getDate(),month:t.getMonth(),year:t.getFullYear(),hour:t.getHours(),minute:t.getMinutes()}),n||(i=i.merge({hour:"",minute:""})),this.updateSelectedDate(i,!0),this.refresh()},close:function(){if(this.closed)return!1;this.callback("before_close"),this.target_element.calendar_date_select=nil,Event.stopObserving(document,"mousedown",this.closeIfClickedOut_handler),Event.stopObserving(document,"keypress",this.keyPress_handler),this.calendar_div.remove(),this.closed=!0,this.iframe&&this.iframe.remove(),this.target_element.type=="hidden"||this.target_element.disabled||this.target_element.focus(),this.callback("after_close")},closeIfClickedOut:function(n){$(Event.element(n)).descendantOf(this.calendar_div)||this.close()},keyPress:function(n){n.keyCode==Event.KEY_ESC&&this.close()},callback:function(n,t){this.options.get(n)&&this.options.get(n).bind(this.target_element)(t)}},Konami=function(n){var t={addEvent:function(n,t,i,r){n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent&&(n["e"+t+i]=i,n[t+i]=function(){n["e"+t+i](window.event,r)},n.attachEvent("on"+t,n[t+i]))},input:"",pattern:"38384040373937396665",load:function(n){this.addEvent(document,"keydown",function(i,r){return r&&(t=r),t.input+=i?i.keyCode:event.keyCode,t.input.length>t.pattern.length&&(t.input=t.input.substr(t.input.length-t.pattern.length)),t.input==t.pattern?(t.code(n),t.input="",i.preventDefault(),!1):void 0},this),this.iphone.load(n)},code:function(n){window.location=n},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:!1,capture:!1,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP"],code:function(n){t.code(n)},load:function(n){this.orig_keys=this.keys,t.addEvent(document,"touchmove",function(n){if(n.touches.length==1&&t.iphone.capture==!0){var i=n.touches[0];t.iphone.stop_x=i.pageX,t.iphone.stop_y=i.pageY,t.iphone.tap=!1,t.iphone.capture=!1,t.iphone.check_direction()}}),t.addEvent(document,"touchend",function(){t.iphone.tap==!0&&t.iphone.check_direction(n)},!1),t.addEvent(document,"touchstart",function(n){t.iphone.start_x=n.changedTouches[0].pageX,t.iphone.start_y=n.changedTouches[0].pageY,t.iphone.tap=!0,t.iphone.capture=!0})},check_direction:function(n){x_magnitude=Math.abs(this.start_x-this.stop_x),y_magnitude=Math.abs(this.start_y-this.stop_y),x=this.start_x-this.stop_x<0?"RIGHT":"LEFT",y=this.start_y-this.stop_y<0?"DOWN":"UP",result=x_magnitude>y_magnitude?x:y,result=this.tap==!0?"TAP":result,result==this.keys[0]&&(this.keys=this.keys.slice(1,this.keys.length)),this.keys.length==0&&(this.keys=this.orig_keys,this.code(n))}}};return typeof n=="string"&&t.load(n),typeof n=="function"&&(t.code=n,t.load()),t},Date.prototype.toFormattedString=function(n){var t,i=this.getFullYear()+"-"+Date.padded2(this.getMonth()+1)+"-"+Date.padded2(this.getDate());return n&&(t=Date.padded2(this.getHours()),i+=" "+t+":"+this.getPaddedMinutes()),i},Date.parseFormattedString=function(n){var t=n.match(new RegExp("([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?")),i=new Date(t[1],0,1);return t[3]&&i.setMonth(t[3]-1),t[5]&&i.setDate(t[5]),t[7]&&i.setHours(t[7]),t[8]&&i.setMinutes(t[8]),i}