var Scale={FILL:"fill",FIT:"fit",imageW:null,imageH:null,oWidth:null,oHeight:null,image:null,resizeType:null,imageScale:null,scale:function(image,maxWidth,maxHeight,resizeMethod){this.oWidth=image.width();this.oHeight=image.height();this.resizeType=resizeMethod;if(image.outerWidth()>maxWidth||image.outerHeight()>maxHeight){if(image.outerWidth()>image.outerHeight()){this.resizeType.toLowerCase()===Scale.FILL?this.resizeLandscapeFill(image,maxWidth,maxHeight):this.resizeLandscapeFit(image,maxWidth,maxHeight);}else{this.resizeType.toLowerCase()===Scale.FILL?this.resizePortraitFill(image,maxWidth,maxHeight):this.resizePortraitFit(image,maxWidth,maxHeight);}if(image.outerWidth()>this.oWidth){image.width(this.oWidth);}if(image.outerHeight()>this.oHeight){image.height(this.oHeight);}}},resizePortraitFit:function(image,maxWidth,maxHeight){this.imageScale=maxHeight/image.outerHeight();this.imageW=Math.floor(image.outerWidth()*this.imageScale);this.imageH=Math.floor(image.outerHeight()*this.imageScale);image.width(this.imageW+(image.width()-image.outerWidth())).height(this.imageH+(image.height()-image.outerHeight()));if(this.imageW>maxWidth)this.resizeLandscapeFit(image,maxWidth,maxHeight);},resizeLandscapeFit:function(image,maxWidth,maxHeight){this.imageScale=maxWidth/image.outerWidth();this.imageH=Math.floor(image.outerHeight()*this.imageScale);this.imageW=Math.floor(image.outerWidth()*this.imageScale);image.width(this.imageW+(image.width()-image.outerWidth())).height(this.imageH+(image.height()-image.outerHeight()));if(this.imageH>maxHeight)this.resizeLandscapeFit(image,maxWidth,maxHeight);},resizePortraitFill:function(image,maxWidth,maxHeight){this.imageScale=maxWidth/image.outerWidth();this.imageW=Math.floor(image.outerWidth()*this.imageScale);this.imageH=Math.floor(image.outerHeight()*this.imageScale);image.width(this.imageW+(image.width()-image.outerWidth())).height(this.imageH+(image.height()-image.outerHeight()));if(this.imageH<maxHeight)this.resizeLandscapeFill(image,maxWidth,maxHeight);},resizeLandscapeFill:function(image,maxWidth,maxHeight){this.imageScale=maxHeight/image.outerHeight();this.imageW=Math.floor(image.outerWidth()*this.imageScale);this.imageH=Math.floor(image.outerHeight()*this.imageScale);image.width(this.imageW+(image.width()-image.outerWidth())).height(this.imageH+(image.height()-image.outerHeight()));if(this.imageW<maxWidth)this.resizePortraitFill(image,maxWidth,maxHeight);}},Position={TL:"TL",TC:"TC",TR:"TR",CL:"CL",CC:"CC",CR:"CR",BL:"BL",BC:"BC",BR:"BR",aLeft:null,aTop:null,position:function(position,object,containerWidth,containerHeight,offsetX,offsetY){object=$(object);position=position.toUpperCase();positions=[];positions.push(position.charAt(0));positions.push(position.charAt(1));switch(positions[0]){case"C":aTop=containerHeight/2-object.outerHeight(true)/2;break;case"B":aTop=containerHeight-object.outerHeight(true);break;default:aTop=0;break;}switch(positions[1]){case"C":aLeft=containerWidth/2-object.outerWidth(true)/2;break;case"R":aLeft=containerWidth-object.outerWidth(true);break;default:aLeft=0;break;}if(offsetX)aLeft+=offsetX;if(offsetY)aTop+=offsetY;object.css({position:"absolute",left:aLeft,top:aTop});}}
