var foswiki;if(!foswiki)foswiki={};foswiki.TwistyPlugin=new function(){var self=this;this._getName=function(inId){var re=new RegExp("(.*)(hide|show|toggle)","g");var m=re.exec(inId);var name=(m&&m[1])?m[1]:"";return name;}
this._getType=function(inId){var re=new RegExp("(.*)(hide|show|toggle)","g");var m=re.exec(inId);var type=(m&&m[2])?m[2]:"";return type;}
this._toggleTwisty=function(ref){if(!ref)return;ref.state=(ref.state==foswiki.TwistyPlugin.CONTENT_HIDDEN)?foswiki.TwistyPlugin.CONTENT_SHOWN:foswiki.TwistyPlugin.CONTENT_HIDDEN;self._update(ref,true);}
this._update=function(ref,inMaySave){var showControl=ref.show;var hideControl=ref.hide;var contentElem=ref.toggle;if(ref.state==foswiki.TwistyPlugin.CONTENT_SHOWN){foswiki.CSS.addClass(showControl,'twistyHidden');foswiki.CSS.removeClass(hideControl,'twistyHidden');foswiki.CSS.removeClass(contentElem,'twistyHidden');}else{foswiki.CSS.removeClass(showControl,'twistyHidden');foswiki.CSS.addClass(hideControl,'twistyHidden');foswiki.CSS.addClass(contentElem,'twistyHidden');}
if(inMaySave&&ref.saveSetting){foswiki.Pref.setPref(foswiki.TwistyPlugin.COOKIE_PREFIX+ref.name,ref.state);}
if(ref.clearSetting){foswiki.Pref.setPref(foswiki.TwistyPlugin.COOKIE_PREFIX+ref.name,"");}}
this._register=function(e){if(!e)return;var name=self._getName(e.id);var ref=self._storage[name];if(!ref){ref=new foswiki.TwistyPlugin.Storage();}
if(foswiki.CSS.hasClass(e,"twistyRememberSetting"))ref.saveSetting=true;if(foswiki.CSS.hasClass(e,"twistyForgetSetting"))ref.clearSetting=true;if(foswiki.CSS.hasClass(e,"twistyStartShow"))ref.startShown=true;if(foswiki.CSS.hasClass(e,"twistyStartHide"))ref.startHidden=true;if(foswiki.CSS.hasClass(e,"twistyFirstStartShow"))ref.firstStartShown=true;if(foswiki.CSS.hasClass(e,"twistyFirstStartHide"))ref.firstStartHidden=true;ref.name=name;var type=self._getType(e.id);ref[type]=e;self._storage[name]=ref;switch(type){case'show':case'hide':e.onclick=function(){self._toggleTwisty(ref);return false;}
break;}
return ref;}
this._storage={};this._UIbehaviour={'.twistyTrigger':function(e){foswiki.TwistyPlugin.init(e.id);e=null;},'.twistyContent':function(e){foswiki.TwistyPlugin.init(e.id);e=null;},'.twistyExpandAll':function(e){e.onclick=function(){foswiki.TwistyPlugin.toggleAll(foswiki.TwistyPlugin.CONTENT_SHOWN);}
e=null;},'.twistyCollapseAll':function(e){e.onclick=function(){foswiki.TwistyPlugin.toggleAll(foswiki.TwistyPlugin.CONTENT_HIDDEN);}
e=null;}};Behaviour.register(this._UIbehaviour);};foswiki.TwistyPlugin.CONTENT_HIDDEN=0;foswiki.TwistyPlugin.CONTENT_SHOWN=1;foswiki.TwistyPlugin.COOKIE_PREFIX="TwistyPlugin_";foswiki.TwistyPlugin.prefList;foswiki.TwistyPlugin.init=function(inId){var e=document.getElementById(inId);if(!e)return;var name=this._getName(inId);var ref=this._storage[name];if(ref&&ref.show&&ref.hide&&ref.toggle)return ref;ref=this._register(e);foswiki.CSS.replaceClass(e,"twistyMakeHidden","twistyHidden");foswiki.CSS.removeClass(e,"foswikiMakeVisible");foswiki.CSS.removeClass(e,"foswikiMakeVisibleBlock");foswiki.CSS.removeClass(e,"foswikiMakeVisibleInline");foswiki.CSS.removeClass(e,"foswikiMakeHidden");if(ref.show&&ref.hide&&ref.toggle){if(foswiki.CSS.hasClass(e,"twistyInited1")){ref.state=foswiki.TwistyPlugin.CONTENT_SHOWN
this._update(ref,false);return ref;}
if(foswiki.CSS.hasClass(e,"twistyInited0")){ref.state=foswiki.TwistyPlugin.CONTENT_HIDDEN
this._update(ref,false);return ref;}
if(foswiki.TwistyPlugin.prefList==null){foswiki.TwistyPlugin.prefList=foswiki.Pref.getPrefList();}
var cookie=foswiki.Pref.getPrefValueFromPrefList(foswiki.TwistyPlugin.COOKIE_PREFIX+ref.name,foswiki.TwistyPlugin.prefList);if(ref.firstStartHidden)ref.state=foswiki.TwistyPlugin.CONTENT_HIDDEN;if(ref.firstStartShown)ref.state=foswiki.TwistyPlugin.CONTENT_SHOWN;if(cookie&&cookie=="0")ref.state=foswiki.TwistyPlugin.CONTENT_HIDDEN;if(cookie&&cookie=="1")ref.state=foswiki.TwistyPlugin.CONTENT_SHOWN;if(ref.startHidden)ref.state=foswiki.TwistyPlugin.CONTENT_HIDDEN;if(ref.startShown)ref.state=foswiki.TwistyPlugin.CONTENT_SHOWN;this._update(ref,false);}
return ref;}
foswiki.TwistyPlugin.toggleAll=function(inState){var i;for(var i in this._storage){var e=this._storage[i];e.state=inState;this._update(e,true);}}
foswiki.TwistyPlugin.Storage=function(){this.name;this.state=foswiki.TwistyPlugin.CONTENT_HIDDEN;this.hide;this.show;this.toggle;this.saveSetting=false;this.clearSetting=false;this.startShown;this.startHidden;this.firstStartShown;this.firstStartHidden;}