;(function($){$.fn.slideOver=function(options){if(options=='show'||options=='hide'){this.each(function(){var drawer=$(this);var mydrawer=drawer.data("myDrawer");if(mydrawer){if(options=='show')mydrawer.show();else if(options=='hide')mydrawer.hide();}});return this;}
else if(options=='get'){var ret=[];this.each(function(){var drawer=$(this);var mydrawer=drawer.data("myDrawer");if(mydrawer){ret.push(mydrawer);}});return ret;}
else if(options=='visible'){var ret=[];this.each(function(){var drawer=$(this);var mydrawer=drawer.data("myDrawer");if(mydrawer){ret.push(mydrawer.isVisible());}});return ret;}
else{this.each(function(){var drawer=$(this);drawer.data("myDrawer",new SonataDrawer(drawer,options));});return this;}}
$.slideOver={};$.slideOver.getRect=function(div){var offs=div.offset();var ret={left:offs.left,top:offs.top,width:div.outerWidth(),height:div.outerHeight(),toString:function(){return"{left:"+this.left+", top:"+this.top+", width:"+this.width+", height:"+this.height+"}";}};ret.right=ret.left+ret.width;ret.bottom=ret.top+ret.height;return ret;}
$.slideOver.windowAsTarget=function(width,height,direction,drawobj){var w=$(window);var doc=$(document);var docleft=doc.scrollLeft();var doctop=doc.scrollTop();var pos=$.slideOver.getFinalFromDim({width:width,height:height},{left:docleft,top:doctop,width:w.width(),height:w.height()},direction);return pos;};$.slideOver.getFinalFromDim=function(drawerdim,divrect,direction){var dwidth=drawerdim.width;var dheight=drawerdim.height;var offs=divrect;var w=divrect.width
var h=divrect.height
var ret={left:divrect.left,top:divrect.top};switch(direction){case"top":ret.left=divrect.left+Math.floor((w-dwidth)/2);break;case"bottom":ret.left=divrect.left+Math.floor((w-dwidth)/2);ret.top=divrect.top+h-dheight;break;case"left":ret.top=divrect.top+(h-dheight)/2;break;case"right":ret.top=divrect.top+Math.floor((h-dheight)/2);ret.left=divrect.left+w-dwidth;break;}
return ret;}
$.slideOver.getFinalFromDiv=function(drawer,div,direction){var drawerdim={width:drawer.outerWidth(),height:drawer.outerHeight()};var offs=div.offset();var divrect=$.slideOver.getRect(div);return $.slideOver.getFinalFromDim(drawerdim,divrect,direction);}
$.slideOver.getFinalFromId=function(drawerId,divId,direction){var drawer=$("#"+drawerId);var div=$("#"+divId);var drawerdim={width:drawer.outerWidth(),height:drawer.outerHeight()};var offs=div.offset();var divrect=$.slideOver.getRect(div);return $.slideOver.getFinalFromDim(drawerdim,divrect,direction);}
$.fn.slideOver.defaults={direction:"right",removedrawer:true,left:0,top:0,target:null,duration:500,dx:0,dy:0,zIndex:10};SonataDrawer=function(drawer,options){var defopts=$.fn.slideOver.defaults;var w=drawer.outerWidth();var h=drawer.outerHeight();var opts={width:w,height:h};opts=$.extend({},defopts,opts,options);if($.metadata){var o=$.metadata.get(drawer[0]);opts=$.extend({},opts,o);}
opts.width+=opts.dx;opts.height+=opts.dy;var dir=opts.direction;var pos;if(opts.target){if(typeof opts.target=='string'){if(opts.target=='window'){pos=$.slideOver.windowAsTarget(opts.width,opts.height,opts.direction,this);}
else pos=$.slideOver.getFinalFromDiv(drawer,$("#"+opts.target),opts.direction);opts.left=pos.left;opts.top=pos.top;}
else if(opts.target==window){pos=$.slideOver.windowAsTarget(opts.width,opts.height,opts.direction,this);opts.left=pos.left;opts.top=pos.top;}
else if(typeof opts.target=='function'){opts.targetFnc=opts.target;}}
var divwrapper=$("<div>").css({position:'absolute',left:opts.left,top:opts.top,width:opts.width,height:opts.height,backgroundColor:'transparent',overflow:'hidden',zIndex:opts.zIndex});drawer.css({position:'relative'});divwrapper.append(drawer);var thisptr=this;this.options=opts;this.visible=false;this.drawer=drawer;this.divwrapper=divwrapper;this.direction=dir;this.setDirection(dir);this.removeDrawer();}
SonataDrawer.prototype.setDirection=function(dir){var show_css={};var hide_css={};var drawer=this.drawer;var w=this.options.width;var h=this.options.height;switch(dir){case"right":drawer.css("left",w+"px");show_css={left:0+"px"};hide_css={left:w+"px"};break;case"left":drawer.css("left",(-w)+"px");show_css={left:0+"px"};hide_css={left:(-w)+"px"};break;case"top":drawer.css("top",(-h)+"px");show_css={top:0+"px"};hide_css={top:(-h)+"px"};break;case"bottom":drawer.css("top",h+"px");show_css={top:0+"px"};hide_css={top:h+"px"};break;}
this.show_css=show_css;this.hide_css=hide_css;drawer.css({display:'block',visibility:"visible"});}
SonataDrawer.prototype.removeDrawer=function()
{try{document.body.removeChild(this.divwrapper[0]);}
catch(e){}}
SonataDrawer.prototype.show=function(){if(this.visible)return;this.visible=true;this.drawer.css(this.hide_css);if(this.options.targetFnc){var pos=this.options.targetFnc(this.options.width,this.options.height,this.options.direction,this);if(pos.left)this.divwrapper.css({left:pos.left,top:pos.top});else this.divwrapper.css({left:pos.left,top:pos.top});}
document.body.appendChild(this.divwrapper[0]);this.drawer.animate(this.show_css,{queue:false,duration:this.options.duration});}
SonataDrawer.prototype.hide=function(){if(this.visible==false)return;var thisptr=this;this.visible=false;this.drawer.animate(this.hide_css,{queue:false,duration:this.options.duration,complete:ondone});function ondone(){if(thisptr.options.removedrawer){thisptr.removeDrawer();}}}
SonataDrawer.prototype.isVisible=function(){return this.visible;}})(jQuery);
