var imedo={}
imedo.Initializer={afterInit:[],beforeExit:[],benchmark:null,init:function(){this.benchmark=new thc2.Benchmark();var d=this.benchmark.benchmark(function(){imedo.Initializer.hideElements();imedo.Initializer.showElements();thc2.CurrentPage.applyBehaviours(document.body);thc2.CurrentPage.reconnect(document.body);try{imedo.Button.init();}catch(e){}
imedo.Initializer.showFlash();imedo.Initializer.afterInit.each(function(func){func();})}).duration();if(Prototype.Browser.IE&&d>2000){$('slow-loading').show();}},exit:function(){if(this.beforeExit){this.beforeExit.each(function(func){func();});}
imedo.Config.self().save();},hideElements:function(){$A(document.getElementsByClassName('hidden')).each(function(element){element.style.display='none';$(element).removeClassName('hidden');});},showElements:function(){$A(document.getElementsByClassName('visible')).each(function(element){$(element).removeClassName('visible');});},showFlash:function(){if($('info-message')){$('flash').show();}},doAfterInit:function(func){this.afterInit.push(func);},doBeforeExit:function(func){this.beforeExit.push(func);}};Event.observe(document,"dom:loaded",imedo.Initializer.init);Event.observe(window,'unload',imedo.Initializer.exit);imedo.Config=thc2.Singleton.create({get:function(key){this.load();return this.attributes.get(key);},set:function(key,value){this.load();this.attributes.set(key,value);},load:function(){if(this.loaded)
return;var content=this.cookie().read()||"";this.attributes=content.split('|').inject($H({}),function(hash,value){var data=value.split(':');hash.set(data[0],data[1]);return hash;});this.loaded=true;},save:function(){var content=this.attributes.collect(function(pair){return pair.join(':');}).join('|');this.cookie().write(content,365);},cookie:function(){return new imedo.Cookie('config');}});imedo.Cookie=Class.create({initialize:function(name,days){this.name=name;this.days=days;},read:function(){var nameEQ=this.name+"=";var ca=document.getCookie().split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;},write:function(value){if(this.days){var date=new Date();date.setTime(date.getTime()+(this.days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else expires="";document.setCookie(this.name+"="+value+expires+"; path=/");}});document.setCookie=function(value){document.cookie=value;};document.getCookie=function(value){return document.cookie;};imedo.Button=Class.create(thc2.Widget,{initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);this.original=this.element;this.convert();},submitClick:function(event){if(!this.original.disabled){this.original.click();}},submitKeyPress:function(event){switch(event.keyCode){case Event.KEY_RETURN:{if(document.activeElement.tagName.toLowerCase()!='textarea'){event.stop();this.original.click();break;}}}},resetClick:function(event){var form=this.form();form.reset();},form:function(){this.formElement=this.formElement||this.findForm(this.original);return this.formElement;},convert:function(){if(this.isFormButton()){this.convertButton();}else{this.convertLink();}
this.addConvertedClass(this.original);},convertLink:function(){var newText=imedo.Button.buttonTemplate.interpolate({text:this.element.innerHTML});this.element.update(newText);},convertButton:function(){if(this.isSubmitButton()){this.convertSubmit();}else if(this.isResetButton()){this.convertReset();}else{this.convertSubmit();}},convertSubmit:function(){this.createButton();this.addConvertedClass(this.original);Event.observe(this.button,'click',this.submitClick.bindAsEventListener(this));this.hideOriginal();this.button.show();if(Prototype.Browser.IE){Event.observe(this.form(),'keypress',this.submitKeyPress.bindAsEventListener(this));}},hideOriginal:function(){this.original.setStyle({position:"absolute",left:"-10000px",width:"1px"})},convertReset:function(){this.createButton();this.addConvertedClass(this.original);Event.observe(this.button,'click',this.resetClick.bindAsEventListener(this));this.hideOriginal();this.button.show();},createButton:function(){this.button=$(Builder.node("a",{className:this.original.className,id:this.original.id,tabIndex:this.original.tabIndex}));this.addConvertedClass(this.button);this.button.update(this.htmlForButton(this.original.value));Element.insert(this.original,{after:this.button});},htmlForButton:function(text){return imedo.Button.buttonTemplate.interpolate({text:text});},isFormButton:function(){return this.element.tagName=='INPUT'&&(['submit','button','reset'].include(this.element.type.toLowerCase()));},isSubmitButton:function(){return this.element.type.toLowerCase()=='submit';},isResetButton:function(){return this.element.type.toLowerCase()=='reset';},addConvertedClass:function(element){element.addClassName(imedo.Button.convertedClassName);element.removeClassName("button");},findForm:function(element){if(element.tagName.toUpperCase()=='HTML'){return undefined;}else if(element.tagName.toUpperCase()=='FORM'){return element;}else{return this.findForm(element.parentNode);}}});Object.extend(imedo.Button,{convertedClassName:'aria-btn',buttonTemplate:"<span><span>#{text}</span></span>",init:function(element){if(imedo.Button.isIncompatibleBrowser())
return;var element=element||document.body;var convertees=$A(element.getElementsByClassName('button'));for(var i=0;i<convertees.length;i++){if(!$(convertees[i]).hasClassName(imedo.Button.convertedClassName)){new imedo.Button(convertees[i]);}}},isIncompatibleBrowser:function(){if(/msie (\d)/.test(navigator.userAgent.toLowerCase())&&RegExp.$1=='6'){return true;}else{return false;}}});imedo.SearchLinkWidget=Class.create(thc2.Widget,{initialize:function(element,options){thc2.Widget.prototype.initialize.apply(this,arguments);var elements=element.select('a');if(elements.length==0){return;}
this.extractTarget();this.shouldUseRelAttributes();this.createHiddenFieldIfNeeded();var self=this;this.links=elements;this.links.each(function(link){var comparison;if(this.useRelAttribute){comparison=link.readAttribute("rel")}else{comparison=link.innerHTML}
if(comparison==this.target.value){link.addClassName('active');}
Event.observe(link,'click',function(event){var clickedLink=event.element();event.stop();if(clickedLink.hasClassName('active')){clickedLink.removeClassName('active');this.target.value='';if(this.hiddenField){this.hiddenField.value='';}}else{if(this.useRelAttribute){this.target.value=clickedLink.readAttribute("rel");}else{this.target.value=clickedLink.innerHTML;}
if(this.hiddenField){this.hiddenField.value=clickedLink.innerHTML;}
this.links.each(function(elem){elem.removeClassName('active')});clickedLink.addClassName('active');}}.bind(this));}.bind(this));element.addClassName('applied');},createHiddenFieldIfNeeded:function(){var classNames=$(this.element).className.split(' ');for(var i=0;i!=classNames.length;++i){if(classNames[i].startsWith("hidden_field_")){var target=classNames[i];break;}}
if(target){this.hiddenField=new Element('input',{'type':'hidden','name':target.gsub("hidden_field_",'')});this.element.insert(this.hiddenField);}},extractTarget:function(){var classNames=$(this.element).className.split(' ');for(var i=0;i!=classNames.length;++i){if(classNames[i].startsWith("target_")){var target=classNames[i];break;}}
if(target){this.target=$(target.gsub("target_",''));}},shouldUseRelAttributes:function(){if($(this.element).hasClassName("use_rel_attrs")){this.useRelAttribute=true}}});thc2.CurrentPage.registerBehaviour("thc2-search-links",imedo.SearchLinkWidget);imedo.DisambiguationLinkWidget=Class.create(thc2.Widget,{initialize:function(element,options){thc2.Widget.prototype.initialize.apply(this,arguments);var elements=element.select('a');if(elements.length==0){return;}
this.extractTarget();var self=this;this.links=elements;this.links.each(function(link){if(link.innerHTML==this.target.value){link.addClassName('active');var data=this.extractDataFromLink(link);this.setHiddenFieldValues(data.city,data.city,data.state);}
Event.observe(link,'click',function(event){var clickedLink=event.element();event.stop();if(clickedLink.hasClassName('active')){clickedLink.removeClassName('active');this.setHiddenFieldValues('','','');this.removeHiddenFields();}else{var data=this.extractDataFromLink(clickedLink);this.createHiddenFields();this.setHiddenFieldValues(data.city,data.city,data.state);this.links.each(function(elem){elem.removeClassName('active')});clickedLink.addClassName('active');}}.bind(this));}.bind(this));element.addClassName('applied');},extractDataFromLink:function(link){var query=link.readAttribute('href').parseQuery();var state=query.state?query.state:link.readAttribute('href').gsub('http://','').split('/')[3];var city=link.innerHTML;return{'city':city,'state':state};},removeHiddenFields:function(){if(this.cityField){this.cityField.remove();}
if(this.stateField){this.stateField.remove();}},setHiddenFieldValues:function(target,city,state){if(!this.hiddenFieldsCreated){this.createHiddenFields()}
this.target.value=target;this.cityField.value=city;this.stateField.value=state;},createHiddenFields:function(){this.cityField=new Element('input',{'type':'hidden','name':'city'});this.element.insert(this.cityField);this.stateField=new Element('input',{'type':'hidden','name':'state'});this.element.insert(this.stateField);this.hiddenFieldsCreated=true},extractTarget:function(){this.target=$('provider_location');}});thc2.CurrentPage.registerBehaviour("thc2-disambiguation-links",imedo.DisambiguationLinkWidget);imedo.FocusWidget=Class.create(thc2.Widget,{initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);if(imedo.FocusWidget.focusedWidget===undefined){imedo.FocusWidget.focusedWidget=this.element;}else{thc2.Logger.warning('Two focused widgets on one page');}
this.element.focus();}});thc2.CurrentPage.registerBehaviour("thc2-focus",imedo.FocusWidget);imedo.HelpTriggerWidget=Class.create(thc2.BubbleTriggerWidget,{initialize:function(element){thc2.BubbleTriggerWidget.prototype.initialize.apply(this,arguments);this.removeAndStoreHelpText();this.removeTooltipClass();},bubble:function(){if(!this.cachedBubble){this.cachedBubble=new HelpBubble(this);}
return this.cachedBubble;},removeAndStoreHelpText:function(){var help_span_tag=$(this.element.getElementsByTagName('span')[0]);this.text=help_span_tag.innerHTML;help_span_tag.addClassName("screenreader");},removeTooltipClass:function(){this.element.removeClassName('tooltip');}});thc2.CurrentPage.registerBehaviour("thc2-help-trigger",imedo.HelpTriggerWidget);imedo.InplaceEditWidget=Class.create(thc2.Widget,{initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);this.view=this.element.getElementsByClassName('inplace-view')[0];this.edit=this.element.getElementsByClassName('inplace-edit')[0];this.form=this.element.getElementsByTagName('form')[0];this.edit.hide();Event.observe(this.element,'click',this.hideView.bindAsEventListener(this));Event.observe(this.form,'submit',this.hideEdit.bindAsEventListener(this));Event.observe(this.edit,'keyup',this.keyup.bindAsEventListener(this));this.cancel=this.edit.getElementsByClassName('inplace-cancel')[0];if(this.cancel){this.cancel.show();Event.observe(this.cancel,'click',this.hideEdit.bindAsEventListener(this));}},lazyInit:function(){this.editFocusOn=this.element.down('.inplace-focus');this.submit=this.form.down('input[type=submit]');},keyup:function(event){if(!this.initialized)this.lazyInit();switch(event.keyCode){case Event.KEY_RETURN:{event.stop();this.submit.click();break;}
case Event.KEY_ESC:{if(this.cancel){this.hideEdit(event);}
break;}}},hideView:function(event){if(!this.initialized)this.lazyInit();this.view.hide();this.edit.show();if(event.element()==this.element){event.stop();}
if(this.editFocusOn){this.editFocusOn.focus();}},hideEdit:function(event){this.edit.hide();this.view.show();event.stop();}});thc2.CurrentPage.registerBehaviour("thc2-inplace-edit",imedo.InplaceEditWidget);imedo.MapWidget=Class.create(thc2.Widget,{initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);var states=$A(this.element.getElementsByTagName('area'));var stateNames=$A(this.element.getElementsByClassName('toplevel'));this.mapDisplay=this.element.getElementsByClassName('map-display')[0];$A([states,stateNames]).each(function(array){var pos=1;array.each(function(state){state.pos=pos;Event.observe(state,'mouseover',function(){this.setSprite(state.pos);}.bind(this));Event.observe(state,'mouseout',function(){this.resetSprite();}.bind(this));pos++;}.bind(this));}.bind(this));},setSprite:function(pos){this.mapDisplay.setStyle({backgroundPosition:"0px "+(-530*pos)+"px"});},resetSprite:function(){this.mapDisplay.setStyle({backgroundPosition:"0 0"});}})
thc2.CurrentPage.registerBehaviour('thc2-map',imedo.MapWidget)
imedo.ModalLinkWidget=Class.create(thc2.Widget,{SizeRegexp:/^box_size_(\d+)x(\d+)$/,defaultWidth:600,defaultOptions:{overlayClose:false,loadingString:"Inhalt wird geladen ...",closeString:"Schließen",autoFocusing:true},initialized:false,initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.showModalBox.bindAsEventListener(this));this.modalboxOptions=Object.clone(this.defaultOptions);},lazyInit:function(){if(!this.initialized){this.url=this.element.href;this.calculateSize();this.modalboxOptions.title=this.element.innerHTML;this.initialized=true;}},calculateSize:function(){var size=this.element.classNames().grep(this.SizeRegexp)[0];if(size){var fixedHeight=this.element.hasClassName("fixed-height");var match=size.match(this.SizeRegexp);this.modalboxOptions.width=parseInt(match[1]);if(fixedHeight){this.modalboxOptions.height=parseInt(match[2]);}}else{this.modalboxOptions.width=this.defaultWidth;}},showModalBox:function(event){this.lazyInit();this.element.blur();Modalbox.show(this.extendUrl(this.url),this.modalboxOptions);event.stop();},extendUrl:function(url){if(url.include("?")){return url+'&modal=1'}else{return url+'?modal=1'}}});imedo.ModalCancelWidget=Class.create(thc2.Widget,{initialize:function(element){thc2.Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.closeModalBox.bindAsEventListener(this));Event.observe(this.element,"submit",this.closeModalBox.bindAsEventListener(this));},closeModalBox:function(event){Modalbox.hide();event.stop();}});thc2.CurrentPage.registerBehaviours({"thc2-modal-link":imedo.ModalLinkWidget,"thc2-modal-cancel":imedo.ModalCancelWidget});imedo.SimpleTabWidget=Class.create(thc2.TabWidget,{doSwitch:function(oldTab,newTab){$(oldTab.link.id+'-tab').hide();$(newTab.link.id+'-tab').show();}});thc2.CurrentPage.registerBehaviour("thc2-simple-tab-widget",imedo.SimpleTabWidget);if(!window.Modalbox)
var Modalbox=new Object();Modalbox.Methods={overrideAlert:false,focusableElements:new Array,currFocused:0,initialized:false,active:true,options:{title:"ModalBox Window",overlayClose:true,width:500,height:90,overlayOpacity:.65,overlayDuration:.25,slideDownDuration:.5,slideUpDuration:.5,resizeDuration:.25,inactiveFade:true,transitions:true,loadingString:"Please wait. Loading...",closeString:"Close window",closeValue:"&times;",params:{},method:'get',autoFocusing:true,aspnet:false},_options:new Object,setOptions:function(options){Object.extend(this.options,options||{});},_init:function(options){Object.extend(this._options,this.options);this.setOptions(options);this.MBoverlay=new Element("div",{id:"MB_overlay",opacity:"0"});this.MBwindow=new Element("div",{id:"MB_window",style:"display: none"}).update(this.MBframe=new Element("div",{id:"MB_frame"}).update(this.MBheader=new Element("div",{id:"MB_header"}).update(this.MBcaption=new Element("div",{id:"MB_caption"}))));this.MBclose=new Element("a",{id:"MB_close",title:this.options.closeString,href:"#"}).update("<span>"+this.options.closeValue+"</span>");this.MBheader.insert({'bottom':this.MBclose});this.MBcontent=new Element("div",{id:"MB_content"}).update(this.MBloading=new Element("div",{id:"MB_loading"}).update(this.options.loadingString));this.MBframe.insert({'bottom':this.MBcontent});var injectToEl=this.options.aspnet?$(document.body).down('form'):$(document.body);injectToEl.insert({'top':this.MBwindow});injectToEl.insert({'top':this.MBoverlay});this.initScrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft;this.initScrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;this.hideObserver=this._hide.bindAsEventListener(this);this.kbdObserver=this._kbdHandler.bindAsEventListener(this);this._initObservers();this.initialized=true;},show:function(content,options){if(!this.initialized)this._init(options);this.content=content;this.setOptions(options);if(this.options.title)
$(this.MBcaption).update(this.options.title);else{$(this.MBheader).hide();$(this.MBcaption).hide();}
if(this.MBwindow.style.display=="none"){this._appear();this.event("onShow");}
else{this._update();this.event("onUpdate");}},hide:function(options){if(this.initialized){if(options&&typeof options.element!='function')Object.extend(this.options,options);this.event("beforeHide");if(this.options.transitions)
Effect.SlideUp(this.MBwindow,{duration:this.options.slideUpDuration,transition:Effect.Transitions.sinoidal,afterFinish:this._deinit.bind(this)});else{$(this.MBwindow).hide();this._deinit();}}else throw("Modalbox is not initialized.");},_hide:function(event){event.stop();if(event.element().id=='MB_overlay'&&!this.options.overlayClose)return false;this.hide();},alert:function(message){var html='<div class="MB_alert"><p>'+message+'</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';Modalbox.show(html,{title:'Alert: '+document.title,width:300});},_appear:function(){if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){window.scrollTo(0,0);this._prepareIE("100%","hidden");}
this._setWidth();this._setPosition();if(this.options.transitions){$(this.MBoverlay).setStyle({opacity:0});new Effect.Fade(this.MBoverlay,{from:0,to:this.options.overlayOpacity,duration:this.options.overlayDuration,afterFinish:function(){new Effect.SlideDown(this.MBwindow,{duration:this.options.slideDownDuration,transition:Effect.Transitions.sinoidal,afterFinish:function(){this._setPosition();this.loadContent();}.bind(this)});}.bind(this)});}else{$(this.MBoverlay).setStyle({opacity:this.options.overlayOpacity});$(this.MBwindow).show();this._setPosition();this.loadContent();}
this._setWidthAndPosition=this._setWidthAndPosition.bindAsEventListener(this);Event.observe(window,"resize",this._setWidthAndPosition);},resize:function(byWidth,byHeight,options){var oWidth=$(this.MBoverlay).getWidth();var wHeight=$(this.MBwindow).getHeight();var wWidth=$(this.MBwindow).getWidth();var hHeight=$(this.MBheader).getHeight();var cHeight=$(this.MBcontent).getHeight();var newHeight=((wHeight-hHeight+byHeight)<cHeight)?(cHeight+hHeight):(wHeight+byHeight);var newWidth=wWidth+byWidth;if(options)this.setOptions(options);if(this.options.transitions){new Effect.Morph(this.MBwindow,{style:"width:"+newWidth+"px; height:"+newHeight+"px; left:"+((oWidth-newWidth)/2)+"px",duration:this.options.resizeDuration,beforeStart:function(fx){fx.element.setStyle({overflow:"hidden"});},afterFinish:function(fx){fx.element.setStyle({overflow:"visible"});this.event("_afterResize");this.event("afterResize");}.bind(this)});}else{this.MBwindow.setStyle({width:newWidth+"px",height:newHeight+"px"});setTimeout(function(){this.event("_afterResize");this.event("afterResize");}.bind(this),1);}},resizeToContent:function(options){var byHeight=this.options.height-$(this.MBwindow).getHeight();if(byHeight!=0){if(options)this.setOptions(options);Modalbox.resize(0,byHeight);}},resizeToInclude:function(element,options){var el=$(element);var elHeight=el.getHeight()+parseInt(el.getStyle('margin-top'),0)+parseInt(el.getStyle('margin-bottom'),0)+parseInt(el.getStyle('border-top-width'),0)+parseInt(el.getStyle('border-bottom-width'),0);if(elHeight>0){if(options)this.setOptions(options);Modalbox.resize(0,elHeight);}},_update:function(){$(this.MBcontent).update($(this.MBloading).update(this.options.loadingString));this.loadContent();},loadContent:function(){if(this.event("beforeLoad")!=false){if(typeof this.content=='string'){var htmlRegExp=new RegExp(/<\/?[^>]+>/gi);if(htmlRegExp.test(this.content)){this._insertContent(this.content.stripScripts(),function(){this.content.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));}.bind(window));}.bind(this));}else
new Ajax.Request(this.content,{method:this.options.method.toLowerCase(),parameters:this.options.params,onSuccess:function(transport){var response=new String(transport.responseText);this._insertContent(transport.responseText.stripScripts(),function(){response.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));}.bind(window));});}.bind(this),onException:function(instance,exception){Modalbox.hide();throw('Modalbox Loading Error: '+exception);}});}else if(typeof this.content=='object'){this._insertContent(this.content);}else{Modalbox.hide();throw('Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)');}}},_insertContent:function(content,callback){$(this.MBcontent).hide().update("");if(typeof content=='string'){this.MBcontent.update(new Element("div",{style:"display: none"}).update(content)).down().show();}else if(typeof content=='object'){var _htmlObj=content.cloneNode(true);if(content.id)content.id="MB_"+content.id;$(content).select('*[id]').each(function(el){el.id="MB_"+el.id;});this.MBcontent.update(_htmlObj).down('div').show();if(Prototype.Browser.IE)
$$("#MB_content select").invoke('setStyle',{'visibility':''});}
if(this.options.height==this._options.height){Modalbox.resize((this.options.width-$(this.MBwindow).getWidth()),$(this.MBcontent).getHeight()-$(this.MBwindow).getHeight()+$(this.MBheader).getHeight(),{afterResize:function(){setTimeout(function(){this._putContent(callback);}.bind(this),1);}.bind(this)});}else{this._setWidth();this.MBcontent.setStyle({overflow:'auto',height:$(this.MBwindow).getHeight()-$(this.MBheader).getHeight()-13+'px'});setTimeout(function(){this._putContent(callback);}.bind(this),1);}},_putContent:function(callback){this.MBcontent.show();this.focusableElements=this._findFocusableElements();this._setFocus();if(callback!=undefined)
callback();this.event("afterLoad");},activate:function(options){this.setOptions(options);this.active=true;$(this.MBclose).observe("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).observe("click",this.hideObserver);$(this.MBclose).show();if(this.options.transitions&&this.options.inactiveFade)
new Effect.Appear(this.MBwindow,{duration:this.options.slideUpDuration});},deactivate:function(options){this.setOptions(options);this.active=false;$(this.MBclose).stopObserving("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).stopObserving("click",this.hideObserver);$(this.MBclose).hide();if(this.options.transitions&&this.options.inactiveFade)
new Effect.Fade(this.MBwindow,{duration:this.options.slideUpDuration,to:.75});},_initObservers:function(){$(this.MBclose).observe("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).observe("click",this.hideObserver);if(Prototype.Browser.Gecko)
Event.observe(document,"keypress",this.kbdObserver);else
Event.observe(document,"keydown",this.kbdObserver);},_removeObservers:function(){$(this.MBclose).stopObserving("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).stopObserving("click",this.hideObserver);if(Prototype.Browser.Gecko)
Event.stopObserving(document,"keypress",this.kbdObserver);else
Event.stopObserving(document,"keydown",this.kbdObserver);},_setFocus:function(){if(this.focusableElements.length>0&&this.options.autoFocusing==true){var firstEl=this.focusableElements.find(function(el){return el.tabIndex==1;})||this.focusableElements.first();this.currFocused=this.focusableElements.toArray().indexOf(firstEl);firstEl.focus();}else if($(this.MBclose).visible())
$(this.MBclose).focus();},_findFocusableElements:function(){this.MBcontent.select('input:not([type~=hidden]), select, textarea, button, a[href]').invoke('addClassName','MB_focusable');return this.MBcontent.select('.MB_focusable');},_kbdHandler:function(event){var node=event.element();switch(event.keyCode){case Event.KEY_TAB:event.stop();if(node!=this.focusableElements[this.currFocused])
this.currFocused=this.focusableElements.toArray().indexOf(node);if(!event.shiftKey){if(this.currFocused==this.focusableElements.length-1){this.focusableElements.first().focus();this.currFocused=0;}else{this.currFocused++;this.focusableElements[this.currFocused].focus();}}else{if(this.currFocused==0){this.focusableElements.last().focus();this.currFocused=this.focusableElements.length-1;}else{this.currFocused--;this.focusableElements[this.currFocused].focus();}}
break;case Event.KEY_ESC:if(this.active)this._hide(event);break;case 32:this._preventScroll(event);break;case 0:if(event.which==32)this._preventScroll(event);break;case Event.KEY_UP:case Event.KEY_DOWN:case Event.KEY_PAGEDOWN:case Event.KEY_PAGEUP:case Event.KEY_HOME:case Event.KEY_END:if(Prototype.Browser.WebKit&&!["textarea","select"].include(node.tagName.toLowerCase()))
event.stop();else if((node.tagName.toLowerCase()=="input"&&["submit","button"].include(node.type))||(node.tagName.toLowerCase()=="a"))
event.stop();break;}},_preventScroll:function(event){if(!["input","textarea","select","button"].include(event.element().tagName.toLowerCase()))
event.stop();},_deinit:function()
{this._removeObservers();Event.stopObserving(window,"resize",this._setWidthAndPosition);if(this.options.transitions){Effect.toggle(this.MBoverlay,'appear',{duration:this.options.overlayDuration,afterFinish:this._removeElements.bind(this)});}else{this.MBoverlay.hide();this._removeElements();}
$(this.MBcontent).setStyle({overflow:'',height:''});},_removeElements:function(){$(this.MBoverlay).remove();$(this.MBwindow).remove();if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){this._prepareIE("","");window.scrollTo(this.initScrollX,this.initScrollY);}
if(typeof this.content=='object'){if(this.content.id&&this.content.id.match(/MB_/)){this.content.id=this.content.id.replace(/MB_/,"");}
this.content.select('*[id]').each(function(el){el.id=el.id.replace(/MB_/,"");});}
this.initialized=false;this.event("afterHide");this.setOptions(this._options);},_setWidth:function(){$(this.MBwindow).setStyle({width:this.options.width+"px",height:this.options.height+"px"});},_setPosition:function(){$(this.MBwindow).setStyle({left:(($(this.MBoverlay).getWidth()-$(this.MBwindow).getWidth())/2)+"px"});},_setWidthAndPosition:function(){$(this.MBwindow).setStyle({width:this.options.width+"px"});this._setPosition();},_getScrollTop:function(){var theTop;if(document.documentElement&&document.documentElement.scrollTop)
theTop=document.documentElement.scrollTop;else if(document.body)
theTop=document.body.scrollTop;return theTop;},_prepareIE:function(height,overflow){$$('html, body').invoke('setStyle',{width:height,height:height,overflow:overflow});$$("select").invoke('setStyle',{'visibility':overflow});},event:function(eventName){if(this.options[eventName]){var returnValue=this.options[eventName]();this.options[eventName]=null;if(returnValue!=undefined)
return returnValue;else
return true;}
return true;}};Object.extend(Modalbox,Modalbox.Methods);if(Modalbox.overrideAlert)window.alert=Modalbox.alert;
