(function(T,P){if(!T.jqDock){var R=["Top","Right","Bottom","Left"],f={src:"Source",altsrc:"AltSource"},g=['<div style="position:relative;padding:0;',"margin:0;border:0 none;background-color:transparent;",'">'],p={v:{wh:"height",xy:1,tl:"top",lead:R[0],trail:R[2],act:"TransInv"},h:{wh:"width",xy:0,tl:"left",lead:R[3],trail:R[1],act:"Trans"}},S=[],Q=[0,0],d=function(k){return(k=T(k).attr("alt"))&&k.match(/\.(gif|jpg|jpeg|png)$/i)?k:false},i=function(k){k=parseInt(k,10);return isNaN(k)?0:k},O=function(o){var m=o.Opts.vh,k=0;if(o=o.Current!==false?o.Elem[o.Current]:0){k=o.Pad[m.lead]+o.Pad[m.trail];k=Math.floor((Q[m.xy]-o.Wrap.parent().offset()[m.tl])*(k+o.Initial)/(k+o.Trans))+o.Offset}return k},M=function(r,q,k){var m={},o=p[k.vh].wh;k=p[k.inv].wh;m[o]=q;m[k]=Math.round(q*r[k]/r[o]);return m},e=function(r){var q=r.Opts.labels,k=r.Opts.vh,m={},o;if(q&&r.Current!==false&&/[mc]/.test(q)){q=q.split("");r=r.Elem[r.Current];o=r.Label;if(q[0]=="m"){m.top=Math.floor((r[k.inv.act]-o.height-o.heightPad)/2)}if(q[1]=="c"){m.left=Math.floor((r[k.act]-o.width-o.widthPad)/2)}o.el.css(m)}},L=function(o){for(var m=o.childNodes.length,k;m;){k=o.childNodes[--m];if(k.childNodes&&k.childNodes.length){L(k)}else{k.nodeType==3&&o.removeChild(k)}}},c=function(s,r){var k=s.Opts.labels,m=r.Label,q,o;if(m.txt){m.el.click(function(){r.Img.trigger("click")});if(/[mc]/.test(k)){q={};T.each(R,function(u,t){q[t]=i(m.el.css("padding"+t))});T.each(p,function(u,t){m[t.wh]=m.el[t.wh]();m[t.wh+"Pad"]=q[t.lead]+q[t.trail]})}o=k.split("");k={top:0,left:0,bottom:"auto",right:"auto"};if(o[0]=="b"){k.top="auto";k.bottom=0}if(o[1]=="r"){k.left="auto";k.right=0}m.el.css(k);q=k=o=null}},l=function(t,s){var k=S[t],m=k.Opts,r=k.Elem.length,q,o;for(s=s||O(k);r;){q=k.Elem[--r];o=Math.abs(s-q.Centre);q.Final=o<m.distance?q[m.vh.wh]-Math.floor((q[m.vh.wh]-q.Initial)*Math.pow(o,m.coefficient)/m.attenuation):q.Initial}},N=function(o,m){var k;if(o.Opts.labels&&o.Current!==false){k=o.Elem[o.Current].Label;k.el[k.txt&&m?"show":"hide"]()}},n=function(v,u,w,x){v=S[v];var t=v.Elem[u],r=v.Opts,q=r.vh.inv,o=t.Source!=t.AltSource,k,m,s;if(x||t.Trans!=w){k=T.boxModel||r.orient.vh=="v"?0:v.Borders[r.vh.lead]+v.Borders[r.vh.trail];if(o&&!x&&t.Trans==t.Initial){t.Img[0].src=t.AltSource}v.Spread+=w-t.Trans;m=M(t,w,r.orient);s=r.size-m[q.wh];switch(r.align){case"bottom":case"right":m["margin"+q.lead]=s;break;case"middle":case"center":m["margin"+q.lead]=(s+s%2)/2;m["margin"+q.trail]=(s-s%2)/2;break;default:m["margin"+q.trail]=s}if(w!=t.Trans||x&&!u){v.Yard[r.vh.wh](v.Spread+k)}t.Wrap.css(m);v.Yard.css(r.vh.tl,Math.floor(Math.max(0,(v[r.vh.wh]-v.Spread)/2)));v.OnDock&&e(v);t.Trans=w;t.TransInv=m[q.wh];if(o&&!x&&t.Trans==t.Initial){t.Img[0].src=t.Source}}},b=function(t,s){var k=S[t],m=k.Opts,r=m.duration+m.step,q=0,o;if(k.Timestamp){r=(new Date).getTime()-k.Timestamp;if(r>=m.duration){k.Timestamp=0}}if(r>m.step){for(r=r<m.duration?r/m.duration:0;q<k.Elem.length;){o=k.Elem[q];o=s?r?Math.floor(o.Final-(o.Final-o.Initial)*r):o.Initial:r?Math.floor(o.Initial+(o.Final-o.Initial)*r):o.Final;n(t,q++,o)}if(k.Spread>k[m.vh.wh]){k.Yard.parent()[m.vh.wh](k.Spread+k.Borders[m.vh.lead]+k.Borders[m.vh.trail]);k[m.vh.wh]=k.Spread}}},j=function(q){var o=S[q],k=o.Elem,m=k.length;if(!o.OnDock){for(;m--&&k[m].Trans<=k[m].Initial;){}O(o);if(m<0){for(m=k.length;m--;){k[m].Trans=k[m].Final=k[m].Initial}o.Current=false}else{b(q,true);P.setTimeout(function(){j(q)},o.Opts.step)}}},h=function(q){var o=S[q],k=o.Elem,m=k.length;if(o.OnDock){for(;m--&&k[m].Trans>=k[m].Final;){}if(m<0){o.Expanded=true;N(o,true)}else{l(q);b(q);P.setTimeout(function(){h(q)},o.Opts.step)}}},z=function(r,q,k){var m=S[q],o=m.Elem;switch(r){case"mousemove":if(k!==m.Current){N(m);m.Current=k}e(m);m.Expanded&&N(m,true);if(m.OnDock&&m.Expanded){l(q);b(q)}break;case"mouseenter":m.OnDock=true;m.Current!==false&&m.Current!==k&&N(m);m.Current=k;e(m);m.Expanded&&N(m,true);m.Timestamp=(new Date).getTime();l(q);h(q);break;case"mouseleave":if(m.Inactive){P.clearTimeout(m.Inactive);m.Inactive=null}m.OnDock=m.Expanded=false;N(m);m.Timestamp=(new Date).getTime();for(r=o.length;r--;){o[r].Final=o[r].Trans}j(q);break;default:}},a=function(r){var q=1*(this.id.match(/^jqDock(\d+)$/)||[0,-1])[1],k=q>=0?S[q]:0,m=k?r.target.className.toString().match(/jqDockMouse(\d+)/):0,o=m?1*m[1]:false;if(k){Q=[r.pageX,r.pageY];if(r.type=="mouseleave"){k.OnDock&&z(r.type,q,o)}else{if(k.Opts.inactivity){if(k.Inactive){P.clearTimeout(k.Inactive);k.Inactive=null}k.Inactive=P.setTimeout(function(){z("mouseleave",q,o)},k.Opts.inactivity)}if(r.type=="mousemove"){if(o===false){k.OnDock&&k.Current!==false&&z("mouseleave",q,o)}else{!k.OnDock||k.Current===false?z("mouseenter",q,o):z(r.type,q,o)}}else{o!==false&&!k.OnDock&&z(r.type,q,o)}}}return false};T.jqDock=function(){return{version:1.3,defaults:{size:48,distance:72,coefficient:1.5,duration:300,align:"bottom",labels:false,source:false,loader:null,inactivity:0,fadeIn:0,step:50},useJqLoader:T.browser.opera||T.browser.safari,initDock:function(w){var v=S[w],x=v.Opts,y=x.vh,u=x.orient,s=v.Borders,r=g.join(""),q=0,m=0,o,t,k;L(v.Menu);for(T(v.Menu).children().each(function(C,B){var A=v.Elem[C].Wrap=T(B).wrap(r+r+"</div></div>").parent();u.vh=="h"&&A.parent().css("float","left")}).find("img").andSelf().css({position:"relative",padding:0,margin:0,borderWidth:0,borderStyle:"none",verticalAlign:"top",display:"block",width:"100%",height:"100%"});m<v.Elem.length;){t=v.Elem[m++];k=M(t,x.size,{vh:u.inv,inv:u.vh});t.Trans=t.Final=t.Initial=k[y.wh];t.Wrap.css(k);t.Img.attr({alt:""}).parent("a").andSelf().removeAttr("title");v[y.inv.wh]=Math.max(v[y.inv.wh],x.size+t.Pad[y.inv.lead]+t.Pad[y.inv.trail]);t.Offset=q;t.Centre=q+t.Pad[y.lead]+t.Initial/2;q+=t.Initial+t.Pad[y.lead]+t.Pad[y.trail]}for(m=0;m<v.Elem.length;){t=v.Elem[m++];o=v.Elem.length;k=t.Pad[y.lead]+t.Pad[y.trail];v.Spread+=t.Initial+k;l(w,t.Centre);for(q=0;o;){q+=v.Elem[--o].Final+k}if(q>v[y.wh]){v[y.wh]=q}l(w,t.Offset);for(q=0;o<v.Elem.length;){q+=v.Elem[o++].Final+k}if(q>v[y.wh]){v[y.wh]=q}}for(;m;){t=v.Elem[--m];t.Final=t.Initial}y=[g[0],g[2],'<div id="jqDock',w,'" class="jqDock" style="position:absolute;top:0;left:0;padding:0;margin:0;overflow:visible;height:',v.height,"px;width:",v.width,'px;"></div></div>'].join("");v.Yard=T(v.Menu).wrapInner(y).find("div.jqDock");T.each(R,function(B,A){s[A]=i(v.Yard.css("border"+A+"Width"))});for(v.Yard.parent().addClass("jqDockWrap").width(v.width+s.Left+s.Right).height(v.height+s.Top+s.Bottom);m<v.Elem.length;){t=v.Elem[m];k=t.Wrap.parent();for(o in t.Pad){t.Pad[o]&&k.css("padding"+o,t.Pad[o])}n(w,m,t.Final,true);k.add(t.Img).addClass("jqDockMouse"+m);t.Label.el=T('<div class="jqDockLabel jqDockMouse'+m+" jqDockLabel"+(t.Linked?"Link":"Image")+'" style="position:absolute;margin:0px;">'+t.Label.txt+"</div>").hide().appendTo(t.Img.parent());m+=1}w=function(){x.labels&&T.each(v.Elem,function(){c(v,this)});v.Yard.bind("mouseenter mouseleave mousemove",a)};if(x.fadeIn){T(v.Menu).fadeIn(x.fadeIn,w)}else{T(v.Menu).show();w()}}}}();T.fn.jqDock=function(k){this.length&&!this.not("img").length?this.each(function(u,m){var o=m.className.toString().match(/jqDockMouse(\d+)/),t=o?(T(m).parents("div.jqDock").attr("id")||"").match(/^jqDock(\d+)$/):0,s=0,r,q;k=k||{};if(t){t=1*t[1];o=1*o[1];r=S[t].Elem[o];q=r.Trans==r.Initial;T.each(f,function(v,w){var x;if(k[v]){x=(T.isFunction(k[v])?k[v].call(m,r[w],v):k[v]).toString();if(r[w]!==x){r[w]=x;s=(v=="src"?q:!q)?w:s}}});s&&T(m).attr("src",r[s])}}):this.not(".jqDocked").filter(function(){return !T(this).parents(".jqDocked").length&&!T(this).children().not("img").filter(function(){return T(this).filter("a").children("img").parent().children().length!==1}).length}).hide().addClass("jqDocked").each(function(){var t=S.length,m=function(w){var u=S[w.data.id],v=u.Elem[w.data.idx];v.height=this.height;v.width=this.width;++u.Loaded>=u.Elem.length&&P.setTimeout(function(){T.jqDock.initDock(w.data.id)},0)},o,s,r,q;S[t]={Elem:[],Menu:this,OnDock:false,Expanded:false,Timestamp:0,width:0,height:0,Spread:0,Borders:{},Yard:false,Opts:T.extend({},T.jqDock.defaults,k||{},T.metadata?T(this).metadata():{}),Current:false,Loaded:0,Inactive:null};o=S[t];s=o.Opts;r=!s.loader&&T.jqDock.useJqLoader||s.loader==="jquery";T.each(["size","distance","duration","inactivity","fadeIn","step"],function(v,u){s[u]=i(s[u])});q=s.coefficient*1;s.coefficient=isNaN(q)?1.5:q;s.attenuation=Math.pow(s.distance,s.coefficient);s.orient={left:1,center:1,right:1}[s.align]?{vh:"v",inv:"h"}:{vh:"h",inv:"v"};s.vh=T.extend({},p[s.orient.vh],{inv:p[s.orient.inv]});s.labels=s.labels===true?{top:"br",left:"tr"}[s.align]||"tl":/^[tmb][lcr]$/.test(s.labels.toString())?s.labels:false;T("img",this).each(function(w,u){var v=T(u),x=v.attr("src"),y=v.parent("a");o.Elem[w]={Img:v,Source:x,AltSource:(s.source?s.source.call(u,w):"")||d(u)||x,Label:{txt:v.attr("title")||y.attr("title")||"",width:0,height:0,widthPad:0,heightPad:0,el:0},Initial:0,Trans:0,TransInv:0,Final:0,Offset:0,Centre:0,Pad:{},Linked:!!y.length,width:0,height:0};T.each(R,function(B,A){o.Elem[w].Pad[A]=i(v.css("padding"+A))})});T.each(o.Elem,function(w,u){var v,x=u.AltSource;if(r){T("<img />").bind("load",{id:t,idx:w},m).attr({src:x})}else{v=new Image;v.onload=function(){m.call(this,{data:{id:t,idx:w}});v.onload="";v=null};v.src=x}})});return this}}})(jQuery,window);
