var Waiter=new Class({options:{baseHref:'images/',containerProps:{styles:{position:'absolute',display:'none',opacity:0,zIndex:999}},msg:false,msgProps:{styles:{textAlign:'center',fontWeight:'bold'}},img:{src:'waiter.gif',styles:{width:32,height:32}},imgPosition:{},layer:{styles:{width:0,height:0,position:'absolute',zIndex:998,display:'none',opacity:0.9,background:'#d1ccb9'},'class':'waitingDiv'},fxOptions:{}},initialize:function(target,options){this.target=$(target||document.body);this.setOptions(options);this.waiterMsg=new Element('div',this.options.containerProps).injectInside(document.body).addClass("waiterDiv");if(this.options.msg)this.waiterMsg.adopt(new Element('div',this.options.msgProps).appendText(this.options.msg));this.waiterImg=$(this.options.img.id)||new Element('img',$merge(this.options.img,{src:this.options.baseHref+this.options.img.src})).injectInside(this.waiterMsg).addClass('waiterImg');this.waiterDiv=$(this.options.layer.id)||new Element('div',this.options.layer).injectInside(document.body);this.waiterFx=this.waiterFx||new Fx.Elements($$(this.waiterMsg,this.waiterDiv),this.options.fxOptions);},toggle:function(element,show){if(this.inTransit){this.chain(this.toggle.bind(this,[element,show]));return this;} element=$(element)||$(this.active)||$(this.target);if(!$(element))return this;if(this.active&&element!=this.active)return this.stop().chain(this.start.bind(this,element));if((!this.active||show)&&show!==false)this.start(element);else if(this.active&&!show)this.stop();return this;},start:function(element){if(this.inTransit){this.chain(this.start.bind(this,element));return this;} this.inTransit=true;element=$(element)||$(this.target);var start=function(){var dim=element.getComputedSize();this.active=element;this.waiterMsg.setPosition($merge(this.options.imgPosition,{relativeTo:element})).show();this.waiterDiv.setStyles({width:dim.totalWidth,height:dim.totalHeight,display:'block'}).setPosition({relativeTo:element,position:'upperLeft'});this.waiterFx.start({0:{opacity:[1]},1:{opacity:[this.options.layer.styles.opacity]}}).chain(function(){this.inTransit=false;this.fireEvent('onShow',element);this.callChain();}.bind(this));}.bind(this);if(this.active&&this.active!=element)this.stop(start);else start();return this;},stop:function(callback){if(this.inTransit){this.chain(this.stop.bind(this,callback));return this;} if(!this.active)return this;this.inTransit=true;this.waiterFx.start({0:{opacity:[0]},1:{opacity:[0]}}).chain(function(){this.inTransit=false;this.active=null;this.waiterDiv.hide();this.waiterMsg.hide();this.fireEvent('onHide',this.active);this.callChain();if($type(callback)=="function")callback.attempt();}.bind(this));return this;}});Waiter.implement(new Options,new Events,new Chain);if(typeof Ajax!="undefined"){var Ajax=Ajax.extend({options:{useWaiter:false,waiterOptions:{}},initialize:function(url,options){this.parent(url,options);if(this.options.useWaiter&&this.options.update){this.waiter=new Waiter(this.options.update,this.options.waiterOptions);this.addEvent('onComplete',this.waiter.stop.bind(this.waiter));this.addEvent('onFailure',this.waiter.stop.bind(this.waiter));}},request:function(data){if(this.waiter)this.waiter.start().chain(this.parent.bind(this,data));else this.parent(data);return this;}});} Element.extend({getDimensions:function(options){options=$merge({computeSize:false},options);var dim={};function getSize(el,options){if(options.computeSize)dim=el.getComputedSize(options);else{dim.width=el.getSize().size.x;dim.height=el.getSize().size.y;} return dim;} try{dim=getSize(this,options);}catch(e){} if(this.getStyle('display')=='none'){var before={};['visibility','display','position'].each(function(style){before[style]=this.style[style]||'';},this);this.setStyles({visibility:'hidden',display:'block',position:'absolute'});dim=getSize(this,options);this.setStyles(before);} return $merge(dim,{x:dim.width,y:dim.height});},getComputedSize:function(options){options=$merge({styles:['padding','border'],plains:{height:['top','bottom'],width:['left','right']},mode:'both'},options);var size={width:0,height:0};switch(options.mode){case'vertical':delete size.width;delete options.plains.width;break;case'horizontal':delete size.height;delete options.plains.height;break;} var getStyles=[];$each(options.plains,function(plain,key){plain.each(function(edge){options.styles.each(function(style){getStyles.push((style=="border")?style+'-'+edge+'-'+'width':style+'-'+edge);});});});var styles=this.getStyles.apply(this,getStyles);var subtracted=[];$each(options.plains,function(plain,key){size['total'+key.capitalize()]=0;size['computed'+key.capitalize()]=0;plain.each(function(edge){size['computed'+edge.capitalize()]=0;getStyles.each(function(style,i){if(style.test(edge)){styles[style]=styles[style].toInt();if(isNaN(styles[style]))styles[style]=0;size['total'+key.capitalize()]=size['total'+key.capitalize()]+styles[style];size['computed'+edge.capitalize()]=size['computed'+edge.capitalize()]+styles[style];} if(style.test(edge)&&key!=style&&(style.test('border')||style.test('padding'))&&!subtracted.test(style)){subtracted.push(style);size['computed'+key.capitalize()]=size['computed'+key.capitalize()]-styles[style];}});});});if($chk(size.width)){size.width=size.width+this.offsetWidth+size.computedWidth;size.totalWidth=size.width+size.totalWidth;delete size.computedWidth;} if($chk(size.height)){size.height=size.height+this.offsetHeight+size.computedHeight;size.totalHeight=size.height+size.totalHeight;delete size.computedHeight;} return $merge(styles,size);}});Element.extend({setPosition:function(options){options=$merge({relativeTo:document.body,position:{x:'center',y:'center'},edge:false,offset:{x:0,y:0},returnPos:false,relFixedPosition:false,ignoreMargins:false,overflown:[]},options);var parentOffset={x:0,y:0};var parentPositioned=false;if(this.getParent()!=document.body){var parent=this.getParent();while(parent!=document.body&&parent.getStyle('position')=="static"){parent=parent.getParent();} if(parent!=document.body){parentOffset=parent.getPosition();parentPositioned=true;} options.offset.x=options.offset.x-parentOffset.x;options.offset.y=options.offset.y-parentOffset.y;} function fixValue(option){if($type(option)!="string")return option;option=option.toLowerCase();var val={};if(option.test('left'))val.x='left';else if(option.test('right'))val.x='right';else val.x='center';if(option.test('upper')||option.test('top'))val.y='top';else if(option.test('bottom'))val.y='bottom';else val.y='center';return val;};options.edge=fixValue(options.edge);options.position=fixValue(options.position);if(!options.edge){if(options.position.x=='center'&&options.position.y=='center')options.edge={x:'center',y:'center'};else options.edge={x:'left',y:'top'};} this.setStyle('position','absolute');var rel=$(options.relativeTo)||document.body;if(window.opera){var top=(rel==document.body)?window.getScrollTop():rel.getTop();var left=(rel==document.body)?window.getScrollLeft():rel.getLeft();}else{var top=(rel==document.body)?window.getScrollTop():rel.getTop(options.overflown);var left=(rel==document.body)?window.getScrollLeft():rel.getLeft(options.overflown);} if(top<0)top=0;if(left<0)left=0;var dim=this.getDimensions({computeSize:true,styles:['padding','border','margin']});if(options.ignoreMargins){options.offset.x+=((options.edge&&options.edge.x=="right")?dim['margin-right']:-dim['margin-left']);options.offset.y+=((options.edge&&options.edge.y=="bottom")?dim['margin-bottom']:-dim['margin-top']);} var pos={};var prefY=options.offset.y.toInt();var prefX=options.offset.x.toInt();switch(options.position.x){case'left':pos.x=left+prefX;break;case'right':pos.x=left+prefX+rel.offsetWidth;break;default:pos.x=left+(((rel==document.body)?window.getWidth():rel.offsetWidth)/2)+prefX;break;};switch(options.position.y){case'top':pos.y=top+prefY;break;case'bottom':pos.y=top+prefY+rel.offsetHeight;break;default:pos.y=top+(((rel==document.body)?window.getHeight():rel.offsetHeight)/2)+prefY;break;};if(options.edge){var edgeOffset={};switch(options.edge.x){case'left':edgeOffset.x=0;break;case'right':edgeOffset.x=-dim.x-dim.computedRight-dim.computedLeft;break;default:edgeOffset.x=-(dim.x/2);break;};switch(options.edge.y){case'top':edgeOffset.y=0;break;case'bottom':edgeOffset.y=-dim.y-dim.computedTop-dim.computedBottom;break;default:edgeOffset.y=-(dim.y/2);break;};pos.x=pos.x+edgeOffset.x;pos.y=pos.y+edgeOffset.y;} pos={left:((pos.x>=0||parentPositioned)?pos.x:0).toInt()+'px',top:((pos.y>=0||parentPositioned)?pos.y:0).toInt()+'px'};if(rel.getStyle('position')=="fixed"||options.relFixedPosition){pos.top=pos.top.toInt()+window.getScrollTop()+'px';pos.left=pos.left.toInt()+window.getScrollLeft()+'px';} if(options.returnPos)return pos;if(options.smoothMove)new Fx.SmoothMove(this,options).start();else this.setStyles(pos);return this;}});Element.extend({isVisible:function(){return this.getStyle('display')!='none';},toggle:function(){return this[this.isVisible()?'hide':'show']();},hide:function(){this.originalDisplay=this.getStyle('display');this.setStyle('display','none');return this;},show:function(display){this.originalDisplay=(this.originalDisplay=="none")?'block':this.originalDisplay;this.setStyle('display',(display||this.originalDisplay||'block'));return this;},tidy:function(){try{if(this.getValue().tidy())this.value=this.getValue().tidy();}catch(e){dbug.log('element.tidy error: %o',e);}},findParent:function(collection){return $$(collection).filter(function(el){return el.hasChild(this);},this)[0];},fxOpacityOk:function(){if(!window.ie6)return true;var isColor=false;try{if(new Color(this.getStyle('backgroundColor')))isColor=true;}catch(e){} return isColor;}});Element.visible=Element.isVisible;if(!Element.empty){Element.extend({empty:function(){return this.setHTML('');}});} var $S=$$;