/**
 * @description		prototype.js based viewswitcher (main purpose is to change font-sizes)
 * 					Most flexible viewswitcher, easy to use and install. Doesn't require any extra stylesheets.
 * @param			parent: container to which the switchButtons should be inserted
 * 					amount: amount of switchButtons
 * 					ui: ui in which the viewswitcher is used
 * @requires		uibase/script/setcookie.js
 * @author        	Peter Slagter; peter [at] procurios [dot] nl;
*/

var viewSwitcher=Class.create({initialize:function(c,b,a,d){this.parent=$(c)||$(document.body);this.amount=b||3;this.position=a||"bottom";this.amountMedian=0;this.switchButtons=[];this.active=d||"";this.buildSwitcher()},buildSwitcher:function(){var c=new Element("ol",{id:"css-switcher"});for(i=0;i<this.amount;i++){var a=new Element("li",{"class":"view-"+i});var b=document.createTextNode("a");a.appendChild(b);c.appendChild(a);a.observe("click",function(d){this.switchView(d.element())}.bind(this));this.switchButtons.push(a);this.amountMedian+=i}if(this.position=="top"){this.parent.insert({top:c})}else{this.parent.insert({bottom:c})}this.amountMedian=(this.amountMedian/this.amount).round();this.active=GetCookie("view-switcher")?GetCookie("view-switcher"):(this.active!==""?this.active:this.amountMedian);this.switchButtons[this.active].addClassName("active");$(document.body).addClassName("view-"+this.active)},switchView:function(a){var b=this.switchButtons.indexOf(a);if(b!=this.active){this.switchButtons[this.active].removeClassName("active");a.addClassName("active");$(document.body).removeClassName("view-"+this.active);$(document.body).addClassName("view-"+b);this.active=this.switchButtons.indexOf(a);SetCookie("view-switcher",this.active,365)}}});
