function $get(key,url){if(arguments.length<2)url=location.href;if(arguments.length>0&&key!=""){if(key=="#"){var regex=new RegExp("[#]([^$]*)");}else if(key=="?"){var regex=new RegExp("[?]([^#$]*)");}else{var regex=new RegExp("[?&]"+key+"=([^&#]*)");}
var results=regex.exec(url);return(results==null)?"":results[1];}else{url=url.split("?");var results={};if(url.length>1){url=url[1].split("#");if(url.length>1)results["hash"]=url[1];url[0].split("&").each(function(item,index){item=item.split("=");results[item[0]]=item[1];});}
return results;}}
var MessageQueue=new Class({listeners:$H(),sentMessages:[],initialize:function(){},register:function(handle,callback,dontCheck){if($type(callback)!='function')return;if(!dontCheck&&this.sentMessages[handle]){callback();}
if(!this.listeners.has(handle))this.listeners[handle]=[];this.listeners[handle].push(callback);},unregister:function(handle,callback){if(this.listeners.has(handle)){this.listeners[handle].erase(callback);}},send:function(handle,contents){this.sentMessages.include(handle);if(this.listeners.has(handle)){this.listeners[handle].each(function(callback){callback(contents);});}}});


var Tabs=new Class({Implements:Options,options:{tabs:'tabs',panels:'panel',selected:'selected',event:'click'},initialize:function(name,options){this.setOptions(options);this.queue=new MessageQueue;var glob=this;var group=document.id(name);var tabs=group.getElements('li.'+this.options.tabs);var panels=group.getElements('div.'+this.options.panels);var event=this.options.event;var height=this.getHeight(tabs)+this.getHeight(panels);var q=this.queue;var reset=function(args){items=args.items;cls=args.cls;items.each(function(p){p.setProperty('class',cls);});};q.register('reset',reset,false);var opt=glob.options;tabs.each(function(tab){var anch=tab.getElements('a');anch.each(function(a){a.onclick=function(){return false;};a.addEvent(event,function(e){q.send('reset',{'items':panels,'cls':opt.panels});q.send('reset',{'items':tabs,'cls':opt.tabs});var href=$get("#",this.href);tab.setProperty('class',opt.tabs+' '+opt.selected);selected=document.id(href);selected.setProperty('class',opt.panels+' '+opt.selected);});});})},getHeight:function(group){var h=0;group.each(function(p){var s=p.getDimensions();if(s.y>h)
h=s.y;});return h;}});


var Carousel2=new Class({Implements:Options,options:{increment:1,frame:'frame',panels:'panels',controls:'controls',navigationcontrols:null,panelsize:null,panelitems:null,columns:null,container:null,update:null,hidecontrols:true,behaviors:null,framesize:null,startposition:null,event:'click',usemousewheel:false,debug:false},hasConsole:function(_method){var _method=_method||"log";return typeof(console)=='object'&&typeof(console[_method])!="undefined";},debug:function(msg){if(this.hasConsole()==false)
return;if(this.options.debug==true)
console.log("Carousel2: ",msg);},initialize:function(name,options){this.setOptions(options);var incr=this.options.increment;var carousel=this.carousel=document.id(name);this.debug("found carousel: "+carousel);var frame=carousel.getElements('div.'+this.options.frame)[0];this.debug("found frame: "+frame);this.debug("panelitems are: "+this.options.panelitems);this.debug("panelsize is: "+this.options.panelsize);if(this.options.panelitems!=null&&this.options.panelsize!=null){this.init();this.fmtpanels();}else{this.panels=carousel.getElements('div.'+this.options.panels);}
var display=frame.getStyle('display');var panels=this.panels;this.debug("found panels: "+panels);this.debug("panels number: "+panels.length);this.sets=Math.round(panels.length/incr);this.cname=name+'.panel';var scroll=this.scroll=new Fx.Scroll(frame,{wheelStops:false,wait:false,duration:500,transition:Fx.Transitions.Quad.easeOut});this.current=0;if(Cookie.read(this.cname)>0){this.current=parseInt(Cookie.read(this.cname));}
var glob=this;var controldiv=carousel.getElements('div.'+this.options.controls);this.debug("found controldiv: "+controldiv);var controls=this.controls=controldiv.getElements('a');this.debug("found controls: "+controls);controls.each(function(a){a.onclick=function(){return false;};});if(this.panels.length<=this.options.increment){}else{if(this.options.navigationcontrols!=null)
carousel.getElements('div.'+this.options.navigationcontrols).removeClass('hide');else
controldiv.removeClass('hide');controls.each(function(a){a.addEvent(glob.options.event,function(e){var direction=$get("#",this.href);glob.spin(direction);return false;});});}
if(this.options.behaviors!=null)
this.options.behaviors(this);if(this.options.usemousewheel==true){this.panels.each(function(p){p.addEvent('mouseover',function(e){p.addClass('hover');});p.addEvent('mouseout',function(e){p.removeClass('hover');});p.addEvent('mousewheel',function(e){e.stop();var direction=(e.wheel<0?'right':'left');glob.spin(direction);});});}
this.hidecontrols();},hidecontrols:function(){var carousel=this.carousel;var controldiv=carousel.getElements('div.'+this.options.controls);var controls=controldiv.getElements('a');this.debug("hidecontrols called");this.debug("hidecontrols:"+this.panels.length<=this.options.increment);if(this.panels.length<=this.options.increment){var ctl;if(this.options.navigationcontrols!=null)
ctl=carousel.getElements('div.'+this.options.navigationcontrols)
else
ctl=controldiv;ctl.setStyle('display','none');ctl.addClass('hidden');}else{if(this.options.navigationcontrols!=null)
carousel.getElements('div.'+this.options.navigationcontrols).removeClass('hide');else
controldiv.removeClass('hide');}},spin:function(direction,incr){var panels=this.panels;var current=this.current;this.debug("spin: panels number "+panels.length);this.debug("spin: current panel is "+current);if(direction==null)
direction='right'
if(incr==null)
incr=this.options.increment;if(direction=='left')
current-=incr;else if(direction=='right')
current+=incr;this.debug("spin: setting current to "+current);if(current<0){current=panels.length-incr;}else if(current>(this.sets*incr)){this.debug("spin: current is 0: current > (this.sets * incr)"+(this.sets*incr));current=0;}else if(current>=panels.length){this.debug("spin: current is 0: current >= panels.length");current=0;}
this.current=current;this.debug("spin: current now is "+current);this.scroll.toElement(panels[current]);},init:function(){var parent=null;if(this.options.container!=null){parent=this.carousel.getElements('.'+this.options.container)[0];}else{first=this.carousel.getElements('.'+this.options.panelitems)[0];parent=first.getParent();}
var items=parent.getChildren();if(this.options.panelitems!=null)
items=parent.getChildren('.'+this.options.panelitems);else
items=parent.getChildren();if(!this.originalitems){this.originalitems=[];var glob=this;glob.debug("items:");items.each(function(i){glob.debug(i);glob.originalitems.push(i.clone());});}
this.container=parent;},fmtpanels:function(){var parent=this.container;var items;items=parent.getChildren();items.each(function(i){i.destroy();});var p=0;var panel=new Element('div',{'class':this.options.panels}).injectInside(parent);var p2=0;for(var n=0;n<this.originalitems.length;n++){var o=this.originalitems[n];var image=o.getElements('img');if(p==this.options.panelsize){panel=new Element('div',{'class':this.options.panels}).injectInside(parent);p=0;}
this.debug("item number: "+p)
this.debug(o)
p++;var clone=o.clone(true,true);if((this.options.columns!=null)&&(p2==this.options.columns)){this.debug("starting new row: "+p2)
p2=0;clone.addClass('rowstart');}
p2++;clone.injectInside(panel);}
this.panels=this.carousel.getElements('div.'+this.options.panels);this.hidecontrols();},update:function(list){var parent=this.container;var items=parent.getChildren();items.each(function(i){i.destroy();});var p=0;var p2=0;var panel=new Element('div',{'class':this.options.panels}).injectInside(parent);var g=this;this.originalitems.each(function(o){g.debug("original item is ");g.debug(o);if(o.getElements('a').length<1)
return;g.debug("length: "+o.getElements('a').length);var anchor=o.getElements('a')[0];g.debug("anchor is "+anchor);if(!list.contains(anchor.get('name'))){return;}
var image=o.getElements('img');if(p==g.options.panelsize){panel=new Element('div',{'class':g.options.panels}).injectInside(parent);p=0;}
p++;var clone=o.clone(true,true);if(p2==g.options.columns){p2=0;clone.addClass('rowstart');}
p2++;if(g.options.update!=null)
g.options.update(clone);clone.injectInside(panel);});this.panels=parent.getElements('.'+this.options.panels);this.hidecontrols();},resetItems:function(){var parent=this.container;var items=parent.getChildren();items.each(function(i){i.destroy();});var p=0;var p2=0;var panel=new Element('div',{'class':this.options.panels}).injectInside(parent);var g=this;this.originalitems.each(function(o){g.debug("original item is ");g.debug(o);if(o.getElements('a').length<1)
return;g.debug("length: "+o.getElements('a').length);var anchor=o.getElements('a')[0];g.debug("anchor is "+anchor);var image=o.getElements('img');if(p==g.options.panelsize){panel=new Element('div',{'class':g.options.panels}).injectInside(parent);p=0;}
p++;var clone=o.clone(true,true);if(p2==g.options.columns){p2=0;clone.addClass('rowstart');}
p2++;if(g.options.update!=null)
g.options.update(clone);clone.injectInside(panel);});this.panels=parent.getElements('.'+this.options.panels);this.hidecontrols();},setcanvasheight:function(){var total=0;this.panels.each(function(p){total+=p.getDimensions().y;});var canvas=this.carousel.getElements('div.canvas')[0];canvas.setStyle('height',total);},reset:function(){this.current=0;this.scroll.toElement(this.panels[0]);return;}});


var SlideShow2=new Class({Implements:Options,options:{increment:1,auto:false,delay:7000,fade:60,continueAfterEvent:false,slides:'slides',enableScrollKeys:false,enableClick:false,timerClick:true,createcontrols:false,controls:'controls',slidePosition:'absolute',preSwap:null,postSwap:null,debug:false,},hasConsole:function(_method){var _method=_method||"log";return typeof(console)=='object'&&typeof(console[_method])!="undefined";},debug:function(msg){if(this.hasConsole()==false)
return;if(this.options.debug==true)
console.log("SlideShow2: ",msg);},initialize:function(name,options){this.setOptions(options);this.window=window;this.document=document;var glob=this;this.inProgress=false;var ss=this.slideshow=document.id(name);if(ss==null)
return;this.slides=ss.getElements('div.'+this.options.slides);if(this.slides.length==0){return;}
if(this.slides.length==1){this.slides[0].setStyle('visibility','visible');ss.getElements('div.'+this.options.controls).each(function(c){c.setStyle('display','none');});return;}
if(this.options.createcontrols==false){var controls=new Array;ss.getElements('div.'+this.options.controls).each(function(c){c.getElements('a').each(function(a){controls.push(a);});});this.controls=controls;if(controls!=null)
controls.each(function(a){a.onclick=function(){return false;};var direction=$get("#",a.href);var p=a.getParent();if(p.hasClass(direction)==false)
p.addClass(direction);a.addEvent('click',function(e){glob.swap(direction);return false;});});}else{}
var zindex=this.slides.length;var n=0;this.slides.each(function(a){a.fx=new Fx.Tween(a,{property:'visibility',duration:glob.options.fade,});a.setStyles({'visibility':'hidden','z-index':zindex,'position':glob.options.slidePosition});if(glob.options.timerClick==true)
a.addEvent('click',function(e){glob.stoptimer();if(glob.options.continueAfterEvent==true){glob.starttimer.delay(parseInt(glob.options.delay)/3,glob);}
return false;});zindex--;if(glob.options.enableClick==true)
a.addEvent('click',function(e){glob.swap('right');return false;});});this.slides[0].setStyle('visibility','visible');this.current=0;this.setHeight();this.enableScrollKeys();if(this.options.auto)
this.starttimer();},appendSlides:function(){var ss=this.slideshow;var glob=this;var old=this.slides.length;this.slides=ss.getElements('div.'+this.options.slides);if(this.slides.length==0)
return;if(this.slides.length==1){this.slides[0].setStyle('visibility','visible');ss.getElements('div.'+this.options.controls).each(function(c){c.setStyle('display','none');});return;}
var zindex=this.slides.length;var n=0;this.slides.each(function(a,index){if(index<old)
return;a.fx=new Fx.Tween(a,{property:'visibility',duration:glob.options.fade});a.setStyles({'visibility':'hidden','z-index':zindex,'position':glob.options.slidePosition});if(glob.options.timerClick==true)
a.addEvent('click',function(e){glob.stoptimer();if(glob.options.continueAfterEvent==true){glob.starttimer.delay(parseInt(glob.options.delay)/3,glob);}
return false;});zindex--;if(glob.options.enableClick==true)
a.addEvent('click',function(e){glob.swap('right');return false;});});this.setHeight();},addcontrols:function(){if(this.options.controls==false)
return
var glob=this;var length=this.slides.length;var div=this.controls=new Element('div',{'class':this.options.controlclass}).injectInside(this.slideshow);var list=new Element('ul',{}).injectInside(div);for(var n=0;n<length;n++){var item=new Element('li',{}).injectInside(list);var a=new Element('a',{'href':n}).injectInside(item);a.addEvent('click',function(e){var direction=$get("#",this.href);glob.swap(direction);return false;});}
list.getElement(':first-child').set('class','active');},enableScrollKeys:function(){if(this.options.enableScrollKeys==false)
return;var glob=this;document.scrollKeys=true;var addKeys=function(doc){doc.addEvent('keydown',function(event){if(document.scrollKeys==false)
return;if(event.control||event.shift)
return;if(!glob.inProgress==true){if(event.key=='right')
glob.swap('right');else if(event.key=='left')
glob.swap('left');}});for(x in['input','textarea']){doc.getElements(x).each(function(a){a.addEvents({'focus':function(){doc.scrollKeys=false;},'blur':function(){doc.scrollKeys=true;}});});}};addKeys(document);if(document!=parent.document)
addKeys(parent.document);},setHeight:function(){var total=0;var ss=this.slideshow;var glob=this;window.addEvent('load',function(){glob.slides.each(function(p){var h=p.getDimensions().y;if(h>total)
total=h;});ss.setStyle('height',total);});},setHeight:function(){var total=0;var ss=this.slideshow;var glob=this;window.addEvent('load',function(){glob.slides.each(function(p){var img=p.getElements('img')[0];if(img==null)
return;var ih=img.getDimensions().y;var ph=p.getDimensions().y;var h=ph;if(ih>ph)
h=ih;if(h>total)
total=h;});ss.setStyle('height',total);});},swap:function(direction,incr){var slides=this.slides;var current=this.current;var last=current;if(direction==null)
direction='right'
if(incr==null)
incr=this.options.increment;if(direction=='left')
current-=incr;else if(direction=='right')
current+=incr;if(current<0)
current=slides.length-incr;else if(current>(this.sets*incr))
current=0;else if(current>=slides.length)
current=0;this.current=current;this._swap(last,current);},showSlide:function(value,fade){if(value==null)
return;try{if(fade==null){this.slides[this.current].fade('out');this.slides[value].fade('in');}else{this.slides[this.current].fade('hide');this.slides[value].fade('show');}}catch(err){};this.current=value;},_swap:function(sout,sin){this.debug("_swap called");var resetTimer=false;if(this.timer){resetTimer=true;}
this.inProgress=true;var glob=this;this.slides[sout].fx.start('visible','hidden');if(glob.options.preSwap)
glob.options.preSwap(glob,sout,sin);this.slides[sin].fx.start('hidden','visible').chain(function(){glob.inProgress=false;if(glob.options.postSwap)
glob.options.postSwap();});if(resetTimer==true)
this.starttimer();this.current=sin;},_swap2:function(sout,sin){var resetTimer=false;if(this.timer){resetTimer=true;}
this.inProgress=true;var glob=this;this.slides[this.current].fade('out');this.slides[sin].fade('in');glob.inProgress=false;if(resetTimer==true)
this.starttimer();this.current=sin;},showSlide:function(value,fade){if(value==null)
return;if(value==this.current){if(this.slides[value].getStyle('visibility')=='visible')
return;}
if(value==this.slides.length)
value=0;try{if(fade==null&&this.options.auto==false){this._swap(this.current,value);}else{this._swap(this.current,value);}}catch(err){};},stoptimer:function(){if(this.timer)
$clear(this.timer);},starttimer:function(){if(this.timer)
$clear(this.timer);this.timer=this.createtimer.periodical(this.options.delay,this);},createtimer:function(){if(this.loaded==false)
return;this.showSlide(parseInt(this.current)+1,1);}});
