/*MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.||Clientcide Copyright (c) 2006-2008, http://www.clientcide.com/wiki/cnet-libraries#license*/

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){if(dbug.firebug){try{dbug.enabled=true;dbug.log=function(){(console.debug||console.log).apply(console,arguments)};dbug.time=function(){console.time.apply(console,arguments)};dbug.timeEnd=function(){console.timeEnd.apply(console,arguments)};if(!silent)dbug.log('enabling dbug');for(var i=0;i<dbug.logged.length;i++){dbug.log.apply(console,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=typeof console!="undefined";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&&console[methodList[i]])?console[methodList[i]]:defaultFunction}};set(debugMethods,dbug.log);set(otherMethods,function(){})})();if(typeof console!="undefined"&&console.warn){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()}var IframeShim=new Class({Implements:[Options,Events],options:{name:'',className:'iframeShim',display:false,zindex:null,margin:0,offset:{x:0,y:0},browsers:(Browser.Engine.trident4||(Browser.Engine.gecko&&!Browser.Engine.gecko19&&Browser.Platform.mac))},initialize:function(element,options){this.setOptions(options);if(this.options.offset&&this.options.offset.top)this.options.offset.y=this.options.offset.top;if(this.options.offset&&this.options.offset.left)this.options.offset.x=this.options.offset.left;this.element=$(element);this.makeShim();return},makeShim:function(){this.shim=new Element('iframe');this.id=this.options.name||new Date().getTime()+"_shim";if(this.element.getStyle('z-Index').toInt()<1||isNaN(this.element.getStyle('z-Index').toInt()))this.element.setStyle('z-Index',5);var z=this.element.getStyle('z-Index')-1;if($chk(this.options.zindex)&&this.element.getStyle('z-Index').toInt()>this.options.zindex)z=this.options.zindex;this.shim.setStyles({'position':'absolute','zIndex':z,'border':'none','filter':'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'}).setProperties({'src':'javascript:void(0);','frameborder':'0','scrolling':'no','id':this.id}).addClass(this.options.className);this.element.store('shim',this);var inject=function(){this.shim.inject(this.element,'after');if(this.options.display)this.show();else this.hide();this.fireEvent('onInject')};if(this.options.browsers){if(Browser.Engine.trident&&!IframeShim.ready){window.addEvent('load',inject.bind(this))}else{inject.run(null,this)}}},position:function(shim){if(!this.options.browsers||!IframeShim.ready)return this;var before=this.element.getStyles('display','visibility','position');this.element.setStyles({display:'block',position:'absolute',visibility:'hidden'});var size=this.element.getSize();this.element.setStyles(before);if($type(this.options.margin)){size.x=size.x-(this.options.margin*2);size.y=size.y-(this.options.margin*2);this.options.offset.x+=this.options.margin;this.options.offset.y+=this.options.margin}this.shim.setStyles({'width':size.x,'height':size.y}).setPosition({relativeTo:this.element,offset:this.options.offset});return this},hide:function(){if(this.options.browsers)this.shim.setStyle('display','none');return this},show:function(){if(!this.options.browsers)return this;this.shim.setStyle('display','block');return this.position()},dispose:function(){if(this.options.browsers)this.shim.dispose();return this}});window.addEvent('load',function(){IframeShim.ready=true});new Native({name:'Date',initialize:Date,protect:true});['now','parse','UTC'].each(function(method){Native.genericize(Date,method,true)});Date.$Methods=new Hash();["Date","Day","FullYear","Hours","Milliseconds","Minutes","Month","Seconds","Time","TimezoneOffset","Week","Timezone","GMTOffset","DayOfYear","LastMonth","UTCDate","UTCDay","UTCFullYear","AMPM","UTCHours","UTCMilliseconds","UTCMinutes","UTCMonth","UTCSeconds"].each(function(method){Date.$Methods.set(method.toLowerCase(),method)});$each({ms:"Milliseconds",year:"FullYear",min:"Minutes",mo:"Month",sec:"Seconds",hr:"Hours"},function(value,key){Date.$Methods.set(key,value)});Date.implement({set:function(key,value){key=key.toLowerCase();var m=Date.$Methods;if(m.has(key))this['set'+m.get(key)](value);return this},get:function(key){key=key.toLowerCase();var m=Date.$Methods;if(m.has(key))return this['get'+m.get(key)]();return null},clone:function(){return new Date(this.get('time'))},increment:function(interval,times){return this.multiply(interval,times)},decrement:function(interval,times){return this.multiply(interval,times,false)},multiply:function(interval,times,increment){interval=interval||'day';times=$pick(times,1);increment=$pick(increment,true);var multiplier=increment?1:-1;var month=this.format("%m").toInt()-1;var year=this.format("%Y").toInt();var time=this.get('time');var offset=0;switch(interval){case'year':times.times(function(val){if(Date.isLeapYear(year+val)&&month>1&&multiplier>0)val++;if(Date.isLeapYear(year+val)&&month<=1&&multiplier<0)val--;offset+=Date.$units.year(year+val)});break;case'month':times.times(function(val){if(multiplier<0)val++;var mo=month+(val*multiplier);var year=year;if(mo<0){year--;mo=12+mo}if(mo>11||mo<0){year+=(mo/12).toInt()*multiplier;mo=mo%12}offset+=Date.$units.month(mo,year)});break;case'day':return this.set('date',this.get('date')+(multiplier*times));default:offset=Date.$units[interval]()*times;break}this.set('time',time+(offset*multiplier));return this},isLeapYear:function(){return Date.isLeapYear(this.get('year'))},clearTime:function(){this.set('hr',0);this.set('min',0);this.set('sec',0);this.set('ms',0);return this},diff:function(d,resolution){resolution=resolution||'day';if($type(d)=='string')d=Date.parse(d);switch(resolution){case'year':return d.format("%Y").toInt()-this.format("%Y").toInt();break;case'month':var months=(d.format("%Y").toInt()-this.format("%Y").toInt())*12;return months+d.format("%m").toInt()-this.format("%m").toInt();break;default:var diff=d.get('time')-this.get('time');if(diff<0&&Date.$units[resolution]()>(-1*(diff)))return 0;else if(diff>=0&&diff<Date.$units[resolution]())return 0;return((d.get('time')-this.get('time'))/Date.$units[resolution]()).round()}},getWeek:function(){var day=(new Date(this.get('year'),0,1)).get('date');return Math.round((this.get('dayofyear')+(day>3?day-4:day+3))/7)},getTimezone:function(){return this.toString().replace(/^.*? ([A-Z]{3}).[0-9]{4}.*$/,'$1').replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,'$1$2$3')},getGMTOffset:function(){var off=this.get('timezoneOffset');return((off>0)?'-':'+')+Math.floor(Math.abs(off)/60).zeroise(2)+(off%60).zeroise(2)},parse:function(str){this.set('time',Date.parse(str));return this},format:function(f){f=f||"%x %X";if(!this.valueOf())return'invalid date';if(Date.$formats[f.toLowerCase()])f=Date.$formats[f.toLowerCase()];var d=this;return f.replace(/\%([aAbBcdHIjmMpSUWwxXyYTZ])/g,function($1,$2){switch($2){case'a':return Date.$days[d.get('day')].substr(0,3);case'A':return Date.$days[d.get('day')];case'b':return Date.$months[d.get('month')].substr(0,3);case'B':return Date.$months[d.get('month')];case'c':return d.toString();case'd':return d.get('date').zeroise(2);case'H':return d.get('hr').zeroise(2);case'I':return((d.get('hr')%12)||12);case'j':return d.get('dayofyear').zeroise(3);case'm':return(d.get('mo')+1).zeroise(2);case'M':return d.get('min').zeroise(2);case'p':return d.get('hr')<12?'AM':'PM';case'S':return d.get('seconds').zeroise(2);case'U':return d.get('week').zeroise(2);case'W':throw new Error('%W is not supported yet');case'w':return d.get('day');case'x':var c=Date.$cultures[Date.$culture];return d.format('%'+c[0].substr(0,1)+c[3]+'%'+c[1].substr(0,1)+c[3]+'%'+c[2].substr(0,1).toUpperCase());case'X':return d.format('%I:%M%p');case'y':return d.get('year').toString().substr(2);case'Y':return d.get('year');case'T':return d.get('GMTOffset');case'Z':return d.get('Timezone');case'%':return'%'}return $2})},setAMPM:function(ampm){ampm=ampm.toUpperCase();if(this.format("%H").toInt()>11&&ampm=="AM")return this.decrement('hour',12);else if(this.format("%H").toInt()<12&&ampm=="PM")return this.increment('hour',12);return this}});Date.prototype.compare=Date.prototype.diff;Date.prototype.strftime=Date.prototype.format;Date.$nativeParse=Date.parse;$extend(Date,{$months:['January','February','March','April','May','June','July','August','September','October','November','December'],$days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],$daysInMonth:function(monthIndex,year){if(Date.isLeapYear(year.toInt())&&monthIndex===1)return 29;return[31,28,31,30,31,30,31,31,30,31,30,31][monthIndex]},$epoch:-1,$era:-2,$units:{ms:function(){return 1},second:function(){return 1000},minute:function(){return 60000},hour:function(){return 3600000},day:function(){return 86400000},week:function(){return 608400000},month:function(monthIndex,year){var d=new Date();return Date.$daysInMonth($pick(monthIndex,d.format("%m").toInt()),$pick(year,d.format("%Y").toInt()))*86400000},year:function(year){year=year||new Date().format("%Y").toInt();return Date.isLeapYear(year.toInt())?31622400000:31536000000}},$formats:{db:'%Y-%m-%d %H:%M:%S',compact:'%Y%m%dT%H%M%S',iso8601:'%Y-%m-%dT%H:%M:%S%T',rfc822:'%a, %d %b %Y %H:%M:%S %Z','short':'%d %b %H:%M','long':'%B %d, %Y %H:%M'},isLeapYear:function(yr){return new Date(yr,1,29).getDate()==29},parseUTC:function(value){var localDate=new Date(value);var utcSeconds=Date.UTC(localDate.get('year'),localDate.get('mo'),localDate.get('date'),localDate.get('hr'),localDate.get('min'),localDate.get('sec'));return new Date(utcSeconds)},parse:function(from){var type=$type(from);if(type=='number')return new Date(from);if(type!='string')return from;if(!from.length)return null;for(var i=0,j=Date.$parsePatterns.length;i<j;i++){var r=Date.$parsePatterns[i].re.exec(from);if(r){try{return Date.$parsePatterns[i].handler(r)}catch(e){dbug.log('date parse error: ',e);return null}}}return new Date(Date.$nativeParse(from))},parseMonth:function(month,num){var ret=-1;switch($type(month)){case'object':ret=Date.$months[month.get('mo')];break;case'number':ret=Date.$months[month-1]||false;if(!ret)throw new Error('Invalid month index value must be between 1 and 12:'+index);break;case'string':var match=Date.$months.filter(function(name){return this.test(name)},new RegExp('^'+month,'i'));if(!match.length)throw new Error('Invalid month string');if(match.length>1)throw new Error('Ambiguous month');ret=match[0]}return(num)?Date.$months.indexOf(ret):ret},parseDay:function(day,num){var ret=-1;switch($type(day)){case'number':ret=Date.$days[day-1]||false;if(!ret)throw new Error('Invalid day index value must be between 1 and 7');break;case'string':var match=Date.$days.filter(function(name){return this.test(name)},new RegExp('^'+day,'i'));if(!match.length)throw new Error('Invalid day string');if(match.length>1)throw new Error('Ambiguous day');ret=match[0]}return(num)?Date.$days.indexOf(ret):ret},fixY2K:function(d){if(!isNaN(d)){var newDate=new Date(d);if(newDate.get('year')<2000&&d.toString().indexOf(newDate.get('year'))<0){newDate.increment('year',100)}return newDate}else return d},$cultures:{'US':['month','date','year','/'],'GB':['date','month','year','/']},$culture:'US',$language:'enUS',$cIndex:function(unit){return Date.$cultures[Date.$culture].indexOf(unit)+1},$parsePatterns:[{re:/^(\d{1,2})[\.\-\/](\d{1,2})[\.\-\/](\d{2,4})$/,handler:function(bits){var d=new Date();var culture=Date.$cultures[Date.$culture];d.set('year',bits[Date.$cIndex('year')]);d.set('month',bits[Date.$cIndex('month')]-1);d.set('date',bits[Date.$cIndex('date')]);return Date.fixY2K(d)}},{re:/^(\d{1,2})[\.\-\/](\d{1,2})[\.\-\/](\d{2,4})\s(\d{1,2}):(\d{1,2})(\w{2})$/,handler:function(bits){var d=new Date();d.set('year',bits[Date.$cIndex('year')]);d.set('month',bits[Date.$cIndex('month')]-1);d.set('date',bits[Date.$cIndex('date')]);d.set('hr',bits[4]);d.set('min',bits[5]);d.set('ampm',bits[6]);return Date.fixY2K(d)}}]});Number.implement({zeroise:function(length){return String(this).zeroise(length)}});String.implement({repeat:function(times){var ret=[];for(var i=0;i<times;i++)ret.push(this);return ret.join('')},zeroise:function(length){return'0'.repeat(length-this.length)+this}});Hash.implement({getFromPath:function(notation){var source=this.getClean();notation.replace(/\[([^\]]+)\]|\.([^.[]+)|[^[.]+/g,function(match){if(!source)return;var prop=arguments[2]||arguments[1]||arguments[0];source=(prop in source)?source[prop]:null;return match});return source},cleanValues:function(method){method=method||$defined;this.each(function(v,k){if(!method(v))this.erase(k)},this);return this}});String.implement({stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'')},parseQuery:function(encodeKeys,encodeValues){encodeKeys=$pick(encodeKeys,true);encodeValues=$pick(encodeValues,true);var vars=this.split(/[&;]/);var rs={};if(vars.length)vars.each(function(val){var keys=val.split('=');if(keys.length&&keys.length==2){rs[(encodeKeys)?encodeURIComponent(keys[0]):keys[0]]=(encodeValues)?encodeURIComponent(keys[1]):keys[1]}});return rs},tidy:function(){var txt=this.toString();$each({"[\xa0\u2002\u2003\u2009]":" ","\xb7":"*","[\u2018\u2019]":"'","[\u201c\u201d]":'"',"\u2026":"...","\u2013":"-","\u2014":"--","\uFFFD":"&raquo;"},function(value,key){txt=txt.replace(new RegExp(key,'g'),value)});return txt},cleanQueryString:function(method){return this.split("&").filter(method||function(set){return $chk(set.split("=")[1])}).join("&")}});Element.implement({expose:function(){if(this.getStyle('display')!='none')return $empty;var before={};var styles={visibility:'hidden',display:'block',position:'absolute'};$each(styles,function(value,style){before[style]=this.style[style]||''},this);this.setStyles(styles);return(function(){this.setStyles(before)}).bind(this)},getDimensions:function(options){options=$merge({computeSize:false},options);var dim={};function getSize(el,options){return(options.computeSize)?el.getComputedSize(options):el.getSize()};if(this.getStyle('display')=='none'){var restore=this.expose();dim=getSize(this,options);restore()}else{try{dim=getSize(this,options)}catch(e){}}return $chk(dim.x)?$extend(dim,{width:dim.x,height:dim.y}):$extend(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.contains(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 $extend(styles,size)}});window.addEvent('domready',function(){var test=new Element('div').setStyles({position:'fixed',top:0,right:0}).inject(document.body);var supported=(test.offsetTop===0);test.dispose();Browser.supportsPositionFixed=supported});Element.implement({pin:function(enable){if(!Browser.loaded)dbug.log('cannot pin '+this+' natively because the dom is not ready');if(this.getStyle('display')=='none'){dbug.log('cannot pin '+this+' because it is hidden');return}if(enable!==false){var p=this.getPosition();if(!this.retrieve('pinned')){var pos={top:(p.y-window.getScroll().y),left:(p.x-window.getScroll().x)};if(Browser.supportsPositionFixed){this.setStyle('position','fixed').setStyles(pos)}else{this.store('pinnedByJS',true);this.setStyles({position:'absolute',top:p.y,left:p.x});this.store('scrollFixer',function(){if(this.retrieve('pinned')){var to={top:(pos.top.toInt()+window.getScroll().y),left:(pos.left.toInt()+window.getScroll().x)};this.setStyles(to)}}.bind(this));window.addEvent('scroll',this.retrieve('scrollFixer'))}this.store('pinned',true)}}else{var op;if(!Browser.Engine.trident){if(this.getParent().getComputedStyle('position')!='static')op=this.getParent();else op=this.getParent().getOffsetParent()}var p=this.getPosition(op);this.store('pinned',false);var reposition;if(Browser.supportsPositionFixed&&!this.retrieve('pinnedByJS')){reposition={top:(p.y+window.getScroll().y),left:(p.x+window.getScroll().x)}}else{this.store('pinnedByJS',false);window.removeEvent('scroll',this.retrieve('scrollFixer'));reposition={top:(p.y),left:(p.x)}}this.setStyles($merge(reposition,{position:'absolute'}))}return this.addClass('isPinned')},unpin:function(){return this.pin(false).removeClass('isPinned')},togglepin:function(){this.pin(!this.retrieve('pinned'))}});Element.implement({setPosition:function(options){$each(options||{},function(v,k){if(!$defined(v))delete options[k]});options=$merge({relativeTo:document.body,position:{x:'center',y:'center'},edge:false,offset:{x:0,y:0},returnPos:false,relFixedPosition:false,ignoreMargins:false},options);var parentOffset={x:0,y:0};var parentPositioned=false;var putItBack=this.expose();var offsetParent=$(this.getOffsetParent());putItBack();if(offsetParent&&offsetParent!=this.getDocument().body){var putItBack=offsetParent.expose();parentOffset=offsetParent.getPosition();putItBack();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;var top=(rel==document.body)?window.getScroll().y:rel.getPosition().y;var left=(rel==document.body)?window.getScroll().x:rel.getPosition().x;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.offset.x-dim['margin-left'];options.offset.y=options.offset.y-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.getSize().x: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.getSize().y: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(),top:((pos.y>=0||parentPositioned)?pos.y:0).toInt()};if(rel.getStyle('position')=="fixed"||options.relFixedPosition){pos.top=pos.top.toInt()+window.getScroll().y;pos.left=pos.left.toInt()+window.getScroll().x}if(options.returnPos)return pos;else this.setStyles(pos);return this}});var StyleWriter=new Class({createStyle:function(css,id){window.addEvent('domready',function(){try{if($(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({Implements:[Options,Events,StyleWriter],options:{closeClassName:'closeSticky',pinClassName:'pinSticky',content:'',zIndex:10000,className:'',width:false,height:false,timeout:-1,allowMultipleByClass:false,allowMultiple:true,showNow:true,useIframeShim:true,iframeShimSelector:''},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={target:document.body,where:'bottom'};this.setOptions(options);this.id=this.options.id||'StickyWin_'+new Date().getTime();this.makeWindow();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))}if(this.options.showNow)this.show();this.createStyle(this.css,'StickyWinClearFix')},toElement:function(){return this.win},makeWindow:function(){this.destroyOthers();if(!$(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=$(this.id);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(){this.fireEvent('onDisplay');this.showWin();if(this.options.useIframeShim)this.showIframeShim();this.visible=true;return this},showWin:function(){this.win.setStyle('display','block');if(!this.positioned)this.position()},hide:function(suppressEvent){if(!suppressEvent)this.fireEvent('onClose');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($(html))this.win.adopt(html);this.win.getElements('.'+this.options.closeClassName).each(function(el){el.addEvent('click',this.hide.bind(this))},this);this.win.getElements('.'+this.options.pinClassName).each(function(el){el.addEvent('click',this.togglepin.bind(this))},this);return this},position:function(){this.positioned=true;this.win.setPosition({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.win)this.win.dispose();if(this.options.useIframeShim&&this.shim)this.shim.dispose();if($('modalOverlay'))$('modalOverlay').dispose()}});StickyWin.ui=function(caption,body,options){options=$extend({width:300,css:"div.DefaultStickyWin div.body{font-family:verdana; font-size:11px; line-height: 13px;}"+"div.DefaultStickyWin div.top_ul{background:url({%baseHref%}full.png) top left no-repeat; height:30px; width:15px; float:left}"+"div.DefaultStickyWin div.top_ur{position:relative; left:0px !important; left:-4px; background:url({%baseHref%}full.png) top right !important; height:30px; margin:0px 0px 0px 15px !important; margin-right:-4px; padding:0px}"+"div.DefaultStickyWin h1.caption{clear: none !important; margin:0px 5px 0px 0px !important; overflow: hidden; padding:0 !important; font-weight:bold; color:#555; font-size:14px !important; position:relative; top:8px !important; left:5px !important; float: left; height: 22px !important;}"+"div.DefaultStickyWin div.middle, div.DefaultStickyWin div.closeBody {background:url({%baseHref%}body.png) top left repeat-y; margin:0px 20px 0px 0px !important;	margin-bottom: -3px; position: relative;	top: 0px !important; top: -3px;}"+"div.DefaultStickyWin div.body{background:url({%baseHref%}body.png) top right repeat-y; padding:8px 30px 8px 0px !important; margin-left:5px !important; position:relative; right:-20px !important;}"+"div.DefaultStickyWin div.bottom{clear:both}"+"div.DefaultStickyWin div.bottom_ll{background:url({%baseHref%}full.png) bottom left no-repeat; width:15px; height:15px; float:left}"+"div.DefaultStickyWin div.bottom_lr{background:url({%baseHref%}full.png) bottom right; position:relative; left:0px !important; left:-4px; margin:0px 0px 0px 15px !important; margin-right:-4px; height:15px}"+"div.DefaultStickyWin div.closeButtons{text-align: center; background:url({%baseHref%}body.png) top right repeat-y; padding: 0px 30px 8px 0px; margin-left:5px; position:relative; right:-20px}"+"div.DefaultStickyWin a.button:hover{background:url({%baseHref%}big_button_over.gif) repeat-x}"+"div.DefaultStickyWin a.button {background:url({%baseHref%}big_button.gif) repeat-x; margin: 2px 8px 2px 8px; padding: 2px 12px; cursor:pointer; border: 1px solid #999 !important; text-decoration:none; color: #000 !important;}"+"div.DefaultStickyWin div.closeButton{width:13px; height:13px; background:url({%baseHref%}closebtn.gif) no-repeat; position: absolute; right: 0px; margin:10px 15px 0px 0px !important; cursor:pointer}"+"div.DefaultStickyWin div.dragHandle {	width: 11px;	height: 25px;	position: relative;	top: 5px;	left: -3px;	cursor: move;	background: url({%baseHref%}drag_corner.gif); float: left;}",cornerHandle:false,cssClass:'',baseHref:'http://www.cnet.com/html/rb/assets/global/stickyWinHTML/',buttons:[]},options);if(options.confirmTxt)options.buttons.push({text:options.confirmTxt,onClick:options.onConfirm||$empty});if(options.closeTxt)options.buttons.push({text:options.closeTxt,onClick:options.onClose||$empty});new StyleWriter().createStyle(options.css.substitute({baseHref:options.baseHref},/\\?\{%([^}]+)%\}/g),'defaultStickyWinStyle');caption=$pick(caption,'%caption%');body=$pick(body,'%body%');var container=new Element('div').setStyle('width',options.width).addClass('DefaultStickyWin');if(options.cssClass)container.addClass(options.cssClass);var h1Caption=new Element('h1').addClass('caption').setStyle('width',(options.width.toInt()-(options.cornerHandle?70:60)));if($(caption))h1Caption.adopt(caption);else h1Caption.set('html',caption);var bodyDiv=new Element('div').addClass('body');if($(body))bodyDiv.adopt(body);else bodyDiv.set('html',body);var top_ur=new Element('div').addClass('top_ur').adopt(new Element('div').addClass('closeButton').addClass('closeSticky')).adopt(h1Caption);if(options.cornerHandle)new Element('div').addClass('dragHandle').inject(top_ur,'top');else h1Caption.addClass('dragHandle');container.adopt(new Element('div').addClass('top').adopt(new Element('div').addClass('top_ul')).adopt(top_ur));container.adopt(new Element('div').addClass('middle').adopt(bodyDiv));if(options.buttons.length>0){var closeButtons=new Element('div').addClass('closeButtons');options.buttons.each(function(button){if(button.properties&&button.properties.className){button.properties['class']=button.properties.className;delete button.properties.className}var properties=$merge({'class':'closeSticky'},button.properties);new Element('a').addEvent('click',button.onClick||$empty).appendText(button.text).inject(closeButtons).setProperties(properties).addClass('button')});container.adopt(new Element('div').addClass('closeBody').adopt(closeButtons))}container.adopt(new Element('div').addClass('bottom').adopt(new Element('div').addClass('bottom_ll')).adopt(new Element('div').addClass('bottom_lr')));return container};var DatePicker=new Class({Implements:[Options,Events,StyleWriter],options:{format:"%x",defaultCss:'div.calendarHolder {height:177px;position: absolute;top: -21px !important;top: -27px;left: -3px;width: 100%;}'+'div.calendarHolder table.cal {margin-right: 15px !important;margin-right: 8px;width: 205px;}'+'div.calendarHolder td {text-align:center;}'+'div.calendarHolder tr.dayRow td {padding: 2px;width: 22px;cursor: pointer;}'+'div.calendarHolder table.datePicker * {font-size:11px;line-height:16px;}'+'div.calendarHolder table.datePicker {margin: 0;padding:0 5px;float: left;}'+'div.calendarHolder table.datePicker table.cal td {cursor:pointer;}'+'div.calendarHolder tr.dateNav {font-weight: bold;height:22px;margin-top:8px;}'+'div.calendarHolder tr.dayNames {height: 23px;}'+'div.calendarHolder tr.dayNames td {color:#666;font-weight:700;border-bottom:1px solid #ddd;}'+'div.calendarHolder table.datePicker tr.dayRow td:hover {background:#ccc;}'+'div.calendarHolder table.datePicker tr.dayRow td {margin: 1px;}'+'div.calendarHolder td.today {color:#bb0904;}'+'div.calendarHolder td.otherMonthDate {border:1px solid #fff;color:#ccc;background:#f3f3f3 !important;margin: 0px !important;}'+'div.calendarHolder td.selectedDate {border: 1px solid #20397b;background:#dcddef;margin: 0px !important;}'+'div.calendarHolder a.leftScroll, div.calendarHolder a.rightScroll {cursor: pointer;}'+'div.datePickerSW div.body {height: 160px !important;height: 149px;}'+'div.datePickerSW .clearfix:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;}'+'div.datePickerSW .clearfix {display: inline-table;}'+'* html div.datePickerSW .clearfix {height: 1%;}'+'div.datePickerSW .clearfix {display: block;}',calendarId:false,stickyWinOptions:{draggable:true,dragOptions:{},position:"bottomLeft",offset:{x:10,y:10},fadeDuration:400},stickyWinUiOptions:{},updateOnBlur:true,additionalShowLinks:[],showOnInputFocus:true,useDefaultCss:true,hideCalendarOnPick:true,weekStartOffset:0},initialize:function(input,options){if($(input))this.inputs=$H({start:$(input)});this.today=new Date();var StickyWinToUse=(typeof StickyWin.Fx=="undefined")?StickyWin:StickyWin.Fx;this.setOptions({stickyWinToUse:StickyWinToUse},options);this.whens=this.whens||['start'];if(!this.calendarId)this.calendarId="popupCalendar"+new Date().getTime();if(this.options.useDefaultCss)this.createStyle(this.options.defaultCss,'datePickerStyle');this.setUpObservers();this.getCalendar();this.formValidatorInterface()},formValidatorInterface:function(){this.inputs.each(function(input){var props;if(input.get('validatorProps')){try{props=JSON.decode(input.get('validatorProps'))}catch(e){}}if(props&&props.dateFormat){dbug.log('using date format specified in validatorProps property of element to play nice with FormValidator');this.setOptions({format:props.dateFormat})}else{if(!props)props={};props.dateFormat=this.options.format;input.set('validatorProps',JSON.encode(props))}},this)},calWidth:260,inputDates:{},selectedDates:{},setUpObservers:function(){this.inputs.each(function(input){if(this.options.showOnInputFocus)input.addEvent('focus',this.show.bind(this));input.addEvent('blur',function(e){if(e){this.selectedDates=this.getDates(null,true);this.fillCalendar(this.selectedDates.start);if(this.options.updateOnBlur)this.updateInput()}}.bind(this))},this);this.options.additionalShowLinks.each(function(lnk){$(lnk).addEvent('click',this.show.bind(this))},this)},getDates:function(dates,getFromInputs){var d={};if(!getFromInputs)dates=dates||this.selectedDates;var getFromInput=function(when){var input=this.inputs.get(when);if(input)d[when]=this.validDate(input.get('value'))}.bind(this);this.whens.each(function(when){switch($type(dates)){case"object":if(dates)d[when]=dates[when]?dates[when]:dates;if(!d[when]&&!d[when].format)getFromInput(when);break;default:getFromInput(when);break}if(!d[when])d[when]=this.selectedDates[when]||new Date()},this);return d},updateInput:function(){var d={};$each(this.getDates(),function(value,key){var input=this.inputs.get(key);if(!input)return;input.set('value',(value)?this.formatDate(value)||"":"")},this);return this},validDate:function(val){if(!$chk(val))return null;var date=Date.parse(val.trim());return isNaN(date)?null:date},formatDate:function(date){return date.format(this.options.format)},getCalendar:function(){if(!this.calendar){var cal=new Element("table",{'id':this.options.calendarId,'border':'0','cellpadding':'0','cellspacing':'0'}).addClass('datePicker');var tbody=new Element('tbody').inject(cal);var rows=[];(8).times(function(i){var row=new Element('tr').inject(tbody);(7).times(function(i){var td=new Element('td').inject(row).set('html','&nbsp;')})});var rows=tbody.getElements('tr');rows[0].addClass('dateNav');rows[1].addClass('dayNames');(6).times(function(i){rows[i+1].addClass('dayRow')});this.rows=rows;var dayCells=rows[1].getElements('td');dayCells.each(function(cell,i){cell.firstChild.data=Date.$days[(i+this.options.weekStartOffset)%7].substring(0,3)},this);[6,5,4,3].each(function(i){rows[0].getElements('td')[i].dispose()});this.prevLnk=rows[0].getElement('td').setStyle('text-align','right');if(!Browser.Engine.trident4)this.prevLnk.adopt(new Element('a').set('html',String.fromCharCode(9668)).addClass('rightScroll'));else this.prevLnk.adopt(new Element('a').set('html','&lt;').addClass('rightScroll'));this.month=rows[0].getElements('td')[1];this.month.set('colspan',5);this.nextLnk=rows[0].getElements('td')[2].setStyle('text-align','left');if(!Browser.Engine.trident4)this.nextLnk.adopt(new Element('a').set('html',String.fromCharCode(9658)).addClass('leftScroll'));else this.nextLnk.adopt(new Element('a').set('html','&gt;').addClass('leftScroll'));cal.addEvent('click',this.clickCalendar.bind(this));this.calendar=cal;this.container=new Element('div').adopt(cal).addClass('calendarHolder');this.content=StickyWin.ui('',this.container,$merge(this.options.stickyWinUiOptions,{cornerHandle:this.options.stickyWinOptions.draggable,width:this.calWidth}));var opts=$merge(this.options.stickyWinOptions,{content:this.content,className:'datePickerSW',allowMultipleByClass:true,showNow:false,relativeTo:this.inputs.get('start')});this.stickyWin=new this.options.stickyWinToUse(opts);var closer=this.content.getElement('div.closeButton');if(closer)closer.setStyle('z-index',this.stickyWin.win.getStyle('z-index').toInt()+2)}return this.calendar},hide:function(){this.stickyWin.hide();this.fireEvent('onHide');return this},show:function(){this.selectedDates={};var dates=this.getDates(null,true);this.whens.each(function(when){this.inputDates[when]=dates[when]?dates[when].clone():dates.start?dates.start.clone():this.today;this.selectedDates[when]=!this.inputDates[when]||isNaN(this.inputDates[when])?this.today:this.inputDates[when].clone();this.getCalendar(when)},this);this.fillCalendar(this.selectedDates.start);this.stickyWin.show();this.fireEvent('onShow');return this},handleScroll:function(e){if(e.target.hasClass('rightScroll')||e.target.hasClass('leftScroll')){var newRef=e.target.hasClass('rightScroll')?this.rows[2].getElement('td').refDate-Date.$units.day():this.rows[7].getElements('td')[6].refDate+Date.$units.day();this.fillCalendar(new Date(newRef));return true}return false},setSelectedDates:function(e,newDate){this.selectedDates.start=newDate},onPick:function(){this.updateSelectors();this.inputs.each(function(input){input.fireEvent("change");input.fireEvent("blur")});this.fireEvent('onPick');if(this.options.hideCalendarOnPick)this.hide()},clickCalendar:function(e){if(this.options.format=="%d/%m/%Y")Date.$culture="GB";if(this.handleScroll(e))return;if(!e.target.firstChild||!e.target.firstChild.data)return;var val=e.target.firstChild.data;if(e.target.refDate){var newDate=Date.parse(e.target.refDate);this.setSelectedDates(e,newDate);this.updateInput();this.onPick()}},fillCalendar:function(date){if($type(date)=="string")date=new Date(date);var startDate=(date)?new Date(date.getTime()):new Date();startDate.setDate(1);startDate.setTime((startDate.getTime()-(Date.$units.day()*startDate.getDay()-1))+(Date.$units.day()*this.options.weekStartOffset));this.rows[0].getElements('td')[1].firstChild.data=Date.$months[date.getMonth()]+" "+date.getFullYear();var atDate=startDate.clone();this.rows.each(function(row,i){if(i<2)return;row.getElements('td').each(function(td){td.firstChild.data=atDate.getDate();td.refDate=atDate.getTime();atDate.setTime(atDate.getTime()+Date.$units.day())},this)},this);this.updateSelectors()},updateSelectors:function(){var atDate;var month=new Date(this.rows[5].getElement('td').refDate).getMonth();this.rows.each(function(row,i){if(i<2)return;row.getElements('td').each(function(td){td.className='';atDate=new Date(td.refDate);if(atDate.format("%x")==this.today.format("%x"))td.addClass('today');this.whens.each(function(when){var date=this.selectedDates[when];if(date&&atDate.format("%x")==date.format("%x")){td.addClass('selectedDate');this.fireEvent('selectedDateMatch',[td,when])}},this);this.fireEvent('rowDateEvaluated',[atDate,td]);if(atDate.getMonth()!=month)td.addClass('otherMonthDate');atDate.setTime(atDate.getTime()+Date.$units.day())},this)},this)}});