(function(a){a.fn.jDrawer=function(b){b=a.extend({},a.jDrawer.Settings,b);return this.each(function(){var o=this,l=a(this);var j=[];l.parent().addClass("jDrawer-container");l.addClass("jDrawer").addClass("jDrawer-"+b.direction).children("li").addClass("jDrawer-item").each(function(){var p=a(this);p.find(".img").after(p.find(".desc"));p.html("<div class='jDrawer-content'>"+p.html()+"</div>");j.push(p)});l.show();var g=j[0],m=j[o.length-1];var h,f;var i=j.length+b.zindex;h=function(p){var p=p===undefined?a(this):p.length?a(p):a(this);if(!a(this).hasClass("jDrawer-active")){a("li.jDrawer-active",l).removeClass("jDrawer-active");p.addClass("jDrawer-active");var q=g.jT*-1;a.each(j,function(){var s=this;var r=function(){q+=s.hasClass("jDrawer-active")?s.jA:s.jN;var t={};t[b.direction]=q+"px";s.stop().animate(t,b.speed)};b.delay>0?setTimeout(r,b.delay):r()})}};if(b.event==="hover"){f=b.sticky?function(){}:h}a.each(j,function(){var u=0,w=0,p=0,s=0,r=0,q=0;var t=this.prev("li.jDrawer-item");if(b.direction==="top"){u=this.height(),w=t.height()}else{if(b.direction==="left"){u=this.width(),w=t.width()}}var v=this.find(".jDrawer-handle");if(b.handle){s=b.handle}else{if(v.length>0){s=u-(v.offset()[b.direction]-this.offset()[b.direction])}else{s=120}}p=t.length>0?u-w:0;this.jT=u,this.jN=s+(p*-1),this.jA=u+(p*-1);b.direction==="left"?this.find(".jDrawer-content").append('<div style="clear: both"></div>'):0;this.css("z-index",i--);f?this.hover(h,f):this.bind(b.event,h)});var n=0,e=g;a.each(j,function(){this.jT>e.jT?e=this:0});e.addClass("jDrawer-biggest");a.each(j,function(){n+=this.hasClass("jDrawer-biggest")?this.removeClass("jDrawer-biggest").jA:this.jN});if(b.direction==="top"){l.height(n+10)}else{if(b.direction==="left"){l.width(n)}}var d=b.color,k=l.parent();if(b.color===undefined){while(k.css("background-color")!==undefined&&!k.is("html")){d=k.css("background-color"),k=k.parent()}}var c=l.attr("id");a("*",o).each(function(){var p=a(this).css("background-image");if(p!=="none"){if(p.match(/^url[("']+(.*)[)"']+$/i)){(new Image()).src=RegExp.$1}}});a(window).load(function(){setTimeout(function(){h(a(".jDrawer-active",l))},1*1000)})})};a.jDrawer={Settings:{direction:"top",speed:300,delay:0,color:"#FFF",sticky:true,zindex:0,handle:undefined,event:"hover",callback:undefined},Initialized:false,Initialize:function(){if(!this.Initialized){if(a.browser.msie===true){try{document.execCommand("BackgroundImageCache",false,true)}catch(b){}}}},PreloadImages:function(){for(var c in arguments.length){if(arguments[c].type==="array"){for(var b in arguments[c]){(new Image()).src=arguments[c][b]}}else{(new Image()).src=arguments[c]}}}};a(document).ready(function(){a.jDrawer.Initialize()})})(jQuery);
