var Clientcide={version:"%build%",assetLocation:"http://github.com/anutron/clientcide/raw/master/Assets",setAssetLocation:function(baseHref){Clientcide.assetLocation=baseHref;if(Clientcide.preloaded){Clientcide.preLoadCss()}},preLoadCss:function(){if(window.StickyWin&&StickyWin.ui){StickyWin.ui()}if(window.StickyWin&&StickyWin.pointy){StickyWin.pointy()}Clientcide.preloaded=true;return true},preloaded:false};(function(){if(!window.addEvent){return }var preload=function(){if(window.dbug){dbug.log("preloading clientcide css")}if(!Clientcide.preloaded){Clientcide.preLoadCss()}};window.addEvent("domready",preload);window.addEvent("load",preload)})();setCNETAssetBaseHref=Clientcide.setAssetLocation;var dbug={logged:[],timers:{},firebug:false,enabled:false,log:function(){dbug.logged.push(arguments)},nolog:function(msg){dbug.logged.push(arguments)},time:function(name){dbug.timers[name]=new Date().getTime()},timeEnd:function(name){if(dbug.timers[name]){var end=new Date().getTime()-dbug.timers[name];dbug.timers[name]=false;dbug.log("%s: %s",name,end)}else{dbug.log("no such timer: %s",name)}},enable:function(silent){var con=window.firebug?firebug.d.console.cmd:window.console;if((!!window.console&&!!window.console.warn)||window.firebug){try{dbug.enabled=true;dbug.log=function(){try{(con.debug||con.log).apply(con,arguments)}catch(e){console.log(Array.slice(arguments))}};dbug.time=function(){con.time.apply(con,arguments)};dbug.timeEnd=function(){con.timeEnd.apply(con,arguments)};if(!silent){dbug.log("enabling dbug")}for(var i=0;i<dbug.logged.length;i++){dbug.log.apply(con,dbug.logged[i])}dbug.logged=[]}catch(e){dbug.enable.delay(400)}}},disable:function(){if(dbug.firebug){dbug.enabled=false}dbug.log=dbug.nolog;dbug.time=function(){};dbug.timeEnd=function(){}},cookie:function(set){var value=document.cookie.match("(?:^|;)\\s*jsdebug=([^;]*)");var debugCookie=value?unescape(value[1]):false;if((!$defined(set)&&debugCookie!="true")||($defined(set)&&set)){dbug.enable();dbug.log("setting debugging cookie");var date=new Date();date.setTime(date.getTime()+(24*60*60*1000));document.cookie="jsdebug=true;expires="+date.toGMTString()+";path=/;"}else{dbug.disableCookie()}},disableCookie:function(){dbug.log("disabling debugging cookie");document.cookie="jsdebug=false;path=/;"}};(function(){var fb=!!window.console||!!window.firebug;var con=window.firebug?window.firebug.d.console.cmd:window.console;var debugMethods=["debug","info","warn","error","assert","dir","dirxml"];var otherMethods=["trace","group","groupEnd","profile","profileEnd","count"];function set(methodList,defaultFunction){for(var i=0;i<methodList.length;i++){dbug[methodList[i]]=(fb&&con[methodList[i]])?con[methodList[i]]:defaultFunction}}set(debugMethods,dbug.log);set(otherMethods,function(){})})();if((!!window.console&&!!window.console.warn)||window.firebug){dbug.firebug=true;var value=document.cookie.match("(?:^|;)\\s*jsdebug=([^;]*)");var debugCookie=value?unescape(value[1]):false;if(window.location.href.indexOf("jsdebug=true")>0||debugCookie=="true"){dbug.enable()}if(debugCookie=="true"){dbug.log("debugging cookie enabled")}if(window.location.href.indexOf("jsdebugCookie=true")>0){dbug.cookie();if(!dbug.enabled){dbug.enable()}}if(window.location.href.indexOf("jsdebugCookie=false")>0){dbug.disableCookie()}}Browser.Popup=new Class({Implements:[Options,Events],options:{width:500,height:300,x:50,y:50,toolbar:0,location:0,directories:0,status:0,scrollbars:"yes",resizable:1,name:"popup"},initialize:function(url,options){this.url=url||false;this.setOptions(options);if(this.options.x=="center"){this.options.x=Math.floor((screen.availWidth-this.options.width)/2)}if(this.options.y=="center"){this.options.y=Math.floor((screen.availHeight-this.options.height)/2)}if(this.url){this.openWin()}},openWin:function(url){url=url||this.url;var options="toolbar="+this.options.toolbar+",location="+this.options.location+",directories="+this.options.directories+",status="+this.options.status+",scrollbars="+this.options.scrollbars+",resizable="+this.options.resizable+",width="+this.options.width+",height="+this.options.height+",top="+this.options.y+",left="+this.options.x;this.window=window.open(url,this.options.name,options);if(!this.window){this.window=window.open("",this.options.name,options);this.window.location.href=url}this.focus.delay(100,this);return this},focus:function(){if(this.window){this.window.focus()}else{if(this.focusTries<10){this.focus.delay(100,this)}else{this.blocked=true;this.fireEvent("onBlock")}}return this},focusTries:0,blocked:null,close:function(){this.window.close();return this}});var IconMenu=new Class({Implements:[Options,Events],options:{container:document,ie7ParentObjectFix:"placeholder",bUseIE7Fix:false,images:".iconImgs",captions:".iconCaptions",removeLinks:false,clearLinks:false,useAxis:"x",onFocusDelay:0,initialFocusDelay:250,onBlurDelay:0,length:"auto",iconPadding:1,scrollFxOptions:{duration:1800,transition:"cubic:in:out"},backScrollButtons:"#scrollLeft",forwardScrollButtons:"#scrollRight",onSelect:function(index,img){img.morph({"border-top-color":"#00A0C6","border-left-color":"#00A0C6","border-right-color":"#00A0C6","border-bottom-color":"#00A0C6"})},onDeSelect:function(index,img){img.morph({"border-top-color":"#555","border-left-color":"#555","border-right-color":"#555","border-bottom-color":"#555"})}},imgs:[],selected:[],initialize:function(options){this.setOptions(options);this.container=document.id(this.options.container);if(Browser.name=="ie"&&Browser.version<8&&this.options.bUseIE7Fix){this.ie7ParentObjectFix=document.getElementById(this.options.ie7ParentObjectFix)}var captions=($type(this.options.captions)=="string")?this.container.getElements(this.options.captions):this.options.captions;var imgs=($type(this.options.images)=="string")?this.container.getElements(this.options.images):this.options.images;imgs.each(function(img,index){this.addItem(img,captions[index],null)},this);this.fireEvent("onItemsAdded",this.imgs,50);this.side=(this.options.useAxis=="x")?"left":"top";this.container.setStyle(this.side,this.container.getStyle(this.side).toInt()||0);this.onFocusDelay=this.options.initialFocusDelay;this.setupEvents()},toElement:function(){},bound:{mouseover:{},mouseout:{}},scrollTo:function(index,useFx){useFx=$pick(useFx,true);var currentRange=this.calculateRange();if(index==currentRange.start){return this}var newRange=this.calculateRange(index);if(!newRange.elements.length){return this}if(this.container.getStyle("position")=="static"){this.container.setStyle("position","relative")}if(!this.scrollerFx){this.scrollerFx=new Fx.Tween(this.container,$merge(this.options.scrollFxOptions,{property:this.side,wait:false}))}if(useFx){this.scrollerFx.start(-newRange.elements[0].offset).chain(function(){this.fireEvent("onScroll",[index,newRange])}.bind(this))}else{this.scrollerFx.set(-newRange.elements[0].offset);this.fireEvent("onScroll",[index,newRange])}this.currentOffset=index;return this},pageForward:function(howMany){var range=this.calculateRange();return this.scrollTo(($type(howMany)=="number")?range.start+howMany:range.end)},pageBack:function(howMany){return this.scrollTo(($type(howMany)=="number")?this.currentOffset-howMany:this.calculateRange(this.currentOffset,true).start)},addItem:function(img,caption,where){if(caption){img.store("caption",caption);caption.store("image",img)}where=($defined(where))?where:this.imgs.length;if(this.imgs.contains(img)){this.removeItems([img],true)}this.imgs.splice(where,0,document.id(img));this.setupIconEvents(img,caption);this.fireEvent("onAdd",[img,caption]);return this},removeItems:function(imgs,useFx){var range=this.calculateRange();if(!imgs.length){return this}imgs=$A(imgs);useFx=$pick(useFx,true);var fadeItems=[];var fadeItemImgs=[];var effect={width:0,"border-width":0};var fadeEffects={};var itemsToQuietlyRemove={before:[],beforeImgs:[],after:[],afterImgs:[]};var indexes=[];imgs.each(function(image){var index=this.imgs.indexOf(image);if(index>=range.end){itemsToQuietlyRemove.after.push(image.getParent());itemsToQuietlyRemove.afterImgs.push(image)}else{if(index<range.start){itemsToQuietlyRemove.before.push(image.getParent());itemsToQuietlyRemove.beforeImgs.push(image)}else{fadeItems.push(image.getParent());fadeItemImgs.push(image);fadeEffects[fadeItems.length-1]=$unlink(effect)}}this.selected.erase(image);indexes.push(index)},this);this.imgs=this.imgs.filter(function(img,index){return !indexes.contains(index)});var removed=[];if(itemsToQuietlyRemove.before.length){var scrollTo=this.imgs.indexOf(range.elements[0].image);itemsToQuietlyRemove.before.each(function(el,index){this.fireEvent("onRemoveItem",[el]);var img=itemsToQuietlyRemove.beforeImgs[index];removed.push(img);try{el.dispose()}catch(e){dbug.log("before: error removing element %o, %o",el,e)}},this);this.scrollTo(scrollTo,false)}itemsToQuietlyRemove.after.each(function(el,index){this.fireEvent("onRemoveItem",[el]);removed.push(itemsToQuietlyRemove.afterImgs[index]);try{el.dispose()}catch(e){dbug.log("after: error removing element %o, %o",el,e)}});function clean(range,additionalItems){var items=[];fadeItems.each(function(el,index){this.fireEvent("onRemoveItem",[el]);items.push(fadeItemImgs[index]);try{el.dispose()}catch(e){dbug.log("fade: error removing element %o, %o",el,e)}},this);items.combine(additionalItems);this.fireEvent("onRemoveItems",[items]);range=this.calculateRange();if(range.elements==0&&range.start>0){this.pageBack()}if(!this.imgs.length){this.fireEvent("onEmpty")}}if(useFx){new Fx.Elements(fadeItems).start(fadeEffects).chain(clean.bind(this,[range,removed]))}else{clean.apply(this,[range,removed])}return this},removeSelected:function(useFx){this.removeItems(this.selected,useFx);return this},empty:function(suppressEvent){var effect={};var items=[];this.imgs.each(function(img,index){items.push(img.getParent());effect[index]={opacity:0}});new Fx.Elements(items).start(effect).chain(function(){this.removeItems(this.imgs,false);if(!suppressEvent){this.fireEvent("onEmpty")}}.bind(this));return this},selectItem:function(index,select){var img=this.imgs[index];if($defined(select)){if(select){img.addClass("selected")}else{img.removeClass("selected")}}else{img.toggleClass("selected")}if(img.hasClass("selected")){this.selected.push(img);this.fireEvent("select",[index,img])}else{this.selected.erase(img);this.fireEvent("onDeSelect",[index,img])}return this},getDefaultWidth:function(){if($type(this.options.length)=="number"){return this.options.length}var container=document.id(this.options.length);if(!container){container=this.container.getParent()}return container.getSize()[this.options.useAxis]},getIE7OffsetLeft:function(elementID){var offsetLeft=0;var tempElement=document.getElementById(elementID);while(tempElement.parentNode){offsetLeft+=(tempElement.offsetLeft)?tempElement.offsetLeft:0;if(tempElement==document.body){break}tempElement=tempElement.parentNode}return offsetLeft},getIconPositions:function(){var offsets=[];var cumulative=0;var prev;var theSize;var ie7PreviousOffset;var ie7OffsetLeft=0;this.imgs.each(function(img,index){var parent=img.getParent();if(Browser.name=="ie"&&Browser.version<8&&this.options.bUseIE7Fix){ie7OffsetLeft=this.getIE7OffsetLeft(img.id);cumulative+=(ie7PreviousOffset)?ie7OffsetLeft-ie7PreviousOffset:0;ie7PreviousOffset=ie7OffsetLeft;theSize=0}else{cumulative+=(prev)?img["offset"+this.side.capitalize()]-prev["offset"+this.side.capitalize()]:0;prev=img;theSize=parent.getSize()[this.options.useAxis]}offsets.push({image:img,size:theSize,offset:cumulative,container:parent})},this);return offsets},calculateRange:function(index,fromEnd){if(!this.imgs.length){return{start:0,end:0,elements:[]}}index=$pick(index,this.currentOffset||0);if(index<0){index=0}var length=this.getDefaultWidth();var positions=this.getIconPositions();var referencePoint;if(positions[index]){referencePoint=positions[index].offset}else{var lastIcon=this.imgs.getLast().getParent();var coords=lastIcon.getCoordinates();referencePoint=coords.width+coords.left-lastIcon.getParent().getPosition().x}var range=positions.filter(function(position,i){if(fromEnd){return i<index&&position.offset<referencePoint&&position.offset>=referencePoint-length}else{return i>=index&&position.offset+position.size<=length+positions[index].offset}});return(fromEnd)?{start:index-range.length,end:index,elements:range}:{start:index,end:range.length+index,elements:range}},inRange:function(index){var range=this.calculateRange();return index<range.end&&index>=range.start},setupEvents:function(){document.id(this.options.container).addEvents({mouseleave:function(){if(this.inFocus){this.inFocus=null}this.imgOut(null,true)}.bind(this)});$$(this.options.backScrollButtons).each(function(el){el.addEvents({click:this.pageBack.bind(this),mouseover:function(){this.addClass("hover")},mouseout:function(){this.removeClass("hover")}})},this);$$(this.options.forwardScrollButtons).each(function(el){el.addEvents({click:this.pageForward.bind(this),mouseover:function(){this.addClass("hover")},mouseout:function(){this.removeClass("hover")}})},this);$$(this.options.clearLinks).each(function(el){el.addEvent("click",this.empty.bind(this))},this);$$(this.options.removeLinks).each(function(el){el.addEvent("click",this.removeSelected.bind(this))},this)},imgOver:function(img){this.inFocus=img;$clear(this.overTimeout);this.overTimeout=(function(){this.onFocusDelay=this.options.onFocusDelay;if(this.inFocus==img){this.fireEvent("onFocus",[img,this.imgs.indexOf(img)])}}).delay(this.onFocusDelay,this)},imgOut:function(img,force){if(!$defined(img)&&force){img=this.prevFocus||this.imgs[0]}if(this.inFocus==img&&img){this.inFocus=null;$clear(this.outTimeout);this.outTimeout=(function(){this.prevFocus=img;if(this.inFocus!=img||(img==null&&force)){this.fireEvent("onBlur",[img,this.imgs.indexOf(img)])}if(!this.inFocus){this.onFocusDelay=this.options.initialFocusDelay}}).delay(this.options.onBlurDelay,this)}},setupIconEvents:function(img,caption){img.addEvents({click:function(e){if(e.control||e.meta){this.selectItem(this.imgs.indexOf(img));e.stop()}}.bind(this)});img.getParent().addEvents({mouseover:this.imgOver.bind(this,img),mouseout:this.imgOver.bind(this,img)})}});Class.ToElement=new Class({toElement:function(){return this.element}});var ToElement=Class.ToElement;var StyleWriter=new Class({createStyle:function(css,id){window.addEvent("domready",function(){try{if(document.id(id)&&id){return }var style=new Element("style",{id:id||""}).inject($$("head")[0]);if(Browser.Engine.trident){style.styleSheet.cssText=css}else{style.set("text",css)}}catch(e){dbug.log("error: %s",e)}}.bind(this))}});var StickyWin=new Class({Binds:["destroy","hide","togglepin","esc"],Implements:[Options,Events,StyleWriter,Class.ToElement],options:{closeClassName:"closeSticky",pinClassName:"pinSticky",content:"",zIndex:10000,className:"",width:false,height:false,timeout:-1,allowMultipleByClass:true,allowMultiple:true,showNow:true,useIframeShim:true,iframeShimSelector:"",destroyOnClose:false,closeOnClickOut:false,closeOnEsc:false,getWindowManager:function(){return StickyWin.WM}},css:'.SWclearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}.SWclearfix {display: inline-table;} * html .SWclearfix {height: 1%;} .SWclearfix {display: block;}',initialize:function(options){this.options.inject=this.options.inject||{target:document.body,where:"bottom"};this.setOptions(options);this.windowManager=this.options.getWindowManager();this.id=this.options.id||"StickyWin_"+new Date().getTime();this.makeWindow();if(this.windowManager){this.windowManager.add(this)}if(this.options.content){this.setContent(this.options.content)}if(this.options.timeout>0){this.addEvent("onDisplay",function(){this.hide.delay(this.options.timeout,this)}.bind(this))}this.createStyle(this.css,"StickyWinClearFix");if(this.options.closeOnClickOut||this.options.closeOnEsc){this.attach()}if(this.options.destroyOnClose){this.addEvent("close",this.destroy)}if(this.options.showNow){this.show()}},attach:function(attach){var method=$pick(attach,true)?"addEvents":"removeEvents";var events={};if(this.options.closeOnClickOut){events.click=this.esc}if(this.options.closeOnEsc){events.keyup=this.esc}document[method](events)},esc:function(e){if(e.key=="esc"){this.hide()}if(e.type=="click"&&this.element!=e.target&&!this.element.hasChild(e.target)){this.hide()}},makeWindow:function(){this.destroyOthers();if(!document.id(this.id)){this.win=new Element("div",{id:this.id}).addClass(this.options.className).addClass("StickyWinInstance").addClass("SWclearfix").setStyles({display:"none",position:"absolute",zIndex:this.options.zIndex}).inject(this.options.inject.target,this.options.inject.where).store("StickyWin",this)}else{this.win=document.id(this.id)}this.element=this.win;if(this.options.width&&$type(this.options.width.toInt())=="number"){this.win.setStyle("width",this.options.width.toInt())}if(this.options.height&&$type(this.options.height.toInt())=="number"){this.win.setStyle("height",this.options.height.toInt())}return this},show:function(suppressEvent){this.showWin();if(!suppressEvent){this.fireEvent("display")}if(this.options.useIframeShim){this.showIframeShim()}this.visible=true;return this},showWin:function(){if(this.windowManager){this.windowManager.focus(this)}if(!this.positioned){this.position()}this.win.show()},hide:function(suppressEvent){if($type(suppressEvent)=="event"||!suppressEvent){this.fireEvent("close")}this.hideWin();if(this.options.useIframeShim){this.hideIframeShim()}this.visible=false;return this},hideWin:function(){this.win.setStyle("display","none")},destroyOthers:function(){if(!this.options.allowMultipleByClass||!this.options.allowMultiple){$$("div.StickyWinInstance").each(function(sw){if(!this.options.allowMultiple||(!this.options.allowMultipleByClass&&sw.hasClass(this.options.className))){sw.retrieve("StickyWin").destroy()}},this)}},setContent:function(html){if(this.win.getChildren().length>0){this.win.empty()}if($type(html)=="string"){this.win.set("html",html)}else{if(document.id(html)){this.win.adopt(html)}}this.win.getElements("."+this.options.closeClassName).each(function(el){el.addEvent("click",this.hide)},this);this.win.getElements("."+this.options.pinClassName).each(function(el){el.addEvent("click",this.togglepin)},this);return this},position:function(options){this.positioned=true;this.setOptions(options);this.win.position({allowNegative:$pick(this.options.allowNegative,this.options.relativeTo!=document.body),relativeTo:this.options.relativeTo,position:this.options.position,offset:this.options.offset,edge:this.options.edge});if(this.shim){this.shim.position()}return this},pin:function(pin){if(!this.win.pin){dbug.log("you must include element.pin.js!");return this}this.pinned=$pick(pin,true);this.win.pin(pin);return this},unpin:function(){return this.pin(false)},togglepin:function(){return this.pin(!this.pinned)},makeIframeShim:function(){if(!this.shim){var el=(this.options.iframeShimSelector)?this.win.getElement(this.options.iframeShimSelector):this.win;this.shim=new IframeShim(el,{display:false,name:"StickyWinShim"})}},showIframeShim:function(){if(this.options.useIframeShim){this.makeIframeShim();this.shim.show()}},hideIframeShim:function(){if(this.shim){this.shim.hide()}},destroy:function(){if(this.windowManager){this.windowManager.remove(this)}if(this.win){this.win.destroy()}if(this.options.useIframeShim&&this.shim){this.shim.destroy()}if(document.id("modalOverlay")){document.id("modalOverlay").destroy()}this.fireEvent("destroy")}});StickyWin.Stacker=new Class({Implements:[Options,Events],Binds:["click"],instances:[],options:{zIndexBase:9000},initialize:function(options){this.setOptions(options);this.zIndex=this.options.zIndex},add:function(sw){this.instances.include(sw);$(sw).addEvent("mousedown",this.click)},click:function(e){this.instances.each(function(sw){var el=$(sw);if(el==e.target||el.hasChild($(e.target))){this.focus(sw)}},this)},focus:function(instance){if(this.focused==instance){return }this.focused=instance;if(instance){this.instances.erase(instance).push(instance)}this.instances.each(function(current,i){$(current).setStyle("z-index",this.options.zIndexBase+i)},this);this.focused=instance},remove:function(sw){this.instances.erase(sw);$(sw).removeEvent("click",this.click)}});StickyWin.WM=new StickyWin.Stacker();var PopupDetail=new Class({Implements:[Options,Events],visible:false,observed:false,hasData:false,options:{observerAction:"mouseenter",closeOnMouseOut:true,linkPopup:false,data:{},templateOptions:{},useAjax:false,ajaxOptions:{method:"get"},ajaxLink:false,ajaxCache:{},delayOn:100,delayOff:100,stickyWinOptions:{},showNow:false,htmlResponse:false,regExp:/\\?%([^%]+)%/g},initialize:function(html,observer,options){this.setOptions({stickyWinToUse:StickyWin},options);this.observer=document.id(observer);this.html=(document.id(html))?document.id(html).get("html"):html||"";if(this.options.showNow){this.show.delay(this.options.delayOn,this)}this.setUpObservers()},setUpObservers:function(){var opt=this.options;this.observer.addEvent(opt.observerAction,function(){this.observed=true;this.show.delay(opt.delayOn,this)}.bind(this));if((opt.observerAction=="mouseenter"||opt.observerAction=="mouseover")&&this.options.closeOnMouseOut){this.observer.addEvent("mouseleave",function(){this.observed=false;this.hide.delay(opt.delayOff,this)}.bind(this))}return this},parseTemplate:function(string,values){return string.substitute(values,this.options.regExp)},makePopup:function(){if(!this.stickyWin){var opt=this.options;if(opt.htmlResponse){this.content=this.data}else{this.content=this.parseTemplate(this.html,opt.data)}this.stickyWin=new opt.stickyWinToUse($merge(opt.stickyWinOptions,{relativeTo:this.observer,showNow:false,content:this.content,allowMultipleByClass:true}));if(document.id(opt.linkPopup)||$type(opt.linkPopup)=="string"){this.stickyWin.win.setStyle("cursor","pointer").addEvent("click",function(){window.location.href=($type(url)=="string")?url:url.src})}this.stickyWin.win.addEvent("mouseenter",function(){this.observed=true}.bind(this));this.stickyWin.win.addEvent("mouseleave",function(){this.observed=false;if(opt.closeOnMouseOut){this.hide.delay(opt.delayOff,this)}}.bind(this))}return this},getContent:function(){try{new Request($merge(this.options.ajaxOptions,{url:this.options.ajaxLink||this.observer.href,onSuccess:this.show.bind(this)})).send()}catch(e){dbug.log("ajax error on PopupDetail: %s",e)}},show:function(data){var opt=this.options;if(data){this.data=data}if(this.observed&&!this.visible){if(opt.useAjax&&!this.data){var cachedVal=opt.ajaxCache[this.options.ajaxLink]||opt.ajaxCache[this.observer.href];if(cachedVal){this.fireEvent("onPopupShow",this);return this.show(cachedVal)}this.cursorStyle=this.observer.getStyle("cursor");this.observer.setStyle("cursor","wait");this.getContent();return false}else{if(this.cursorStyle){this.observer.setStyle("cursor",this.cursorStyle)}if(opt.useAjax&&!opt.htmlResponse){opt.data=JSON.decode(this.data)}this.makePopup();this.fireEvent("onPopupShow",this);this.stickyWin.show();this.visible=true;return this}}return this},hide:function(){if(!this.observed){this.fireEvent("onPopupHide");if(this.stickyWin){this.stickyWin.hide()}this.visible=false}return this}});var PopupDetailCollection=new Class({Implements:[Options],options:{details:{},links:[],ajaxLinks:[],useCache:true,template:"",popupDetailOptions:{}},cache:{},initialize:function(observers,options){this.observers=$$(observers);this.setOptions(options);var ln=this.options.ajaxLinks.length;if(ln<=0){ln=this.options.details.length}if(this.observers.length!=ln){dbug.log("warning: observers and details are out of sync.")}this.makePopupDetails()},makePopupDetails:function(){this.popupDetailObjs=this.observers.map(function(observer,index){var opt=this.options.popupDetailOptions;var pd=new PopupDetail(this.options.template,observer,$merge(opt,{data:$pick(this.options.details[index],{}),linkItem:$pick(this.options.links[index],$pick(opt.linkItem,false)),ajaxLink:$pick(this.options.ajaxLinks[index],false),ajaxCache:(this.options.useCache)?this.cache:{},useAjax:this.options.ajaxLinks.length>0}));return pd},this)}});var SimpleCarousel=new Class({Implements:[Options,Events],options:{slideInterval:4000,transitionDuration:700,startIndex:0,buttonOnClass:"selected",buttonOffClass:"off",rotateAction:"none",rotateActionDuration:100,autoplay:true},initialize:function(container,slides,buttons,options){this.container=document.id(container);var instance=this.container.retrieve("SimpleCarouselInstance");if(instance){return instance}this.container.store("SimpleCarouselInstance",this);this.setOptions(options);this.container.addClass("hasCarousel");this.slides=$$(slides);this.buttons=$$(buttons);this.createFx();this.showSlide(this.options.startIndex);if(this.options.autoplay){this.autoplay()}if(this.options.rotateAction!="none"){this.setupAction(this.options.rotateAction)}return this},toElement:function(){return this.container},setupAction:function(action){this.buttons.each(function(el,idx){document.id(el).addEvent(action,function(){this.slideFx.setOptions(this.slideFx.options,{duration:this.options.rotateActionDuration});if(this.currentSlide!=idx){this.showSlide(idx)}this.stop()}.bind(this))},this)},createFx:function(){if(!this.slideFx){this.slideFx=new Fx.Elements(this.slides,{duration:this.options.transitionDuration})}this.slides.each(function(slide){slide.setStyle("opacity",0)})},showSlide:function(slideIndex){var action={};this.slides.each(function(slide,index){if(index==slideIndex&&index!=this.currentSlide){if(document.id(this.buttons[index])){document.id(this.buttons[index]).swapClass(this.options.buttonOffClass,this.options.buttonOnClass)}action[index.toString()]={opacity:1}}else{if(document.id(this.buttons[index])){document.id(this.buttons[index]).swapClass(this.options.buttonOnClass,this.options.buttonOffClass)}action[index.toString()]={opacity:0}}},this);this.fireEvent("onShowSlide",slideIndex);this.currentSlide=slideIndex;this.slideFx.start(action);return this},autoplay:function(){this.slideshowInt=this.rotate.periodical(this.options.slideInterval,this);this.fireEvent("onAutoPlay");return this},stop:function(){$clear(this.slideshowInt);this.fireEvent("onStop");return this},rotate:function(){var current=this.currentSlide;var next=(current+1>=this.slides.length)?0:current+1;this.showSlide(next);this.fireEvent("onRotate",next);return this}});var TabSwapper=new Class({Implements:[Options,Events],options:{selectedClass:"tabSelected",mouseoverClass:"tabOver",deselectedClass:"",rearrangeDOM:true,initPanel:0,smooth:false,smoothSize:false,maxSize:null,effectOptions:{duration:500},cookieName:null,cookieDays:999},tabs:[],sections:[],clickers:[],sectionFx:[],initialize:function(options){this.setOptions(options);var prev=this.setup();if(prev){return prev}if(this.options.cookieName&&this.recall()){this.show(this.recall().toInt())}else{this.show(this.options.initPanel)}},setup:function(){var opt=this.options;sections=$$(opt.sections);tabs=$$(opt.tabs);if(tabs[0]&&tabs[0].retrieve("tabSwapper")){return tabs[0].retrieve("tabSwapper")}clickers=$$(opt.clickers);tabs.each(function(tab,index){this.addTab(tab,sections[index],clickers[index],index)},this)},addTab:function(tab,section,clicker,index){tab=document.id(tab);clicker=document.id(clicker);section=document.id(section);if(this.tabs.indexOf(tab)>=0&&tab.retrieve("tabbered")&&this.tabs.indexOf(tab)!=index&&this.options.rearrangeDOM){this.moveTab(this.tabs.indexOf(tab),index);return this}if(!$defined(index)){index=this.tabs.length}if(index>0&&this.tabs[index-1]&&this.options.rearrangeDOM){tab.inject(this.tabs[index-1],"after");section.inject(this.tabs[index-1].retrieve("section"),"after")}this.tabs.splice(index,0,tab);clicker=clicker||tab;tab.addEvents({mouseout:function(){tab.removeClass(this.options.mouseoverClass)}.bind(this),mouseover:function(){tab.addClass(this.options.mouseoverClass)}.bind(this)});clicker.addEvent("click",function(e){e.preventDefault();this.show(index)}.bind(this));tab.store("tabbered",true);tab.store("section",section);tab.store("clicker",clicker);this.hideSection(index);return this},removeTab:function(index){var now=this.tabs[this.now];if(this.now==index){if(index>0){this.show(index-1)}else{if(index<this.tabs.length){this.show(index+1)}}}this.now=this.tabs.indexOf(now);return this},moveTab:function(from,to){var tab=this.tabs[from];var clicker=tab.retrieve("clicker");var section=tab.retrieve("section");var toTab=this.tabs[to];var toClicker=toTab.retrieve("clicker");var toSection=toTab.retrieve("section");this.tabs.erase(tab).splice(to,0,tab);tab.inject(toTab,"before");clicker.inject(toClicker,"before");section.inject(toSection,"before");return this},show:function(i){if(!$chk(this.now)){this.tabs.each(function(tab,idx){if(i!=idx){this.hideSection(idx)}},this)}this.showSection(i).save(i);return this},save:function(index){if(this.options.cookieName){Cookie.write(this.options.cookieName,index,{duration:this.options.cookieDays})}return this},recall:function(){return(this.options.cookieName)?$pick(Cookie.read(this.options.cookieName),false):false},hideSection:function(idx){var tab=this.tabs[idx];if(!tab){return this}var sect=tab.retrieve("section");if(!sect){return this}if(sect.getStyle("display")!="none"){this.lastHeight=sect.getSize().y;sect.setStyle("display","none");tab.swapClass(this.options.selectedClass,this.options.deselectedClass);this.fireEvent("onBackground",[idx,sect,tab])}return this},showSection:function(idx){var tab=this.tabs[idx];if(!tab){return this}var sect=tab.retrieve("section");if(!sect){return this}var smoothOk=this.options.smooth&&!Browser.Engine.trident4;if(this.now!=idx){if(!tab.retrieve("tabFx")){tab.store("tabFx",new Fx.Morph(sect,this.options.effectOptions))}var overflow=sect.getStyle("overflow");var start={display:"block",overflow:"hidden"};if(smoothOk){start.opacity=0}var effect=false;if(smoothOk){effect={opacity:1}}else{if(sect.getStyle("opacity").toInt()<1){sect.setStyle("opacity",1);if(!this.options.smoothSize){this.fireEvent("onActiveAfterFx",[idx,sect,tab])}}}if(this.options.smoothSize){var size=sect.getDimensions().height;if($chk(this.options.maxSize)&&this.options.maxSize<size){size=this.options.maxSize}if(!effect){effect={}}effect.height=size}if($chk(this.now)){this.hideSection(this.now)}if(this.options.smoothSize&&this.lastHeight){start.height=this.lastHeight}sect.setStyles(start);if(effect){tab.retrieve("tabFx").start(effect).chain(function(){this.fireEvent("onActiveAfterFx",[idx,sect,tab]);sect.setStyles({height:this.options.maxSize==effect.height?this.options.maxSize:"auto",overflow:overflow});sect.getElements("input, textarea").setStyle("opacity",1)}.bind(this))}this.now=idx;this.fireEvent("onActive",[idx,sect,tab])}tab.swapClass(this.options.deselectedClass,this.options.selectedClass);return this}});
