;(function($){if(!$.fn.jqDock){var h=function(){return{version:1.2,defaults:{size:36,distance:54,coefficient:1.5,duration:500,align:'bottom',labels:false,source:false,loader:null},useJqLoader:$.browser.opera||$.browser.safari,shrinkInterval:100,docks:[],X:0,Y:0,verthorz:{v:{wh:'height',xy:'Y',tl:'top',lead:'Top',trail:'Bottom',act:'ActualInv'},h:{wh:'width',xy:'X',tl:'left',lead:'Left',trail:'Right',act:'Actual'}},elementCss:{position:'relative',borderWidth:0,borderStyle:'none',verticalAlign:'top'},vanillaDiv:'<div style="position:relative;margin:0px;padding:0px;border:0px none;background-color:transparent;">',initDock:function(a){var b=this,Dock=this.docks[a],op=Dock.Opts,off=0,AI=$('a, img',Dock.Menu),i=0,j,el,wh,acc,upad,opPre95=($.browser.opera&&(1*($.browser.version.match(/^(\d+\.\d+)/)||[0,0])[1])<9.5);this.removeText(Dock.Menu);if(op.orient.vh=='h'){AI.css(this.elementCss);if(opPre95||!$.boxModel){AI.filter('a').css({lineHeight:0,fontSize:'0px'})}else{var c={display:'block'};c['float']='left';AI.filter('img').css(c)}}else{AI.not($('a img',Dock.Menu)).wrap(this.vanillaDiv+'</div>').end().css(this.elementCss).css({display:'block'})}while(i<Dock.Elem.length){el=Dock.Elem[i++];wh=this.keepProportion(el,op.size,{vh:op.orient.inv,inv:op.orient.vh});el.Actual=el.Final=el.Initial=wh[op.vh.wh];el.SizeDiff=el[op.vh.wh]-el.Initial;el.Img.css(wh);el.Img.removeAttr('title').attr({alt:''}).parent('a').removeAttr('title');el.ShrinkStep=Math.floor(el.SizeDiff*this.shrinkInterval/op.duration);Dock[op.vh.inv.wh]=Math.max(Dock[op.vh.inv.wh],op.size+el.Pad[op.vh.inv.lead]+el.Pad[op.vh.inv.trail]);el.Offset=off;el.Centre=el.Offset+el.Pad[op.vh.lead]+(el.Initial/2);off+=el.Initial+el.Pad[op.vh.lead]+el.Pad[op.vh.trail]}i=0;while(i<Dock.Elem.length){el=Dock.Elem[i++];acc=0;upad=el.Pad[op.vh.lead]+el.Pad[op.vh.trail];Dock.Spread+=el.Initial+upad;this.setSizes(a,el.Centre);j=Dock.Elem.length;while(j){acc+=Dock.Elem[--j].Final+upad}Dock[op.vh.wh]=Math.max(Dock[op.vh.wh],acc)}while(i){el=Dock.Elem[--i];el.Final=el.Initial}var d=[this.vanillaDiv,'<div class="jqDock" style="position:absolute;top:0px;left:0px;padding:0px;','margin:0px;overflow:visible;height:',Dock.height,'px;width:',Dock.width,'px;"></div></div>'].join('');Dock.Yard=$(Dock.Menu).wrapInner(d).find('div.jqDock');$.each([op.vh.lead,op.vh.trail],function(n,v){Dock.Borders[v]=b.asNumber(Dock.Yard.css('border'+v+'Width'))});if(Dock.Borders[op.vh.lead]){Dock.Yard.css(op.vh.tl,Math.ceil(Dock.Borders[op.vh.lead]/2))}while(i<Dock.Elem.length){el=Dock.Elem[i];this.changeSize(a,i,el.Final,true);el.Img.addClass('jqDockMouse'+a+'_'+(i++))}$(Dock.Menu).show();if(Dock.Opts.labels){$.each(Dock.Elem,function(i){b.setLabel(a,this.Label)});Dock.Label.hide()}Dock.Yard.bind('mouseover mouseout mousemove',function(e){b.mouseHandler(e)})},altImage:function(){var a=$(this).attr('alt');return(a&&a.match(/\.(gif|jpg|jpeg|png)$/i))?a:false},removeText:function(a){var i=a.childNodes.length,j;while(i){j=a.childNodes[--i];if(j.childNodes&&j.childNodes.length){this.removeText(j)}else if(j.nodeType==3){a.removeChild(j)}}},asNumber:function(x){var r=parseInt(x,10);return isNaN(r)?0:r},keepProportion:function(a,b,c){var r={},vh=this.verthorz[c.vh],inv=this.verthorz[c.inv];r[vh.wh]=b;r[inv.wh]=Math.round(b*a[inv.wh]/a[vh.wh]);return r},deltaXY:function(a){var b=this.docks[a];if(b.Current!==false){var c=b.Opts,el=b.Elem[b.Current],p=el.Pad[c.vh.lead]+el.Pad[c.vh.trail],off=el.Img.offset();b.Delta=Math.floor((this[c.vh.xy]-off[c.vh.tl])*(p+el.Initial)/(p+el.Actual))+el.Offset;this.doLabel(a,off)}},setLabel:function(b,c){var d=this.docks[b],ME=this,pad={};if(!d.Label){d.Label=$('<div class="jqDockLabel jqDockMouse'+b+'_00 jqDockLabelImage" style="position:absolute;margin:0px;"></div>').hide().bind('click',function(){d.Elem[d.Current].Img.trigger('click')}).appendTo(d.Yard)}if(c.txt){d.Label.text(c.txt);$.each(['Top','Right','Bottom','Left'],function(n,v){pad[v]=ME.asNumber(d.Label.css('padding'+v))});$.each(this.verthorz,function(a,o){c[o.wh]=d.Label[o.wh]();c[o.wh+'Pad']=pad[o.lead]+pad[o.trail]})}},doLabel:function(a,b){var c=this.docks[a];if(c.Opts.labels&&c.Current!==false){var d=c.Elem[c.Current],L=d.Label,op=c.Opts,what=typeof b=='string'?b:'move';switch(what){case'show':case'hide':c.Label[L.txt?what:'hide']();break;case'change':c.Label[0].className=c.Label[0].className.replace(/(jqDockLabel)(Link|Image)/,'$1'+(d.Linked?'Link':'Image'));c.Label.text(L.txt).css({width:L.width,height:L.height}).hide();break;default:var e=c.Yard.offset(),css={top:b.top-e.top,left:b.left-e.left},splt=op.labels.split('');if(splt[0]=='m'){css.top+=Math.floor((d[op.vh.inv.act]-L.height-L.heightPad)/2)}else if(splt[0]=='b'){css.top+=d[op.vh.inv.act]+d.Pad.Top+d.Pad.Bottom-L.height-L.heightPad}if(splt[1]=='c'){css.left+=Math.floor((d[op.vh.act]-L.width-L.widthPad)/2)}else if(splt[1]=='r'){css.left+=d[op.vh.act]+d.Pad.Left+d.Pad.Right-L.width-L.widthPad}c.Label.css(css)}}},mouseHandler:function(e){var r=null,t=e.target.className.match(/jqDockMouse(\d+)_(\d+)/),rt=!!(e.relatedTarget)&&e.relatedTarget.tagName!==undefined;if(t){r=false;var a=1*t[1],Dock=this.docks[a],idx=t[2]=='00'?Dock.Current:1*t[2];this.X=e.pageX;this.Y=e.pageY;if(e.type=='mousemove'){if(idx==Dock.Current){this.deltaXY(a);if(Dock.OnDock&&Dock.Expanded){this.setSizes(a);this.factorSizes(a)}}}else{var b=null;if(e.relatedTarget==null||e.relatedTarget.nodeName==null||e.relatedTarget.nodeName=="svg"){b=null}else{b=e.relatedTarget.className.match(/jqDockMouse(\d+)_(\d+)/)}var c=rt&&b;if(e.type=='mouseover'&&(!Dock.OnDock||idx!==Dock.Current)){Dock.Current=idx;this.doLabel(a,'change');this.deltaXY(a);if(Dock.Expanded){this.doLabel(a,'show')}if(rt&&(!c||c[1]!=a)){Dock.Timestamp=(new Date()).getTime();this.setSizes(a);Dock.OnDock=true;this.overDock(a)}}else{if(rt&&e.type=='mouseout'){if(!c||c[1]!=a){Dock.OnDock=false;this.doLabel(a,'hide');var i=Dock.Elem.length;while((i--)){Dock.Elem[i].Final=Dock.Elem[i].Intial}this.offDock(a)}}}}}return r},overDock:function(a){var b=this.docks[a];if(b.OnDock){var c=this,el=b.Elem,i=el.length;while((i--)&&!(el[i].Actual<el[i].Final)){}if(i<0){b.Expanded=true;this.deltaXY(a);this.doLabel(a,'show')}else{this.setSizes(a);this.factorSizes(a);setTimeout(function(){c.overDock(a)},60)}}},offDock:function(a){var b=this.docks[a];if(!b.OnDock){var c=this,done=true,i=b.Elem.length,el,sz;while(i){el=b.Elem[--i];if(el.Actual>el.Initial){sz=el.Actual-el.ShrinkStep;if(sz>el.Initial){done=false}else{sz=el.Initial}this.changeSize(a,i,sz)}}this.deltaXY(a);if(done){while(i<b.Elem.length){el=b.Elem[i++];el.Actual=el.Final=el.Initial}b.Current=b.Expanded=false}else{setTimeout(function(){c.offDock(a)},this.shrinkInterval)}}},setSizes:function(a,b){var c=this.docks[a],op=c.Opts,i=c.Elem.length,el,sz;b=b||c.Delta;while(i){el=c.Elem[--i];sz=Math.floor(el.SizeDiff*Math.pow(Math.abs(b-el.Centre),op.coefficient)/op.attenuation);el.Final=(sz<el.SizeDiff?el[op.vh.wh]-sz:el.Initial)}},factorSizes:function(a){var b=this.docks[a],op=b.Opts,lapse=op.duration+60;if(b.Timestamp){lapse=(new Date()).getTime()-b.Timestamp;if(lapse>=op.duration){b.Timestamp=0}}if(lapse>60){var f=lapse<op.duration?lapse/op.duration:0,i=0,el;while(i<b.Elem.length){el=b.Elem[i];this.changeSize(a,i++,(f?Math.floor(el.Initial+((el.Final-el.Initial)*f)):el.Final))}}},changeSize:function(a,b,c,d){var e=this.docks[a],el=e.Elem[b];if(d||el.Actual!=c){var f=e.Opts,bdr=($.boxModel||f.orient.vh=='v')?0:e.Borders[f.vh.lead]+e.Borders[f.vh.trail];if(el.Source[2]&&!d&&el.Actual==el.Initial){el.Img[0].src=el.Source[1]}if(e.OnDock){this.deltaXY(a)}e.Spread+=c-el.Actual;var g=this.keepProportion(el,c,f.orient),diff=f.size-g[f.vh.inv.wh],m='margin',z=f.vh.inv;switch(f.align){case'bottom':case'right':g[m+z.lead]=diff;break;case'middle':case'center':g[m+z.lead]=(diff+diff%2)/2;g[m+z.trail]=(diff-diff%2)/2;break;case'top':case'left':g[m+z.trail]=diff;break;default:}e.Yard[f.vh.wh](e.Spread+bdr);el.Img.css(g);e.Yard.css('margin'+f.vh.lead,Math.floor(Math.max(0,(e[f.vh.wh]-e.Spread)/2)));el.Actual=c;el.ActualInv=g[f.vh.inv.wh];if(el.Source[2]&&!d&&el.Actual==el.Initial){el.Img[0].src=el.Source[0]}}}}}();$.fn.jqDock=function(f){return this.filter(function(){var i=h.docks.length;while((i--)&&this!=h.docks[i].Menu){}return(i<0)&&($('img',this).length)}).hide().each(function(){var c=h.docks.length;h.docks[c]={Elem:[],Menu:this,OnDock:false,Expanded:false,Timestamp:0,width:0,height:0,Spread:0,Borders:{},Yard:false,Opts:$.extend({},h.defaults,f||{}),Current:false,Delta:0,Loaded:0,Label:false};var d=h.docks[c],op=d.Opts;op.attenuation=Math.pow(op.distance,op.coefficient);op.orient=({left:1,center:1,right:1}[op.align])?{vh:'v',inv:'h'}:{vh:'h',inv:'v'};op.vh=$.extend({},h.verthorz[op.orient.vh],{inv:h.verthorz[op.orient.inv]});op.loader=(op.loader)&&typeof op.loader=='string'&&/^image|jquery$/i.test(op.loader)?op.loader.toLowerCase():'';op.labels=op.labels===true?{top:'bc',left:'tr',right:'tl'}[op.align]||'tc':(typeof op.labels=='string'&&{tl:1,tc:1,tr:1,ml:1,mc:1,mr:1,bl:1,bc:1,br:1}[op.labels]?op.labels:false);$('img',this).each(function(n){var a=$(this),s0=a.attr('src'),s1=(op.source?op.source.call(a[0],n):false)||h.altImage.call(this)||s0,tx=op.labels?a.attr('title')||a.parent('a').attr('title')||'':'';d.Elem[n]={Img:a,Source:[s0,s1,!(s0==s1)],Label:{txt:tx,width:0,height:0,widthPad:0,heightPad:0},Initial:0,Actual:0,ActualInv:0,Final:0,Offset:0,Centre:0,Pad:{},Linked:!!a.parent('a').length,width:0,height:0};$.each(['Top','Right','Bottom','Left'],function(i,v){d.Elem[n].Pad[v]=h.asNumber(a.css('padding'+v))})});var e=(!op.loader&&h.useJqLoader)||op.loader=='jquery';$.each(d.Elem,function(i){var a=this,iLoaded=function(){a.height=this.height;a.width=this.width;if(++d.Loaded>=d.Elem.length){setTimeout(function(){h.initDock(c)},0)}};if(e){$('<img />').bind('load',iLoaded).attr({src:this.Source[1]})}else{var b=new Image();b.onload=function(){iLoaded.call(this);b.onload=function(){}};b.src=this.Source[1]}})}).end()};$.jqDock=function(x){return h[x]?h[x]:null}}})(jQuery);